Test: the request.json write is gated, with the lease lost the moment the worker is healthy

The stub marks its first healthy answer; the stdout line it prints before ready
had been taking the lease through the log-sink gate first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-24 03:57:06 +02:00
commit b4a4e770cf
2 changed files with 3 additions and 2 deletions

View file

@ -6,7 +6,7 @@ import http from "node:http";
import os from "node:os";
import path from "node:path";
import { spawn } from "node:child_process";
import { appendFileSync } from "node:fs";
import { appendFileSync, writeFileSync } from "node:fs";
const argv = process.argv.slice(2);
const flag = (name) => {
@ -56,6 +56,7 @@ if (model === "hang-before-ready") {
if (request.method === "GET" && request.url === "/health") {
healthCalls += 1;
if (model === "sick" || model === "die-after-ready" || (model === "slow-health" && healthCalls <= 2)) return send(200, { ok: false });
writeFileSync(path.join(process.env.VILI_EMBEDDINGS_DIR, "stub-healthy"), ""); // a test can act the moment the worker is healthy
send(200, { ok: true, model: model || "stub-model", displayModel: model || "Stub Model", pid: process.pid, requests });
} else if (request.method === "POST" && request.url === "/generate") {
requests += 1;

View file

@ -874,7 +874,7 @@ const losses = [
{ when: "artifacts/*/meta.json", absent: ["logs", "embeddings"] },
{ when: "logs", absent: ["embeddings"] },
{ when: "embeddings", absent: ["logs/worker.log"] },
{ when: "embeddings/stub-spawns.log", absent: ["artifacts/*/request.json", "jobs/*"] },
{ when: "embeddings/stub-healthy", absent: ["artifacts/*/request.json", "jobs/*"] },
];
for (const { when, absent } of losses) {
test(`a request is stopped at its next write when the lease goes at ${when}`, async () => {