summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorcdoern <cbdoer23@g.holycross.edu>2022-05-13 10:52:57 -0400
committercdoern <cdoern@redhat.com>2022-06-10 14:23:19 -0400
commit958759a71955860b01b17bd3bebf38f9dae1018e (patch)
tree34872e81fb126f854c7612ca39f11932ccd3f8bb /test
parent6a2c0e96011d36e5b459a010d472facd26c67389 (diff)
downloadpodman-958759a71955860b01b17bd3bebf38f9dae1018e.tar.gz
podman-958759a71955860b01b17bd3bebf38f9dae1018e.tar.bz2
podman-958759a71955860b01b17bd3bebf38f9dae1018e.zip
podman pod clone
implement podman pod clone, a command to create an exact copy of a pod while changing certain config elements current supported flags are: --name change the pod name --destroy remove the original pod --start run the new pod on creation and all infra-container related flags from podman pod create (namespaces etc) resolves #12843 Signed-off-by: cdoern <cdoern@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/e2e/pod_clone_test.go141
1 files changed, 141 insertions, 0 deletions
diff --git a/test/e2e/pod_clone_test.go b/test/e2e/pod_clone_test.go
new file mode 100644
index 000000000..b62e1205c
--- /dev/null
+++ b/test/e2e/pod_clone_test.go
@@ -0,0 +1,141 @@
+package integration
+
+import (
+ "os"
+
+ . "github.com/containers/podman/v4/test/utils"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("Podman pod clone", func() {
+ var (
+ tempdir string
+ err error
+ podmanTest *PodmanTestIntegration
+ )
+
+ BeforeEach(func() {
+ SkipIfRemote("podman pod clone is not supported in remote")
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanTestCreate(tempdir)
+ podmanTest.Setup()
+ })
+
+ AfterEach(func() {
+ podmanTest.Cleanup()
+ f := CurrentGinkgoTestDescription()
+ processTestResult(f)
+
+ })
+
+ It("podman pod clone basic test", func() {
+ create := podmanTest.Podman([]string{"pod", "create", "--name", "1"})
+ create.WaitWithDefaultTimeout()
+ Expect(create).To(Exit(0))
+
+ run := podmanTest.Podman([]string{"run", "--pod", "1", "-dt", ALPINE})
+ run.WaitWithDefaultTimeout()
+ Expect(run).To(Exit(0))
+
+ clone := podmanTest.Podman([]string{"pod", "clone", create.OutputToString()})
+ clone.WaitWithDefaultTimeout()
+ Expect(clone).To(Exit(0))
+
+ podInspect := podmanTest.Podman([]string{"pod", "inspect", clone.OutputToString()})
+ podInspect.WaitWithDefaultTimeout()
+ Expect(podInspect).To(Exit(0))
+ data := podInspect.InspectPodToJSON()
+ Expect(data.Name).To(ContainSubstring("-clone"))
+
+ podStart := podmanTest.Podman([]string{"pod", "start", clone.OutputToString()})
+ podStart.WaitWithDefaultTimeout()
+ Expect(podStart).To(Exit(0))
+
+ podInspect = podmanTest.Podman([]string{"pod", "inspect", clone.OutputToString()})
+ podInspect.WaitWithDefaultTimeout()
+ Expect(podInspect).To(Exit(0))
+ data = podInspect.InspectPodToJSON()
+ Expect(data.Containers[1].State).To(ContainSubstring("running")) // make sure non infra ctr is running
+ })
+
+ It("podman pod clone renaming test", func() {
+ create := podmanTest.Podman([]string{"pod", "create", "--name", "1"})
+ create.WaitWithDefaultTimeout()
+ Expect(create).To(Exit(0))
+
+ clone := podmanTest.Podman([]string{"pod", "clone", "--name", "2", create.OutputToString()})
+ clone.WaitWithDefaultTimeout()
+ Expect(clone).To(Exit(0))
+
+ podInspect := podmanTest.Podman([]string{"pod", "inspect", clone.OutputToString()})
+ podInspect.WaitWithDefaultTimeout()
+ Expect(podInspect).To(Exit(0))
+ data := podInspect.InspectPodToJSON()
+ Expect(data.Name).To(ContainSubstring("2"))
+
+ podStart := podmanTest.Podman([]string{"pod", "start", clone.OutputToString()})
+ podStart.WaitWithDefaultTimeout()
+ Expect(podStart).To(Exit(0))
+ })
+
+ It("podman pod clone start test", func() {
+ create := podmanTest.Podman([]string{"pod", "create", "--name", "1"})
+ create.WaitWithDefaultTimeout()
+ Expect(create).To(Exit(0))
+
+ clone := podmanTest.Podman([]string{"pod", "clone", "--start", create.OutputToString()})
+ clone.WaitWithDefaultTimeout()
+ Expect(clone).To(Exit(0))
+
+ podInspect := podmanTest.Podman([]string{"pod", "inspect", clone.OutputToString()})
+ podInspect.WaitWithDefaultTimeout()
+ Expect(podInspect).To(Exit(0))
+ data := podInspect.InspectPodToJSON()
+ Expect(data.State).To(ContainSubstring("Running"))
+
+ })
+
+ It("podman pod clone destroy test", func() {
+ create := podmanTest.Podman([]string{"pod", "create", "--name", "1"})
+ create.WaitWithDefaultTimeout()
+ Expect(create).To(Exit(0))
+
+ clone := podmanTest.Podman([]string{"pod", "clone", "--destroy", create.OutputToString()})
+ clone.WaitWithDefaultTimeout()
+ Expect(clone).To(Exit(0))
+
+ podInspect := podmanTest.Podman([]string{"pod", "inspect", create.OutputToString()})
+ podInspect.WaitWithDefaultTimeout()
+ Expect(podInspect).ToNot(Exit(0))
+ })
+
+ It("podman pod clone infra option test", func() {
+ // proof of concept that all currently tested infra options work since
+
+ volName := "testVol"
+ volCreate := podmanTest.Podman([]string{"volume", "create", volName})
+ volCreate.WaitWithDefaultTimeout()
+ Expect(volCreate).Should(Exit(0))
+
+ podName := "testPod"
+ podCreate := podmanTest.Podman([]string{"pod", "create", "--name", podName})
+ podCreate.WaitWithDefaultTimeout()
+ Expect(podCreate).Should(Exit(0))
+
+ podClone := podmanTest.Podman([]string{"pod", "clone", "--volume", volName + ":/tmp1", podName})
+ podClone.WaitWithDefaultTimeout()
+ Expect(podClone).Should(Exit(0))
+
+ podInspect := podmanTest.Podman([]string{"pod", "inspect", "testPod-clone"})
+ podInspect.WaitWithDefaultTimeout()
+ Expect(podInspect).Should(Exit(0))
+ data := podInspect.InspectPodToJSON()
+ Expect(data.Mounts[0]).To(HaveField("Name", volName))
+ })
+
+})