summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorAdrian Reber <areber@redhat.com>2021-07-12 16:19:15 +0000
committerAdrian Reber <adrian@lisas.de>2021-07-27 16:10:45 +0200
commit60b9e8c0da683d253f3828f00442fc5a75540368 (patch)
tree570e045462274cd4c54ceb0e2d61bd6271f4e0f6 /test/e2e
parenteb94467780eab06a452586c9751fc4f571d9e089 (diff)
downloadpodman-60b9e8c0da683d253f3828f00442fc5a75540368.tar.gz
podman-60b9e8c0da683d253f3828f00442fc5a75540368.tar.bz2
podman-60b9e8c0da683d253f3828f00442fc5a75540368.zip
Added tests for out of and into pod checkpoint and restore support
Signed-off-by: Adrian Reber <areber@redhat.com>
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/checkpoint_test.go162
1 files changed, 162 insertions, 0 deletions
diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go
index cbebffe81..1c9a8dc6f 100644
--- a/test/e2e/checkpoint_test.go
+++ b/test/e2e/checkpoint_test.go
@@ -1,11 +1,13 @@
package integration
import (
+ "fmt"
"net"
"os"
"os/exec"
"strings"
+ "github.com/containers/podman/v3/pkg/checkpoint/crutils"
"github.com/containers/podman/v3/pkg/criu"
. "github.com/containers/podman/v3/test/utils"
. "github.com/onsi/ginkgo"
@@ -977,4 +979,164 @@ var _ = Describe("Podman checkpoint", func() {
// Remove exported checkpoint
os.Remove(fileName)
})
+
+ namespaceCombination := []string{
+ "cgroup,ipc,net,uts,pid",
+ "cgroup,ipc,net,uts",
+ "cgroup,ipc,net",
+ "cgroup,ipc",
+ "ipc,net,uts,pid",
+ "ipc,net,uts",
+ "ipc,net",
+ "net,uts,pid",
+ "net,uts",
+ "uts,pid",
+ }
+ for _, share := range namespaceCombination {
+ testName := fmt.Sprintf(
+ "podman checkpoint and restore container out of and into pod (%s)",
+ share,
+ )
+ It(testName, func() {
+ if !criu.CheckForCriu(criu.PodCriuVersion) {
+ Skip("CRIU is missing or too old.")
+ }
+ if !crutils.CRRuntimeSupportsPodCheckpointRestore(podmanTest.OCIRuntime) {
+ Skip("runtime does not support pod restore")
+ }
+ // Create a pod
+ session := podmanTest.Podman([]string{
+ "pod",
+ "create",
+ "--share",
+ share,
+ })
+ session.WaitWithDefaultTimeout()
+ Expect(session).To(Exit(0))
+ podID := session.OutputToString()
+
+ session = podmanTest.Podman([]string{
+ "run",
+ "-d",
+ "--rm",
+ "--pod",
+ podID,
+ ALPINE,
+ "top",
+ })
+ session.WaitWithDefaultTimeout()
+ Expect(session).To(Exit(0))
+ cid := session.OutputToString()
+
+ fileName := "/tmp/checkpoint-" + cid + ".tar.gz"
+
+ // Checkpoint the container
+ result := podmanTest.Podman([]string{
+ "container",
+ "checkpoint",
+ "-e",
+ fileName,
+ cid,
+ })
+ result.WaitWithDefaultTimeout()
+
+ // As the container has been started with '--rm' it will be completely
+ // cleaned up after checkpointing.
+ Expect(result).To(Exit(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+ Expect(podmanTest.NumberOfContainers()).To(Equal(1))
+
+ // Remove the pod and create a new pod
+ result = podmanTest.Podman([]string{
+ "pod",
+ "rm",
+ podID,
+ })
+ result.WaitWithDefaultTimeout()
+ Expect(result).To(Exit(0))
+
+ // First create a pod with different shared namespaces.
+ // Restore should fail
+
+ wrongShare := share[:strings.LastIndex(share, ",")]
+
+ session = podmanTest.Podman([]string{
+ "pod",
+ "create",
+ "--share",
+ wrongShare,
+ })
+ session.WaitWithDefaultTimeout()
+ Expect(session).To(Exit(0))
+ podID = session.OutputToString()
+
+ // Restore container with different port mapping
+ result = podmanTest.Podman([]string{
+ "container",
+ "restore",
+ "--pod",
+ podID,
+ "-i",
+ fileName,
+ })
+ result.WaitWithDefaultTimeout()
+ Expect(result).To(Exit(125))
+ Expect(result.ErrorToString()).To(ContainSubstring("does not share the"))
+
+ // Remove the pod and create a new pod
+ result = podmanTest.Podman([]string{
+ "pod",
+ "rm",
+ podID,
+ })
+ result.WaitWithDefaultTimeout()
+ Expect(result).To(Exit(0))
+
+ session = podmanTest.Podman([]string{
+ "pod",
+ "create",
+ "--share",
+ share,
+ })
+ session.WaitWithDefaultTimeout()
+ Expect(session).To(Exit(0))
+ podID = session.OutputToString()
+
+ // Restore container with different port mapping
+ result = podmanTest.Podman([]string{
+ "container",
+ "restore",
+ "--pod",
+ podID,
+ "-i",
+ fileName,
+ })
+ result.WaitWithDefaultTimeout()
+
+ Expect(result).To(Exit(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
+
+ result = podmanTest.Podman([]string{
+ "rm",
+ "-f",
+ result.OutputToString(),
+ })
+ result.WaitWithDefaultTimeout()
+ Expect(result).To(Exit(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+ Expect(podmanTest.NumberOfContainers()).To(Equal(1))
+
+ result = podmanTest.Podman([]string{
+ "pod",
+ "rm",
+ "-fa",
+ })
+ result.WaitWithDefaultTimeout()
+ Expect(result).To(Exit(0))
+
+ // Remove exported checkpoint
+ os.Remove(fileName)
+ })
+ }
})