diff --git a/e2e/idle_reap_test.py b/e2e/idle_reap_test.py index 05ba22e33..8d67fb427 100644 --- a/e2e/idle_reap_test.py +++ b/e2e/idle_reap_test.py @@ -170,11 +170,21 @@ class IdleReapTests(unittest.TestCase): ) def kernel_of(self, session): + """The pid of the kernel the session's last turn ran its cell in. The + link is written before the kernel boots and is kept while the kernel + lives, so a missing one means the cell never reached a kernel or the + kernel ended; the turn's tool output says which.""" with sqlite3.connect(self.app.home / "albedo.sqlite") as database: - (kernel,) = database.execute( + row = database.execute( "SELECT pid FROM kernel_links WHERE session=?", (session,) ).fetchone() - return kernel + outputs = [ + item["output"] + for item in self.provider.requests[-1]["request"]["input"] + if "output" in item + ] + self.assertIsNotNone(row, f"no kernel link after the turn: {outputs}") + return row[0] def first_save(self, session): """The state file once a release has written it, with its identity."""