Skip to content

Commit 3cb29b8

Browse files
committed
add key sharing
1 parent 70b37e5 commit 3cb29b8

File tree

2 files changed

+49
-9
lines changed

2 files changed

+49
-9
lines changed

performance-testing/uid2-operator/k6-token-generate-refresh-identitymap.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ export const options = {
4848
{ duration: '30s', target: identityMapVUs}
4949
],
5050
gracefulRampDown: '0s',
51-
},
52-
// keySharingWarmup: {
53-
// executor: 'ramping-vus',
54-
// exec: 'keySharing',
55-
// stages: [
56-
// { duration: '30s', target: keySharingVUs}
57-
// ],
58-
// gracefulRampDown: '0s',
59-
// },
51+
},/*
52+
keySharingWarmup: {
53+
executor: 'ramping-vus',
54+
exec: 'keySharing',
55+
stages: [
56+
{ duration: '30s', target: keySharingVUs}
57+
],
58+
gracefulRampDown: '0s',
59+
},*/
6060
// Actual testing scenarios
6161
tokenGenerate: {
6262
executor: 'constant-vus',

performance-testing/uid2-operator/k6-token-generate.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const clientKey = "";
1212
const generateVUs = vus;
1313
const refreshVUs = vus;
1414
const identityMapVUs = vus;
15+
const keySharingVUs = vus;
1516
const testDuration = '10m'
1617

1718
//30 warm up on each
@@ -47,6 +48,14 @@ export const options = {
4748
{ duration: '30s', target: identityMapVUs}
4849
],
4950
gracefulRampDown: '0s',
51+
},
52+
keySharingWarmup: {
53+
executor: 'ramping-vus',
54+
exec: 'keySharing',
55+
stages: [
56+
{ duration: '30s', target: keySharingVUs}
57+
],
58+
gracefulRampDown: '0s',
5059
},*/
5160
// Actual testing scenarios
5261
tokenGenerate: {
@@ -73,6 +82,14 @@ export const options = {
7382
gracefulStop: '0s',
7483
startTime: '30s',
7584
},
85+
keySharing:{
86+
executor: 'constant-vus',
87+
exec: 'keySharing',
88+
vus: keySharingVUs,
89+
duration: testDuration,
90+
gracefulStop: '0s',
91+
startTime: '30s',
92+
}
7693
identityMapLargeBatchSequential: {
7794
executor: 'constant-vus',
7895
exec: 'identityMapLargeBatch',
@@ -213,6 +230,24 @@ export function identityBuckets(data) {
213230
execute(bucketData, true);
214231
}
215232

233+
export async function keySharing(data) {
234+
const endpoint = '/v2/key/sharing';
235+
if (data.keySharing == null) {
236+
var newData = await generateKeySharingRequestWithTime();
237+
data.keySharing = newData;
238+
} else if (data.keySharing.time < (Date.now() - 45000)) {
239+
data.keySharing = await generateKeySharingRequestWithTime();
240+
}
241+
242+
var requestBody = data.keySharing.requestBody;
243+
var keySharingData = {
244+
endpoint: endpoint,
245+
requestBody: requestBody,
246+
}
247+
248+
execute(keySharingData, true);
249+
}
250+
216251
// Helpers
217252
async function createReqWithTimestamp(timestampArr, obj) {
218253
var envelope = getEnvelopeWithTimestamp(timestampArr, obj);
@@ -401,6 +436,11 @@ async function generateIdentityMapRequestWithTime(emailCount) {
401436
return await generateRequestWithTime(emails);
402437
}
403438

439+
async function generateKeySharingRequestWithTime() {
440+
let requestData = { };
441+
return await generateRequestWithTime(requestData);
442+
}
443+
404444
const generateSinceTimestampStr = () => {
405445
var date = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000 /* 2 days ago */);
406446
var year = date.getFullYear();

0 commit comments

Comments
 (0)