Skip to content

Commit

Permalink
Improvement: let performance test check status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
ivard committed Oct 24, 2023
1 parent d3fd89d commit 7bd85bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions testdata/performance/irma-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ function checkResponse(response, expectedOutput = '') {
'verify status code': (r) => r.status === 200,
'verify body': (r) => r.body.includes(expectedOutput),
});
if (!checkOutput) fail('unexpected response');
if (!checkOutput) fail('unexpected response: status ${response.status}');
}

export default function () {
const newSessionResp = http.post(`${url}/session`, JSON.stringify({
"@context": "https://irma.app/ld/request/disclosure/v2",
"disclose": [
[
[ "irma-demo.sidn-pbdf.email.email" ]
["irma-demo.sidn-pbdf.email.email"]
]
]
}), {
Expand Down
19 changes: 14 additions & 5 deletions testdata/performance/keyshare-server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fail } from 'k6';
import { check, fail } from 'k6';
import { instance, vu } from 'k6/execution';
import http from 'k6/http';

Expand All @@ -14,6 +14,14 @@ export const options = {
},
};

function checkResponse(response, expectedOutput = '') {
const checkOutput = check(response, {
'verify status code': (r) => r.status === 200,
'verify body': (r) => r.body.includes(expectedOutput),
});
if (!checkOutput) fail('unexpected response: status ${response.status}');
}

export function setup() {
if (!url || !issuerID) {
fail('Must specify URL and ISSUER_ID options via environment variables');
Expand All @@ -27,7 +35,7 @@ export function setup() {
const registerPayloadStr = JSON.stringify(registerPayload);

// An IRMA account cannot be used in parallel, so every VU needs its own account.
const testAccounts = Array.from({length: instance.vusInitialized}, () => {
const testAccounts = Array.from({ length: instance.vusInitialized }, () => {
const registerResp = http.post(`${url}/client/register`, registerPayloadStr, {
headers: {
'Content-Type': 'application/json',
Expand All @@ -41,8 +49,9 @@ export function setup() {
'X-IRMA-MaxProtocolVersion': '2.8',
},
});
checkResponse(sessionResp);

http.del(registerResp.json().u);
checkResponse(http.del(registerResp.json().u));

return {
id: Object.values(sessionResp.json().request.credentials[0].attributes)[0],
Expand All @@ -67,7 +76,7 @@ export default function ({ testAccounts }) {
},
};

http.post(`${url}/prove/getCommitments`, `["${issuerID}-0"]`, proveParams);
checkResponse(http.post(`${url}/prove/getCommitments`, `["${issuerID}-0"]`, proveParams));

http.post(`${url}/prove/getResponse`, '"5adEmlEg9U2zjNlPxyPvRym2AzWkBo4kIZJ7ytNg0q0="', proveParams);
checkResponse(http.post(`${url}/prove/getResponse`, '"5adEmlEg9U2zjNlPxyPvRym2AzWkBo4kIZJ7ytNg0q0="', proveParams));
}

0 comments on commit 7bd85bf

Please sign in to comment.