diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/images_test.go | 32 | ||||
-rw-r--r-- | test/e2e/play_kube_test.go | 74 | ||||
-rw-r--r-- | test/e2e/pod_create_test.go | 76 |
3 files changed, 178 insertions, 4 deletions
diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index a615a9f99..ddf2e20b8 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -241,6 +241,38 @@ WORKDIR /test Expect(result.OutputToStringArray()).Should(HaveLen(0), "dangling image output: %q", result.OutputToString()) }) + It("podman pull by digest and list --all", func() { + // Prevent regressing on issue #7651. + digestPullAndList := func(noneTag bool) { + session := podmanTest.Podman([]string{"pull", ALPINEAMD64DIGEST}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + + result := podmanTest.Podman([]string{"images", "--all", ALPINEAMD64DIGEST}) + result.WaitWithDefaultTimeout() + Expect(result).Should(Exit(0)) + + found, _ := result.GrepString("<none>") + if noneTag { + Expect(found).To(BeTrue()) + } else { + Expect(found).To(BeFalse()) + } + } + // No "<none>" tag as tagged alpine instances should be present. + session := podmanTest.Podman([]string{"pull", ALPINELISTTAG}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + digestPullAndList(false) + + // Now remove all images, re-pull by digest and check for the "<none>" tag. + session = podmanTest.Podman([]string{"rmi", "-af"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + + digestPullAndList(true) + }) + It("podman check for image with sha256: prefix", func() { session := podmanTest.Podman([]string{"inspect", "--format=json", ALPINE}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 5e01971cb..87de92357 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -30,9 +30,14 @@ apiVersion: v1 kind: Pod metadata: creationTimestamp: "2019-07-17T14:44:08Z" + name: {{ .Name }} labels: app: {{ .Name }} - name: {{ .Name }} +{{ with .Labels }} + {{ range $key, $value := . }} + {{ $key }}: {{ $value }} + {{ end }} +{{ end }} {{ with .Annotations }} annotations: {{ range $key, $value := . }} @@ -125,9 +130,14 @@ apiVersion: v1 kind: Deployment metadata: creationTimestamp: "2019-07-17T14:44:08Z" + name: {{ .Name }} labels: app: {{ .Name }} - name: {{ .Name }} +{{ with .Labels }} + {{ range $key, $value := . }} + {{ $key }}: {{ $value }} + {{ end }} +{{ end }} {{ with .Annotations }} annotations: {{ range $key, $value := . }} @@ -145,6 +155,9 @@ spec: metadata: labels: app: {{ .Name }} + {{- with .Labels }}{{ range $key, $value := . }} + {{ $key }}: {{ $value }} + {{- end }}{{ end }} {{ with .Annotations }} annotations: {{ range $key, $value := . }} @@ -266,6 +279,7 @@ type Pod struct { HostAliases []HostAlias Ctrs []*Ctr Volumes []*Volume + Labels map[string]string Annotations map[string]string } @@ -278,7 +292,15 @@ type HostAlias struct { // and the configured options // if no containers are added, it will add the default container func getPod(options ...podOption) *Pod { - p := Pod{defaultPodName, "", nil, make([]*Ctr, 0), make([]*Volume, 0), make(map[string]string)} + p := Pod{ + Name: defaultPodName, + Hostname: "", + HostAliases: nil, + Ctrs: make([]*Ctr, 0), + Volumes: make([]*Volume, 0), + Labels: make(map[string]string), + Annotations: make(map[string]string), + } for _, option := range options { option(&p) } @@ -311,6 +333,12 @@ func withCtr(c *Ctr) podOption { } } +func withLabel(k, v string) podOption { + return func(pod *Pod) { + pod.Labels[k] = v + } +} + func withAnnotation(k, v string) podOption { return func(pod *Pod) { pod.Annotations[k] = v @@ -327,12 +355,19 @@ func withVolume(v *Volume) podOption { type Deployment struct { Name string Replicas int32 + Labels map[string]string Annotations map[string]string PodTemplate *Pod } func getDeployment(options ...deploymentOption) *Deployment { - d := Deployment{defaultDeploymentName, 1, make(map[string]string), getPod()} + d := Deployment{ + Name: defaultDeploymentName, + Replicas: 1, + Labels: make(map[string]string), + Annotations: make(map[string]string), + PodTemplate: getPod(), + } for _, option := range options { option(&d) } @@ -342,6 +377,12 @@ func getDeployment(options ...deploymentOption) *Deployment { type deploymentOption func(*Deployment) +func withDeploymentLabel(k, v string) deploymentOption { + return func(deployment *Deployment) { + deployment.Labels[k] = v + } +} + func withDeploymentAnnotation(k, v string) deploymentOption { return func(deployment *Deployment) { deployment.Annotations[k] = v @@ -1077,4 +1118,29 @@ spec: correct := fmt.Sprintf("%s:%s:%s", hostPathLocation, hostPathLocation, "ro") Expect(inspect.OutputToString()).To(ContainSubstring(correct)) }) + + It("podman play kube applies labels to pods", func() { + SkipIfRemote() + var numReplicas int32 = 5 + expectedLabelKey := "key1" + expectedLabelValue := "value1" + deployment := getDeployment( + withReplicas(numReplicas), + withPod(getPod(withLabel(expectedLabelKey, expectedLabelValue))), + ) + err := generateDeploymentKubeYaml(deployment, kubeYaml) + Expect(err).To(BeNil()) + + kube := podmanTest.Podman([]string{"play", "kube", kubeYaml}) + kube.WaitWithDefaultTimeout() + Expect(kube.ExitCode()).To(Equal(0)) + + correctLabels := expectedLabelKey + ":" + expectedLabelValue + for _, pod := range getPodNamesInDeployment(deployment) { + inspect := podmanTest.Podman([]string{"pod", "inspect", pod.Name, "--format", "'{{ .Labels }}'"}) + inspect.WaitWithDefaultTimeout() + Expect(inspect.ExitCode()).To(Equal(0)) + Expect(inspect.OutputToString()).To(ContainSubstring(correctLabels)) + } + }) }) diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index f260a123a..ed62e8a4b 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -329,4 +329,80 @@ var _ = Describe("Podman pod create", func() { Expect(session.ExitCode()).To(Equal(0)) } }) + + It("podman create pod with defaults", func() { + name := "test" + session := podmanTest.Podman([]string{"pod", "create", "--name", name}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + check := podmanTest.Podman([]string{"pod", "inspect", name}) + check.WaitWithDefaultTimeout() + Expect(check.ExitCode()).To(Equal(0)) + data := check.InspectPodToJSON() + + check1 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Config.Entrypoint}}", data.Containers[0].ID}) + check1.WaitWithDefaultTimeout() + Expect(check1.ExitCode()).To(Equal(0)) + Expect(check1.OutputToString()).To(Equal("/pause")) + }) + + It("podman create pod with --infra-command", func() { + name := "test" + session := podmanTest.Podman([]string{"pod", "create", "--infra-command", "/pause1", "--name", name}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + check := podmanTest.Podman([]string{"pod", "inspect", name}) + check.WaitWithDefaultTimeout() + Expect(check.ExitCode()).To(Equal(0)) + data := check.InspectPodToJSON() + + check1 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Config.Entrypoint}}", data.Containers[0].ID}) + check1.WaitWithDefaultTimeout() + Expect(check1.ExitCode()).To(Equal(0)) + Expect(check1.OutputToString()).To(Equal("/pause1")) + }) + + It("podman create pod with --infra-image", func() { + dockerfile := `FROM docker.io/library/alpine:latest +entrypoint ["/fromimage"] +` + podmanTest.BuildImage(dockerfile, "localhost/infra", "false") + name := "test" + session := podmanTest.Podman([]string{"pod", "create", "--infra-image", "localhost/infra", "--name", name}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + check := podmanTest.Podman([]string{"pod", "inspect", name}) + check.WaitWithDefaultTimeout() + Expect(check.ExitCode()).To(Equal(0)) + data := check.InspectPodToJSON() + + check1 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Config.Entrypoint}}", data.Containers[0].ID}) + check1.WaitWithDefaultTimeout() + Expect(check1.ExitCode()).To(Equal(0)) + Expect(check1.OutputToString()).To(Equal("/fromimage")) + }) + + It("podman create pod with --infra-command --infra-image", func() { + dockerfile := `FROM docker.io/library/alpine:latest +entrypoint ["/fromimage"] +` + podmanTest.BuildImage(dockerfile, "localhost/infra", "false") + name := "test" + session := podmanTest.Podman([]string{"pod", "create", "--infra-image", "localhost/infra", "--infra-command", "/fromcommand", "--name", name}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + check := podmanTest.Podman([]string{"pod", "inspect", name}) + check.WaitWithDefaultTimeout() + Expect(check.ExitCode()).To(Equal(0)) + data := check.InspectPodToJSON() + + check1 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Config.Entrypoint}}", data.Containers[0].ID}) + check1.WaitWithDefaultTimeout() + Expect(check1.ExitCode()).To(Equal(0)) + Expect(check1.OutputToString()).To(Equal("/fromcommand")) + }) }) |