mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-10 01:39:02 +00:00
test: harden resilience integration server startup
This commit is contained in:
parent
94ba3b3a23
commit
9aa89b17a5
1 changed files with 26 additions and 2 deletions
|
|
@ -183,7 +183,8 @@ function createFakeOpenAiRelay() {
|
|||
function createServerProcess(dataDir: string, port: number) {
|
||||
const stdoutLines: string[] = [];
|
||||
const stderrLines: string[] = [];
|
||||
const child = spawn(process.execPath, ["scripts/run-next.mjs", "dev"], {
|
||||
let exitInfo: { code: number | null; signal: NodeJS.Signals | null } | null = null;
|
||||
const child = spawn(process.execPath, ["scripts/run-next-playwright.mjs", "dev"], {
|
||||
cwd: REPO_ROOT,
|
||||
env: {
|
||||
...process.env,
|
||||
|
|
@ -201,10 +202,14 @@ function createServerProcess(dataDir: string, port: number) {
|
|||
OMNIROUTE_DISABLE_TOKEN_HEALTHCHECK: "true",
|
||||
OMNIROUTE_DISABLE_LOCAL_HEALTHCHECK: "true",
|
||||
OMNIROUTE_HIDE_HEALTHCHECK_LOGS: "true",
|
||||
OMNIROUTE_E2E_BOOTSTRAP_MODE: "open",
|
||||
},
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
});
|
||||
|
||||
child.once("exit", (code, signal) => {
|
||||
exitInfo = { code, signal };
|
||||
});
|
||||
child.stdout.on("data", (chunk) => {
|
||||
const lines = String(chunk).split(/\r?\n/).filter(Boolean);
|
||||
stdoutLines.push(...lines);
|
||||
|
|
@ -221,16 +226,35 @@ function createServerProcess(dataDir: string, port: number) {
|
|||
stdoutLines,
|
||||
stderrLines,
|
||||
baseUrl: `http://127.0.0.1:${port}`,
|
||||
get exitInfo() {
|
||||
return exitInfo;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async function waitForServer(
|
||||
baseUrl: string,
|
||||
logs: { stdoutLines: string[]; stderrLines: string[] }
|
||||
logs: {
|
||||
stdoutLines: string[];
|
||||
stderrLines: string[];
|
||||
exitInfo?: { code: number | null; signal: NodeJS.Signals | null } | null;
|
||||
}
|
||||
) {
|
||||
const startedAt = Date.now();
|
||||
let lastError = "";
|
||||
while (Date.now() - startedAt < 120_000) {
|
||||
if (logs.exitInfo) {
|
||||
throw new Error(
|
||||
[
|
||||
`OmniRoute exited before it became ready (code=${logs.exitInfo.code}, signal=${logs.exitInfo.signal})`,
|
||||
"--- stdout ---",
|
||||
...logs.stdoutLines.slice(-40),
|
||||
"--- stderr ---",
|
||||
...logs.stderrLines.slice(-40),
|
||||
].join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${baseUrl}/api/monitoring/health`, {
|
||||
signal: AbortSignal.timeout(5_000),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue