Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

test: qualify owned cleanup with real Chromium writers

pulse-triage[bot]38f0960d4b62
diff --git a/tests/integration/scripts/owned-run-browser.test.py b/tests/integration/scripts/owned-run-browser.test.py
new file mode 100644
index 0000000000..416ead59ad
--- /dev/null
+++ b/tests/integration/scripts/owned-run-browser.test.py
@@ -0,0 +1,103 @@
+"""Opt-in real Chromium cleanup proof. Run through pulse-heavy-run, not unit discovery.
+
+Uses synthetic cookies and an offline page; does not qualify Docker teardown,
+Pulse authentication, sharing, or the Playwright Test reporter lifecycle.
+"""
+import json
+import os
+from pathlib import Path
+import signal
+import subprocess
+import tempfile
+import time
+import unittest
+
+SUPERVISOR = Path(__file__).with_name('owned-run.py')
+PLAYWRIGHT = (SUPERVISOR.parent.parent / 'node_modules/playwright/index.mjs').as_uri()
+LAUNCH = '''import importlib.util, sys
+from pathlib import Path
+s = importlib.util.spec_from_file_location('owned', sys.argv[1])
+m = importlib.util.module_from_spec(s); s.loader.exec_module(m)
+sys.exit(m.supervise(['node', '--input-type=module', '-e', sys.argv[3]], Path(sys.argv[2])))
+'''
+BROWSER = r'''
+import { chromium } from 'PLAYWRIGHT_MODULE';
+import fs from 'node:fs';
+const env = process.env;
+const results = env.PULSE_E2E_RESULTS_DIR;
+const report = env.PULSE_E2E_REPORT_DIR;
+fs.mkdirSync(results, { recursive: true });
+fs.mkdirSync(report, { recursive: true });
+const server = await chromium.launchServer({ headless: true,
+ handleSIGINT: false, handleSIGTERM: false, handleSIGHUP: false });
+const browser = await chromium.connect(server.wsEndpoint());
+const context = await browser.newContext({ recordVideo: { dir: results } });
+await context.addCookies([{ name: 'fixture', value: 'synthetic-only', domain: 'example.invalid', path: '/' }]);
+await context.tracing.start({ screenshots: true, snapshots: true });
+const page = await context.newPage();
+await page.setContent('<h1>Offline interruption qualification</h1>');
+await context.storageState({ path: env.PULSE_E2E_COOKIE_STATE_PATH });
+await page.screenshot({ path: results + '/before.png' });
+let stopping = false;
+process.on('SIGTERM', async () => {
+ if (stopping) return;
+ stopping = true;
+ try {
+ // Exercise genuine browser writers after interruption, before reaping.
+ await new Promise(resolve => setTimeout(resolve, 200));
+ await page.screenshot({ path: results + '/late.png' });
+ await context.storageState({ path: env.PULSE_E2E_COOKIE_STATE_PATH });
+ await context.tracing.stop({ path: results + '/trace.zip' });
+ const video = page.video();
+ await context.close();
+ await video.saveAs(results + '/finished.webm');
+ const videos = fs.readdirSync(results).filter(name => name.endsWith('.webm'));
+ if (!videos.length || videos.some(name => fs.statSync(results + '/' + name).size === 0)) throw Error('no finished video');
+ fs.writeFileSync(report + '/summary.json', JSON.stringify({ videos: videos.length }));
+ await browser.close();
+ await server.close();
+ fs.writeFileSync(env.PROOF_ROOT + '/closed', 'browser closed; late screenshot, storage, trace, video and summary written');
+ process.exit(0);
+ } catch (error) { console.error(error); process.exit(1); }
+});
+fs.writeFileSync(env.PROOF_ROOT + '/ready', JSON.stringify({ pid: server.process().pid,
+ paths: [env.PULSE_E2E_COOKIE_STATE_PATH, report, results] }));
+'''.replace('PLAYWRIGHT_MODULE', PLAYWRIGHT)
+
+
+class BrowserCleanupTest(unittest.TestCase):
+ def test_catchable_signals(self):
+ for sig in (signal.SIGTERM, signal.SIGINT, signal.SIGHUP):
+ with self.subTest(signal=sig.name), tempfile.TemporaryDirectory(prefix='pulse-browser-proof-') as temp:
+ root = Path(temp)
+ neighbour = root / 'unowned-cookie'
+ neighbour.write_text('keep')
+ process = subprocess.Popen(['python3', '-c', LAUNCH, str(SUPERVISOR), temp, BROWSER],
+ env={**os.environ, 'PROOF_ROOT': temp, 'PULSE_E2E_COOKIE_STATE_PATH': str(neighbour)})
+ try:
+ deadline = time.monotonic() + 30
+ while not (root / 'ready').exists():
+ self.assertIsNone(process.poll(), 'browser exited before ready')
+ self.assertLess(time.monotonic(), deadline, 'browser startup timeout')
+ time.sleep(.05)
+ receipt = json.loads((root / 'ready').read_text())
+ self.assertTrue(Path(receipt['paths'][0]).is_file())
+ self.assertTrue(Path('/proc', str(receipt['pid'])).exists())
+ process.send_signal(sig)
+ self.assertEqual(process.wait(timeout=20), 128 + sig)
+ self.assertTrue((root / 'closed').exists(), 'real browser late writes and close must finish')
+ self.assertFalse(Path('/proc', str(receipt['pid'])).exists())
+ for index, value in enumerate(receipt['paths']):
+ owned = Path(value).parent if index == 0 else Path(value)
+ self.assertFalse(owned.exists(), str(owned))
+ time.sleep(.3)
+ self.assertFalse(Path(receipt['paths'][2]).exists(), 'no surviving writer recreation')
+ self.assertEqual(neighbour.read_text(), 'keep')
+ finally:
+ if process.poll() is None:
+ process.send_signal(signal.SIGTERM)
+ process.wait(timeout=20)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/qualification/runner-isolation/2026-09-05-real-browser-writers.md b/tests/qualification/runner-isolation/2026-09-05-real-browser-writers.md
new file mode 100644
index 0000000000..378ff4fa45
--- /dev/null
+++ b/tests/qualification/runner-isolation/2026-09-05-real-browser-writers.md
@@ -0,0 +1,58 @@
+# Real browser writer interruption — 5 September 2026
+
+Base: 07404979e2e65238b7f5a89290c855675571b923. Qualification-only;
+no runtime behaviour, permissions or user-visible surface changed.
+
+## Judgment and fresh evidence
+
+The accepted supervisor needed real-browser proof rather than another synthetic
+process fixture. Fresh reads of https://playwright.dev/docs/auth confirm stored
+browser state can impersonate accounts. Fresh community discovery and a visible
+thread read at
+https://www.reddit.com/r/Proxmox/comments/1t1h834/deploying_pulse_monitoring_agents_as_root_on/
+surface operator questions about root-agent deployment. That is trust context,
+not evidence of a sharing defect, new demand, or a complete issue-triage audit.
+No new bet or feature was introduced.
+
+## Reproduction
+
+Install the locked integration dependencies if absent:
+`npm ci --prefix tests/integration --ignore-scripts --no-audit --no-fund`.
+With the locked Playwright Chromium installed, run:
+
+```
+pulse-heavy-run -- python3 tests/integration/scripts/owned-run-browser.test.py
+```
+
+One test method, three real Chromium subcases (TERM, INT, HUP), passed in
+3.255 seconds. Each waits for live browser PID and synthetic cookie storage,
+signals the actual supervisor, then requires completed late screenshot, storage,
+trace, nonempty saved video and summary writes before browser close. Supervisor
+exit must match the signal. Browser PID and owned cookie/report/results roots
+must be absent; a later check rejects recreation and an unowned sentinel stays
+unchanged. Temporary synthetic artefacts are removed, never committed.
+
+The first run failed all three subcases at the nonempty-video assertion: a
+connected browser requires explicitly saving its video to the client results
+path. Added `video.saveAs` after context close; the passing rerun retains the
+nonempty-video assertion. No product fix is inferred from that harness repair.
+
+## Scope limits and next proof
+
+This launches real Chromium through the actual Python supervisor, with browser
+signal handlers disabled so delayed client shutdown exercises late writers.
+The report summary is a fixture, not the Playwright Test HTML reporter. The
+page is offline and cookies synthetic; no Pulse server, Docker stack or customer
+account is used. It does not replace full shell/Playwright Test interruption or
+actual container inventory proof, and does not qualify supervisor SIGKILL or
+host failure. Existing process fixtures cover escalation and detached writers.
+
+Delayed outgoing admission, failed/superseded incoming admission, reconnect
+recovery and fresh 390x844 table-clipping inspection remain unqualified. The
+accepted identity/RBAC happy paths were not repeated. No release readiness,
+visual-polish or quarantined-tier promotion claim.
+
+Focused regression checks also passed: `python3
+ tests/integration/scripts/owned-run.test.py` (3 methods) and `node --test` on
+`run-tests-images.test.mjs`, `run-tests-cleanup.test.mjs` and
+`run-tests-interruption.test.mjs` (19 tests). `git diff --check` passed.