Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make load tests more resilient to slow metrics-server startup in GH CI #1634

Merged
merged 3 commits into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 40 additions & 6 deletions hack/load.cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ program
log(await cmd.run(), "");

//
// run test
// run deploy
//

log(`Pepr CLI version`);
Expand Down Expand Up @@ -479,6 +479,27 @@ program
});
log({ cmd: cmd.cmd, cwd: cmd.cwd, env });
log(await cmd.run(), "");

log(`Wait for metrics on the Pepr controller to become available`);
const start = Date.now();
const max = lib.toMs("2m");
while (true) {
const now = Date.now();
const dur = now - start;
if (dur > max) {
console.error(`Timeout waiting for metrics-server to be ready.`);
process.exit(1);
}

cmd = new Cmd({ cmd: `kubectl top --namespace pepr-system pod --no-headers`, env });
let res = await cmd.runRaw();
if (res.exitcode === 0) {
log({ max: lib.toHuman(max), actual: lib.toHuman(dur) }, "");
break;
}

await nap(lib.toMs("5s"));
}
});

program
Expand Down Expand Up @@ -736,8 +757,15 @@ program
.concat("\n");
await fs.appendFile(audFile, outlines);
};
audience(); // run immediately, then on schedule
const ticket = setInterval(audience, opts.audInterval);
await audience(); // run immediately, then on schedule
const ticket = setInterval(async () => {
try {
await audience();
} catch (e) {
console.error(e);
process.exit(1);
}
}, opts.audInterval);

await nap(opts.stagger); // stagger interval starts

Expand All @@ -763,9 +791,15 @@ program
await fs.appendFile(actFile, Date.now().toString() + "\n");
}
};
actress(); // run immediately, then on schedule
const backstagePass = setInterval(() => actress(abort), opts.actInterval);

await actress(); // run immediately, then on schedule
const backstagePass = setInterval(async () => {
try {
await actress(abort);
} catch (e) {
console.error(e);
process.exit(1);
}
}, opts.actInterval);
// wait until total duration has elapsed
const startWait = Date.now();
await nap(opts.duration - (startWait - alpha));
Expand Down
Loading