Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **test(autoCombo):** two AutoCombo Vitest tests no longer time out under parallel load — `autoCombo.test.ts` and `tieredRotation.test.ts` warm the task-fitness DB in a scoped `beforeAll`, so the lazy first-call init no longer counts against a pure-computation test's 5 s budget ([#15253](https://github.com/diegosouzapw/OmniRoute/pull/15253)) — thanks @yourspraveen
9 changes: 8 additions & 1 deletion open-sse/services/autoCombo/__tests__/autoCombo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Unit tests for Auto-Combo Engine (Phase 5)
*/

import { describe, it, expect, beforeEach } from "vitest";
import { beforeAll, describe, it, expect, beforeEach } from "vitest";
import { calculateFactors, calculateScore, DEFAULT_WEIGHTS, validateWeights } from "../scoring";
import type { ProviderCandidate, ScoringWeights } from "../scoring";
import {
Expand All @@ -19,6 +19,13 @@ import { MODE_PACKS, getModePack, getModePackNames } from "../modePacks";
import { getStrategy } from "../routerStrategy";
import type { RoutingContext } from "../routerStrategy";

// #15106: the first getTaskFitness() call in a worker pays the lazy, synchronous
// model-intelligence DB init. Pay it here, under its own generous budget, so the
// 5s per-test timeout measures the test and not first-call setup under parallel load.
beforeAll(() => {
getTaskFitness("warmup-model", "coding");
}, 30_000);

describe("Scoring", () => {
const candidate: ProviderCandidate = {
provider: "anthropic",
Expand Down
67 changes: 39 additions & 28 deletions tests/unit/autoCombo/tieredRotation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* and that tiered rotation distributes traffic fairly.
*/

import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
import { beforeAll, describe, it, expect, beforeEach, afterEach, vi } from "vitest";
import { selectProvider, type AutoComboConfig } from "../../../open-sse/services/autoCombo/engine";
import {
calculateFactors,
Expand Down Expand Up @@ -53,12 +53,27 @@ function makeConfig(name: string): AutoComboConfig {
};
}

// #15106: the first getTaskFitness() call in a worker pays the lazy, synchronous
// model-intelligence DB init. Pay it here, under its own generous budget, so the
// 5s per-test timeout measures the test and not first-call setup under parallel load.
beforeAll(() => {
getTaskFitness("warmup-model", "coding");
}, 30_000);

describe("Connection Density Factor", () => {
const baseCandidate = makeCandidate({ provider: "cerebras", model: "llama-70b" });

it("multi-connection provider scores higher than single-connection at same quality", () => {
const multiConn = makeCandidate({ provider: "cerebras", model: "llama-70b", connectionPoolSize: 43 });
const singleConn = makeCandidate({ provider: "anthropic", model: "claude-sonnet", connectionPoolSize: 1 });
const multiConn = makeCandidate({
provider: "cerebras",
model: "llama-70b",
connectionPoolSize: 43,
});
const singleConn = makeCandidate({
provider: "anthropic",
model: "claude-sonnet",
connectionPoolSize: 1,
});
const pool = [multiConn, singleConn];

const multiFactors = calculateFactors(multiConn, pool, "coding", getTaskFitness);
Expand Down Expand Up @@ -175,31 +190,27 @@ describe("scorePool with connectionDensity", () => {
});

describe("Per-Connection Rotation", () => {
it(
"rotates across all 43 Cerebras connection IDs, not just one",
() => {
const cerebrasCandidates: ProviderCandidate[] = Array.from({ length: 43 }, (_, i) =>
makeCandidate({
provider: "cerebras",
model: "llama-3.1-70b",
connectionId: `cerebras-conn-${i + 1}`,
})
);
const config = makeConfig("smart");

const seenConnections = new Set<string>();
for (let i = 0; i < 200; i++) {
const result = selectProvider(config, cerebrasCandidates, "coding");
if (result.connectionId) seenConnections.add(result.connectionId);
}
expect(seenConnections.size).toBeGreaterThanOrEqual(10);
},
// 200 synchronous selectProvider() calls over a 43-connection pool are CPU-bound and can
// exceed 20s under the full Vitest worker load on the validation VPS, while the isolated
// file remains green. The assertion is unchanged; only the execution budget is widened.
// Refs #9985.
60000
);
// 200 synchronous selectProvider() calls over a 43-connection pool are CPU-bound and can
// exceed 20s under the full Vitest worker load on the validation VPS, while the isolated
// file remains green. The assertion is unchanged; only the execution budget is widened.
// Refs #9985.
it("rotates across all 43 Cerebras connection IDs, not just one", () => {
const cerebrasCandidates: ProviderCandidate[] = Array.from({ length: 43 }, (_, i) =>
makeCandidate({
provider: "cerebras",
model: "llama-3.1-70b",
connectionId: `cerebras-conn-${i + 1}`,
})
);
const config = makeConfig("smart");

const seenConnections = new Set<string>();
for (let i = 0; i < 200; i++) {
const result = selectProvider(config, cerebrasCandidates, "coding");
if (result.connectionId) seenConnections.add(result.connectionId);
}
expect(seenConnections.size).toBeGreaterThanOrEqual(10);
}, 60000);

it("different combos maintain independent round-robin state", () => {
const candidates: ProviderCandidate[] = Array.from({ length: 5 }, (_, i) =>
Expand Down
Loading