aboutsummaryrefslogtreecommitdiff
path: root/test/e2e/generate_kube_test.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-06-24 14:45:07 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-06-24 14:45:07 -0400
commit567e7c60fa696d3332159fc9641d54f242c42804 (patch)
tree656038dd33ab14d104ef0af0988b5856900379b6 /test/e2e/generate_kube_test.go
parentebf48ff45991363a05a7f84225a415dbaaa85e80 (diff)
downloadpodman-567e7c60fa696d3332159fc9641d54f242c42804.tar.gz
podman-567e7c60fa696d3332159fc9641d54f242c42804.tar.bz2
podman-567e7c60fa696d3332159fc9641d54f242c42804.zip
Add test for generate kube on a pod with ports
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'test/e2e/generate_kube_test.go')
-rw-r--r--test/e2e/generate_kube_test.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go
index 40cc534c2..760ba6851 100644
--- a/test/e2e/generate_kube_test.go
+++ b/test/e2e/generate_kube_test.go
@@ -10,6 +10,7 @@ import (
"github.com/ghodss/yaml"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
+ "k8s.io/api/core/v1"
)
var _ = Describe("Podman generate kube", func() {
@@ -106,6 +107,49 @@ var _ = Describe("Podman generate kube", func() {
Expect(err).To(BeNil())
})
+ It("podman generate kube on pod with ports", func() {
+ podName := "test"
+ podSession := podmanTest.Podman("pod", "create", "--name", podName, "-p", "4000:4000", "-p", "5000:5000")
+ podSession.WaitWithDefaultTimeout()
+ Expect(podSession.ExitCode()).To(Equal(0))
+
+ ctr1Name := "ctr1"
+ ctr1Session := podmanTest.Podman("create", "--name", ctr1Name, "--pod", podName, ALPINE, "top")
+ ctr1Session.WaitWithDefaultTimeout()
+ Expect(ctr1Session.ExitCode()).To(Equal(0))
+
+ ctr2Name := "ctr2"
+ ctr2Session := podmanTest.Podman("create", "--name", ctr2Name, "--pod", podName, ALPINE, "top")
+ ctr2Session.WaitWithDefaultTimeout()
+ Expect(ctr2Session.ExitCode()).To(Equal(0))
+
+ kube := podmanTest.Podman([]string{"generate", "kube", podName})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ pod := new(v1.Pod)
+ err := yaml.Unmarshal(kube.OutputToString(), pod)
+ Expect(err).To(BeNil())
+
+ foundPort4000 := 0
+ foundPort5000 := 0
+ foundOtherPort := 0
+ for _, ctr := range pod.Spec.Containers {
+ for _, port := range ctr.Ports {
+ if port.HostPort == 4000 {
+ foundPort4000 = foundPort4000 + 1
+ } else if port.HostPort == 5000 {
+ foundPort5000 = foundPort5000 + 1
+ } else {
+ foundOtherPort = foundOtherPort + 1
+ }
+ }
+ }
+ Expect(foundPort4000).To(Equal(1))
+ Expect(foundPort5000).To(Equal(1))
+ Expect(foundOtherPort).To(Equal(0))
+ })
+
It("podman generate and reimport kube on pod", func() {
podName := "toppod"
_, rc, _ := podmanTest.CreatePod(podName)