Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

test(runtime): separate scale workloads from routine regressions

kashorince22da565de4
diff --git a/package.json b/package.json
index ddf9b9c3..f4727525 100644
--- a/package.json
+++ b/package.json
@@ -172,6 +172,7 @@
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs",
"test": "node test/run.mjs",
+ "test:runtime-scale": "node test/run.mjs runtime-scale",
"test:whisperx-service": "uv run --project services/whisperx --frozen python -m unittest discover -s services/whisperx/tests -p \"test_*.py\"",
"test:image-opencv": "node test/run.mjs image-opencv",
"hypit": "node bin/hypit.mjs",
diff --git a/packages/runtime-local/README.md b/packages/runtime-local/README.md
index c09e3e6b..9c5ef806 100644
--- a/packages/runtime-local/README.md
+++ b/packages/runtime-local/README.md
@@ -224,3 +224,14 @@ Managed Programs have independent lifetimes. A healthy WhisperX service keeps it
Distribution changes and shell environment changes still concern the coordinator's bootstrap process.
Inspect active work before restarting it. Environment-backed credentials use that inherited process
environment; external writable Credential Stores resolve through their own implementation.
+
+### Concurrency checks
+
+`pnpm test` exercises 24 Builds with an eight-task remote pool and with all 24 submissions pending
+at once. Both cases verify local progress, per-Build module isolation, one submission per Build,
+capacity release and every completed Result. They use the production execution process and SQLite.
+
+`pnpm test:runtime-scale` runs the same checks with 1000 simultaneous remote submissions, on its own.
+This is a load experiment rather than part of every package regression. It reports fixture preparation,
+local progress, completion, executor RSS and cleanup separately; total test time also includes creating
+and removing the temporary Result repositories. Neither suite uses a completion-time performance target.
diff --git a/packages/runtime-local/test/concurrency-process.test.ts b/packages/runtime-local/test/concurrency-process.test.ts
index 77c47b47..9b39a6f8 100644
--- a/packages/runtime-local/test/concurrency-process.test.ts
+++ b/packages/runtime-local/test/concurrency-process.test.ts
@@ -22,8 +22,16 @@ async function until(predicate: () => boolean | Promise<boolean>): Promise<void>
}
}
-for (const scenario of [{ count: 100, capacity: 8 }, { count: 1000, capacity: 1000 }]) {
+// Ordinary regressions exercise queueing and fully concurrent submissions without making
+// every package test compete with a thousand-Build load experiment. The scale suite uses
+// the same production path and assertions, and runs by itself through test/run.mjs.
+const scenarios = process.env.HYPIT_RUNTIME_SCALE_TESTS === "1"
+ ? [{ count: 1000, capacity: 1000 }]
+ : [{ count: 24, capacity: 8 }, { count: 24, capacity: 24 }];
+
+for (const scenario of scenarios) {
test(`${scenario.count} Builds advance local work while remote capacity is ${scenario.capacity}`, { timeout: 120_000 }, async (t) => {
+ const setupAt = Date.now();
const root = await mkdtemp(join(tmpdir(), "hypit-many-builds-"));
const dataRoot = join(root, "runtime");
const profile = join(root, "profile.json");
@@ -99,6 +107,7 @@ for (const scenario of [{ count: 100, capacity: 8 }, { count: 1000, capacity: 10
});
}
const startedAt = Date.now();
+ t.diagnostic(`prepared ${ids.length} Builds in ${startedAt-setupAt}ms`);
supervision = superviseBuilds({ profile, dataRoot, readyFile: join(root,"ready"), owner:"concurrency-test", launch:{command:process.execPath,args:[join(distribution,"bin/hypit.mjs")]}, signal:abort.signal,ready:async()=>{} });
await until(() => local.size === scenario.count && starts.size === scenario.capacity);
assert.equal(processes.size, 1, "remote requests share one process, with private module bindings per Build");
@@ -121,11 +130,13 @@ for (const scenario of [{ count: 100, capacity: 8 }, { count: 1000, capacity: 10
}
t.diagnostic(`local-ready=${allLocalAt-startedAt}ms total=${Date.now()-startedAt}ms executor-rss=${Math.round(peakRss/1024/1024)}MiB processes=${processes.size}`);
} finally {
+ const cleanupAt = Date.now();
completed = true; submitted = true;
for (const response of pending) if (!response.writableEnded) response.end(JSON.stringify({complete:true}));
abort.abort(); await supervision;
server.closeAllConnections(); await new Promise<void>((resolve) => server.close(() => resolve()));
state.close(); await rm(root,{recursive:true,force:true});
+ t.diagnostic(`executor shutdown and fixture cleanup=${Date.now()-cleanupAt}ms`);
}
});
}
diff --git a/packages/runtime-local/test/programs.test.ts b/packages/runtime-local/test/programs.test.ts
index 3336521e..b0695825 100644
--- a/packages/runtime-local/test/programs.test.ts
+++ b/packages/runtime-local/test/programs.test.ts
@@ -359,12 +359,25 @@ test("up stops waiting when a started program exits", async () => {
start: nodeProgram("process.exit(1);"),
probe: async () => ({ state: "down", detail: "nothing is answering" }),
}));
- const startedAt = Date.now();
- const result = await bringManagedProgramsUp(path, { ...options, maxWaitMs: 20_000 });
- assert.ok(Date.now() - startedAt < 5_000, "a dead program must not consume the readiness timeout");
- assert.equal(result.programs[0]!.action, "unchanged");
- assert.match(result.programs[0]!.detail ?? "", /process exited; see/u);
- await assert.rejects(async () => await readFile(join(root, "programs", "example", "process.pid"), "utf8"));
+ const maxWaitMs = 20_000;
+ let waitingAt: number | undefined;
+ try {
+ const result = await bringManagedProgramsUp(path, {
+ ...options, maxWaitMs,
+ onProgress(event) {
+ // Windows starts a separate console through PowerShell before readiness waiting
+ // begins. Its launch time says nothing about detecting an exited service.
+ if (event.phase === "waiting") waitingAt = Date.now();
+ },
+ });
+ assert.notEqual(waitingAt, undefined, "the program must have started");
+ assert.ok(Date.now() - waitingAt! < maxWaitMs, "a dead program must not consume the readiness timeout");
+ assert.equal(result.programs[0]!.action, "unchanged");
+ assert.match(result.programs[0]!.detail ?? "", /process exited; see/u);
+ await assert.rejects(async () => await readFile(join(root, "programs", "example", "process.pid"), "utf8"));
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
});
test("status probes and changes nothing, so it claims no action", async () => {
diff --git a/test/run.mjs b/test/run.mjs
index 240107cd..7e1e39ee 100644
--- a/test/run.mjs
+++ b/test/run.mjs
@@ -22,6 +22,10 @@ function managedPython(project) {
}
const suites = {
+ "runtime-scale": {
+ files: ["packages/runtime-local/test/concurrency-process.test.ts"],
+ env: { HYPIT_RUNTIME_SCALE_TESTS: "1" },
+ },
"image-opencv": {
files: ["packages/provider-image-opencv-local/test/provider.test.ts"],
env: {