aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorUrvashi Mohnani <umohnani@redhat.com>2022-07-19 11:58:27 -0400
committerUrvashi Mohnani <umohnani@redhat.com>2022-07-20 10:02:32 -0400
commitda33f100551ebd9b5e8790d677a1a8be2ea4fae4 (patch)
treedaebdd87c3056614f7f74545db2fe392cf95371b /test
parent21cf30f2f895a3c453760f800077b8f7dbfce23c (diff)
downloadpodman-da33f100551ebd9b5e8790d677a1a8be2ea4fae4.tar.gz
podman-da33f100551ebd9b5e8790d677a1a8be2ea4fae4.tar.bz2
podman-da33f100551ebd9b5e8790d677a1a8be2ea4fae4.zip
Update init ctr default for play kube
Update the init container type default to once instead of always to match k8s behavior. Add a new annotation that can be used to change the init ctr type in the kube yaml. Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/e2e/play_kube_test.go29
1 files changed, 27 insertions, 2 deletions
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go
index 457aaebb2..9e2d4de19 100644
--- a/test/e2e/play_kube_test.go
+++ b/test/e2e/play_kube_test.go
@@ -1559,8 +1559,10 @@ var _ = Describe("Podman play kube", func() {
})
// If you have an init container in the pod yaml, podman should create and run the init container with play kube
- It("podman play kube test with init containers", func() {
- pod := getPod(withPodInitCtr(getCtr(withImage(ALPINE), withCmd([]string{"echo", "hello"}), withInitCtr(), withName("init-test"))), withCtr(getCtr(withImage(ALPINE), withCmd([]string{"top"}))))
+ // With annotation set to always
+ It("podman play kube test with init containers and annotation set", func() {
+ // With the init container type annotation set to always
+ pod := getPod(withAnnotation("io.podman.annotations.init.container.type", "always"), withPodInitCtr(getCtr(withImage(ALPINE), withCmd([]string{"echo", "hello"}), withInitCtr(), withName("init-test"))), withCtr(getCtr(withImage(ALPINE), withCmd([]string{"top"}))))
err := generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -1585,6 +1587,29 @@ var _ = Describe("Podman play kube", func() {
Expect(inspect.OutputToString()).To(ContainSubstring("running"))
})
+ // If you have an init container in the pod yaml, podman should create and run the init container with play kube
+ // Using default init container type (once)
+ It("podman play kube test with init container type set to default value", func() {
+ // Using the default init container type (once)
+ pod := getPod(withPodInitCtr(getCtr(withImage(ALPINE), withCmd([]string{"echo", "hello"}), withInitCtr(), withName("init-test"))), withCtr(getCtr(withImage(ALPINE), withCmd([]string{"top"}))))
+ err := generateKubeYaml("pod", pod, kubeYaml)
+ Expect(err).To(BeNil())
+
+ kube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube).Should(Exit(0))
+
+ // Expect the number of containers created to be 2, infra and regular container
+ numOfCtrs := podmanTest.NumberOfContainers()
+ Expect(numOfCtrs).To(Equal(2))
+
+ // Regular container should be in running state
+ inspect := podmanTest.Podman([]string{"inspect", "--format", "{{.State.Status}}", "testPod-" + defaultCtrName})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect).Should(Exit(0))
+ Expect(inspect.OutputToString()).To(ContainSubstring("running"))
+ })
+
// If you supply only args for a Container, the default Entrypoint defined in the Docker image is run with the args that you supplied.
It("podman play kube test correct command with only set args in yaml file", func() {
pod := getPod(withCtr(getCtr(withImage(REGISTRY_IMAGE), withCmd(nil), withArg([]string{"echo", "hello"}))))