Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 34 additions & 25 deletions performance-testing/uid2-core/k6-test-core-ramping.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -21,8 +30,8 @@ export const options = {
exec: 'opsHealthcheck',
startRate: 4,
timeUnit: '1s',
preAllocatedVUs: 1000,
maxVUs: 1000,
preAllocatedVUs: vus,
maxVUs: vus,
stages: getStages(4),
},

Expand All @@ -31,8 +40,8 @@ export const options = {
exec: 'attest',
startRate: 1,
timeUnit: '1s',
preAllocatedVUs: 1000,
maxVUs: 1000,
preAllocatedVUs: vus,
maxVUs: vus,
stages: getStages(1),
},

Expand All @@ -41,35 +50,35 @@ export const options = {
exec: 'clientsRefresh',
startRate: 1,
timeUnit: '1s',
preAllocatedVUs: 1000,
maxVUs: 1000,
preAllocatedVUs: vus,
maxVUs: vus,
stages: getStages(16),
},
keysets_refresh: {
executor: 'ramping-arrival-rate',
exec: 'keysetRefresh',
startRate: 1,
timeUnit: '1s',
preAllocatedVUs: 1000,
maxVUs: 1000,
preAllocatedVUs: vus,
maxVUs: vus,
stages: getStages(16),
},
keyset_keys_refresh: {
executor: 'ramping-arrival-rate',
exec: 'keysetKeysRefresh',
startRate: 1,
timeUnit: '1s',
preAllocatedVUs: 1000,
maxVUs: 1000,
preAllocatedVUs: vus,
maxVUs: vus,
stages: getStages(16),
},
salt_refresh: {
executor: 'ramping-arrival-rate',
exec: 'saltRefresh',
startRate: 1,
timeUnit: '1s',
preAllocatedVUs: 1000,
maxVUs: 1000,
preAllocatedVUs: vus,
maxVUs: vus,
stages: getStages(16),
},

Expand All @@ -78,35 +87,35 @@ export const options = {
exec: 'sitesRefresh',
startRate: 1,
timeUnit: '1s',
preAllocatedVUs: 1000,
maxVUs: 1000,
preAllocatedVUs: vus,
maxVUs: vus,
stages: getStages(9),
},
cstg_refresh: {
executor: 'ramping-arrival-rate',
exec: 'clientSideKeypairsRefresh',
startRate: 1,
timeUnit: '1s',
preAllocatedVUs: 1000,
maxVUs: 1000,
preAllocatedVUs: vus,
maxVUs: vus,
stages: getStages(9),
},
services_refresh: {
executor: 'ramping-arrival-rate',
exec: 'servicesRefresh',
startRate: 1,
timeUnit: '1s',
preAllocatedVUs: 1000,
maxVUs: 1000,
preAllocatedVUs: vus,
maxVUs: vus,
stages: getStages(9),
},
service_links_refresh: {
executor: 'ramping-arrival-rate',
exec: 'serviceLinksRefresh',
startRate: 1,
timeUnit: '1s',
preAllocatedVUs: 1000,
maxVUs: 1000,
preAllocatedVUs: vus,
maxVUs: vus,
stages: getStages(9),
},
},
Expand Down
4 changes: 2 additions & 2 deletions performance-testing/uid2-core/k6-test-core-static.js
Original file line number Diff line number Diff line change
@@ -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' }};
Expand Down
21 changes: 21 additions & 0 deletions performance-testing/uid2-core/k6-test-resource.yml
Original file line number Diff line number Diff line change
@@ -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"
48 changes: 48 additions & 0 deletions performance-testing/uid2-core/start-named-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

if [ "$#" -ne 2 ]; then
echo "Usage: $0 <test_file_name> <comment>"
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
9 changes: 9 additions & 0 deletions performance-testing/uid2-core/start-ramping.sh
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions performance-testing/uid2-core/start-static.sh
Original file line number Diff line number Diff line change
@@ -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