Skip to content

Commit acdb86d

Browse files
committed
fix : add logic to abort test execution when max devworkspaces target is reached
Instead of returning from each VU iteration after checking number of currently running DevWorkspaces, abort the test execution to save time and reduce load on K8s apiserver. Signed-off-by: Rohan Kumar <[email protected]>
1 parent 81d2ec4 commit acdb86d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/load/devworkspace_load_test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import http from 'k6/http';
1717
import {check, sleep} from 'k6';
1818
import {Trend, Counter} from 'k6/metrics';
19+
import { test } from 'k6/execution';
1920
import {htmlReport} from "https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js";
2021
import {textSummary} from "https://jslib.k6.io/k6-summary/0.0.1/index.js";
2122

@@ -92,7 +93,7 @@ export default function () {
9293
if (maxDevWorkspaces > 0) {
9394
const totalDevWorkspaces = getDevWorkspacesFromApiServer().length;
9495
if (totalDevWorkspaces > maxDevWorkspaces) {
95-
return;
96+
test.abort('Max concurrent DevWorkspaces target achieved, stopping test gracefully', { abortOnFail: false });
9697
}
9798
}
9899
const vuId = __VU;
@@ -457,7 +458,9 @@ function getDevWorkspacesFromApiServer() {
457458
}
458459

459460
const body = JSON.parse(res.body);
460-
return body.items.map((dw) => dw.metadata.name);
461+
return body.items
462+
.filter((dw) => dw.status && dw.status.phase === 'Running')
463+
.map((dw) => dw.metadata.name);
461464
}
462465

463466
function generateDevWorkspaceToCreate(vuId, iteration, namespace) {

0 commit comments

Comments
 (0)