27 lines
692 B
TypeScript
27 lines
692 B
TypeScript
const baseUrl = process.env.LOAD_BASE_URL ?? 'http://localhost:3000';
|
|
const rounds = Number(process.env.LOAD_ROUNDS ?? 25);
|
|
|
|
const run = async () => {
|
|
const start = Date.now();
|
|
|
|
for (let i = 0; i < rounds; i += 1) {
|
|
const [live, ready, metrics] = await Promise.all([
|
|
fetch(`${baseUrl}/ops/live`),
|
|
fetch(`${baseUrl}/ops/ready`),
|
|
fetch(`${baseUrl}/ops/metrics`),
|
|
]);
|
|
|
|
if (!live.ok || !ready.ok || !metrics.ok) {
|
|
throw new Error(`Smoke load failed at round ${i + 1}`);
|
|
}
|
|
}
|
|
|
|
const totalMs = Date.now() - start;
|
|
console.log(`Completed ${rounds} rounds in ${totalMs}ms`);
|
|
};
|
|
|
|
run().catch((error) => {
|
|
console.error(error);
|
|
process.exit(1);
|
|
});
|