diff options
Diffstat (limited to 'test/e2e/play_kube_test.go')
-rw-r--r-- | test/e2e/play_kube_test.go | 79 |
1 files changed, 38 insertions, 41 deletions
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 97e97baa4..96ad2954c 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -319,16 +319,16 @@ spec: image: {{ .Image }} name: {{ .Name }} imagePullPolicy: {{ .PullPolicy }} - {{- if or .CpuRequest .CpuLimit .MemoryRequest .MemoryLimit }} + {{- if or .CPURequest .CPULimit .MemoryRequest .MemoryLimit }} resources: - {{- if or .CpuRequest .MemoryRequest }} + {{- if or .CPURequest .MemoryRequest }} requests: - {{if .CpuRequest }}cpu: {{ .CpuRequest }}{{ end }} + {{if .CPURequest }}cpu: {{ .CPURequest }}{{ end }} {{if .MemoryRequest }}memory: {{ .MemoryRequest }}{{ end }} {{- end }} - {{- if or .CpuLimit .MemoryLimit }} + {{- if or .CPULimit .MemoryLimit }} limits: - {{if .CpuLimit }}cpu: {{ .CpuLimit }}{{ end }} + {{if .CPULimit }}cpu: {{ .CPULimit }}{{ end }} {{if .MemoryLimit }}memory: {{ .MemoryLimit }}{{ end }} {{- end }} {{- end }} @@ -491,16 +491,16 @@ spec: image: {{ .Image }} name: {{ .Name }} imagePullPolicy: {{ .PullPolicy }} - {{- if or .CpuRequest .CpuLimit .MemoryRequest .MemoryLimit }} + {{- if or .CPURequest .CPULimit .MemoryRequest .MemoryLimit }} resources: - {{- if or .CpuRequest .MemoryRequest }} + {{- if or .CPURequest .MemoryRequest }} requests: - {{if .CpuRequest }}cpu: {{ .CpuRequest }}{{ end }} + {{if .CPURequest }}cpu: {{ .CPURequest }}{{ end }} {{if .MemoryRequest }}memory: {{ .MemoryRequest }}{{ end }} {{- end }} - {{- if or .CpuLimit .MemoryLimit }} + {{- if or .CPULimit .MemoryLimit }} limits: - {{if .CpuLimit }}cpu: {{ .CpuLimit }}{{ end }} + {{if .CPULimit }}cpu: {{ .CPULimit }}{{ end }} {{if .MemoryLimit }}memory: {{ .MemoryLimit }}{{ end }} {{- end }} {{- end }} @@ -832,12 +832,6 @@ 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 @@ -878,8 +872,8 @@ type Ctr struct { Image string Cmd []string Arg []string - CpuRequest string - CpuLimit string + CPURequest string + CPULimit string MemoryRequest string MemoryLimit string SecurityContext bool @@ -959,15 +953,15 @@ func withImage(img string) ctrOption { } } -func withCpuRequest(request string) ctrOption { +func withCPURequest(request string) ctrOption { return func(c *Ctr) { - c.CpuRequest = request + c.CPURequest = request } } -func withCpuLimit(limit string) ctrOption { +func withCPULimit(limit string) ctrOption { return func(c *Ctr) { - c.CpuLimit = limit + c.CPULimit = limit } } @@ -1881,7 +1875,7 @@ var _ = Describe("Podman play kube", func() { It("podman play kube seccomp container level", func() { SkipIfRemote("podman-remote does not support --seccomp-profile-root flag") // expect play kube is expected to set a seccomp label if it's applied as an annotation - jsonFile, err := podmanTest.CreateSeccompJson(seccompPwdEPERM) + jsonFile, err := podmanTest.CreateSeccompJSON(seccompPwdEPERM) if err != nil { fmt.Println(err) Skip("Failed to prepare seccomp.json for test.") @@ -1894,7 +1888,7 @@ var _ = Describe("Podman play kube", func() { err = generateKubeYaml("pod", pod, kubeYaml) Expect(err).To(BeNil()) - // CreateSeccompJson will put the profile into podmanTest.TempDir. Use --seccomp-profile-root to tell play kube where to look + // CreateSeccompJSON will put the profile into podmanTest.TempDir. Use --seccomp-profile-root to tell play kube where to look kube := podmanTest.Podman([]string{"play", "kube", "--seccomp-profile-root", podmanTest.TempDir, kubeYaml}) kube.WaitWithDefaultTimeout() Expect(kube).Should(Exit(0)) @@ -1908,7 +1902,7 @@ var _ = Describe("Podman play kube", func() { It("podman play kube seccomp pod level", func() { SkipIfRemote("podman-remote does not support --seccomp-profile-root flag") // expect play kube is expected to set a seccomp label if it's applied as an annotation - jsonFile, err := podmanTest.CreateSeccompJson(seccompPwdEPERM) + jsonFile, err := podmanTest.CreateSeccompJSON(seccompPwdEPERM) if err != nil { fmt.Println(err) Skip("Failed to prepare seccomp.json for test.") @@ -1921,7 +1915,7 @@ var _ = Describe("Podman play kube", func() { err = generateKubeYaml("pod", pod, kubeYaml) Expect(err).To(BeNil()) - // CreateSeccompJson will put the profile into podmanTest.TempDir. Use --seccomp-profile-root to tell play kube where to look + // CreateSeccompJSON will put the profile into podmanTest.TempDir. Use --seccomp-profile-root to tell play kube where to look kube := podmanTest.Podman([]string{"play", "kube", "--seccomp-profile-root", podmanTest.TempDir, kubeYaml}) kube.WaitWithDefaultTimeout() Expect(kube).Should(Exit(0)) @@ -2051,8 +2045,8 @@ spec: ctr := inspect.InspectContainerToJSON() Expect(ctr[0].Config.WorkingDir).To(ContainSubstring("/etc")) - Expect(ctr[0].Config.Labels["key1"]).To(ContainSubstring("value1")) - Expect(ctr[0].Config.Labels["key1"]).To(ContainSubstring("value1")) + Expect(ctr[0].Config.Labels).To(HaveKeyWithValue("key1", ContainSubstring("value1"))) + Expect(ctr[0].Config.Labels).To(HaveKeyWithValue("key1", ContainSubstring("value1"))) Expect(ctr[0].Config.StopSignal).To(Equal(uint(51))) }) @@ -2325,7 +2319,7 @@ VOLUME %s`, ALPINE, hostPathDir+"/") // If two volumes are specified and share the same destination, // only one will be mounted. Host path volumes take precedence. ctrJSON := inspect.InspectContainerToJSON() - Expect(len(ctrJSON[0].Mounts)).To(Equal(1)) + Expect(ctrJSON[0].Mounts).To(HaveLen(1)) Expect(ctrJSON[0].Mounts[0].Type).To(Equal("bind")) }) @@ -2450,19 +2444,19 @@ VOLUME %s`, ALPINE, hostPathDir+"/") var ( numReplicas int32 = 3 - expectedCpuRequest string = "100m" - expectedCpuLimit string = "200m" + expectedCPURequest string = "100m" + expectedCPULimit string = "200m" expectedMemoryRequest string = "10000000" expectedMemoryLimit string = "20000000" ) - expectedCpuQuota := milliCPUToQuota(expectedCpuLimit) + expectedCPUQuota := milliCPUToQuota(expectedCPULimit) deployment := getDeployment( withReplicas(numReplicas), withPod(getPod(withCtr(getCtr( - withCpuRequest(expectedCpuRequest), - withCpuLimit(expectedCpuLimit), + withCPURequest(expectedCPURequest), + withCPULimit(expectedCPULimit), withMemoryRequest(expectedMemoryRequest), withMemoryLimit(expectedMemoryLimit), ))))) @@ -2474,6 +2468,7 @@ VOLUME %s`, ALPINE, hostPathDir+"/") Expect(kube).Should(Exit(0)) for _, pod := range getPodNamesInDeployment(deployment) { + pod := pod // copy into local scope inspect := podmanTest.Podman([]string{"inspect", getCtrNameInPod(&pod), "--format", ` CpuPeriod: {{ .HostConfig.CpuPeriod }} CpuQuota: {{ .HostConfig.CpuQuota }} @@ -2481,7 +2476,7 @@ Memory: {{ .HostConfig.Memory }} MemoryReservation: {{ .HostConfig.MemoryReservation }}`}) inspect.WaitWithDefaultTimeout() Expect(inspect).Should(Exit(0)) - Expect(inspect.OutputToString()).To(ContainSubstring(fmt.Sprintf("%s: %d", "CpuQuota", expectedCpuQuota))) + Expect(inspect.OutputToString()).To(ContainSubstring(fmt.Sprintf("%s: %d", "CpuQuota", expectedCPUQuota))) Expect(inspect.OutputToString()).To(ContainSubstring("MemoryReservation: " + expectedMemoryRequest)) Expect(inspect.OutputToString()).To(ContainSubstring("Memory: " + expectedMemoryLimit)) } @@ -2493,12 +2488,12 @@ MemoryReservation: {{ .HostConfig.MemoryReservation }}`}) podmanTest.CgroupManager = "systemd" var ( - expectedCpuLimit string = "1" + expectedCPULimit string = "1" ) deployment := getDeployment( withPod(getPod(withCtr(getCtr( - withCpuLimit(expectedCpuLimit), + withCPULimit(expectedCPULimit), ))))) err := generateKubeYaml("deployment", deployment, kubeYaml) Expect(err).To(BeNil()) @@ -2508,6 +2503,7 @@ MemoryReservation: {{ .HostConfig.MemoryReservation }}`}) Expect(kube).Should(Exit(0)) for _, pod := range getPodNamesInDeployment(deployment) { + pod := pod // copy into local scope inspect := podmanTest.Podman([]string{"inspect", getCtrNameInPod(&pod), "--format", `{{ .HostConfig.CpuPeriod }}:{{ .HostConfig.CpuQuota }}`}) inspect.WaitWithDefaultTimeout() @@ -2876,7 +2872,7 @@ invalid kube kind ls := podmanTest.Podman([]string{"pod", "ps", "--format", "'{{.ID}}'"}) ls.WaitWithDefaultTimeout() Expect(ls).Should(Exit(0)) - Expect(len(ls.OutputToStringArray())).To(Equal(1)) + Expect(ls.OutputToStringArray()).To(HaveLen(1)) // teardown teardown := podmanTest.Podman([]string{"play", "kube", "--down", kubeYaml}) @@ -2886,7 +2882,7 @@ invalid kube kind checkls := podmanTest.Podman([]string{"pod", "ps", "--format", "'{{.ID}}'"}) checkls.WaitWithDefaultTimeout() Expect(checkls).Should(Exit(0)) - Expect(len(checkls.OutputToStringArray())).To(Equal(0)) + Expect(checkls.OutputToStringArray()).To(BeEmpty()) }) It("podman play kube teardown pod does not exist", func() { @@ -2968,7 +2964,7 @@ invalid kube kind ls := podmanTest.Podman([]string{"pod", "ps", "--format", "'{{.ID}}'"}) ls.WaitWithDefaultTimeout() Expect(ls).Should(Exit(0)) - Expect(len(ls.OutputToStringArray())).To(Equal(1)) + Expect(ls.OutputToStringArray()).To(HaveLen(1)) containerLen := podmanTest.Podman([]string{"pod", "inspect", pod.Name, "--format", "'{{len .Containers}}'"}) @@ -3007,7 +3003,7 @@ invalid kube kind ls := podmanTest.Podman([]string{"pod", "ps", "--format", "'{{.ID}}'"}) ls.WaitWithDefaultTimeout() Expect(ls).Should(Exit(0)) - Expect(len(ls.OutputToStringArray())).To(Equal(1)) + Expect(ls.OutputToStringArray()).To(HaveLen(1)) }) Describe("verify environment variables", func() { @@ -3156,6 +3152,7 @@ ENV OPENJ9_JAVA_OPTIONS=%q deployment := getDeployment(withPod(pod)) deploymentYaml, err := getKubeYaml("deployment", deployment) + Expect(err).To(BeNil(), "getKubeYaml(deployment)") yamls := []string{cmYaml, deploymentYaml} err = generateMultiDocKubeYaml(yamls, kubeYaml) Expect(err).To(BeNil()) |