mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-30 15:30:22 +00:00
test: make vitest worker caps deterministic
This commit is contained in:
@@ -7,12 +7,6 @@ import baseConfig, {
|
||||
} from "../../vitest.config.ts";
|
||||
import { parseVitestProcessStats } from "../../vitest.system-load.ts";
|
||||
|
||||
const idleVitestStats = {
|
||||
otherVitestRootCount: 0,
|
||||
otherVitestWorkerCount: 0,
|
||||
otherVitestCpuPercent: 0,
|
||||
} as const;
|
||||
|
||||
describe("resolveLocalVitestMaxWorkers", () => {
|
||||
it("uses a moderate local worker cap on larger hosts", () => {
|
||||
expect(
|
||||
@@ -26,7 +20,6 @@ describe("resolveLocalVitestMaxWorkers", () => {
|
||||
totalMemoryBytes: 64 * 1024 ** 3,
|
||||
},
|
||||
"threads",
|
||||
idleVitestStats,
|
||||
),
|
||||
).toBe(6);
|
||||
});
|
||||
@@ -43,7 +36,6 @@ describe("resolveLocalVitestMaxWorkers", () => {
|
||||
totalMemoryBytes: 128 * 1024 ** 3,
|
||||
},
|
||||
"threads",
|
||||
idleVitestStats,
|
||||
),
|
||||
).toBe(2);
|
||||
});
|
||||
@@ -60,7 +52,6 @@ describe("resolveLocalVitestMaxWorkers", () => {
|
||||
totalMemoryBytes: 128 * 1024 ** 3,
|
||||
},
|
||||
"threads",
|
||||
idleVitestStats,
|
||||
),
|
||||
).toBe(3);
|
||||
});
|
||||
@@ -75,7 +66,6 @@ describe("resolveLocalVitestMaxWorkers", () => {
|
||||
totalMemoryBytes: 16 * 1024 ** 3,
|
||||
},
|
||||
"threads",
|
||||
idleVitestStats,
|
||||
),
|
||||
).toBe(2);
|
||||
});
|
||||
@@ -90,7 +80,6 @@ describe("resolveLocalVitestMaxWorkers", () => {
|
||||
totalMemoryBytes: 128 * 1024 ** 3,
|
||||
},
|
||||
"threads",
|
||||
idleVitestStats,
|
||||
),
|
||||
).toBe(8);
|
||||
});
|
||||
@@ -105,7 +94,6 @@ describe("resolveLocalVitestMaxWorkers", () => {
|
||||
totalMemoryBytes: 128 * 1024 ** 3,
|
||||
},
|
||||
"threads",
|
||||
idleVitestStats,
|
||||
),
|
||||
).toBe(2);
|
||||
});
|
||||
@@ -120,54 +108,43 @@ describe("resolveLocalVitestMaxWorkers", () => {
|
||||
totalMemoryBytes: 256 * 1024 ** 3,
|
||||
},
|
||||
"threads",
|
||||
idleVitestStats,
|
||||
),
|
||||
).toBe(12);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveLocalVitestScheduling", () => {
|
||||
it("scales back to half capacity when other Vitest work is already consuming most cores", () => {
|
||||
it("scales back to half capacity when the host load is already saturated", () => {
|
||||
expect(
|
||||
resolveLocalVitestScheduling(
|
||||
{},
|
||||
{
|
||||
cpuCount: 16,
|
||||
loadAverage1m: 0.5,
|
||||
loadAverage1m: 16,
|
||||
totalMemoryBytes: 128 * 1024 ** 3,
|
||||
},
|
||||
"threads",
|
||||
{
|
||||
otherVitestRootCount: 2,
|
||||
otherVitestWorkerCount: 12,
|
||||
otherVitestCpuPercent: 1200,
|
||||
},
|
||||
),
|
||||
).toEqual({
|
||||
maxWorkers: 4,
|
||||
maxWorkers: 2,
|
||||
fileParallelism: true,
|
||||
throttledBySystem: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps big hosts parallel under moderate contention", () => {
|
||||
it("keeps big hosts parallel under moderate host contention", () => {
|
||||
expect(
|
||||
resolveLocalVitestScheduling(
|
||||
{},
|
||||
{
|
||||
cpuCount: 16,
|
||||
loadAverage1m: 0.5,
|
||||
loadAverage1m: 12,
|
||||
totalMemoryBytes: 128 * 1024 ** 3,
|
||||
},
|
||||
"threads",
|
||||
{
|
||||
otherVitestRootCount: 1,
|
||||
otherVitestWorkerCount: 7,
|
||||
otherVitestCpuPercent: 700,
|
||||
},
|
||||
),
|
||||
).toEqual({
|
||||
maxWorkers: 6,
|
||||
maxWorkers: 5,
|
||||
fileParallelism: true,
|
||||
throttledBySystem: true,
|
||||
});
|
||||
@@ -185,7 +162,6 @@ describe("resolveLocalVitestScheduling", () => {
|
||||
totalMemoryBytes: 128 * 1024 ** 3,
|
||||
},
|
||||
"threads",
|
||||
idleVitestStats,
|
||||
),
|
||||
).toEqual({
|
||||
maxWorkers: 8,
|
||||
|
||||
Reference in New Issue
Block a user