mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-19 21:32:20 +03:00
Two shards on release/v3.8.51 went red in one day with the same signature —
"ENOTEMPTY, Directory not empty: /tmp/omniroute-<test>-XXXXXX" — from
combo-same-provider-cascade (Unit Tests fast-path 4/4, on a PR that touches only
.github/) and auth-policy-embeddings-webfetch-7785 (the 20k-test TIA step). Both pass
alone and on re-run: the cleanup races something still writing into the directory
(SQLite WAL/-shm checkpoint, a worker, the backup) and under a loaded hosted runner
the window opens. 1154 test files do their own cleanup with
fs.rmSync(dir, { recursive: true, force: true }); 57 already asked for retries.
One-shot codemod (scripts/ad-hoc/codemod-rm-maxretries.mjs, kept for the record):
every rm / rmSync / rmdirSync option object with `recursive: true` and no
`maxRetries` gains `maxRetries: 5, retryDelay: 100` — Node itself then retries
ENOTEMPTY/EBUSY/EPERM for up to ~0.5 s before giving up. 2243 call sites in 1292
files under tests/, the shared tests/_setup/isolateDataDir.ts exit hook included.
Only the option object changes: no call site, assertion or import is touched.
Validation: prettier and ESLint (with the frozen suppressions) clean on all 1292
files; a random 20-file sample runs green (quota-redis-store hangs identically on
the untouched tree — it needs a Redis on localhost, an environment matter). The
four unit shards on this PR are the full run.
138 lines
5.5 KiB
TypeScript
138 lines
5.5 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-alias-seed-"));
|
|
process.env.DATA_DIR = TEST_DATA_DIR;
|
|
|
|
const core = await import("../../src/lib/db/core.ts");
|
|
const modelsDb = await import("../../src/lib/db/models.ts");
|
|
const sseModelService = await import("../../src/sse/services/model.ts");
|
|
const { DEFAULT_MODEL_ALIAS_SEED, seedDefaultModelAliases } =
|
|
await import("../../src/lib/modelAliasSeed.ts");
|
|
|
|
async function resetStorage() {
|
|
core.resetDbInstance();
|
|
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
fs.mkdirSync(TEST_DATA_DIR, { recursive: true });
|
|
}
|
|
|
|
test.beforeEach(async () => {
|
|
await resetStorage();
|
|
});
|
|
|
|
test.after(async () => {
|
|
core.resetDbInstance();
|
|
fs.rmSync(TEST_DATA_DIR, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
});
|
|
|
|
test("default model alias seed writes missing aliases and is idempotent", async () => {
|
|
const first = await seedDefaultModelAliases();
|
|
const aliases = await modelsDb.getModelAliases();
|
|
|
|
assert.deepEqual(first.failed, []);
|
|
assert.equal(first.applied.length, Object.keys(DEFAULT_MODEL_ALIAS_SEED).length);
|
|
assert.equal(aliases["gemini-3.1-pro"], "agy/gemini-pro-agent");
|
|
assert.equal(aliases["gemini-3-pro-high"], undefined);
|
|
assert.equal(aliases["gemini-3-pro-low"], undefined);
|
|
assert.equal(aliases["gemini-3-pro-preview"], undefined);
|
|
assert.equal(aliases["gemini-3.1-pro-preview"], undefined);
|
|
assert.equal(aliases["gemini-3-flash-preview"], undefined);
|
|
|
|
const routed = await sseModelService.getModelInfo("gemini-3.1-pro");
|
|
// The stored alias target is "agy/gemini-pro-agent", but getModelInfo canonicalizes
|
|
// the "agy" alias to its provider id "antigravity" (ALIAS_TO_PROVIDER_ID, #8013).
|
|
// supportsThinking is surfaced from the registry's supportsReasoning flag since #9485.
|
|
assert.deepEqual(routed, {
|
|
provider: "antigravity",
|
|
model: "gemini-pro-agent",
|
|
extendedContext: false,
|
|
supportsThinking: true,
|
|
});
|
|
|
|
const second = await seedDefaultModelAliases();
|
|
assert.equal(second.applied.length, 0);
|
|
assert.equal(second.failed.length, 0);
|
|
assert.equal(second.skipped.length, Object.keys(DEFAULT_MODEL_ALIAS_SEED).length);
|
|
});
|
|
|
|
test("default model alias seed preserves existing aliases and skips invalid entries", async () => {
|
|
await modelsDb.setModelAlias("gemini-3.1-pro", "custom/canonical-model");
|
|
await modelsDb.setModelAlias("gemini-3-pro-low", "custom/legacy-model");
|
|
|
|
const warnings = [];
|
|
const result = await seedDefaultModelAliases({
|
|
logger: {
|
|
warn: (message) => warnings.push(String(message)),
|
|
},
|
|
seedMap: {
|
|
...DEFAULT_MODEL_ALIAS_SEED,
|
|
"broken-entry": null,
|
|
},
|
|
});
|
|
const aliases = await modelsDb.getModelAliases();
|
|
|
|
assert.equal(aliases["gemini-3.1-pro"], "custom/canonical-model");
|
|
assert.equal(aliases["gemini-3-pro-low"], "custom/legacy-model");
|
|
assert.ok(result.skipped.includes("gemini-3.1-pro"));
|
|
assert.equal(result.removed.includes("gemini-3-pro-low"), false);
|
|
assert.ok(result.failed.includes("broken-entry"));
|
|
assert.ok(warnings.some((message) => message.includes("broken-entry")));
|
|
});
|
|
|
|
test("default model alias seed replaces superseded Gemini Pro aliases with 3.1 Pro", async () => {
|
|
await modelsDb.setModelAlias("gemini-3-pro-high", "agy/gemini-3.1-pro-high");
|
|
await modelsDb.setModelAlias("gemini-3-pro-low", "agy/gemini-3.1-pro-low");
|
|
await modelsDb.setModelAlias("gemini-3-pro-preview", "agy/gemini-pro-agent");
|
|
await modelsDb.setModelAlias("gemini-3.1-pro-preview", "agy/gemini-pro-agent");
|
|
|
|
const result = await seedDefaultModelAliases();
|
|
const aliases = await modelsDb.getModelAliases();
|
|
|
|
assert.deepEqual(result.removed.sort(), [
|
|
"gemini-3-pro-high",
|
|
"gemini-3-pro-low",
|
|
"gemini-3-pro-preview",
|
|
"gemini-3.1-pro-preview",
|
|
]);
|
|
assert.ok(result.applied.includes("gemini-3.1-pro"));
|
|
assert.equal(aliases["gemini-3.1-pro"], "agy/gemini-pro-agent");
|
|
assert.equal(aliases["gemini-3-pro-high"], undefined);
|
|
assert.equal(aliases["gemini-3-pro-low"], undefined);
|
|
assert.equal(aliases["gemini-3-pro-preview"], undefined);
|
|
assert.equal(aliases["gemini-3.1-pro-preview"], undefined);
|
|
});
|
|
|
|
test("default model alias seed removes the short-lived Pro High alias", async () => {
|
|
await modelsDb.setModelAlias("gemini-3-pro-high", "agy/gemini-pro-agent");
|
|
|
|
const result = await seedDefaultModelAliases();
|
|
const aliases = await modelsDb.getModelAliases();
|
|
|
|
assert.ok(result.removed.includes("gemini-3-pro-high"));
|
|
assert.equal(aliases["gemini-3-pro-high"], undefined);
|
|
assert.equal(aliases["gemini-3.1-pro"], "agy/gemini-pro-agent");
|
|
});
|
|
|
|
test("default model alias seed removes the retired Gemini Flash default alias", async () => {
|
|
await modelsDb.setModelAlias("gemini-3-flash-preview", "agy/gemini-3.5-flash-medium");
|
|
|
|
const result = await seedDefaultModelAliases();
|
|
const aliases = await modelsDb.getModelAliases();
|
|
|
|
assert.deepEqual(result.removed, ["gemini-3-flash-preview"]);
|
|
assert.equal(aliases["gemini-3-flash-preview"], undefined);
|
|
});
|
|
|
|
test("default model alias seed preserves a customized retired alias", async () => {
|
|
await modelsDb.setModelAlias("gemini-3-flash-preview", "custom/provider-model");
|
|
|
|
const result = await seedDefaultModelAliases();
|
|
const aliases = await modelsDb.getModelAliases();
|
|
|
|
assert.deepEqual(result.removed, []);
|
|
assert.equal(aliases["gemini-3-flash-preview"], "custom/provider-model");
|
|
});
|