-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* K6 create-schemas.js scenario * Refactor HA config validation scripts * Fix typo * Rework error handling * Override config * Refactored collections * Fix coverage
- Loading branch information
Showing
14 changed files
with
476 additions
and
237 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
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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* global __ENV, __ITER, __VU */ | ||
/* eslint-disable no-undefined, no-console, camelcase */ | ||
|
||
import { check, sleep } from "k6"; | ||
import { SharedArray } from "k6/data"; | ||
import file from "k6/x/file"; | ||
import { getGovernanceBearerToken } from "../libs/auth.js"; | ||
import { createSchema, getSchema } from "../libs/functions.js"; | ||
|
||
const outputFilepath = "output/create-schemas.json"; | ||
const vus = Number.parseInt(__ENV.VUS, 10); | ||
const iterations = Number.parseInt(__ENV.ITERATIONS, 10); | ||
const schemaPrefix = __ENV.SCHEMA_PREFIX; | ||
|
||
export const options = { | ||
scenarios: { | ||
default: { | ||
executor: "per-vu-iterations", | ||
vus, | ||
iterations, | ||
maxDuration: "24h", | ||
}, | ||
}, | ||
setupTimeout: "180s", // Increase the setup timeout to 120 seconds | ||
teardownTimeout: "180s", // Increase the teardown timeout to 120 seconds | ||
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"], | ||
"http_reqs{scenario:default}": ["count >= 0"], | ||
"iteration_duration{scenario:default}": ["max>=0"], | ||
checks: ["rate==1"], | ||
}, | ||
tags: { | ||
test_run_id: "phased-issuance", | ||
test_phase: "create-schemas", | ||
}, | ||
}; | ||
|
||
// Seed data: Generating a list of options.iterations unique wallet names | ||
const schemas = new SharedArray("schemas", () => { | ||
const schemasArray = []; | ||
for (let i = 0; i < options.scenarios.default.iterations * options.scenarios.default.vus; i++) { | ||
schemasArray.push({ | ||
schemaName: `${schemaPrefix}_${i}`, | ||
schemaVersion: `0.0.${i}`, | ||
}); | ||
} | ||
return schemasArray; | ||
}); | ||
|
||
export function setup() { | ||
file.writeString(outputFilepath, ""); | ||
const governanceBearerToken = getGovernanceBearerToken(); | ||
return { governanceBearerToken }; // eslint-disable-line no-eval | ||
} | ||
|
||
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 governanceBearerToken = data.governanceBearerToken; | ||
const walletIndex = getWalletIndex(__VU, __ITER + 1); // __ITER starts from 0, adding 1 to align with the logic | ||
const schema = schemas[walletIndex]; | ||
|
||
const checkSchemaResponse = getSchema(governanceBearerToken, schema.schemaName, schema.schemaVersion); | ||
check(checkSchemaResponse, { | ||
"Schema doesn't exist yet": (r) => r.status === 200 && r.body === "[]", | ||
}); | ||
|
||
const createSchemaResponse = createSchema(governanceBearerToken, schema.schemaName, schema.schemaVersion); | ||
check(createSchemaResponse, { | ||
"Schema created successfully": (r) => r.status === 200 && r.json("id") != null && r.json("id") !== "", | ||
}); | ||
|
||
const getSchemaResponse = getSchema(governanceBearerToken, schema.schemaName, schema.schemaVersion); | ||
check(getSchemaResponse, { | ||
"getSchema check passes": (r) => { | ||
if (r.status !== 200 || r.body === "[]") { | ||
return false; | ||
} | ||
|
||
try { | ||
const schemaData = JSON.parse(r.body); | ||
return schemaData.length > 0 && schemaData[0].id != null; | ||
} catch (e) { | ||
console.error("Failed to parse schema data:", e); | ||
return false; | ||
} | ||
}, | ||
}); | ||
|
||
const { id: schemaId } = JSON.parse(getSchemaResponse.body)[0]; | ||
|
||
const schemaData = JSON.stringify({ | ||
schema_name: schema.schemaName, | ||
schema_version: schema.schemaVersion, | ||
schema_id: schemaId, | ||
}); | ||
file.appendString(outputFilepath, `${schemaData}\n`); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source "$(dirname "${BASH_SOURCE[0]}")/common.sh" | ||
|
||
config() { | ||
export VUS=5 # setting any higher will exceed 30s lifecyce pre-stop on tenant-web | ||
export ITERATIONS=8 | ||
export ISSUER_PREFIX="k6_issuer_creddef" | ||
} | ||
|
||
init() { | ||
run_test ./scenarios/create-issuers.js | ||
} | ||
|
||
scenario() { | ||
run_test ./scenarios/create-creddef.js | ||
} | ||
|
||
cleanup() { | ||
echo "Cleaning up..." | ||
export ITERATIONS=$((INITIAL_ITERATIONS * INTIAL_VUS)) | ||
export VUS=1 | ||
xk6 run ./scenarios/delete-issuers.js | ||
} | ||
|
||
run_collection() { | ||
local deployments="$1" | ||
|
||
config | ||
init | ||
run_ha_iterations "${deployments}" scenario | ||
cleanup | ||
} |
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,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source "$(dirname "${BASH_SOURCE[0]}")/common.sh" | ||
|
||
config() { | ||
export VUS=15 | ||
export ITERATIONS=10 | ||
export ISSUER_PREFIX="k6_issuer_issuer" | ||
} | ||
|
||
init() { | ||
log "No init function specified" | ||
} | ||
|
||
scenario() { | ||
run_test ./scenarios/create-issuers.js | ||
} | ||
|
||
cleanup() { | ||
echo "Cleaning up..." | ||
export ITERATIONS=$((INITIAL_ITERATIONS * INTIAL_VUS)) | ||
export VUS=1 | ||
xk6 run ./scenarios/delete-issuers.js | ||
} | ||
|
||
run_collection() { | ||
local deployments="$1" | ||
|
||
config | ||
init | ||
run_ha_iterations "${deployments}" scenario | ||
cleanup | ||
} |
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,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source "$(dirname "${BASH_SOURCE[0]}")/common.sh" | ||
|
||
config() { | ||
export VUS=10 | ||
export ITERATIONS=10 | ||
export ISSUER_PREFIX="k6_issuer_proof" | ||
export HOLDER_PREFIX="k6_holder_proof" | ||
} | ||
|
||
init() { | ||
run_test ./scenarios/create-holders.js | ||
run_test ./scenarios/create-invitation.js | ||
run_test ./scenarios/create-credentials.js | ||
} | ||
|
||
scenario() { | ||
run_test ./scenarios/create-proof.js | ||
} | ||
|
||
cleanup() { | ||
echo "Cleaning up..." | ||
local iterations=$((INITIAL_ITERATIONS * INTIAL_VUS)) | ||
local vus=1 | ||
xk6 run ./scenarios/delete-holders.js -e ITERATIONS=${iterations} -e VUS=${vus} | ||
xk6 run ./scenarios/delete-issuers.js -e ITERATIONS=1 -e VUS=1 | ||
} | ||
|
||
run_collection() { | ||
local deployments="$1" | ||
|
||
config | ||
init | ||
run_ha_iterations "${deployments}" scenario | ||
cleanup | ||
} |
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,44 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source "$(dirname "${BASH_SOURCE[0]}")/common.sh" | ||
|
||
config() { | ||
export VUS=10 | ||
export ITERATIONS=5 | ||
export ISSUER_PREFIX="k6_issuer_revocation" | ||
export HOLDER_PREFIX="k6_holder_revocation" | ||
} | ||
|
||
init() { | ||
run_test ./scenarios/create-holders.js | ||
run_test ./scenarios/create-invitation.js | ||
run_test ./scenarios/create-credentials.js | ||
run_test ./scenarios/create-proof.js | ||
} | ||
|
||
scenario() { | ||
local iterations=$((ITERATIONS * VUS)) # revoke sequentially | ||
local vus=1 | ||
run_test ./scenarios/revoke-credentials.js -e INTERATIONS=${iterations} -e VUS=${vus} | ||
export IS_REVOKED=true | ||
run_test ./scenarios/create-proof.js | ||
} | ||
|
||
cleanup() { | ||
echo "Cleaning up..." | ||
local iterations=$((ITERATIONS * VUS)) | ||
local vus=1 | ||
run_test ./scenarios/delete-holders.js -e ITERATIONS=${iterations} -e VUS=${vus} | ||
run_test ./scenarios/delete-issuers.js -e ITERATIONS=1 -e VUS=1 | ||
} | ||
|
||
run_collection() { | ||
local deployments="$1" | ||
|
||
config | ||
init | ||
run_ha_iterations "${deployments}" scenario | ||
cleanup | ||
} |
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,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source "$(dirname "${BASH_SOURCE[0]}")/common.sh" | ||
|
||
config() { | ||
export VUS=20 | ||
export ITERATIONS=25 | ||
export SCHEMA_PREFIX="k6_schema" | ||
} | ||
|
||
init() { | ||
echo "No init function specified" | ||
} | ||
|
||
scenario() { | ||
run_test ./scenarios/create-schemas.js | ||
} | ||
|
||
cleanup() { | ||
echo "No cleanup specified for schema collection" | ||
} | ||
|
||
run_collection() { | ||
local deployments="$1" | ||
|
||
config | ||
init | ||
run_ha_iterations "${deployments}" scenario | ||
cleanup | ||
} |
Oops, something went wrong.