mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:30:42 +00:00
test: isolate gateway prewarm scheduling
This commit is contained in:
@@ -313,9 +313,8 @@ describe("startGatewayPostAttachRuntime", () => {
|
||||
});
|
||||
|
||||
it("starts channels without waiting for primary model prewarm completion", async () => {
|
||||
hoisted.resolveAgentModelPrimaryValue.mockReturnValue("openai/gpt-5.4");
|
||||
let resolvePrewarm!: () => void;
|
||||
hoisted.ensureOpenClawModelsJson.mockImplementation(
|
||||
const prewarmPrimaryModel = vi.fn(
|
||||
async () =>
|
||||
await new Promise<undefined>((resolve) => {
|
||||
resolvePrewarm = () => resolve(undefined);
|
||||
@@ -332,6 +331,7 @@ describe("startGatewayPostAttachRuntime", () => {
|
||||
defaultWorkspaceDir: "/tmp/openclaw-workspace",
|
||||
deps: {} as never,
|
||||
startChannels,
|
||||
prewarmPrimaryModel: prewarmPrimaryModel as never,
|
||||
log: { warn: vi.fn() },
|
||||
logHooks: {
|
||||
info: vi.fn(),
|
||||
@@ -346,7 +346,7 @@ describe("startGatewayPostAttachRuntime", () => {
|
||||
|
||||
await vi.waitFor(
|
||||
() => {
|
||||
expect(hoisted.ensureOpenClawModelsJson).toHaveBeenCalledTimes(1);
|
||||
expect(prewarmPrimaryModel).toHaveBeenCalledTimes(1);
|
||||
expect(startChannels).toHaveBeenCalledTimes(1);
|
||||
},
|
||||
{ timeout: 2_000 },
|
||||
|
||||
@@ -208,6 +208,7 @@ export async function startGatewaySidecars(params: {
|
||||
defaultWorkspaceDir: string;
|
||||
deps: CliDeps;
|
||||
startChannels: () => Promise<void>;
|
||||
prewarmPrimaryModel?: typeof prewarmConfiguredPrimaryModel;
|
||||
log: { warn: (msg: string) => void };
|
||||
logHooks: {
|
||||
info: (msg: string) => void;
|
||||
@@ -329,11 +330,14 @@ export async function startGatewaySidecars(params: {
|
||||
await measureStartup(params.startupTrace, "sidecars.channels", async () => {
|
||||
if (!skipChannels) {
|
||||
try {
|
||||
schedulePrimaryModelPrewarm({
|
||||
cfg: params.cfg,
|
||||
log: params.log,
|
||||
startupTrace: params.startupTrace,
|
||||
});
|
||||
schedulePrimaryModelPrewarm(
|
||||
{
|
||||
cfg: params.cfg,
|
||||
log: params.log,
|
||||
startupTrace: params.startupTrace,
|
||||
},
|
||||
params.prewarmPrimaryModel,
|
||||
);
|
||||
await measureStartup(params.startupTrace, "sidecars.channel-start", () =>
|
||||
params.startChannels(),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user