mirror of
https://github.com/containers/podman.git
synced 2025-12-01 10:38:05 +08:00
CI: e2e: fix checkpoint flake
Two flakes seen in the last three months. One of them was in August, so it's not related to ongoing criu-4.0 problems. Suspected cause: race waiting for "podman run --rm" container to transition from stopped to removed. Solution: allow a 5-second grace period, retrying every second. Also: add explanations to the Expect()s, remove unnecessary code, and tighten up the CID check. Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
@@ -711,12 +711,13 @@ var _ = Describe("Podman checkpoint", func() {
|
|||||||
session := podmanTest.Podman([]string{"run", "--network=none", "-d", "--rm", ALPINE, "top"})
|
session := podmanTest.Podman([]string{"run", "--network=none", "-d", "--rm", ALPINE, "top"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(ExitCleanly())
|
||||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
|
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1), "# of running containers at start")
|
||||||
cid := session.OutputToString()
|
cid := session.OutputToString()
|
||||||
fileName := filepath.Join(podmanTest.TempDir, "/checkpoint-"+cid+".tar.gz")
|
fileName := filepath.Join(podmanTest.TempDir, "/checkpoint-"+cid+".tar.gz")
|
||||||
|
|
||||||
// Change the container's root file-system
|
// Change the container's root file-system
|
||||||
result := podmanTest.Podman([]string{"exec", cid, "/bin/sh", "-c", "echo test" + cid + "test > /test.output"})
|
signalFile := "/test.output"
|
||||||
|
result := podmanTest.Podman([]string{"exec", cid, "touch", signalFile})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result).Should(ExitCleanly())
|
Expect(result).Should(ExitCleanly())
|
||||||
|
|
||||||
@@ -725,23 +726,32 @@ var _ = Describe("Podman checkpoint", func() {
|
|||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
|
|
||||||
Expect(result).Should(ExitCleanly())
|
Expect(result).Should(ExitCleanly())
|
||||||
Expect(result.OutputToString()).To(ContainSubstring(cid))
|
Expect(result.OutputToString()).To(Equal(cid), "checkpoint output")
|
||||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
|
// Allow a few seconds for --rm to take effect
|
||||||
Expect(podmanTest.NumberOfContainers()).To(Equal(0))
|
ncontainers := podmanTest.NumberOfContainers()
|
||||||
|
for try := 0; try < 4; try++ {
|
||||||
|
if ncontainers == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
ncontainers = podmanTest.NumberOfContainers()
|
||||||
|
}
|
||||||
|
Expect(ncontainers).To(Equal(0), "# of containers (total) after checkpoint")
|
||||||
|
|
||||||
// Restore the container
|
// Restore the container
|
||||||
result = podmanTest.Podman([]string{"container", "restore", "--ignore-rootfs", "-i", fileName})
|
result = podmanTest.Podman([]string{"container", "restore", "--ignore-rootfs", "-i", fileName})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
|
|
||||||
Expect(result).Should(ExitCleanly())
|
Expect(result).Should(ExitCleanly())
|
||||||
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
|
|
||||||
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
|
runCheck := podmanTest.Podman([]string{"ps", "-a", "--noheading", "--no-trunc", "--format", "{{.ID}} {{.State}}"})
|
||||||
Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
|
runCheck.WaitWithDefaultTimeout()
|
||||||
|
Expect(runCheck).Should(ExitCleanly())
|
||||||
|
Expect(runCheck.OutputToString()).To(Equal(cid+" running"), "podman ps, after restore")
|
||||||
|
|
||||||
// Verify the changes to the container's root file-system
|
// Verify the changes to the container's root file-system
|
||||||
result = podmanTest.Podman([]string{"exec", cid, "cat", "/test.output"})
|
result = podmanTest.Podman([]string{"exec", cid, "cat", signalFile})
|
||||||
result.WaitWithDefaultTimeout()
|
result.WaitWithDefaultTimeout()
|
||||||
Expect(result).Should(ExitWithError(1, "cat: can't open '/test.output': No such file or directory"))
|
Expect(result).Should(ExitWithError(1, "cat: can't open '"+signalFile+"': No such file or directory"))
|
||||||
|
|
||||||
// Remove exported checkpoint
|
// Remove exported checkpoint
|
||||||
os.Remove(fileName)
|
os.Remove(fileName)
|
||||||
|
|||||||
Reference in New Issue
Block a user