Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

#5646/#5647: wait for the held pull to start instead of a fixed 300 ms sleep, and keep the shared-VM e2e under 1,000 lines

milind-soni997fc8cc55fa
diff --git a/server/phone-shared-vm.e2e.test.ts b/server/phone-shared-vm.e2e.test.ts
index b160e9f1c1..d1e8731420 100644
--- a/server/phone-shared-vm.e2e.test.ts
+++ b/server/phone-shared-vm.e2e.test.ts
@@ -28,12 +28,7 @@ const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
const lease = () => randomUUID().replaceAll("-", "");
describe("a person's hold on the shared Local VM", () => {
- let home = "";
- let base = "";
- let stateFile = "";
- let dumpFile = "";
- let finishFile = "";
- let output = "";
+ let home = "", base = "", stateFile = "", dumpFile = "", finishFile = "", output = "";
let child: ChildProcess | null = null;
let boatServer: Server;
let boatRow: { id: string; name: string; state: string } | null = null;
@@ -357,9 +352,9 @@ describe("a person's hold on the shared Local VM", () => {
vmState();
await setIdleMinutes(480);
- vmState({ ...READY, holdPull: true });
+ rmSync(`${stateFile}.pull`, { force: true }); vmState({ ...READY, holdPull: true });
const pulling = api("POST", "/api/local-computer/pull", {});
- await sleep(300);
+ await until(() => existsSync(`${stateFile}.pull`), Boolean);
const refused = await control(api, witness, { action: "take" });
expect(refused.status).toBe(409);
expect(await held(witness)).toBe(false);
diff --git a/server/testing/group-local-vm-hooks.mjs b/server/testing/group-local-vm-hooks.mjs
index fcb355780f..a220287f20 100644
--- a/server/testing/group-local-vm-hooks.mjs
+++ b/server/testing/group-local-vm-hooks.mjs
@@ -83,7 +83,7 @@ registerHooks({
}
export async function containerComputerAction(action, _run, _platform, target = SHARED_LOCAL_VM_TARGET) {
if (action === 'pull' && read().containers) {
- while (read().holdPull) await new Promise(r => setTimeout(r, 30));
+ while (read().holdPull) { writeFileSync(file + '.pull', '1'); await new Promise(r => setTimeout(r, 30)); }
const state = read();
state.imageMissing = false;
state.actions = [...(state.actions ?? []), { action, target: target.key }];