mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-17 20:32:25 +03:00
* test(infra): retry recursive temp-dir removal on main (main twin of #11968)
`main` has been red since b342c1a361 on the vitest and integration gates:
✖ tests/unit/autoCombo/provider-family-combos.test.ts > auto/<family>
✖ chat pipeline applies Codex OAuth fingerprint and priority tier inside combos
Both call resetStorage() from beforeEach, which does an fs.rmSync(TEST_DATA_DIR,
{recursive: true, force: true}) with no retry, and intermittently loses the race
with a not-yet-released SQLite handle (ENOTEMPTY).
release/v3.8.51 fixed this in #11968 with a mechanical codemod adding
maxRetries/retryDelay to every recursive rm/rmSync/rmdirSync under tests/, but
that PR landed only on the release branch. Because main only receives work at
the release squash, it stayed broken for the whole cycle — and repo-wide gates
then turn every open PR into main red on checks unrelated to their diff.
This is the --base main twin: re-runs the same codemod that already shipped on
the release branch (scripts/ad-hoc/codemod-rm-maxretries.mjs), so the two
branches converge on identical test-teardown semantics. Test-only; no product
logic is touched.
The remaining three failures reported on #12133 (unit full suite exceeding its
4800s ceiling, package-artifact exceeding 1200s, and the boot-smoke that is
skipped as a consequence) are runner-contention timeouts, not code defects —
validate-release-green.mjs runs those heavy gates concurrently on one shared
hosted runner. There is no fix to port for those.
* chore(scripts): carry the rm-maxretries codemod onto main alongside its output
The codemod that generated the previous commit lives in the repo on
release/v3.8.51 (added by #11968) but was never on main. Bringing it over keeps
the tool next to the change it produced, so the transformation stays
reproducible and auditable from either branch.
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");
|
|
});
|