diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-01-07 13:11:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-07 13:11:50 +0100 |
commit | 67dab9e360dca6c478259459157c5666d77ee817 (patch) | |
tree | fa72d2109adfa756fd4f8e3854baaeec6a23d0ac /test/e2e | |
parent | 8a2238440635d497dbdacceb6826c850582766ea (diff) | |
parent | 4191616cc567d553776001d640e7f2d945a4fae7 (diff) | |
download | podman-67dab9e360dca6c478259459157c5666d77ee817.tar.gz podman-67dab9e360dca6c478259459157c5666d77ee817.tar.bz2 podman-67dab9e360dca6c478259459157c5666d77ee817.zip |
Merge pull request #12726 from hikhvar/remove-superflous-pod-rename
Don't rename pod if container has the same name
Diffstat (limited to 'test/e2e')
-rw-r--r-- | test/e2e/play_kube_test.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index f79710ee6..1c7eb09a4 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -37,6 +37,31 @@ metadata: spec: hostname: unknown ` + +var podnameEqualsContainerNameYaml = ` +apiVersion: v1 +kind: Pod +metadata: + name: podnameEqualsContainerNameYaml +spec: + containers: + - name: podnameEqualsContainerNameYaml + image: quay.io/libpod/alpine:latest + ports: + - containerPort: 80 +` + +var podWithoutAName = ` +apiVersion: v1 +kind: Pod +spec: + containers: + - name: podDoesntHaveAName + image: quay.io/libpod/alpine:latest + ports: + - containerPort: 80 +` + var checkInfraImagePodYaml = ` apiVersion: v1 kind: Pod @@ -1278,6 +1303,39 @@ var _ = Describe("Podman play kube", func() { Expect(sharednamespaces).To(ContainSubstring("pid")) }) + It("podman play kube should not rename pod if container in pod has same name", func() { + err := writeYaml(podnameEqualsContainerNameYaml, kubeYaml) + Expect(err).To(BeNil()) + + kube := podmanTest.Podman([]string{"play", "kube", kubeYaml}) + kube.WaitWithDefaultTimeout() + Expect(kube).Should(Exit(0)) + + testPodCreated := podmanTest.Podman([]string{"pod", "exists", "podnameEqualsContainerNameYaml"}) + testPodCreated.WaitWithDefaultTimeout() + Expect(testPodCreated).Should(Exit(0)) + + inspect := podmanTest.Podman([]string{"inspect", "podnameEqualsContainerNameYaml"}) + inspect.WaitWithDefaultTimeout() + podInspect := inspect.InspectPodArrToJSON() + Expect(podInspect).Should(HaveLen(1)) + var containerNames []string + for _, container := range podInspect[0].Containers { + containerNames = append(containerNames, container.Name) + } + Expect(containerNames).To(ContainElement("podnameEqualsContainerNameYaml-podnameEqualsContainerNameYaml")) + }) + + It("podman play kube should error if pod dont have a name", func() { + err := writeYaml(podWithoutAName, kubeYaml) + Expect(err).To(BeNil()) + + kube := podmanTest.Podman([]string{"play", "kube", kubeYaml}) + kube.WaitWithDefaultTimeout() + Expect(kube).Should(Exit(125)) + + }) + It("podman play kube support container liveness probe", func() { err := writeYaml(livenessProbePodYaml, kubeYaml) Expect(err).To(BeNil()) |