mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 05:02:40 +00:00
fix(ci): synchronize build computer cancellation tests
This commit is contained in:
1 parent
b21db3f329
commit
8412ce74ff
3 files changed
+22
-16
No files matched your search
@@ -7,7 +7,6 @@ import {
|
||||
writeFile,
|
||||
} from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { setTimeout as delay } from "node:timers/promises";
|
||||
|
||||
import type { Client } from "@modelcontextprotocol/client";
|
||||
import type { CallToolResult } from "@modelcontextprotocol/server";
|
||||
@@ -591,7 +590,7 @@ it("stops the helper when the caller cancels a start", async () => {
|
||||
const { runner } = await fakes();
|
||||
const client = await connect({
|
||||
...runner.environment,
|
||||
FAKE_DEPLOY_SECONDS: "30",
|
||||
FAKE_HOLD_DEPLOY: "1",
|
||||
});
|
||||
const controller = new AbortController();
|
||||
const call = client.callTool(
|
||||
@@ -601,14 +600,16 @@ it("stops the helper when the caller cancels a start", async () => {
|
||||
},
|
||||
{ signal: controller.signal },
|
||||
);
|
||||
while ((await runner.notes("runs.jsonl")).length === 0) await delay(50);
|
||||
controller.abort();
|
||||
await expect(call).rejects.toThrow();
|
||||
for (let attempt = 0; attempt < 100; attempt += 1) {
|
||||
if ((await runner.notes("interrupted.jsonl")).length > 0) break;
|
||||
await delay(50);
|
||||
}
|
||||
expect(await runner.notes("interrupted.jsonl")).toHaveLength(1);
|
||||
const deploying = waitFor(async () => {
|
||||
const notes = await runner.notes("deploying.jsonl");
|
||||
expect(notes).toHaveLength(1);
|
||||
return notes;
|
||||
}).finally(() => controller.abort());
|
||||
const [, helper] = await Promise.all([
|
||||
expect(call).rejects.toThrow(),
|
||||
deploying,
|
||||
]);
|
||||
await expect.poll(() => runner.notes("interrupted.jsonl")).toEqual(helper);
|
||||
});
|
||||
|
||||
/** An app whose reset keeps the computer unready for `polls` readiness polls, 500 ms apart. */
|
||||
|
||||
@@ -6,26 +6,30 @@ import { expect, it, onTestFinished } from "vitest";
|
||||
|
||||
import { fakeBuildComputers as setUp } from "../../fixtures/fakeAgentEnvComputer.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { waitFor } from "../../support/testWait.js";
|
||||
|
||||
it("joins a start still in progress when the owner closes, and refuses later starts", async () => {
|
||||
const { computers, runner, start } = await setUp(
|
||||
{},
|
||||
{ FAKE_DEPLOY_SECONDS: "30" },
|
||||
{ FAKE_HOLD_DEPLOY: "1" },
|
||||
);
|
||||
const order: string[] = [];
|
||||
const pending = start().then((result) => {
|
||||
order.push("start settled");
|
||||
return result;
|
||||
});
|
||||
while ((await runner.notes("runs.jsonl")).length === 0) await delay(50);
|
||||
await computers.closeAll();
|
||||
const helper = await waitFor(async () => {
|
||||
const notes = await runner.notes("deploying.jsonl");
|
||||
expect(notes).toHaveLength(1);
|
||||
return notes;
|
||||
}).finally(() => computers.closeAll());
|
||||
order.push("closeAll returned");
|
||||
expect(order).toEqual(["start settled", "closeAll returned"]);
|
||||
const started = await pending;
|
||||
expect(started.ok).toBe(false);
|
||||
if (!started.ok) expect(started.error._tag).toBe("AnalysisCancelledError");
|
||||
// Shutdown cancelled the deploy, whose own interruption tore it down.
|
||||
expect(await runner.notes("interrupted.jsonl")).toHaveLength(1);
|
||||
expect(await runner.notes("interrupted.jsonl")).toEqual(helper);
|
||||
const later = await start();
|
||||
expect(later.ok).toBe(false);
|
||||
expect(await runner.notes("runs.jsonl")).toHaveLength(1);
|
||||
|
||||
+3
-2
@@ -658,7 +658,6 @@ import shutil
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import types
|
||||
|
||||
STATE = os.environ["FAKE_STATE"]
|
||||
@@ -705,7 +704,9 @@ def run_bundle(root, *, tasks=(), keep=False, emulate=True, sandbox=None, on_pro
|
||||
os.system("echo a build writing to stdout")
|
||||
print("agentenv writing to stdout")
|
||||
on_progress("deploying the computer")
|
||||
time.sleep(float(os.environ.get("FAKE_DEPLOY_SECONDS", "0")))
|
||||
if os.environ.get("FAKE_HOLD_DEPLOY"):
|
||||
_note("deploying.jsonl", {"pid": os.getpid()})
|
||||
signal.pause()
|
||||
signal.signal(signal.SIGTERM, previous)
|
||||
chatter = int(os.environ.get("FAKE_CHATTER_BYTES", "0"))
|
||||
for line in range(chatter // 80):
|
||||
|
||||
Reference in new issue
Block a user