Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Tests: wait for the outcome, not a fixed time, in the sweep and beat checks

Adarshd62319d5edc4
diff --git a/tests/moderation-hook.test.ts b/tests/moderation-hook.test.ts
index 74ca348b..5e19b2f6 100644
--- a/tests/moderation-hook.test.ts
+++ b/tests/moderation-hook.test.ts
@@ -175,8 +175,9 @@ describe("the output check", () => {
// Show: served, and the row succeeds.
mod.output = { decision: "show" };
db().prepare("UPDATE output_checks SET next_at = 0 WHERE generation_id = ?").run(id);
+ // A sweep already under way (the run loop's) makes this one return at once: the next one settles it.
await checks.sweepOutputChecks();
- expect(row(id).status).toBe("succeeded");
+ await until(() => row(id).status === "succeeded");
expect(fileHeld(held)).toBe(false);
expect(fileAccount(held)).toBe(a);
});
diff --git a/tests/worker-recovery.test.ts b/tests/worker-recovery.test.ts
index ecfef0da..7dab705d 100644
--- a/tests/worker-recovery.test.ts
+++ b/tests/worker-recovery.test.ts
@@ -487,8 +487,8 @@ http.createServer((q, s) => {
await until(() => p.logs.some((l) => /stopped answering/.test(l)), 60_000);
expect(Date.now() - t0).toBeLessThan(30_000);
const beats = s.calls.filter((c) => c.endsWith("/beat")).length;
- await sleep(12_000);
- expect(s.calls.filter((c) => c.endsWith("/beat")).length).toBeGreaterThan(beats);
+ // Beats come every 10 s while idle: the next one within two of them (a slow machine runs the loop late).
+ await until(() => s.calls.filter((c) => c.endsWith("/beat")).length > beats, 20_000);
await until(() => p.logs.filter((l) => /Starting its own ComfyUI/.test(l)).length >= 2, 30_000);
});
@@ -929,12 +929,14 @@ describe("its model folders", () => {
return false;
}, 30_000);
await until(() => beats.some((b) => typeof b.slept === "number" && (b.slept as number) >= 5 * 60_000));
+ const told = beats.findIndex((b) => typeof b.slept === "number");
const done = await ended(id);
expect(done.state).toBe("done");
// The attempt lost to the sleep was taken back: no blame on the worker.
expect(done.requeues).toBe(0);
expect(done.tried_json).toBeNull();
- // Once heard, the sleep isn't said again.
+ // Once heard, the sleep isn't said again (on a slow machine the job can end before the next beat: wait for it).
+ await until(() => beats.length > told + 1);
const last = beats.at(-1)!;
expect(last.slept).toBeUndefined();
});
diff --git a/tests/worker-turns-run.test.ts b/tests/worker-turns-run.test.ts
index c612c9bd..701b60cd 100644
--- a/tests/worker-turns-run.test.ts
+++ b/tests/worker-turns-run.test.ts
@@ -425,7 +425,7 @@ describe("studio jobs first", () => {
expect(p.logs.some((l) => /runs nothing and keeps its models loaded/.test(l))).toBe(true);
expect((await until(() => ["done", "failed"].includes(task(id).state) && task(id), 60_000)).state).toBe("done");
// It never asked for room, and never paused; a minute after the job (shortened here) it writes 0 again.
- expect(p.logs.some((l) => /make room|Another program/.test(l))).toBe(false);
+ expect(p.logs.filter((l) => /make room|Another program/.test(l))).toEqual([]);
await until(() => site(p)?.siteWaiting === 0, 20_000);
});