-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
👷 K6 create issuers #918
👷 K6 create issuers #918
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[tools] | ||
node = "20" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"files": { | ||
"ignore": ["node_modules", "output"] | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true | ||
}, | ||
"ignore": ["node_modules", "output"] | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"scripts": { | ||
"format:check": "biome format .", | ||
"format": "biome format --write .", | ||
"lint:fix": "biome lint --write --unsafe .", | ||
"lint": "biome lint ." | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "^1.8.3" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/* global __ENV, __ITER, __VU */ | ||
// Solve Codacy '__ENV' is not defined. error | ||
|
||
import { check } from 'k6'; | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
import { SharedArray } from 'k6/data'; | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
import { getBearerToken } from '../libs/auth.js'; | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
import { Trend, Counter } from 'k6/metrics'; | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
import { | ||
getWalletIdByWalletName, | ||
deleteTenant, | ||
createIssuerTenant, | ||
getTrustRegistryActor, | ||
createCredentialDefinition, | ||
} from '../libs/functions.js'; | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
|
||
const vus = parseInt(__ENV.VUS, 10); | ||
const iterations = parseInt(__ENV.ITERATIONS, 10); | ||
const issuerPrefix = __ENV.ISSUER_PREFIX; | ||
// const holderPrefix = __ENV.HOLDER_PREFIX; | ||
|
||
export let options = { | ||
scenarios: { | ||
default: { | ||
executor: 'per-vu-iterations', | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
vus: vus, | ||
Check notice Code scanning / Eslint (reported by Codacy) Expected property shorthand. Note
Expected property shorthand.
|
||
iterations: iterations, | ||
Check notice Code scanning / Eslint (reported by Codacy) Expected property shorthand. Note
Expected property shorthand.
|
||
maxDuration: '24h', | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
}, | ||
}, | ||
setupTimeout: '300s', // Increase the setup timeout to 120 seconds | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
teardownTimeout: '120s', // Increase the teardown timeout to 120 seconds | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
maxRedirects: 4, | ||
thresholds: { //https://community.grafana.com/t/ignore-http-calls-made-in-setup-or-teardown-in-results/97260/2 | ||
'http_req_duration{scenario:default}': [`max>=0`], | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
'http_reqs{scenario:default}': ['count >= 0'], | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
'iteration_duration{scenario:default}': ['max>=0'], | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
}, | ||
tags: { | ||
test_run_id: 'phased-issuance', | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
Check warning Code scanning / Eslint (reported by Codacy) Identifier 'test_run_id' is not in camel case. Warning
Identifier 'test_run_id' is not in camel case.
|
||
test_phase: 'create-issuers', | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
Check warning Code scanning / Eslint (reported by Codacy) Identifier 'test_phase' is not in camel case. Warning
Identifier 'test_phase' is not in camel case.
|
||
}, | ||
}; | ||
|
||
const testFunctionReqs = new Counter('test_function_reqs'); | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
const mainIterationDuration = new Trend('main_iteration_duration'); | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
|
||
// Seed data: Generating a list of options.iterations unique wallet names | ||
const wallets = new SharedArray('wallets', function() { | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
const walletsArray = []; | ||
for (let i = 0; i < options.scenarios.default.iterations * options.scenarios.default.vus; i++) { | ||
walletsArray.push({ | ||
walletLabel: `${issuerPrefix} ${i}`, | ||
walletName: `${issuerPrefix}_${i}` | ||
}); | ||
} | ||
return walletsArray; | ||
}); | ||
|
||
export function setup() { | ||
const bearerToken = getBearerToken(); | ||
return { bearerToken }; | ||
Check warning Code scanning / Pmd (reported by Codacy) Unnecessary block. Warning
Unnecessary block.
|
||
} | ||
|
||
const iterationsPerVU = options.scenarios.default.iterations; | ||
// Helper function to calculate the wallet index based on VU and iteration | ||
function getWalletIndex(vu, iter) { | ||
const walletIndex = (vu - 1) * iterationsPerVU + (iter - 1); | ||
return walletIndex; | ||
} | ||
|
||
export default function(data) { | ||
const start = Date.now(); | ||
const bearerToken = data.bearerToken; | ||
const walletIndex = getWalletIndex(__VU, __ITER + 1); // __ITER starts from 0, adding 1 to align with the logic | ||
const wallet = wallets[walletIndex]; | ||
const credDefTag = wallet.walletName; | ||
|
||
const createIssuerTenantResponse = createIssuerTenant(bearerToken, wallet.walletName); | ||
check(createIssuerTenantResponse, { | ||
"Issuer tenant created successfully": (r) => r.status === 200 | ||
}); | ||
const issuerAccessToken = createIssuerTenantResponse.json().access_token; | ||
|
||
const getTrustRegistryActorResponse = getTrustRegistryActor(wallet.walletName); | ||
check(getTrustRegistryActorResponse, { | ||
"Trust Registry Actor Response status code is 200": (r) => { | ||
if (r.status !== 200) { | ||
console.error(`Unexpected response status while getting trust registry actor for issuer tenant ${wallet.walletName}: ${r.status}`); | ||
Check warning Code scanning / Eslint (reported by Codacy) Unexpected console statement. Warning
Unexpected console statement.
|
||
return false; | ||
} else { | ||
console.log(`Got trust registry actor for issuer tenant ${wallet.walletName} successfully.`); | ||
Check warning Code scanning / Eslint (reported by Codacy) Unexpected console statement. Warning
Unexpected console statement.
|
||
return true; | ||
} | ||
} | ||
}); | ||
|
||
// const createCredentialDefinitionResponse = createCredentialDefinition(bearerToken, issuerAccessToken, credDefTag); | ||
// check(createCredentialDefinitionResponse, { | ||
// "Credential definition created successfully": (r) => r.status === 200 | ||
// }); | ||
|
||
const end = Date.now(); | ||
const duration = end - start; | ||
// console.log(`Duration for iteration ${__ITER}: ${duration} ms`); | ||
mainIterationDuration.add(duration); | ||
testFunctionReqs.add(1); | ||
} | ||
|
||
export function teardown(data) { | ||
const bearerToken = data.bearerToken; | ||
|
||
// // Delete issuer tenants | ||
if (__ENV.SKIP_DELETE_ISSUERS !== 'true') { | ||
Check warning Code scanning / Eslint (reported by Codacy) Strings must use doublequote. Warning
Strings must use doublequote.
|
||
for (const wallet of wallets) { | ||
const walletId = getWalletIdByWalletName(bearerToken, wallet.walletName); | ||
const deleteIssuerResponse = deleteTenant(bearerToken, walletId); | ||
check (deleteIssuerResponse, { | ||
"Delete Issuer Tenant Response status code is 200": (r) => { | ||
if (r.status !== 200) { | ||
console.error(`Unexpected response status while deleting issuer tenant ${walletId}: ${r.status}`); | ||
Check warning Code scanning / Eslint (reported by Codacy) Unexpected console statement. Warning
Unexpected console statement.
|
||
return false; | ||
} else { | ||
console.log(`Deleted issuer tenant ${walletId} successfully.`); | ||
Check warning Code scanning / Eslint (reported by Codacy) Unexpected console statement. Warning
Unexpected console statement.
|
||
return true; | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
} |
Check warning
Code scanning / Markdownlint (reported by Codacy)
Expected: 1; Actual: 0; Below Warning