Merge pull request #10565 from dotCooCoo/fix/rpm-smoke-checks-fixture

Release CI: RPM smoke check waits for its SVG fixture to open
This commit is contained in:
.CooCoo
2026-12-02 11:10:12 -08:00
committed by GitHub
2 changed files with 42 additions and 6 deletions
+16 -4
View File
@@ -51,16 +51,28 @@ def run_smoke(results):
time.sleep(1)
channel.settimeout(30)
with channel, channel.makefile("rwb") as stream:
for request_id, method, params in (
(0, "auth", {"token": token}),
(1, "ui.inspect", {}),
):
def request(request_id, method, params):
stream.write((json.dumps(dict(id=request_id, method=method, params=params)) + "\n").encode())
stream.flush()
response = json.loads(stream.readline())
(results / f"{method}.json").write_text(json.dumps(response, indent=2))
if response.get("id") != request_id or response.get("ok") is not True:
raise RuntimeError(f"GUI request failed: {method}")
return response.get("result") or {}
request(0, "auth", {"token": token})
# The fixture opens off the UI thread: inspect until it is listed as an open document.
deadline = time.monotonic() + 90
request_id = 1
while True:
state = request(request_id, "ui.inspect", {})
titles = [d.get("title", "") for d in state.get("documents", [])]
if not state.get("opening") and fixture.name in titles:
break
if time.monotonic() >= deadline:
raise RuntimeError(f"GUI did not open the fixture; open documents: {titles}")
request_id += 1
time.sleep(1)
finally:
app.terminate()
try:
@@ -27,7 +27,7 @@ class SmokeLifecycleTests(unittest.TestCase):
self.channel = MagicMock()
self.stream = self.channel.makefile.return_value.__enter__.return_value
self.stream.readline.side_effect = [
b'{"id":0,"ok":true}\n', b'{"id":1,"ok":true,"result":{"window":"fixture"}}\n',
b'{"id":0,"ok":true}\n', self.inspection(1, ["original-smoke.svg"]),
]
self.runtime = None
@@ -41,6 +41,11 @@ class SmokeLifecycleTests(unittest.TestCase):
self.connect = self.start_patch(smoke.socket, "create_connection", return_value=self.channel)
self.start_patch(smoke.time, "sleep")
@staticmethod
def inspection(request_id, titles, opening=()):
result = {"documents": [{"title": title, "dirty": False} for title in titles], "opening": list(opening)}
return (json.dumps({"id": request_id, "ok": True, "result": result}) + "\n").encode()
def start_patch(self, owner, name, **kwargs):
patcher = patch.object(owner, name, **kwargs)
result = patcher.start()
@@ -54,7 +59,7 @@ class SmokeLifecycleTests(unittest.TestCase):
def test_success_records_inspection_and_removes_private_runtime(self):
smoke.run_smoke(self.results)
report = json.loads((self.results / "ui.inspect.json").read_text())
self.assertEqual(report["result"], {"window": "fixture"})
self.assertEqual(report["result"]["documents"][0]["title"], "original-smoke.svg")
requests = [json.loads(call.args[0]) for call in self.stream.write.call_args_list]
self.assertEqual(requests[0]["method"], "auth")
self.assertEqual(requests[0]["params"]["token"], self.launch.call_args.kwargs["env"]["VECTORCRAFT_CONTROL_TOKEN"])
@@ -99,6 +104,25 @@ class SmokeLifecycleTests(unittest.TestCase):
smoke.run_smoke(self.results)
self.assert_cleaned_up()
def test_inspection_is_repeated_while_the_fixture_is_opening(self):
self.stream.readline.side_effect = [
b'{"id":0,"ok":true}\n',
self.inspection(1, [], opening=["/results/original-smoke.svg"]),
self.inspection(2, ["original-smoke.svg"]),
]
smoke.run_smoke(self.results)
requests = [json.loads(call.args[0]) for call in self.stream.write.call_args_list]
self.assertEqual([r["method"] for r in requests], ["auth", "ui.inspect", "ui.inspect"])
self.assertEqual([r["id"] for r in requests], [0, 1, 2])
self.assert_cleaned_up()
def test_fixture_that_never_opens_is_a_failure(self):
self.stream.readline.side_effect = [b'{"id":0,"ok":true}\n', self.inspection(1, ["Untitled-1"])]
self.start_patch(smoke.time, "monotonic", side_effect=[0, 0, 91])
with self.assertRaisesRegex(RuntimeError, "did not open the fixture"):
smoke.run_smoke(self.results)
self.assert_cleaned_up()
def test_malformed_response_still_stops_child(self):
self.stream.readline.side_effect = [b'not json\n']
with self.assertRaises(json.JSONDecodeError):