summaryrefslogtreecommitdiff
path: root/test/e2e/play_kube_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/e2e/play_kube_test.go')
-rw-r--r--test/e2e/play_kube_test.go44
1 files changed, 41 insertions, 3 deletions
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go
index 4b68f6232..052db3842 100644
--- a/test/e2e/play_kube_test.go
+++ b/test/e2e/play_kube_test.go
@@ -1,5 +1,3 @@
-// +build !remote
-
package integration
import (
@@ -87,6 +85,11 @@ spec:
{{ end }}
privileged: false
readOnlyRootFilesystem: false
+ ports:
+ - containerPort: {{ .Port }}
+ hostIP: {{ .HostIP }}
+ hostPort: {{ .Port }}
+ protocol: TCP
workingDir: /
{{ end }}
{{ end }}
@@ -338,12 +341,14 @@ type Ctr struct {
CapAdd []string
CapDrop []string
PullPolicy string
+ HostIP string
+ Port string
}
// getCtr takes a list of ctrOptions and returns a Ctr with sane defaults
// and the configured options
func getCtr(options ...ctrOption) *Ctr {
- c := Ctr{defaultCtrName, defaultCtrImage, defaultCtrCmd, defaultCtrArg, true, false, nil, nil, ""}
+ c := Ctr{defaultCtrName, defaultCtrImage, defaultCtrCmd, defaultCtrArg, true, false, nil, nil, "", "", ""}
for _, option := range options {
option(&c)
}
@@ -396,6 +401,13 @@ func withPullPolicy(policy string) ctrOption {
}
}
+func withHostIP(ip string, port string) ctrOption {
+ return func(c *Ctr) {
+ c.HostIP = ip
+ c.Port = port
+ }
+}
+
func getCtrNameInPod(pod *Pod) string {
return fmt.Sprintf("%s-%s", pod.Name, defaultCtrName)
}
@@ -447,6 +459,7 @@ var _ = Describe("Podman generate kube", func() {
})
It("podman play kube test correct command", func() {
+ SkipIfRemote()
pod := getPod()
err := generatePodKubeYaml(pod, kubeYaml)
Expect(err).To(BeNil())
@@ -464,6 +477,7 @@ var _ = Describe("Podman generate kube", func() {
})
It("podman play kube test correct command with only set command in yaml file", func() {
+ SkipIfRemote()
pod := getPod(withCtr(getCtr(withCmd([]string{"echo", "hello"}), withArg(nil))))
err := generatePodKubeYaml(pod, kubeYaml)
Expect(err).To(BeNil())
@@ -498,6 +512,7 @@ var _ = Describe("Podman generate kube", func() {
})
It("podman play kube test correct output", func() {
+ SkipIfRemote()
p := getPod(withCtr(getCtr(withCmd([]string{"echo", "hello"}), withArg([]string{"world"}))))
err := generatePodKubeYaml(p, kubeYaml)
@@ -601,6 +616,7 @@ var _ = Describe("Podman generate kube", func() {
})
It("podman play kube seccomp container level", func() {
+ SkipIfRemote()
// expect play kube is expected to set a seccomp label if it's applied as an annotation
jsonFile, err := podmanTest.CreateSeccompJson(seccompPwdEPERM)
if err != nil {
@@ -627,6 +643,7 @@ var _ = Describe("Podman generate kube", func() {
})
It("podman play kube seccomp pod level", func() {
+ SkipIfRemote()
// expect play kube is expected to set a seccomp label if it's applied as an annotation
jsonFile, err := podmanTest.CreateSeccompJson(seccompPwdEPERM)
if err != nil {
@@ -778,6 +795,7 @@ spec:
// Deployment related tests
It("podman play kube deployment 1 replica test correct command", func() {
+ SkipIfRemote()
deployment := getDeployment()
err := generateDeploymentKubeYaml(deployment, kubeYaml)
Expect(err).To(BeNil())
@@ -796,6 +814,7 @@ spec:
})
It("podman play kube deployment more than 1 replica test correct command", func() {
+ SkipIfRemote()
var i, numReplicas int32
numReplicas = 5
deployment := getDeployment(withReplicas(numReplicas))
@@ -815,4 +834,23 @@ spec:
Expect(inspect.OutputToString()).To(ContainSubstring(correctCmd))
}
})
+
+ It("podman play kube test with network portbindings", func() {
+ ip := "127.0.0.100"
+ port := "5000"
+ ctr := getCtr(withHostIP(ip, port), withImage(BB))
+
+ pod := getPod(withCtr(ctr))
+ err := generatePodKubeYaml(pod, kubeYaml)
+ Expect(err).To(BeNil())
+
+ kube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ inspect := podmanTest.Podman([]string{"port", getCtrNameInPod(pod)})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.ExitCode()).To(Equal(0))
+ Expect(inspect.OutputToString()).To(Equal("5000/tcp -> 127.0.0.100:5000"))
+ })
})