Skip to content

Commit b8fb4e9

Browse files
committed
test(qa): cover health monitor and cache boundaries
1 parent f73a780 commit b8fb4e9

9 files changed

Lines changed: 1251 additions & 0 deletions
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
title: Cached health snapshot boundaries
2+
3+
scenario:
4+
id: cached-health-snapshot-boundaries
5+
surface: observability
6+
category: observability.health-and-repair
7+
coverage:
8+
primary:
9+
- observability.cached-health-snapshots-kitchen-sink
10+
- observability.cached-health-snapshots-lifecycle
11+
- observability.cached-health-snapshots-performance
12+
- observability.cached-health-snapshots-plugin-tools
13+
objective: Prove health cache reuse, invalidation, live overlays, scope isolation, and plugin tool coexistence.
14+
successCriteria:
15+
- Fresh cache hits preserve snapshot timestamps and emit the production cached response metadata.
16+
- Request-driven passive refresh is bounded while stale, explicit probe, and lifecycle mismatch requests refresh synchronously.
17+
- Cached responses merge current live overlays and public refreshes omit sensitive collection.
18+
- A real fixture plugin loads, exposes, and executes a Gateway tool without disrupting health collection.
19+
docsRefs:
20+
- docs/gateway/health.md
21+
- docs/gateway/protocol.md
22+
codeRefs:
23+
- src/gateway/server-methods/health.ts
24+
- src/gateway/server/health-state.ts
25+
- test/e2e/qa-lab/runtime/cached-health-snapshot-boundaries.ts
26+
execution:
27+
kind: script
28+
path: test/e2e/qa-lab/runtime/cached-health-snapshot-boundaries.ts
29+
summary: Exercises the production health handler cache boundary and crosses a real authenticated Gateway plugin-tool invocation.
30+
args:
31+
- --artifact-base
32+
- ${outputDir}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
title: Channel health monitor lifecycle
2+
3+
scenario:
4+
id: channel-health-monitor-lifecycle
5+
surface: observability
6+
category: observability.health-and-repair
7+
coverage:
8+
primary:
9+
- observability.background-health-monitor-loop
10+
- observability.startup-grace
11+
- observability.restart-logging
12+
objective: Prove the production channel health monitor schedules, evaluates, and repairs unhealthy account lifecycles.
13+
successCriteria:
14+
- No health evaluation runs before startup grace expires.
15+
- Connect grace, stale transport, busy, and stuck snapshots follow the production health policy.
16+
- A restart performs stop, restart-attempt reset, and start in order and emits the exact restart reason.
17+
- Slow checks never overlap, settled checks rearm, cooldown and hourly caps bound restart attempts, and failures do not stop the loop.
18+
- Shutdown prevents future checks and abandons restart resurrection.
19+
docsRefs:
20+
- docs/gateway/health.md
21+
codeRefs:
22+
- src/gateway/channel-health-monitor.ts
23+
- src/gateway/channel-health-policy.ts
24+
- test/e2e/qa-lab/runtime/channel-health-monitor-lifecycle-runtime.ts
25+
execution:
26+
kind: script
27+
path: test/e2e/qa-lab/runtime/channel-health-monitor-lifecycle-runtime.ts
28+
summary: Runs the production channel health monitor with controlled real-time account snapshots and captures lifecycle operations and logs.
29+
args:
30+
- --artifact-base
31+
- ${outputDir}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
title: Gateway RPC account health
2+
3+
scenario:
4+
id: gateway-rpc-account-health
5+
surface: observability
6+
category: observability.health-and-repair
7+
coverage:
8+
primary:
9+
- observability.gateway-rpc-health
10+
- observability.per-account-enable-disable-settings
11+
objective: Prove authenticated Gateway health and status RPCs reflect real per-account configuration reloads.
12+
successCriteria:
13+
- Authenticated health and channels.status RPCs report two running QA channel accounts, while status exposes both account summaries.
14+
- A real CAS config.patch disables one named account and the Gateway applies the new runtime revision.
15+
- Only the selected account configuration leaf changes.
16+
- The default sibling remains enabled and running while the disabled account is configured, stopped, and operator-visible.
17+
docsRefs:
18+
- docs/gateway/health.md
19+
- docs/gateway/protocol.md
20+
codeRefs:
21+
- src/gateway/server-methods/health.ts
22+
- src/gateway/server-methods/channels.ts
23+
- test/e2e/qa-lab/runtime/gateway-rpc-account-health.ts
24+
execution:
25+
kind: script
26+
path: test/e2e/qa-lab/runtime/gateway-rpc-account-health.ts
27+
summary: Starts a real QA bus and CLI Gateway child, performs authenticated health and status RPCs, and patches one account through config CAS and hot reload.
28+
args:
29+
- --artifact-base
30+
- ${outputDir}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import path from "node:path";
2+
import { describe, expect, it } from "vitest";
3+
import {
4+
createFixturePlugin,
5+
runCachedHealthSnapshotBoundariesProof,
6+
runHandlerBoundaryProof,
7+
withFixturePlugin,
8+
} from "./cached-health-snapshot-boundaries.js";
9+
10+
describe("cached health snapshot boundary producer", () => {
11+
it("proves deterministic cache reuse and invalidation boundaries", async () => {
12+
await expect(runHandlerBoundaryProof()).resolves.toEqual({
13+
cacheHitSameTimestamp: true,
14+
cachedMeta: true,
15+
passiveRefreshBounded: true,
16+
staleRefresh: true,
17+
explicitProbeRefresh: true,
18+
lifecycleMismatchRefresh: true,
19+
liveOverlayMerged: true,
20+
publicSensitiveOmitted: true,
21+
});
22+
});
23+
24+
it("builds the fixture plugin configuration used by the real-Gateway lane", async () => {
25+
const fixture = await createFixturePlugin();
26+
try {
27+
const config = withFixturePlugin({} as never, fixture.pluginDir);
28+
expect(config.plugins).toMatchObject({
29+
enabled: true,
30+
allow: ["qa-cached-health-tool"],
31+
entries: { "qa-cached-health-tool": { enabled: true } },
32+
});
33+
expect(config.plugins?.load?.paths).toContain(fixture.pluginDir);
34+
} finally {
35+
await fixture.cleanup();
36+
}
37+
});
38+
39+
it.runIf(process.env.OPENCLAW_QA_REAL_GATEWAY === "1")(
40+
"crosses the real Gateway plugin-tool boundary",
41+
async () => {
42+
const proof = await runCachedHealthSnapshotBoundariesProof(
43+
path.resolve(import.meta.dirname, "../../../.."),
44+
);
45+
46+
expect(proof.pluginLoaded).toBe(true);
47+
expect(proof.pluginToolCataloged).toBe(true);
48+
expect(proof.pluginToolInvoked).toBe(true);
49+
expect(proof.healthAfterTool).toBe(true);
50+
},
51+
180_000,
52+
);
53+
});

0 commit comments

Comments
 (0)