diff --git a/performance-testing/uid2-core/k6-test-core-ramping.js b/performance-testing/uid2-core/k6-test-core-ramping.js index 7afb758..50a2823 100644 --- a/performance-testing/uid2-core/k6-test-core-ramping.js +++ b/performance-testing/uid2-core/k6-test-core-ramping.js @@ -1,17 +1,26 @@ import http from 'k6/http'; -const CORE_API_TOKEN = "UID2-O-L-999-dp9Dt0.JVoGpynN4J8nMA7FxmzsavxJa8B9H74y9xdEE="; // Mock token for E2E tests -const CORE_BASE_URL = 'http://localhost:8088'; +const CORE_API_TOKEN = __ENV.OPERATOR_KEY; // Mock token for E2E tests +const CORE_BASE_URL = __ENV.CORE_URL; const AUTH_HEADERS = { headers: { 'Authorization': `Bearer ${CORE_API_TOKEN}` }}; const HEADERS = { headers: { ...AUTH_HEADERS.headers, 'X-UID2-AppVersion': 'uid2-operator=0.0.0-local-load-test' }}; +const vus = 1000; const STAGE_DURATION = '120s'; const STAGE_LOAD_MULTIPLIER = [ 1, - 2, - 5, - 10, + 4, + 16, + 64, + 128, + 256, + 512, + 512, + 512, + 512, + 512, + 512 ]; export const options = { @@ -21,8 +30,8 @@ export const options = { exec: 'opsHealthcheck', startRate: 4, timeUnit: '1s', - preAllocatedVUs: 1000, - maxVUs: 1000, + preAllocatedVUs: vus, + maxVUs: vus, stages: getStages(4), }, @@ -31,8 +40,8 @@ export const options = { exec: 'attest', startRate: 1, timeUnit: '1s', - preAllocatedVUs: 1000, - maxVUs: 1000, + preAllocatedVUs: vus, + maxVUs: vus, stages: getStages(1), }, @@ -41,8 +50,8 @@ export const options = { exec: 'clientsRefresh', startRate: 1, timeUnit: '1s', - preAllocatedVUs: 1000, - maxVUs: 1000, + preAllocatedVUs: vus, + maxVUs: vus, stages: getStages(16), }, keysets_refresh: { @@ -50,8 +59,8 @@ export const options = { exec: 'keysetRefresh', startRate: 1, timeUnit: '1s', - preAllocatedVUs: 1000, - maxVUs: 1000, + preAllocatedVUs: vus, + maxVUs: vus, stages: getStages(16), }, keyset_keys_refresh: { @@ -59,8 +68,8 @@ export const options = { exec: 'keysetKeysRefresh', startRate: 1, timeUnit: '1s', - preAllocatedVUs: 1000, - maxVUs: 1000, + preAllocatedVUs: vus, + maxVUs: vus, stages: getStages(16), }, salt_refresh: { @@ -68,8 +77,8 @@ export const options = { exec: 'saltRefresh', startRate: 1, timeUnit: '1s', - preAllocatedVUs: 1000, - maxVUs: 1000, + preAllocatedVUs: vus, + maxVUs: vus, stages: getStages(16), }, @@ -78,8 +87,8 @@ export const options = { exec: 'sitesRefresh', startRate: 1, timeUnit: '1s', - preAllocatedVUs: 1000, - maxVUs: 1000, + preAllocatedVUs: vus, + maxVUs: vus, stages: getStages(9), }, cstg_refresh: { @@ -87,8 +96,8 @@ export const options = { exec: 'clientSideKeypairsRefresh', startRate: 1, timeUnit: '1s', - preAllocatedVUs: 1000, - maxVUs: 1000, + preAllocatedVUs: vus, + maxVUs: vus, stages: getStages(9), }, services_refresh: { @@ -96,8 +105,8 @@ export const options = { exec: 'servicesRefresh', startRate: 1, timeUnit: '1s', - preAllocatedVUs: 1000, - maxVUs: 1000, + preAllocatedVUs: vus, + maxVUs: vus, stages: getStages(9), }, service_links_refresh: { @@ -105,8 +114,8 @@ export const options = { exec: 'serviceLinksRefresh', startRate: 1, timeUnit: '1s', - preAllocatedVUs: 1000, - maxVUs: 1000, + preAllocatedVUs: vus, + maxVUs: vus, stages: getStages(9), }, }, diff --git a/performance-testing/uid2-core/k6-test-core-static.js b/performance-testing/uid2-core/k6-test-core-static.js index 37a6bc5..562baf2 100644 --- a/performance-testing/uid2-core/k6-test-core-static.js +++ b/performance-testing/uid2-core/k6-test-core-static.js @@ -1,7 +1,7 @@ import http from 'k6/http'; -const CORE_API_TOKEN = "UID2-O-L-999-dp9Dt0.JVoGpynN4J8nMA7FxmzsavxJa8B9H74y9xdEE="; // Mock token for E2E tests -const CORE_BASE_URL = 'http://localhost:8088'; +const CORE_API_TOKEN = __ENV.OPERATOR_KEY; // Mock token for E2E tests +const CORE_BASE_URL = __ENV.CORE_URL; const AUTH_HEADERS = { headers: { 'Authorization': `Bearer ${CORE_API_TOKEN}` }}; const HEADERS = { headers: { ...AUTH_HEADERS.headers, 'X-UID2-AppVersion': 'uid2-operator=0.0.0-local-load-test' }}; diff --git a/performance-testing/uid2-core/k6-test-resource.yml b/performance-testing/uid2-core/k6-test-resource.yml new file mode 100644 index 0000000..bfb9445 --- /dev/null +++ b/performance-testing/uid2-core/k6-test-resource.yml @@ -0,0 +1,21 @@ +apiVersion: k6.io/v1alpha1 +kind: TestRun +metadata: + name: k6-uid2-load-test +spec: + parallelism: 10 # original 4 + arguments: --out experimental-prometheus-rw --tag "testid=replacecomment" + script: + configMap: + name: operator-stress-test + file: replaced + runner: + env: + - name: K6_PROMETHEUS_RW_SERVER_URL + value: "http://prometheus-server.prometheus/api/v1/write" + - name: K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM + value: "true" + - name: CORE_URL + value: "core_url" + - name: OPERATOR_KEY + value: "operator_key" diff --git a/performance-testing/uid2-core/start-named-test.sh b/performance-testing/uid2-core/start-named-test.sh new file mode 100755 index 0000000..a712654 --- /dev/null +++ b/performance-testing/uid2-core/start-named-test.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +TEST_FILE=$1 +COMMENT=$2 + +echo "Delete existing tests" +kubectl delete -f ./k6-test-resource-edited.yml +kubectl delete configmap operator-stress-test + +echo "Starting tests" +rm ./k6-test-resource-edited.yml +cp ./k6-test-resource.yml ./k6-test-resource-edited.yml +sed -i -e "s/replaced/$TEST_FILE/g" ./k6-test-resource-edited.yml +sed -i -e "s/replacecomment/$COMMENT/g" ./k6-test-resource-edited.yml + +core_url_value=$CORE_URL +operator_key_value=$OPERATOR_KEY + +if [[ -v core_url_value ]]; then + if [[ "$CORE_URL" == *"/"* ]]; then + core_url_value=$(echo "$CORE_URL" | sed 's/\//\\\//g') + echo "Escaped CORE_URL: $core_url_value" + else + core_url_value="$CORE_URL" + echo "CORE_URL has no slashes: $core_url_value" + fi + sed -i -e "s/core_url/$core_url_value/g" ./k6-test-resource-edited.yml +fi + +if [[ -v operator_key_value ]]; then + if [[ "$OPERATOR_KEY" == *"/"* ]]; then + operator_key_value=$(echo "$OPERATOR_KEY" | sed 's/\//\\\//g') + echo "Escaped OPERATOR_KEY: $operator_key_value" + else + operator_key_value="$OPERATOR_KEY" + echo "OPERATOR_KEY has no slashes: $operator_key_value" + fi + sed -i -e "s/operator_key/$operator_key_value/g" ./k6-test-resource-edited.yml +fi + + +kubectl create configmap operator-stress-test --from-file ./$TEST_FILE +kubectl apply -f ./k6-test-resource-edited.yml diff --git a/performance-testing/uid2-core/start-ramping.sh b/performance-testing/uid2-core/start-ramping.sh new file mode 100755 index 0000000..39554db --- /dev/null +++ b/performance-testing/uid2-core/start-ramping.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +COMMENT=$1 + +if [ "$#" -ne 1 ]; then + COMMENT=$( date '+%F_%H:%M:%S' ) +fi + +./start-named-test.sh k6-test-core-ramping.js $COMMENT diff --git a/performance-testing/uid2-core/start-static.sh b/performance-testing/uid2-core/start-static.sh new file mode 100755 index 0000000..12bab31 --- /dev/null +++ b/performance-testing/uid2-core/start-static.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +COMMENT=$1 + +if [ "$#" -ne 1 ]; then + COMMENT=$( date '+%F_%H:%M:%S' ) +fi + +./start-named-test.sh k6-test-core-static.js $COMMENT