Skip to content

Commit 34b8a65

Browse files
authored
test(gateway): boot a minimal test gateway in the gateway lane (#121134)
* test(gateway): boot a minimal test gateway in the gateway lane A gateway startup stall (#120926, awaited chat-metadata refresh in minimal mode) shipped with green CI and first surfaced by hanging every checks-ui-e2e suite that boots a minimal test gateway: no gateway-lane test booted one with bundled plugins enabled (gateway.test.ts disables them, which masked the stall), and the changed-scope classifier only selects the ui-e2e lane for ui-touching diffs. Add a minimal-gateway boot smoke in src/gateway that mirrors the ui-e2e boot environment (bundled plugins enabled, minimal skips, strict time budget). Selection is automatic: the smoke imports the gateway server, so the changed node test plan picks it up through the import graph for any diff that can affect startup, and full-suite plans run it in the agentic-control-plane-startup-core shard. Reintroducing the #120926 hunk makes the smoke fail (watchdog kill) in the gateway lane; healthy code boots in ~10s. A planner regression test keeps the smoke classified as a gateway-server test file and import-graph-reachable from gateway startup sources, so a rename or graph-invisible import shape cannot silently drop the coverage again. * test(ui): resolve labs rows by registry id, not positional index Unblocks landing onto red main: 8fdf757 (#120727) added the Cloud Worker Desktop labs entry with a hardcoded row index that collides with Message audit metadata, so enabling it toggled the neighboring row and the full-suite lane failed deterministically (labs-page.test.ts, exposed only on PRs that run the compact full suite). Derive each table case's row index from LAB_FEATURES by feature id — the idiom the rest of the suite already uses — so a new labs entry can no longer silently retarget an existing case.
1 parent ad1a2cd commit 34b8a65

3 files changed

Lines changed: 87 additions & 9 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Minimal-gateway boot smoke: guards the startup path the Control UI e2e suites
2+
// depend on. Bundled plugins stay enabled on purpose — disabling them (as other
3+
// gateway boot tests do) hides startup work that materializes plugin runtime,
4+
// which is exactly how a startup stall shipped green while hanging every
5+
// ui-e2e suite that boots a minimal test gateway.
6+
import { describe, expect, it } from "vitest";
7+
import { createOpenClawTestState } from "../test-utils/openclaw-test-state.js";
8+
import { getFreePort } from "../test-utils/ports.js";
9+
10+
// Local boot completes in ~10s; the budget only buys headroom for loaded CI
11+
// runners. A stall exhausts it and fails in the gateway lane instead of first
12+
// surfacing on unrelated UI PRs.
13+
const BOOT_BUDGET_MS = 90_000;
14+
15+
describe("gateway minimal boot smoke", () => {
16+
it("boots a minimal test gateway within budget", { timeout: BOOT_BUDGET_MS }, async () => {
17+
const port = await getFreePort();
18+
const state = await createOpenClawTestState({
19+
label: "gateway-minimal-boot-smoke",
20+
layout: "home",
21+
env: {
22+
OPENCLAW_GATEWAY_PASSWORD: undefined,
23+
OPENCLAW_GATEWAY_TOKEN: undefined,
24+
OPENCLAW_SKIP_BROWSER_CONTROL_SERVER: "1",
25+
OPENCLAW_SKIP_CANVAS_HOST: "1",
26+
OPENCLAW_SKIP_CHANNELS: "1",
27+
OPENCLAW_SKIP_CRON: "1",
28+
OPENCLAW_SKIP_GMAIL_WATCHER: "1",
29+
OPENCLAW_SKIP_PROVIDERS: "1",
30+
OPENCLAW_TEST_MINIMAL_GATEWAY: "1",
31+
VITEST: "1",
32+
},
33+
});
34+
const token = "gateway-minimal-boot-smoke-token";
35+
await state.writeConfig({
36+
gateway: {
37+
auth: { mode: "token", token },
38+
controlUi: { enabled: false },
39+
port,
40+
},
41+
});
42+
state.applyEnv();
43+
try {
44+
const { startGatewayServer } = await import("./server.js");
45+
const server = await startGatewayServer(port, {
46+
auth: { mode: "token", token },
47+
bind: "loopback",
48+
controlUiEnabled: false,
49+
sidecarStartup: "defer",
50+
});
51+
expect(server).toBeTruthy();
52+
await server.close({ reason: "minimal boot smoke complete" });
53+
} finally {
54+
await state.cleanup();
55+
}
56+
});
57+
});

‎test/scripts/ci-changed-node-test-plan.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import {
88
hasPromptSnapshotAffectingChange,
99
hasQaSmokeAffectingChange,
1010
} from "../../scripts/lib/ci-changed-node-test-plan.mts";
11+
import { hasImportGraphImpactOnTargets } from "../../scripts/test-projects.test-support.mts";
1112
import { listGitTrackedFiles } from "../../src/test-utils/repo-files.js";
13+
import { isGatewayServerTestFile } from "../vitest/vitest.gateway-server-paths.mjs";
1214

1315
describe("CI changed Node test plan", () => {
1416
it("routes a focused source change into one targeted job", () => {
@@ -116,6 +118,22 @@ describe("CI changed Node test plan", () => {
116118
expect(createChangedNodeTestShards(["package.json"])).toBeNull();
117119
});
118120

121+
it("keeps minimal-gateway boot coverage reachable from gateway startup changes", () => {
122+
// A gateway startup stall must fail in the gateway lane; the boot smoke is
123+
// selected purely through the import graph, so a rename or an import shape
124+
// the graph walker cannot see would silently drop it from targeted plans
125+
// and the stall would first surface on unrelated ui-e2e PRs again.
126+
const bootSmoke = "src/gateway/server-startup-minimal-boot.test.ts";
127+
expect(isGatewayServerTestFile(bootSmoke)).toBe(true);
128+
expect(
129+
hasImportGraphImpactOnTargets(
130+
["src/gateway/server-startup-bootstrap.ts"],
131+
[bootSmoke],
132+
process.cwd(),
133+
),
134+
).toBe(true);
135+
});
136+
119137
it("fails safe whenever a diff deletes source files", () => {
120138
expect(createChangedNodeTestShards(["src/infra/format-time/deleted-helper.ts"])).toBeNull();
121139
expect(

‎ui/src/pages/labs/labs-page.test.ts‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,14 @@ describe("LabsPage", () => {
147147
// The on position restores the shipped "auto" tier, never `true`: Labs
148148
// offers Auto/Off, and force-on stays a config-only power-user state.
149149
label: "Code Mode",
150-
index: 0,
150+
id: "codeMode",
151151
sourceConfig: { tools: { codeMode: { enabled: false } } },
152152
expectedPatch: { tools: { codeMode: { enabled: null } } },
153153
note: "labs: update codeMode",
154154
},
155155
{
156156
label: "Swarm",
157-
index: 1,
157+
id: "swarm",
158158
sourceConfig: { tools: { swarm: { enabled: false } } },
159159
expectedPatch: { tools: { swarm: { enabled: true } } },
160160
note: "labs: update swarm",
@@ -164,28 +164,28 @@ describe("LabsPage", () => {
164164
// mode to "code", so a bare `enabled: true` would select the surface with
165165
// the weakest recall rather than the one this row advertises.
166166
label: "Tool Search",
167-
index: 2,
167+
id: "toolSearch",
168168
sourceConfig: { tools: { toolSearch: { enabled: false } } },
169169
expectedPatch: { tools: { toolSearch: { enabled: true, mode: "directory" } } },
170170
note: "labs: update toolSearch",
171171
},
172172
{
173173
label: "Tool-loop detection",
174-
index: 3,
174+
id: "loopDetection",
175175
sourceConfig: { tools: { loopDetection: { enabled: false } } },
176176
expectedPatch: { tools: { loopDetection: { enabled: true } } },
177177
note: "labs: update loopDetection",
178178
},
179179
{
180180
label: "Lean tools for local models",
181-
index: 4,
181+
id: "localModelLean",
182182
sourceConfig: {},
183183
expectedPatch: { agents: { defaults: { experimental: { localModelLean: true } } } },
184184
note: "labs: update localModelLean",
185185
},
186186
{
187187
label: "CLI agents",
188-
index: 5,
188+
id: "cliAgents",
189189
sourceConfig: {},
190190
expectedPatch: { gateway: { cliAgents: { enabled: true } } },
191191
note: "labs: update cliAgents",
@@ -194,21 +194,24 @@ describe("LabsPage", () => {
194194
// Not a boolean gate: the on state is the conservative `direct` mode, so
195195
// enabling here cannot start recording group or unknown conversations.
196196
label: "Message audit metadata",
197-
index: 6,
197+
id: "auditMessages",
198198
sourceConfig: { logging: { audit: { messages: "off" } } },
199199
expectedPatch: { logging: { audit: { messages: "direct" } } },
200200
note: "labs: update auditMessages",
201201
},
202202
{
203203
label: "Cloud Worker Desktop",
204-
index: 7,
204+
id: "workerDesktop",
205205
sourceConfig: { cloudWorkers: { desktop: false } },
206206
expectedPatch: { cloudWorkers: { desktop: true } },
207207
note: "labs: update workerDesktop",
208208
},
209209
])("writes the on value at the registered config path when enabling $label", async (testCase) => {
210+
// Resolve the row from the registry: hardcoded indices rot when a new lab
211+
// entry lands and silently toggle a neighboring row instead.
212+
const rowIndex = LAB_FEATURES.findIndex((feature) => feature.id === testCase.id);
210213
const { page, runtimeConfig } = await mountPage(testCase.sourceConfig);
211-
const toggle = labToggle(page, testCase.index, testCase.label);
214+
const toggle = labToggle(page, rowIndex, testCase.label);
212215

213216
toggle.checked = true;
214217
toggle.dispatchEvent(new Event("change", { bubbles: true, composed: true }));

0 commit comments

Comments
 (0)