summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/e2e/cp_test.go4
-rw-r--r--test/e2e/generate_kube_test.go73
-rw-r--r--test/e2e/inspect_test.go27
3 files changed, 99 insertions, 5 deletions
diff --git a/test/e2e/cp_test.go b/test/e2e/cp_test.go
index f7596d77d..5e98e73eb 100644
--- a/test/e2e/cp_test.go
+++ b/test/e2e/cp_test.go
@@ -58,6 +58,10 @@ var _ = Describe("Podman cp", func() {
session = podmanTest.Podman([]string{"cp", name + ":foo", dstPath})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"start", name})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
})
It("podman cp file to dir", func() {
diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go
index 40cc534c2..1df54f753 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() {
@@ -57,8 +58,15 @@ var _ = Describe("Podman generate kube", func() {
kube.WaitWithDefaultTimeout()
Expect(kube.ExitCode()).To(Equal(0))
- _, err := yaml.Marshal(kube.OutputToString())
+ pod := new(v1.Pod)
+ err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil())
+
+ numContainers := 0
+ for range pod.Spec.Containers {
+ numContainers = numContainers + 1
+ }
+ Expect(numContainers).To(Equal(1))
})
It("podman generate service kube on container", func() {
@@ -70,8 +78,11 @@ var _ = Describe("Podman generate kube", func() {
kube.WaitWithDefaultTimeout()
Expect(kube.ExitCode()).To(Equal(0))
- _, err := yaml.Marshal(kube.OutputToString())
- Expect(err).To(BeNil())
+ // TODO - test generated YAML - service produces multiple
+ // structs.
+ // pod := new(v1.Pod)
+ // err := yaml.Unmarshal([]byte(kube.OutputToString()), pod)
+ // Expect(err).To(BeNil())
})
It("podman generate kube on pod", func() {
@@ -86,8 +97,15 @@ var _ = Describe("Podman generate kube", func() {
kube.WaitWithDefaultTimeout()
Expect(kube.ExitCode()).To(Equal(0))
- _, err := yaml.Marshal(kube.OutputToString())
+ pod := new(v1.Pod)
+ err := yaml.Unmarshal(kube.Out.Contents(), pod)
Expect(err).To(BeNil())
+
+ numContainers := 0
+ for range pod.Spec.Containers {
+ numContainers = numContainers + 1
+ }
+ Expect(numContainers).To(Equal(1))
})
It("podman generate service kube on pod", func() {
@@ -102,8 +120,53 @@ var _ = Describe("Podman generate kube", func() {
kube.WaitWithDefaultTimeout()
Expect(kube.ExitCode()).To(Equal(0))
- _, err := yaml.Marshal(kube.OutputToString())
+ // TODO: How do we test unmarshal with a service? We have two
+ // structs that need to be unmarshalled...
+ // _, err := yaml.Marshal(kube.OutputToString())
+ // Expect(err).To(BeNil())
+ })
+
+ It("podman generate kube on pod with ports", func() {
+ podName := "test"
+ podSession := podmanTest.Podman([]string{"pod", "create", "--name", podName, "-p", "4000:4000", "-p", "5000:5000"})
+ podSession.WaitWithDefaultTimeout()
+ Expect(podSession.ExitCode()).To(Equal(0))
+
+ ctr1Name := "ctr1"
+ ctr1Session := podmanTest.Podman([]string{"create", "--name", ctr1Name, "--pod", podName, ALPINE, "top"})
+ ctr1Session.WaitWithDefaultTimeout()
+ Expect(ctr1Session.ExitCode()).To(Equal(0))
+
+ ctr2Name := "ctr2"
+ ctr2Session := podmanTest.Podman([]string{"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.Out.Contents(), 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() {
diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go
index ccd8602c4..790115133 100644
--- a/test/e2e/inspect_test.go
+++ b/test/e2e/inspect_test.go
@@ -107,4 +107,31 @@ var _ = Describe("Podman inspect", func() {
Expect(result.ExitCode()).To(Equal(125))
})
+ It("podman inspect with mount filters", func() {
+ SkipIfRemote()
+
+ ctrSession := podmanTest.Podman([]string{"create", "-v", "/tmp:/test1", ALPINE, "top"})
+ ctrSession.WaitWithDefaultTimeout()
+ Expect(ctrSession.ExitCode()).To(Equal(0))
+
+ inspectSource := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Source}}"})
+ inspectSource.WaitWithDefaultTimeout()
+ Expect(inspectSource.ExitCode()).To(Equal(0))
+ Expect(inspectSource.OutputToString()).To(Equal("/tmp"))
+
+ inspectSrc := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Src}}"})
+ inspectSrc.WaitWithDefaultTimeout()
+ Expect(inspectSrc.ExitCode()).To(Equal(0))
+ Expect(inspectSrc.OutputToString()).To(Equal("/tmp"))
+
+ inspectDestination := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Destination}}"})
+ inspectDestination.WaitWithDefaultTimeout()
+ Expect(inspectDestination.ExitCode()).To(Equal(0))
+ Expect(inspectDestination.OutputToString()).To(Equal("/test1"))
+
+ inspectDst := podmanTest.Podman([]string{"inspect", "-l", "--format", "{{(index .Mounts 0).Dst}}"})
+ inspectDst.WaitWithDefaultTimeout()
+ Expect(inspectDst.ExitCode()).To(Equal(0))
+ Expect(inspectDst.OutputToString()).To(Equal("/test1"))
+ })
})