Skip to content

Commit 06b81de

Browse files
committed
fix : use shared-iterations executor to run an exact number of devworkspace iterations
The previous ramping-vus configuration generated inconsistent iteration counts due to VU loop timing. Switched to shared-iterations, configured with `vus: maxVUs` and `iterations: maxDevWorkspaces`, ensuring the test creates exactly the intended number of devworkspaces. Signed-off-by: Rohan Kumar <[email protected]>
1 parent b36af07 commit 06b81de

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

test/load/devworkspace_load_test.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,18 @@ const headers = {
4545
export const options = {
4646
scenarios: {
4747
create_and_delete_devworkspaces: {
48-
executor: 'ramping-vus',
49-
startVUs: 0,
50-
stages: generateLoadTestStages(maxVUs),
51-
gracefulRampDown: '1m',
48+
executor: 'shared-iterations',
49+
vus: maxVUs,
50+
iterations: maxDevWorkspaces,
51+
maxDuration: '0', // 0 disables the time limit; run until all iterations complete
5252
},
5353
final_cleanup: {
5454
executor: 'per-vu-iterations',
5555
vus: 1,
5656
iterations: 1,
57-
startTime: `${loadTestDurationInMinutes}m`,
5857
exec: 'final_cleanup',
58+
startTime: '0s', // run after main scenario finishes
59+
maxDuration: '0',
5960
},
6061
}, thresholds: {
6162
'checks': ['rate>0.95'],
@@ -91,7 +92,10 @@ export function setup() {
9192

9293
export default function () {
9394
if (maxDevWorkspaces > 0) {
94-
const devWorkspaces = getDevWorkspacesFromApiServer();
95+
const { error, devWorkspaces } = getDevWorkspacesFromApiServer();
96+
if (error) {
97+
return;
98+
}
9599
const totalDevWorkspaces = devWorkspaces.length;
96100

97101
const runningDevWorkspaces = devWorkspaces.filter(
@@ -468,12 +472,21 @@ function getDevWorkspacesFromApiServer() {
468472
const res = http.get(url, { headers });
469473

470474
if (res.status !== 200) {
471-
console.error(`Failed to fetch DevWorkspaces: ${res.status} ${res.statusText || ''}`);
472-
return [];
475+
const errorMsg = `Failed to fetch DevWorkspaces: ${res.status} ${res.statusText || ''}`;
476+
console.error(errorMsg);
477+
478+
return {
479+
error: errorMsg,
480+
devWorkspaces: null,
481+
};
473482
}
474483

475484
const body = JSON.parse(res.body);
476-
return body.items;
485+
486+
return {
487+
error: null,
488+
devWorkspaces: body.items,
489+
};
477490
}
478491

479492
function generateDevWorkspaceToCreate(vuId, iteration, namespace) {
@@ -523,4 +536,4 @@ function parseCpuToMillicores(cpuStr) {
523536
if (cpuStr.endsWith("u")) return Math.round(parseInt(cpuStr) / 1e3);
524537
if (cpuStr.endsWith("m")) return parseInt(cpuStr);
525538
return Math.round(parseFloat(cpuStr) * 1000);
526-
}
539+
}

0 commit comments

Comments
 (0)