Skip to content

Commit

Permalink
test: Fix testLifecycleOperationsUser restart test
Browse files Browse the repository at this point in the history
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".
  • Loading branch information
martinpitt authored and jelly committed Jul 3, 2023
1 parent c954081 commit 4ba8fc1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/Containers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
}
Expand Down
18 changes: 11 additions & 7 deletions test/check-application
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4ba8fc1

Please sign in to comment.