From 4ba8fc1c564e62564723c47f053e4d3cddb2b220 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 3 Jul 2023 16:11:02 +0200 Subject: [PATCH] test: Fix testLifecycleOperationsUser restart test The old "pid changed" waiting loop was completely broken, as the old pid wasn't stripped (thus ending in `\n`), while the new one was. Thus the wait condition was immediately true. Nevertheless, it's not enough to wait for the system state to change, as the UI gets updated asynchronously. The restart events leaked into the following "Force stop" check, and caused unexpected UI changes. There is no steady state change visible in the UI after a restart. Expose the "Pid" and "StartedAt" properties as additional data properties, and use them in the test to wait until the UI actually caught up with the restart. Also, drop the unnecessary no-op filter change, the filter is already set to "All". --- src/Containers.jsx | 2 ++ test/check-application | 18 +++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Containers.jsx b/src/Containers.jsx index 73962a8cd..2ea1b5c78 100644 --- a/src/Containers.jsx +++ b/src/Containers.jsx @@ -468,6 +468,8 @@ class Containers extends React.Component { props: { key: container.Id + container.isSystem.toString(), "data-row-id": container.Id + container.isSystem.toString(), + "data-pid": container.Pid, + "data-started-at": container.StartedAt, }, }; } diff --git a/test/check-application b/test/check-application index a67958f42..232ebf4f4 100755 --- a/test/check-application +++ b/test/check-application @@ -1215,16 +1215,20 @@ class TestApplication(testlib.MachineCase): self.assertEqual(self.getContainerAttr(IMG_BUSYBOX, "CPU"), "n/a") self.assertEqual(memory, "n/a") - # Restart the container - old_pid = self.execute(auth, "podman inspect --format '{{.State.Pid}}' swamped-crate") + # Restart the container; there is no steady state change in the visible UI, so look for + # a changed data-pid attribute + old_pid = self.execute(auth, "podman inspect --format '{{.State.Pid}}' swamped-crate").strip() + b.wait_in_text(f'#containers-containers tr[data-pid="{old_pid}"]', "swamped-crate") self.performContainerAction(IMG_BUSYBOX, "Force restart") - b.wait(lambda: old_pid != self.execute(auth, - "podman inspect --format '{{.State.Pid}}' swamped-crate".strip())) + for _ in range(10): + new_pid = self.execute(auth, "podman inspect --format '{{.State.Pid}}' swamped-crate").strip() + if new_pid and new_pid != old_pid: + break + else: + self.fail("Timed out waiting for pid change") + b.wait_in_text(f'#containers-containers tr[data-pid="{new_pid}"]', "swamped-crate") self.waitContainer(container_sha, auth, name='swamped-crate', image=IMG_BUSYBOX, state='Running') - self.filter_containers('all') - b.wait_visible("#containers-containers") - self.waitContainerRow(IMG_BUSYBOX) if not auth: # Check that the checkpoint option is not present for rootless