diff --git a/performance-testing/uid2-operator/k6-test-resource.yml b/performance-testing/uid2-operator/k6-test-resource.yml index 9acf421..d3b5679 100644 --- a/performance-testing/uid2-operator/k6-test-resource.yml +++ b/performance-testing/uid2-operator/k6-test-resource.yml @@ -1,9 +1,9 @@ apiVersion: k6.io/v1alpha1 -kind: K6 +kind: TestRun metadata: name: k6-uid2-load-test spec: - parallelism: 3 + parallelism: 10 # original 4 arguments: --out experimental-prometheus-rw --tag "testid=replacecomment" script: configMap: @@ -14,4 +14,10 @@ spec: - name: K6_PROMETHEUS_RW_SERVER_URL value: "http://prometheus-server.prometheus/api/v1/write" - name: K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM - value: "true" \ No newline at end of file + value: "true" + - name: OPERATOR_URL + value: "operator_url" + - name: CLIENT_KEY + value: "client_key" + - name: CLIENT_SECRET + value: "client_secret" diff --git a/performance-testing/uid2-operator/k6-token-generate-refresh-identitymap-keysharing.js b/performance-testing/uid2-operator/k6-token-generate-refresh-identitymap-keysharing.js new file mode 100755 index 0000000..149714d --- /dev/null +++ b/performance-testing/uid2-operator/k6-token-generate-refresh-identitymap-keysharing.js @@ -0,0 +1,446 @@ + +import { crypto } from "k6/experimental/webcrypto"; +import encoding from 'k6/encoding'; +import { check } from 'k6'; +import http from 'k6/http'; + +const vus = 300; +const baseUrl = __ENV.OPERATOR_URL; +const clientSecret = __ENV.CLIENT_SECRET; +const clientKey = __ENV.CLIENT_KEY; + +const generateVUs = vus; +const refreshVUs = vus; +const identityMapVUs = vus; +const keySharingVUs = vus; +const testDuration = '6h' + +export const options = { + insecureSkipTLSVerify: true, + noConnectionReuse: false, + scenarios: { + // Warmup scenarios + tokenGenerateWarmup: { + executor: 'ramping-vus', + exec: 'tokenGenerate', + stages: [ + { duration: '30s', target: generateVUs} + ], + gracefulRampDown: '0s', + }, + tokenRefreshWarmup: { + executor: 'ramping-vus', + exec: 'tokenRefresh', + stages: [ + { duration: '30s', target: refreshVUs} + ], + gracefulRampDown: '0s', + }, + identityMapWarmup: { + executor: 'ramping-vus', + exec: 'identityMap', + stages: [ + { duration: '30s', target: identityMapVUs} + ], + gracefulRampDown: '0s', + }, + keySharingWarmup: { + executor: 'ramping-vus', + exec: 'keySharing', + stages: [ + { duration: '30s', target: keySharingVUs} + ], + gracefulRampDown: '0s', + }, + // Actual testing scenarios + tokenGenerate: { + executor: 'constant-vus', + exec: 'tokenGenerate', + vus: generateVUs, + duration: testDuration, + gracefulStop: '0s', + startTime: '30s', + }, + tokenRefresh: { + executor: 'constant-vus', + exec: 'tokenRefresh', + vus: refreshVUs, + duration: testDuration, + gracefulStop: '0s', + startTime: '30s', + }, + identityMap: { + executor: 'constant-vus', + exec: 'identityMapLargeBatch', + vus: identityMapVUs, + duration: testDuration, + gracefulStop: '0s', + startTime: '30s', + }, + keySharing:{ + executor: 'constant-vus', + exec: 'keySharing', + vus: keySharingVUs, + duration: testDuration, + gracefulStop: '0s', + startTime: '30s', + }, + identityMapLargeBatchSequential: { + executor: 'constant-vus', + exec: 'identityMapLargeBatch', + vus: 1, + duration: '300s', + gracefulStop: '0s', + startTime: '970s', + }, + identityMapLargeBatch: { + executor: 'constant-vus', + exec: 'identityMapLargeBatch', + vus: 16, + duration: '300s', + gracefulStop: '0s', + startTime: '1280s', + }, + identityBuckets: { + executor: 'constant-vus', + exec: 'identityBuckets', + vus: 2, + duration: '300s', + gracefulStop: '0s', + startTime: '1590s', + }, + }, + // So we get count in the summary, to demonstrate different metrics are different + summaryTrendStats: ['avg', 'min', 'med', 'max', 'p(90)', 'p(95)', 'p(99)', 'count'], + thresholds: { + // Intentionally empty. We'll programatically define our bogus + // thresholds (to generate the sub-metrics) below. In your real-world + // load test, you can add any real threshoulds you want here. + } +}; + +// https://community.k6.io/t/multiple-scenarios-metrics-per-each/1314/3 +for (let key in options.scenarios) { + // Each scenario automaticall tags the metrics it generates with its own name + let thresholdName = `http_req_duration{scenario:${key}}`; + // Check to prevent us from overwriting a threshold that already exists + if (!options.thresholds[thresholdName]) { + options.thresholds[thresholdName] = []; + } + // 'max>=0' is a bogus condition that will always be fulfilled + options.thresholds[thresholdName].push('max>=0'); +} + +export async function setup() { + var token = await generateRefreshRequest(); + return { + tokenGenerate: null, + identityMap: null, + refreshToken: token + }; + + async function generateRefreshRequest() { + let request = await createReq( {'optout_check': 1, 'email': 'test5000@example.com'}); + var requestData = { + endpoint: '/v2/token/generate', + requestBody: request, + } + let response = await send(requestData, clientKey); + let decrypt = await decryptEnvelope(response.body, clientSecret) + return decrypt.body.refresh_token; + }; +} + +export function handleSummary(data) { + return { + 'summary.json': JSON.stringify(data), + } +} + +// Scenarios +export async function tokenGenerate(data) { + const endpoint = '/v2/token/generate'; + if (data.tokenGenerate == null) { + var newData = await generateTokenGenerateRequestWithTime(); + data.tokenGenerate = newData; + } else if (data.tokenGenerate.time < (Date.now() - 45000)) { + data.tokenGenerate = await generateTokenGenerateRequestWithTime(); + } + + var requestBody = data.tokenGenerate.requestBody; + var tokenGenerateData = { + endpoint: endpoint, + requestBody: requestBody, + } + + execute(tokenGenerateData, true); +} + +export function tokenRefresh(data) { + var requestBody = data.refreshToken; + var refreshData = { + endpoint: '/v2/token/refresh', + requestBody: requestBody + } + + execute(refreshData, false); +} + +export async function identityMap(data) { + const endpoint = '/v2/identity/map'; + if ((data.identityMap == null) || (data.identityMap.time < (Date.now() - 45000))) { + data.identityMap = await generateIdentityMapRequestWithTime(2);; + } + + var requestBody = data.identityMap.requestBody; + var identityData = { + endpoint: endpoint, + requestBody: requestBody, + } + execute(identityData, true); +} + +export async function identityMapLargeBatch(data) { + const endpoint = '/v2/identity/map'; + if ((data.identityMap == null) || (data.identityMap.time < (Date.now() - 45000))) { + data.identityMap = await generateIdentityMapRequestWithTime(5000);; + } + + var requestBody = data.identityMap.requestBody; + var identityData = { + endpoint: endpoint, + requestBody: requestBody, + } + execute(identityData, true); +} + +export function identityBuckets(data) { + var requestData = data.identityBuckets.requestData; + var elementToUse = selectRequestData(requestData); + + var bucketData = { + endpoint: data.identityBuckets.endpoint, + requestBody: elementToUse.requestBody, + } + execute(bucketData, true); +} + +export async function keySharing(data) { + const endpoint = '/v2/key/sharing'; + if (data.keySharing == null) { + var newData = await generateKeySharingRequestWithTime(); + data.keySharing = newData; + } else if (data.keySharing.time < (Date.now() - 45000)) { + data.keySharing = await generateKeySharingRequestWithTime(); + } + + var requestBody = data.keySharing.requestBody; + var keySharingData = { + endpoint: endpoint, + requestBody: requestBody, + } + + execute(keySharingData, true); +} + +// Helpers +async function createReqWithTimestamp(timestampArr, obj) { + var envelope = getEnvelopeWithTimestamp(timestampArr, obj); + return encoding.b64encode((await encryptEnvelope(envelope, clientSecret)).buffer); +} + +function generateIdentityMapRequest(emailCount) { + var data = { + 'optout_check': 1, + "email": [] + }; + + for (var i = 0; i < emailCount; ++i) { + data.email.push(`test${i}@example.com`); + } + + return data; +} + +function send(data, auth) { + var options = {}; + if (auth) { + options.headers = { + 'Authorization': `Bearer ${clientKey}` + }; + } + + return http.post(`${baseUrl}${data.endpoint}`, data.requestBody, options); +} + +function execute(data, auth) { + var response = send(data, auth); + + check(response, { + 'status is 200': r => r.status === 200, + }); +} + +async function encryptEnvelope(envelope, clientSecret) { + const rawKey = encoding.b64decode(clientSecret); + const key = await crypto.subtle.importKey("raw", rawKey, "AES-GCM", true, [ + "encrypt", + "decrypt", + ]); + + const iv = crypto.getRandomValues(new Uint8Array(12)); + + const ciphertext = new Uint8Array(await crypto.subtle.encrypt( + { + name: "AES-GCM", + iv: iv, + }, + key, + envelope + )); + + const result = new Uint8Array(+(1 + iv.length + ciphertext.length)); + + // The version of the envelope format. + result[0] = 1; + + result.set(iv, 1); + + // The tag is at the end of ciphertext. + result.set(ciphertext, 1 + iv.length); + + return result; +} + +async function decryptEnvelope(envelope, clientSecret) { + const rawKey = encoding.b64decode(clientSecret); + const rawData = encoding.b64decode(envelope); + const key = await crypto.subtle.importKey("raw", rawKey, "AES-GCM", true, [ + "encrypt", + "decrypt", + ]); + const length = rawData.byteLength; + const iv = rawData.slice(0, 12); + + const decrypted = await crypto.subtle.decrypt( + { + name: "AES-GCM", + iv: iv, + tagLength: 128 + }, + key, + rawData.slice(12) + ); + + + const decryptedResponse = String.fromCharCode.apply(String, new Uint8Array(decrypted.slice(16))); + const response = JSON.parse(decryptedResponse); + + return response; +} + +function getEnvelopeWithTimestamp(timestampArray, obj) { + var randomBytes = new Uint8Array(8); + crypto.getRandomValues(randomBytes); + + var payload = stringToUint8Array(JSON.stringify(obj)); + + var envelope = new Uint8Array(timestampArray.length + randomBytes.length + payload.length); + envelope.set(timestampArray); + envelope.set(randomBytes, timestampArray.length); + envelope.set(payload, timestampArray.length + randomBytes.length); + + return envelope; + +} +function getEnvelope(obj) { + var timestampArr = new Uint8Array(getTimestamp()); + return getEnvelopeWithTimestamp(timestampArr, obj); +} + +function getTimestamp() { + const now = Date.now(); + return getTimestampFromTime(now); +} + +function getTimestampFromTime(time) { + const res = new ArrayBuffer(8); + const { hi, lo } = Get32BitPartsBE(time); + const view = new DataView(res); + view.setUint32(0, hi, false); + view.setUint32(4, lo, false); + return res; +} + +// http://anuchandy.blogspot.com/2015/03/javascript-how-to-extract-lower-32-bit.html +function Get32BitPartsBE(bigNumber) { + if (bigNumber > 9007199254740991) { + // Max int that JavaScript can represent is 2^53. + throw new Error('The 64-bit value is too big to be represented in JS :' + bigNumber); + } + + var bigNumberAsBinaryStr = bigNumber.toString(2); + // Convert the above binary str to 64 bit (actually 52 bit will work) by padding zeros in the left + var bigNumberAsBinaryStr2 = ''; + for (var i = 0; i < 64 - bigNumberAsBinaryStr.length; i++) { + bigNumberAsBinaryStr2 += '0'; + }; + + bigNumberAsBinaryStr2 += bigNumberAsBinaryStr; + + return { + hi: parseInt(bigNumberAsBinaryStr2.substring(0, 32), 2), + lo: parseInt(bigNumberAsBinaryStr2.substring(32), 2), + }; +} + +function stringToUint8Array(str) { + const buffer = new ArrayBuffer(str.length); + const view = new Uint8Array(buffer); + for (var i = 0; i < str.length; i++) { + view[i] = str.charCodeAt(i); + } + return view; +} + +async function createReq(obj) { + var envelope = getEnvelope(obj); + return encoding.b64encode((await encryptEnvelope(envelope, clientSecret)).buffer); +}; + +async function generateRequestWithTime(obj) { + var time = Date.now(); + var timestampArr = new Uint8Array(getTimestampFromTime(time)); + var requestBody = await createReqWithTimestamp(timestampArr, obj); + var element = { + time: time, + requestBody: requestBody + }; + + return element; +} + + +async function generateTokenGenerateRequestWithTime() { + let requestData = { 'optout_check': 1, 'email': 'test500@example.com' }; + return await generateRequestWithTime(requestData); +} + +async function generateIdentityMapRequestWithTime(emailCount) { + let emails = generateIdentityMapRequest(emailCount); + return await generateRequestWithTime(emails); +} + +async function generateKeySharingRequestWithTime() { + let requestData = { }; + return await generateRequestWithTime(requestData); +} + +const generateSinceTimestampStr = () => { + var date = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000 /* 2 days ago */); + var year = date.getFullYear(); + var month = (date.getMonth() + 1).toString().padStart(2, '0'); + var day = date.getDate().toString().padStart(2, '0'); + + return `${year}-${month}-${day}T00:00:00`; +}; diff --git a/performance-testing/uid2-operator/k6-token-generate-refresh-identitymap.js b/performance-testing/uid2-operator/k6-token-generate-refresh-identitymap.js index ac3ca2c..5a705e4 100644 --- a/performance-testing/uid2-operator/k6-token-generate-refresh-identitymap.js +++ b/performance-testing/uid2-operator/k6-token-generate-refresh-identitymap.js @@ -4,20 +4,16 @@ import encoding from 'k6/encoding'; import { check } from 'k6'; import http from 'k6/http'; -const vus = 500; -const baseUrl = "http://uid2-prod-opr-use2-alb-698161474.us-east-2.elb.amazonaws.com"; -const clientSecret = ""; -const clientKey = ""; +const vus = 50; +const baseUrl = __ENV.OPERATOR_URL; +const clientSecret = __ENV.CLIENT_SECRET; +const clientKey = __ENV.CLIENT_KEY; const generateVUs = vus; const refreshVUs = vus; const identityMapVUs = vus; -const testDuration = '10m' - -//30 warm up on each -// 5 min each -// 12, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600 -// 13 scenarios, each 5.5 min = 4290 se +const keySharingVUs = vus; +const testDuration = '6h' export const options = { insecureSkipTLSVerify: true, @@ -47,7 +43,15 @@ export const options = { { duration: '30s', target: identityMapVUs} ], gracefulRampDown: '0s', - }, + },/* + keySharingWarmup: { + executor: 'ramping-vus', + exec: 'keySharing', + stages: [ + { duration: '30s', target: keySharingVUs} + ], + gracefulRampDown: '0s', + },*/ // Actual testing scenarios tokenGenerate: { executor: 'constant-vus', @@ -72,7 +76,15 @@ export const options = { duration: testDuration, gracefulStop: '0s', startTime: '30s', - }/*, + },/* + keySharing:{ + executor: 'constant-vus', + exec: 'keySharing', + vus: keySharingVUs, + duration: testDuration, + gracefulStop: '0s', + startTime: '30s', + },*/ identityMapLargeBatchSequential: { executor: 'constant-vus', exec: 'identityMapLargeBatch', @@ -96,7 +108,7 @@ export const options = { duration: '300s', gracefulStop: '0s', startTime: '1590s', - },*/ + }, }, // So we get count in the summary, to demonstrate different metrics are different summaryTrendStats: ['avg', 'min', 'med', 'max', 'p(90)', 'p(95)', 'p(99)', 'count'], @@ -213,6 +225,24 @@ export function identityBuckets(data) { execute(bucketData, true); } +export async function keySharing(data) { + const endpoint = '/v2/key/sharing'; + if (data.keySharing == null) { + var newData = await generateKeySharingRequestWithTime(); + data.keySharing = newData; + } else if (data.keySharing.time < (Date.now() - 45000)) { + data.keySharing = await generateKeySharingRequestWithTime(); + } + + var requestBody = data.keySharing.requestBody; + var keySharingData = { + endpoint: endpoint, + requestBody: requestBody, + } + + execute(keySharingData, true); +} + // Helpers async function createReqWithTimestamp(timestampArr, obj) { var envelope = getEnvelopeWithTimestamp(timestampArr, obj); @@ -401,6 +431,11 @@ async function generateIdentityMapRequestWithTime(emailCount) { return await generateRequestWithTime(emails); } +async function generateKeySharingRequestWithTime() { + let requestData = { }; + return await generateRequestWithTime(requestData); +} + const generateSinceTimestampStr = () => { var date = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000 /* 2 days ago */); var year = date.getFullYear(); diff --git a/performance-testing/uid2-operator/k6-token-generate.js b/performance-testing/uid2-operator/k6-token-generate.js old mode 100644 new mode 100755 index 6ee199b..553d955 --- a/performance-testing/uid2-operator/k6-token-generate.js +++ b/performance-testing/uid2-operator/k6-token-generate.js @@ -5,19 +5,15 @@ import { check } from 'k6'; import http from 'k6/http'; const vus = 500; -const baseUrl = "http://uid2-prod-opr-use2-alb-698161474.us-east-2.elb.amazonaws.com"; -const clientSecret = ""; -const clientKey = ""; +const baseUrl = __ENV.OPERATOR_URL; +const clientSecret = __ENV.CLIENT_SECRET; +const clientKey = __ENV.CLIENT_KEY; const generateVUs = vus; const refreshVUs = vus; const identityMapVUs = vus; -const testDuration = '10m' - -//30 warm up on each -// 5 min each -// 12, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600 -// 13 scenarios, each 5.5 min = 4290 se +const keySharingVUs = vus; +const testDuration = '6h' export const options = { insecureSkipTLSVerify: true, @@ -47,6 +43,14 @@ export const options = { { duration: '30s', target: identityMapVUs} ], gracefulRampDown: '0s', + }, + keySharingWarmup: { + executor: 'ramping-vus', + exec: 'keySharing', + stages: [ + { duration: '30s', target: keySharingVUs} + ], + gracefulRampDown: '0s', },*/ // Actual testing scenarios tokenGenerate: { @@ -56,7 +60,7 @@ export const options = { duration: testDuration, gracefulStop: '0s', startTime: '30s', - }/*, + },/* tokenRefresh: { executor: 'constant-vus', exec: 'tokenRefresh', @@ -73,6 +77,14 @@ export const options = { gracefulStop: '0s', startTime: '30s', }, + keySharing:{ + executor: 'constant-vus', + exec: 'keySharing', + vus: keySharingVUs, + duration: testDuration, + gracefulStop: '0s', + startTime: '30s', + }, identityMapLargeBatchSequential: { executor: 'constant-vus', exec: 'identityMapLargeBatch', @@ -213,6 +225,24 @@ export function identityBuckets(data) { execute(bucketData, true); } +export async function keySharing(data) { + const endpoint = '/v2/key/sharing'; + if (data.keySharing == null) { + var newData = await generateKeySharingRequestWithTime(); + data.keySharing = newData; + } else if (data.keySharing.time < (Date.now() - 45000)) { + data.keySharing = await generateKeySharingRequestWithTime(); + } + + var requestBody = data.keySharing.requestBody; + var keySharingData = { + endpoint: endpoint, + requestBody: requestBody, + } + + execute(keySharingData, true); +} + // Helpers async function createReqWithTimestamp(timestampArr, obj) { var envelope = getEnvelopeWithTimestamp(timestampArr, obj); @@ -401,6 +431,11 @@ async function generateIdentityMapRequestWithTime(emailCount) { return await generateRequestWithTime(emails); } +async function generateKeySharingRequestWithTime() { + let requestData = { }; + return await generateRequestWithTime(requestData); +} + const generateSinceTimestampStr = () => { var date = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000 /* 2 days ago */); var year = date.getFullYear(); diff --git a/performance-testing/uid2-operator/k6-uid2-operator.js b/performance-testing/uid2-operator/k6-uid2-operator.js index bb262fc..b6d97f4 100644 --- a/performance-testing/uid2-operator/k6-uid2-operator.js +++ b/performance-testing/uid2-operator/k6-uid2-operator.js @@ -8,6 +8,7 @@ const tokenGenerateTests = true; const tokenRefreshTests = true; const identityMapTests = true; const identityBucketTests = true; +const keySharingTests = true; //30 warm up on each @@ -48,6 +49,13 @@ export const options = { duration: '30s', gracefulStop: '0s', }, + keySharingWarmup: { + executor: 'constant-vus', + exec: 'keySharing', + vus: 300, + duration: '30s', + gracefulStop: '0s', + }, // Actual testing scenarios tokenGenerate: { executor: 'constant-vus', @@ -73,6 +81,14 @@ export const options = { gracefulStop: '0s', startTime: '660s', }, + keySharing:{ + executor: 'constant-vus', + exec: 'keySharing', + vus: 300, + duration: '300s', + gracefulStop: '0s', + startTime: '30s', + }, identityMapLargeBatchSequential: { executor: 'constant-vus', exec: 'identityMapLargeBatch', @@ -178,12 +194,21 @@ export async function setup() { }; } + let keySharingData = {}; + if(keySharingTests) { + keySharingData = { + endpoint: '/v2/key/sharing', + requestData: await generateFutureKeySharingRequests(numberOfRequestsToGenerate) + }; + } + return { tokenGenerate: tokenGenerateData, tokenRefresh: tokenRefreshData, identityMap: identityMapData, identityMapLargeBatch: identityMapLargeBatchData, - identityBuckets: identityBucketData + identityBuckets: identityBucketData, + keySharing: keySharingData }; } @@ -237,6 +262,17 @@ export function identityBuckets(data) { execute(bucketData, true); } +export async function keySharing(data) { + var requestData = data.keySharing.requestData; + var elementToUse = selectRequestData(requestData); + + var keySharingData = { + endpoint: data.keySharing.endpoint, + requestBody: elementToUse.requestBody, + } + execute(keySharingData, true); +} + // Helpers function selectRequestData(requestData) { var elementToUse = requestData[0]; @@ -440,6 +476,11 @@ async function generateFutureGenerateRequests(count) { return await generateFutureRequests(count, obj) } +async function generateFutureKeySharingRequests(count) { + let obj = { }; + return await generateFutureRequests(count, obj); +} + const generateSinceTimestampStr = () => { var date = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000 /* 2 days ago */); var year = date.getFullYear(); diff --git a/performance-testing/uid2-operator/start-full.sh b/performance-testing/uid2-operator/start-full.sh old mode 100644 new mode 100755 index 374f372..f21fd53 --- a/performance-testing/uid2-operator/start-full.sh +++ b/performance-testing/uid2-operator/start-full.sh @@ -6,4 +6,4 @@ if [ "$#" -ne 1 ]; then COMMENT=$( date '+%F_%H:%M:%S' ) fi -./start-named-test.sh k6-token-generate-refresh-identitymap.js $COMMENT \ No newline at end of file +./start-named-test.sh k6-token-generate-refresh-identitymap-keysharing.js $COMMENT diff --git a/performance-testing/uid2-operator/start-generate-refresh-identitymap.sh b/performance-testing/uid2-operator/start-generate-refresh-identitymap.sh new file mode 100755 index 0000000..374f372 --- /dev/null +++ b/performance-testing/uid2-operator/start-generate-refresh-identitymap.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-token-generate-refresh-identitymap.js $COMMENT \ No newline at end of file diff --git a/performance-testing/uid2-operator/start-token-generate.sh b/performance-testing/uid2-operator/start-generate.sh old mode 100644 new mode 100755 similarity index 100% rename from performance-testing/uid2-operator/start-token-generate.sh rename to performance-testing/uid2-operator/start-generate.sh diff --git a/performance-testing/uid2-operator/start-named-test.sh b/performance-testing/uid2-operator/start-named-test.sh old mode 100644 new mode 100755 index 1c59433..d60ff57 --- a/performance-testing/uid2-operator/start-named-test.sh +++ b/performance-testing/uid2-operator/start-named-test.sh @@ -18,5 +18,43 @@ 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 +operator_url_value=$OPERATOR_URL +client_key_value=$CLIENT_KEY_VALUE +client_secret_value=$CLIENT_SECRET_VALUE + +if [[ -v operator_url_value ]]; then + if [[ "$OPERATOR_URL" == *"/"* ]]; then + operator_url_value=$(echo "$OPERATOR_URL" | sed 's/\//\\\//g') + echo "Escaped OPERATOR_URL: $operator_url_value" + else + operator_url_value="$OPERATOR_URL" + echo "OPERATOR_URL has no slashes: $operator_url_value" + fi + sed -i -e "s/operator_url/$operator_url_value/g" ./k6-test-resource-edited.yml +fi + +if [[ -v client_key_value ]]; then + if [[ "$CLIENT_KEY" == *"/"* ]]; then + client_key_value=$(echo "$CLIENT_KEY" | sed 's/\//\\\//g') + echo "Escaped CLIENT_KEY: $client_key_value" + else + client_key_value="$CLIENT_KEY" + echo "CLIENT_KEY has no slashes: $client_key_value" + fi + sed -i -e "s/client_key/$client_key_value/g" ./k6-test-resource-edited.yml +fi + +if [[ -v client_secret_value ]]; then + if [[ "$CLIENT_SECRET" == *"/"* ]]; then + client_secret_value=$(echo "$CLIENT_SECRET" | sed 's/\//\\\//g') + echo "Escaped CLIENT_SECRET: $client_secret_value" + else + client_secret_value="$CLIENT_SECRET" + echo "CLIENT_SECRET has no slashes: $client_secret_value" + fi + sed -i -e "s/client_secret/$client_secret_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 \ No newline at end of file +kubectl apply -f ./k6-test-resource-edited.yml