Skip to content

Commit 67d9057

Browse files
committed
Replication benchmark cleanup and readme
1 parent 8023370 commit 67d9057

File tree

2 files changed

+38
-36
lines changed

2 files changed

+38
-36
lines changed

apps/webapp/test/runsReplicationBenchmark.README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,13 @@ cd apps/webapp
8484
BENCHMARK_NUM_RUNS=50000 pnpm run test ./test/runsReplicationBenchmark.test.ts --run
8585
```
8686

87-
**Note:** The test is marked with `.skip` by default. To run it, remove the `.skip` from the test:
87+
**Note:** The benchmark is gated by the `BENCHMARKS_ENABLED` environment variable
88+
(via `containerTest.skipIf`), so you don't need to edit the test file. Set
89+
`BENCHMARKS_ENABLED=1` (and optionally `BENCHMARK_NUM_RUNS`) then run:
8890

89-
```typescript
90-
// Change this:
91-
containerTest.skip("should benchmark...", async () => {
92-
93-
// To this:
94-
containerTest("should benchmark...", async () => {
91+
```bash
92+
cd apps/webapp
93+
BENCHMARKS_ENABLED=1 pnpm run test ./test/runsReplicationBenchmark.test.ts --run
9594
```
9695

9796
## What Gets Measured

apps/webapp/test/runsReplicationBenchmark.test.ts

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -344,36 +344,39 @@ async function runBenchmark(
344344
const eluMonitor = new ELUMonitor();
345345
eluMonitor.start(100);
346346

347-
// Run producer in separate process
348-
console.log("\n[Benchmark] Starting producer...");
349-
const producerStats = await runProducer({
350-
postgresUrl: postgresContainer.getConnectionUri(),
351-
organizationId: organization.id,
352-
projectId: project.id,
353-
environmentId: runtimeEnvironment.id,
354-
numRuns: BENCHMARK_CONFIG.NUM_RUNS,
355-
errorRate: BENCHMARK_CONFIG.ERROR_RATE,
356-
batchSize: BENCHMARK_CONFIG.PRODUCER_BATCH_SIZE,
357-
});
358-
359-
console.log("\n[Benchmark] Waiting for replication to complete...");
360-
const replicationResult = await waitForReplication(
361-
clickhouse,
362-
organization.id,
363-
producerStats.created,
364-
BENCHMARK_CONFIG.REPLICATION_TIMEOUT_MS
365-
);
366-
367-
// Stop ELU monitoring
368-
const eluStats = eluMonitor.stop();
369-
370-
// Get metrics
371-
const metrics = await metricsHelper.getMetrics();
372-
const metricsStats = extractMetrics(metrics);
347+
let producerStats!: BenchmarkResult["producerStats"];
348+
let replicationResult!: { duration: number; replicatedRuns: number };
349+
let metricsStats!: BenchmarkResult["metricsStats"];
350+
let eluStats!: BenchmarkResult["eluStats"];
351+
352+
try {
353+
// Run producer in separate process
354+
console.log("\n[Benchmark] Starting producer...");
355+
producerStats = await runProducer({
356+
postgresUrl: postgresContainer.getConnectionUri(),
357+
organizationId: organization.id,
358+
projectId: project.id,
359+
environmentId: runtimeEnvironment.id,
360+
numRuns: BENCHMARK_CONFIG.NUM_RUNS,
361+
errorRate: BENCHMARK_CONFIG.ERROR_RATE,
362+
batchSize: BENCHMARK_CONFIG.PRODUCER_BATCH_SIZE,
363+
});
373364

374-
// Cleanup
375-
await runsReplicationService.stop();
376-
await metricsHelper.shutdown();
365+
console.log("\n[Benchmark] Waiting for replication to complete...");
366+
replicationResult = await waitForReplication(
367+
clickhouse,
368+
organization.id,
369+
producerStats.created,
370+
BENCHMARK_CONFIG.REPLICATION_TIMEOUT_MS
371+
);
372+
373+
const metrics = await metricsHelper.getMetrics();
374+
metricsStats = extractMetrics(metrics);
375+
} finally {
376+
eluStats = eluMonitor.stop();
377+
await runsReplicationService.stop();
378+
await metricsHelper.shutdown();
379+
}
377380

378381
const throughput = (replicationResult.replicatedRuns / replicationResult.duration) * 1000;
379382

0 commit comments

Comments
 (0)