mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:10:43 +00:00
test: stabilize BlueBubbles catchup parallelism
This commit is contained in:
@@ -115,16 +115,21 @@ describe("runBlueBubblesCatchup", () => {
|
||||
|
||||
let fetchCount = 0;
|
||||
let processCount = 0;
|
||||
let resolveFetch: (() => void) | null = null;
|
||||
let releaseFetch: (() => void) | undefined;
|
||||
let fetchStartedResolve: (() => void) | undefined;
|
||||
const fetchStarted = new Promise<void>((resolve) => {
|
||||
fetchStartedResolve = resolve;
|
||||
});
|
||||
|
||||
const call1 = runBlueBubblesCatchup(makeTarget(), {
|
||||
now: () => now,
|
||||
fetchMessages: async () => {
|
||||
fetchCount++;
|
||||
fetchStartedResolve?.();
|
||||
// Block until we fire the second call, so we can verify it
|
||||
// coalesces rather than starting a new run.
|
||||
await new Promise<void>((resolve) => {
|
||||
resolveFetch = resolve;
|
||||
releaseFetch = resolve;
|
||||
});
|
||||
return {
|
||||
resolved: true,
|
||||
@@ -136,8 +141,9 @@ describe("runBlueBubblesCatchup", () => {
|
||||
},
|
||||
});
|
||||
|
||||
// Wait a tick for call1 to enter fetchMessages, then fire call2.
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, 5));
|
||||
// Wait for call1 to enter fetchMessages, then fire call2. A fixed
|
||||
// sleep is load-sensitive and can leave call1 permanently blocked.
|
||||
await fetchStarted;
|
||||
const call2 = runBlueBubblesCatchup(makeTarget(), {
|
||||
now: () => now,
|
||||
fetchMessages: async () => {
|
||||
@@ -149,7 +155,7 @@ describe("runBlueBubblesCatchup", () => {
|
||||
},
|
||||
});
|
||||
|
||||
resolveFetch!();
|
||||
releaseFetch?.();
|
||||
const [r1, r2] = await Promise.all([call1, call2]);
|
||||
|
||||
expect(fetchCount).toBe(1); // second call coalesced, didn't re-fetch
|
||||
|
||||
@@ -17,7 +17,6 @@ export function createExtensionBlueBubblesVitestConfig(
|
||||
{
|
||||
dir: "extensions",
|
||||
env,
|
||||
isolate: true,
|
||||
name: "extension-bluebubbles",
|
||||
passWithNoTests: true,
|
||||
setupFiles: ["test/setup.extensions.ts"],
|
||||
|
||||
Reference in New Issue
Block a user