Skip to content

Commit 279f96f

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 279f96f

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

test/load/devworkspace_load_test.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,16 @@ 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,
5251
},
5352
final_cleanup: {
5453
executor: 'per-vu-iterations',
5554
vus: 1,
5655
iterations: 1,
57-
startTime: `${loadTestDurationInMinutes}m`,
5856
exec: 'final_cleanup',
57+
startTime: '0s', // run after main scenario finishes
5958
},
6059
}, thresholds: {
6160
'checks': ['rate>0.95'],
@@ -91,7 +90,10 @@ export function setup() {
9190

9291
export default function () {
9392
if (maxDevWorkspaces > 0) {
94-
const devWorkspaces = getDevWorkspacesFromApiServer();
93+
const { error, devWorkspaces } = getDevWorkspacesFromApiServer();
94+
if (error) {
95+
return;
96+
}
9597
const totalDevWorkspaces = devWorkspaces.length;
9698

9799
const runningDevWorkspaces = devWorkspaces.filter(
@@ -468,12 +470,21 @@ function getDevWorkspacesFromApiServer() {
468470
const res = http.get(url, { headers });
469471

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

475482
const body = JSON.parse(res.body);
476-
return body.items;
483+
484+
return {
485+
error: null,
486+
devWorkspaces: body.items,
487+
};
477488
}
478489

479490
function generateDevWorkspaceToCreate(vuId, iteration, namespace) {
@@ -523,4 +534,4 @@ function parseCpuToMillicores(cpuStr) {
523534
if (cpuStr.endsWith("u")) return Math.round(parseInt(cpuStr) / 1e3);
524535
if (cpuStr.endsWith("m")) return parseInt(cpuStr);
525536
return Math.round(parseFloat(cpuStr) * 1000);
526-
}
537+
}

0 commit comments

Comments
 (0)