Skip to content

Commit 084fac1

Browse files
committed
test: make event-store soak deterministic on windows
1 parent 6abb915 commit 084fac1

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

universal-refiner/scripts/stress/event-store-soak-worker.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import { EventStore } from "../../dist/src/history/event-store.js";
22

33
const workerId = process.argv[2];
44
const durationMs = Number.parseInt(process.argv[3] || "10000", 10);
5+
const minOperations = Number.parseInt(process.argv[4] || "0", 10);
56
const deadline = Date.now() + durationMs;
67
const counts = { events: 0, prompts: 0, executions: 0, operations: 0 };
78
const store = EventStore.getInstance();
89
let index = 0;
910
let lastPromptId;
1011

11-
while (Date.now() < deadline) {
12+
while (Date.now() < deadline || counts.operations < minOperations) {
1213
const id = `soak-${workerId}-${index}`;
1314
const operation = index % 3;
1415

universal-refiner/scripts/stress/event-store-soak.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ export async function runEventStoreSoak(options = {}) {
2525
const workers = readPositiveInteger(options.workers, 4, "workers");
2626
const durationMs = readPositiveInteger(options.durationMs, 10_000, "durationMs");
2727
const minOperations = readPositiveInteger(options.minOperations, workers * 10, "minOperations");
28+
const minOperationsPerWorker = Math.ceil(minOperations / workers);
2829
const maxLossRatio = readRatio(options.maxLossRatio, 0, "maxLossRatio");
2930
const directory = await mkdtemp(join(tmpdir(), "prompt-refiner-soak-"));
3031
const databasePath = join(directory, "events.db");
3132

3233
try {
3334
const results = await Promise.all(Array.from({ length: workers }, async (_, index) => {
34-
const result = await runProcess(process.execPath, [workerScript, String(index), String(durationMs)], {
35+
const result = await runProcess(process.execPath, [workerScript, String(index), String(durationMs), String(minOperationsPerWorker)], {
3536
cwd: repoRoot,
3637
env: { ...process.env, PROMPT_REFINER_GLOBAL_DIR: directory, PROMPT_REFINER_LOG_LEVEL: "error" },
3738
timeoutMs: durationMs + 30_000,

0 commit comments

Comments
 (0)