summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-01-12 07:57:05 -0500
committerGitHub <noreply@github.com>2021-01-12 07:57:05 -0500
commit5575c7be2023d0709432b12b60124168c6956c8a (patch)
tree3856aabbe4003f23663978d3f01062a091d80c1c /test/e2e
parent1955eee89f083ec814a44025dc0abe59748205b3 (diff)
parent2aa381f2d0cdc8abb28aa8759c681198cb1e47a7 (diff)
downloadpodman-5575c7be2023d0709432b12b60124168c6956c8a.tar.gz
podman-5575c7be2023d0709432b12b60124168c6956c8a.tar.bz2
podman-5575c7be2023d0709432b12b60124168c6956c8a.zip
Merge pull request #8819 from chen-zhuohan/add-pre-checkpoint
Add pre-checkpoint and restore with previous
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/checkpoint_test.go75
1 files changed, 75 insertions, 0 deletions
diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go
index 4c6b2cf5c..abc37792a 100644
--- a/test/e2e/checkpoint_test.go
+++ b/test/e2e/checkpoint_test.go
@@ -4,6 +4,7 @@ import (
"net"
"os"
"os/exec"
+ "strings"
"github.com/containers/podman/v2/pkg/criu"
. "github.com/containers/podman/v2/test/utils"
@@ -747,4 +748,78 @@ var _ = Describe("Podman checkpoint", func() {
// Remove exported checkpoint
os.Remove(checkpointFileName)
})
+
+ It("podman checkpoint container with --pre-checkpoint", func() {
+ if !strings.Contains(podmanTest.OCIRuntime, "runc") {
+ Skip("Test only works on runc 1.0-rc3 or higher.")
+ }
+ localRunString := getRunString([]string{ALPINE, "top"})
+ session := podmanTest.Podman(localRunString)
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ cid := session.OutputToString()
+
+ result := podmanTest.Podman([]string{"container", "checkpoint", "-P", cid})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
+
+ result = podmanTest.Podman([]string{"container", "checkpoint", "--with-previous", cid})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Exited"))
+
+ result = podmanTest.Podman([]string{"container", "restore", cid})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
+ })
+
+ It("podman checkpoint container with --pre-checkpoint and export (migration)", func() {
+ if !strings.Contains(podmanTest.OCIRuntime, "runc") {
+ Skip("Test only works on runc 1.0-rc3 or higher.")
+ }
+ localRunString := getRunString([]string{ALPINE, "top"})
+ session := podmanTest.Podman(localRunString)
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ cid := session.OutputToString()
+ preCheckpointFileName := "/tmp/pre-checkpoint-" + cid + ".tar.gz"
+ checkpointFileName := "/tmp/checkpoint-" + cid + ".tar.gz"
+
+ result := podmanTest.Podman([]string{"container", "checkpoint", "-P", "-e", preCheckpointFileName, cid})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
+
+ result = podmanTest.Podman([]string{"container", "checkpoint", "--with-previous", "-e", checkpointFileName, cid})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Exited"))
+
+ result = podmanTest.Podman([]string{"rm", "-f", cid})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+
+ result = podmanTest.Podman([]string{"container", "restore", "-i", checkpointFileName, "--import-previous", preCheckpointFileName})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
+
+ os.Remove(checkpointFileName)
+ os.Remove(preCheckpointFileName)
+ })
})