-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure all defined performance tests compile and run
Signed-off-by: David Poltorak <[email protected]>
- Loading branch information
1 parent
1a904a6
commit 168e817
Showing
14 changed files
with
103 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,8 @@ import { sleep } from "k6"; | |
import { HttpService } from "./HttpService"; | ||
import { ISSUER_AGENT_URL, WAITING_LOOP_MAX_ITERATIONS, WAITING_LOOP_PAUSE_INTERVAL } from "./Config"; | ||
import { IssueCredentialRecord, Connection, CredentialSchemaResponse } from "@input-output-hk/prism-typescript-client"; | ||
import {v4 as uuidv4} from 'uuid'; | ||
import { crypto } from "k6/experimental/webcrypto"; | ||
|
||
|
||
/** | ||
* A service class for managing credentials in the application. | ||
|
@@ -18,8 +19,8 @@ export class CredentialsService extends HttpService { | |
*/ | ||
createCredentialOffer(issuingDid: string, connection: Connection, schema: CredentialSchemaResponse): IssueCredentialRecord { | ||
const payload = `{ | ||
"claims": { | ||
"emailAddress": "${uuidv4()}[email protected]", | ||
"claims": { | ||
"emailAddress": "${crypto.randomUUID()}[email protected]", | ||
"familyName": "Test", | ||
"dateOfIssuance": "${new Date()}", | ||
"drivingLicenseID": "Test", | ||
|
@@ -31,13 +32,13 @@ export class CredentialsService extends HttpService { | |
"automaticIssuance": false | ||
}`; | ||
const res = this.post("issue-credentials/credential-offers", payload); | ||
return res.json() as unknown as IssueCredentialRecord; | ||
return this.toJson(res) as unknown as IssueCredentialRecord; | ||
} | ||
|
||
createCredentialSchema(issuingDid: string): CredentialSchemaResponse { | ||
const payload = ` | ||
{ | ||
"name": "${uuidv4()}}", | ||
"name": "${crypto.randomUUID()}}", | ||
"version": "1.0.0", | ||
"description": "Simple credential schema for the driving licence verifiable credential.", | ||
"type": "https://w3c-ccg.github.io/vc-json-schemas/schema/2.0/schema.json", | ||
|
@@ -85,7 +86,7 @@ export class CredentialsService extends HttpService { | |
} | ||
` | ||
const res = this.post("schema-registry/schemas", payload); | ||
return res.json() as unknown as CredentialSchemaResponse; | ||
return this.toJson(res) as unknown as CredentialSchemaResponse; | ||
} | ||
|
||
/** | ||
|
@@ -95,7 +96,7 @@ export class CredentialsService extends HttpService { | |
*/ | ||
getCredentialRecord(record: IssueCredentialRecord): IssueCredentialRecord { | ||
const res = this.get(`issue-credentials/records/${record.recordId}`); | ||
return res.json() as unknown as IssueCredentialRecord; | ||
return this.toJson(res) as unknown as IssueCredentialRecord; | ||
} | ||
|
||
/** | ||
|
@@ -104,7 +105,7 @@ export class CredentialsService extends HttpService { | |
*/ | ||
getCredentialRecords(thid: string): IssueCredentialRecord[] { | ||
const res = this.get(`issue-credentials/records?thid=${thid}`); | ||
return res.json("contents") as unknown as IssueCredentialRecord[]; | ||
return this.toJson(res).contents as unknown as IssueCredentialRecord[]; | ||
} | ||
|
||
/** | ||
|
@@ -116,7 +117,7 @@ export class CredentialsService extends HttpService { | |
acceptCredentialOffer(record: IssueCredentialRecord, subjectDid: string): IssueCredentialRecord { | ||
const payload = { subjectId: subjectDid }; | ||
const res = this.post(`issue-credentials/records/${record.recordId}/accept-offer`, payload, 200); | ||
return res.json() as unknown as IssueCredentialRecord; | ||
return this.toJson(res) as unknown as IssueCredentialRecord; | ||
} | ||
|
||
/** | ||
|
@@ -126,7 +127,7 @@ export class CredentialsService extends HttpService { | |
*/ | ||
issueCredential(record: IssueCredentialRecord): IssueCredentialRecord { | ||
const res = this.post(`issue-credentials/records/${record.recordId}/issue-credential`, null, 200); | ||
return res.json() as unknown as IssueCredentialRecord; | ||
return this.toJson(res) as unknown as IssueCredentialRecord; | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/performance-tests/atala-performance-tests-k6/src/scenarios/default.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Scenario, Threshold } from "k6/options"; | ||
|
||
export const defaultScenarios: { [name: string]: Scenario } = { | ||
smoke: { | ||
// a simple test to ensure performance tests work and requests don't fail | ||
executor: "constant-vus", | ||
vus: 3, | ||
duration: "10s", | ||
tags: { scenario_label: __ENV.SCENARIO_LABEL || "defaultScenarioLabel" }, // add label for filtering in observability platform | ||
}, | ||
}; | ||
|
||
export const defaultThresholds: { [name: string]: Threshold[] } = { | ||
http_req_failed: [ | ||
// fail if any requests fail during smoke test | ||
{ | ||
threshold: "rate==0", | ||
abortOnFail: true, | ||
}, | ||
], | ||
http_req_duration: [ | ||
// fail if any requests take longer than 500ms on smoke test | ||
{ threshold: "p(95)<500", abortOnFail: true }, // 95% of requests should complete within 500ms | ||
{ threshold: "p(99)<1500", abortOnFail: true }, // 99% of requests should complete within 1500ms | ||
], | ||
checks: ["rate==1"], // fail if any checks fail (the checks are defined in test code which is executed) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 12 additions & 22 deletions
34
...formance-tests/atala-performance-tests-k6/src/tests/credentials/credential-schema-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,33 @@ | ||
import { group } from 'k6'; | ||
import { Options } from 'k6/options'; | ||
import { Issuer } from '../../actors'; | ||
|
||
import { group } from "k6"; | ||
import { Options } from "k6/options"; | ||
import { Issuer } from "../../actors"; | ||
import {defaultScenarios, defaultThresholds} from "../../scenarios/default"; | ||
export let options: Options = { | ||
scenarios: { | ||
smoke: { | ||
executor: 'constant-vus', | ||
vus: 3, | ||
duration: "1s", | ||
}, | ||
...defaultScenarios | ||
}, | ||
thresholds: { | ||
'http_req_duration{group:::Issuer creates credential schema}': ['max >= 0'], | ||
'http_reqs{group:::Issuer creates credential schema}': ['count >= 0'], | ||
'group_duration{group:::Issuer creates credential schema}': ['max >= 0'], | ||
checks: ['rate==1'], | ||
http_req_duration: ['p(95)<=100'], | ||
}, | ||
}; | ||
|
||
...defaultThresholds | ||
} | ||
} | ||
export const issuer = new Issuer(); | ||
|
||
export function setup() { | ||
group('Issuer publishes DID', function () { | ||
group("Issuer publishes DID", function () { | ||
issuer.createUnpublishedDid(); | ||
issuer.publishDid(); | ||
}); | ||
|
||
return { | ||
return { | ||
issuerDid: issuer.did, | ||
}; | ||
} | ||
|
||
export default (data: { issuerDid: string; }) => { | ||
|
||
export default (data: { issuerDid: string }) => { | ||
// This is the only way to pass data from setup to default | ||
issuer.did = data.issuerDid; | ||
|
||
group('Issuer creates credential schema', function () { | ||
group("Issuer creates credential schema", function () { | ||
issuer.createCredentialSchema(); | ||
}); | ||
}; |
23 changes: 7 additions & 16 deletions
23
tests/performance-tests/atala-performance-tests-k6/src/tests/dids/create-prism-did-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.