test(ci): isolate flaky scenarios and retain failure diagnostics (#6622)
* test(ci): isolate HTTP stubs and retain failure diagnostics * test(agent): scope compaction watchdogs to each phase * test(webui): isolate settings skeleton scenarios * test(webui): await rendered rail content before scroll checks
This commit is contained in:
1 parent
220d5e6970
commit
62c05e7f7e
7 files changed
+40
-22
No files matched your search
@@ -185,6 +185,7 @@ jobs:
|
||||
run: >-
|
||||
uv run --no-sync python -m pytest
|
||||
${{ matrix.pytest_args }}
|
||||
-o faulthandler_timeout=60
|
||||
--junitxml=test-results/main.xml --timing-report=test-results/main.json
|
||||
--durations=25 --durations-min=1.0
|
||||
|
||||
@@ -371,7 +372,18 @@ jobs:
|
||||
|
||||
- name: Test browser layout and history motion
|
||||
working-directory: webui
|
||||
run: bun run test:browser
|
||||
run: bun run test:browser --trace=retain-on-failure
|
||||
|
||||
- name: Retain browser failure details
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: browser-failures
|
||||
path: |
|
||||
webui/test-results/browser/**/trace.zip
|
||||
webui/test-results/browser/**/test-failed-*.png
|
||||
webui/test-results/browser/**/error-context.md
|
||||
retention-days: 7
|
||||
|
||||
webui:
|
||||
needs: [changes, webui_checks, webui_browser]
|
||||
|
||||
@@ -10,3 +10,5 @@ def isolate_websocket_runtime_data(
|
||||
) -> None:
|
||||
"""Keep transcripts and other runtime files out of the active user data directory."""
|
||||
monkeypatch.setattr("nanobot.config.paths.get_data_dir", lambda: tmp_path)
|
||||
# In-process routes must not intercept a later test's real listener on a reused port.
|
||||
monkeypatch.setattr("nanobot.channels.websocket.tests.ws_test_client._IN_PROCESS_HTTP_CHANNELS", {})
|
||||
@@ -46,6 +46,8 @@ class _TimingReport:
|
||||
case["phases"][report.when] = {
|
||||
"seconds": report.duration, "outcome": report.outcome,
|
||||
}
|
||||
if report.failed:
|
||||
case["phases"][report.when]["failure"] = report.longreprtext
|
||||
|
||||
def pytest_sessionfinish(self, exitstatus: int) -> None:
|
||||
elapsed = time.perf_counter() - self.started
|
||||
|
||||
@@ -1361,7 +1361,7 @@ async def test_idle_compaction_rechecks_settled_activity(tmp_path, monkeypatch,
|
||||
_add_turns(session, 2)
|
||||
session.updated_at = now[0] - timedelta(minutes=20)
|
||||
loop.sessions.save(session)
|
||||
entered, release = asyncio.Event(), asyncio.Event()
|
||||
entered, release, settled = asyncio.Event(), asyncio.Event(), asyncio.Event()
|
||||
archived = []
|
||||
other_responses = []
|
||||
|
||||
@@ -1381,30 +1381,30 @@ async def test_idle_compaction_rechecks_settled_activity(tmp_path, monkeypatch,
|
||||
try:
|
||||
await asyncio.wait_for(entered.wait(), 5)
|
||||
now[0] += timedelta(minutes=20)
|
||||
if ordering == "scan_during_turn":
|
||||
loop._next_idle_compact_check_at = 0
|
||||
await loop._check_expired_sessions_if_due()
|
||||
other_responses.append(await asyncio.wait_for(
|
||||
loop.process_direct("other input", session_key="cli:other"), 5,
|
||||
))
|
||||
assert archived == []
|
||||
async with asyncio.timeout(5):
|
||||
if ordering == "scan_during_turn":
|
||||
loop._next_idle_compact_check_at = 0
|
||||
await loop._check_expired_sessions_if_due()
|
||||
other_responses.append(await loop.process_direct("other input", session_key="cli:other"))
|
||||
assert archived == []
|
||||
finally:
|
||||
release.set()
|
||||
await asyncio.wait_for(settled.wait(), 5)
|
||||
|
||||
loop.provider.chat_stream_with_retry.side_effect = respond
|
||||
loop.consolidator.archive_session = archive
|
||||
finishing = None
|
||||
try:
|
||||
if ordering == "archive_queued_before_turn":
|
||||
loop._next_idle_compact_check_at = 0
|
||||
await loop._check_expired_sessions_if_due()
|
||||
assert key in loop.auto_compact._archiving
|
||||
finishing = asyncio.create_task(finish_turn())
|
||||
# Await inline: the direct call takes the free lock before the already
|
||||
# scheduled archive task runs. No scheduler or lock is replaced.
|
||||
async with asyncio.timeout(5):
|
||||
# Each phase owns its watchdog; the held turn intentionally waits for
|
||||
# another session. A phase failure cancels the inline turn through the group.
|
||||
async with asyncio.TaskGroup() as tasks:
|
||||
tasks.create_task(finish_turn())
|
||||
# Await inline so admission still precedes the queued archive task.
|
||||
response = await loop.process_direct("new input", session_key=key)
|
||||
await asyncio.wait_for(finishing, 5)
|
||||
settled.set()
|
||||
await asyncio.wait_for(_drain_background_tasks(loop), 5)
|
||||
assert len(archived) == 0
|
||||
saved = await loop.sessions.state.get(key)
|
||||
@@ -1426,6 +1426,4 @@ async def test_idle_compaction_rechecks_settled_activity(tmp_path, monkeypatch,
|
||||
assert key not in loop.auto_compact._archiving
|
||||
finally:
|
||||
release.set()
|
||||
if finishing is not None:
|
||||
await asyncio.wait_for(asyncio.gather(finishing, return_exceptions=True), 5)
|
||||
await asyncio.wait_for(loop.aclose(), 10)
|
||||
@@ -24,6 +24,7 @@ def test_timing_report_preserves_phases_and_failed_results(pytester: pytest.Pyte
|
||||
cases = {key.rsplit("::", 1)[-1]: value for key, value in report["cases"].items()}
|
||||
assert cases["test_pass"]["phases"]["call"]["outcome"] == "passed"
|
||||
assert cases["test_fail"]["phases"]["call"]["outcome"] == "failed"
|
||||
assert "AssertionError" in cases["test_fail"]["phases"]["call"]["failure"]
|
||||
assert cases["test_skip"]["phases"]["setup"]["outcome"] == "skipped"
|
||||
assert sum(phase["seconds"] for case in cases.values()
|
||||
for phase in case["phases"].values()) > 0
|
||||
|
||||
@@ -29,7 +29,10 @@ test("complete rail scrolls independently, jumps to unloaded history and returns
|
||||
await expectRailCentered();
|
||||
await expect.poll(() => rail.evaluate((node) => node.scrollHeight)).toBe(32024);
|
||||
expect(reads).toHaveLength(0);
|
||||
// Lazy markdown and content-visibility can change the scroll range during startup.
|
||||
// A stationary lazy-render fallback is not a settled transcript.
|
||||
await expect(body.locator('[data-thread-display-unit="a1999"] .markdown-content p')).toHaveCount(8);
|
||||
await page.evaluate(async () => { await document.fonts.ready; });
|
||||
// Content visibility and the camera can still settle after the renderer is ready.
|
||||
await body.evaluate(async (node) => {
|
||||
let previous = -1;
|
||||
let stable = 0;
|
||||
|
||||
@@ -54,8 +54,8 @@ for (const width of [390, 1440]) for (const locale of ["en", "zh-CN"]) {
|
||||
}
|
||||
});
|
||||
|
||||
test("settings sections preserve their loaded row layout", async ({ page }, testInfo) => {
|
||||
for (const surface of ["notifications", "capabilities", "runtime", "advanced", "sandbox", "overview", "models", "about"]) {
|
||||
for (const surface of ["notifications", "capabilities", "runtime", "advanced", "sandbox", "overview", "models", "about"]) {
|
||||
test(`settings ${surface} preserves its loaded row layout`, async ({ page }, testInfo) => {
|
||||
const section = surface === "sandbox" ? "advanced" : surface;
|
||||
const extra = `§ion=${section}${section === "notifications" ? "¬ificationPermission=granted" : ""}${surface === "sandbox" ? "&sandboxSettings" : ""}`;
|
||||
await page.goto(fixture("settings", "loaded", extra));
|
||||
@@ -93,8 +93,8 @@ for (const width of [390, 1440]) for (const locale of ["en", "zh-CN"]) {
|
||||
await testInfo.attach("notifications-layout", { body: JSON.stringify({ loaded, skeleton, loadedControls, skeletonControls }, null, 2), contentType: "application/json" });
|
||||
}
|
||||
await accessibleSkeleton(page);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
test("appearance stays usable and keeps its layout while gateway settings load or fail", async ({ page }) => {
|
||||
await page.addInitScript(() => localStorage.setItem("nanobot-webui.settings-preferences", JSON.stringify({
|
||||
|
||||
Reference in new issue
Block a user