summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-11-22 15:44:10 +0100
committerGitHub <noreply@github.com>2021-11-22 15:44:10 +0100
commit26b45a1564fb01090f6a10776922654641a76681 (patch)
tree84dc1b3a6ab425b201c0e56360dfe3c20d61afd2 /test/e2e
parent2f6cdd353f50e6c26b34f0b1bff028e8393d2580 (diff)
parentced0ffbe8f6dae9031a1ae3b48d4f24bca93b5bd (diff)
downloadpodman-26b45a1564fb01090f6a10776922654641a76681.tar.gz
podman-26b45a1564fb01090f6a10776922654641a76681.tar.bz2
podman-26b45a1564fb01090f6a10776922654641a76681.zip
Merge pull request #12351 from adrianreber/2021-11-18-restore-runtime-verification
Restore runtime verification
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/checkpoint_test.go173
1 files changed, 173 insertions, 0 deletions
diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go
index 6b9a96e9f..e34c07d49 100644
--- a/test/e2e/checkpoint_test.go
+++ b/test/e2e/checkpoint_test.go
@@ -1377,4 +1377,177 @@ var _ = Describe("Podman checkpoint", func() {
Expect(result).Should(Exit(0))
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
})
+
+ It("podman checkpoint container with export and verify runtime", func() {
+ SkipIfRemote("podman-remote does not support --runtime flag")
+ localRunString := getRunString([]string{
+ "--rm",
+ ALPINE,
+ "top",
+ })
+ session := podmanTest.Podman(localRunString)
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+ cid := session.OutputToString()
+
+ session = podmanTest.Podman([]string{
+ "inspect",
+ "--format",
+ "{{.OCIRuntime}}",
+ cid,
+ })
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ runtime := session.OutputToString()
+
+ fileName := "/tmp/checkpoint-" + cid + ".tar.gz"
+
+ result := podmanTest.Podman([]string{
+ "container",
+ "checkpoint",
+ cid, "-e",
+ fileName,
+ })
+ result.WaitWithDefaultTimeout()
+
+ // As the container has been started with '--rm' it will be completely
+ // cleaned up after checkpointing.
+ Expect(result).Should(Exit(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainers()).To(Equal(0))
+
+ result = podmanTest.Podman([]string{
+ "container",
+ "restore",
+ "-i",
+ fileName,
+ })
+ result.WaitWithDefaultTimeout()
+ Expect(result).Should(Exit(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
+
+ // The restored container should have the same runtime as the original container
+ result = podmanTest.Podman([]string{
+ "inspect",
+ "--format",
+ "{{.OCIRuntime}}",
+ cid,
+ })
+ result.WaitWithDefaultTimeout()
+ Expect(result).Should(Exit(0))
+ Expect(session.OutputToString()).To(Equal(runtime))
+
+ // Remove exported checkpoint
+ os.Remove(fileName)
+ })
+
+ It("podman checkpoint container with export and try to change the runtime", func() {
+ SkipIfRemote("podman-remote does not support --runtime flag")
+ // This test will only run if runc and crun both exist
+ if !strings.Contains(podmanTest.OCIRuntime, "crun") {
+ Skip("Test requires crun and runc")
+ }
+ cmd := exec.Command("runc")
+ if err := cmd.Start(); err != nil {
+ Skip("Test requires crun and runc")
+ }
+ if err := cmd.Wait(); err != nil {
+ Skip("Test requires crun and runc")
+ }
+ localRunString := getRunString([]string{
+ "--rm",
+ ALPINE,
+ "top",
+ })
+ // Let's start a container with runc and try to restore it with crun (expected to fail)
+ localRunString = append(
+ []string{
+ "--runtime",
+ "runc",
+ },
+ localRunString...,
+ )
+ session := podmanTest.Podman(localRunString)
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+ cid := session.OutputToString()
+
+ session = podmanTest.Podman([]string{
+ "inspect",
+ "--format",
+ "{{.OCIRuntime}}",
+ cid,
+ })
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ runtime := session.OutputToString()
+
+ fileName := "/tmp/checkpoint-" + cid + ".tar.gz"
+
+ result := podmanTest.Podman([]string{
+ "container",
+ "checkpoint",
+ cid, "-e",
+ fileName,
+ })
+ result.WaitWithDefaultTimeout()
+
+ // As the container has been started with '--rm' it will be completely
+ // cleaned up after checkpointing.
+ Expect(result).Should(Exit(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainers()).To(Equal(0))
+
+ // This should fail as the container was checkpointed with runc
+ result = podmanTest.Podman([]string{
+ "--runtime",
+ "crun",
+ "container",
+ "restore",
+ "-i",
+ fileName,
+ })
+ result.WaitWithDefaultTimeout()
+
+ Expect(result).Should(Exit(125))
+ Expect(result.ErrorToString()).To(
+ ContainSubstring("and cannot be restored with runtime"),
+ )
+
+ result = podmanTest.Podman([]string{
+ "--runtime",
+ "runc",
+ "container",
+ "restore",
+ "-i",
+ fileName,
+ })
+ result.WaitWithDefaultTimeout()
+ Expect(result).Should(Exit(0))
+
+ result = podmanTest.Podman([]string{
+ "inspect",
+ "--format",
+ "{{.OCIRuntime}}",
+ cid,
+ })
+ result.WaitWithDefaultTimeout()
+ Expect(result).Should(Exit(0))
+ Expect(result.OutputToString()).To(Equal(runtime))
+
+ result = podmanTest.Podman([]string{
+ "--runtime",
+ "runc",
+ "rm",
+ "-fa",
+ })
+ result.WaitWithDefaultTimeout()
+ Expect(result).Should(Exit(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ // Remove exported checkpoint
+ os.Remove(fileName)
+ })
})