summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorEd Santiago <santiago@redhat.com>2021-11-23 11:12:34 -0700
committerEd Santiago <santiago@redhat.com>2021-11-29 08:30:00 -0700
commitb63d696405593d056cce850e1503a6bef17c2cf8 (patch)
tree77aa079636ea326eec76520734e0ae9e815ca6c2 /test/e2e
parent3d19f1a7fac5705518693cad3f2c7f94dcc2f1d4 (diff)
downloadpodman-b63d696405593d056cce850e1503a6bef17c2cf8.tar.gz
podman-b63d696405593d056cce850e1503a6bef17c2cf8.tar.bz2
podman-b63d696405593d056cce850e1503a6bef17c2cf8.zip
e2e tests: enable golint
...and fix problems found therewith. Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/checkpoint_test.go3
-rw-r--r--test/e2e/common_test.go46
-rw-r--r--test/e2e/config_amd64.go16
-rw-r--r--test/e2e/container_create_volume_test.go2
-rw-r--r--test/e2e/containers_conf_test.go6
-rw-r--r--test/e2e/image_scp_test.go2
-rw-r--r--test/e2e/libpod_suite_remote_test.go1
-rw-r--r--test/e2e/logs_test.go5
-rw-r--r--test/e2e/network_test.go6
-rw-r--r--test/e2e/play_build_test.go4
-rw-r--r--test/e2e/play_kube_test.go69
-rw-r--r--test/e2e/pod_rm_test.go12
-rw-r--r--test/e2e/ps_test.go7
-rw-r--r--test/e2e/pull_test.go18
-rw-r--r--test/e2e/rmi_test.go6
-rw-r--r--test/e2e/run_networking_test.go6
-rw-r--r--test/e2e/run_privileged_test.go12
-rw-r--r--test/e2e/run_selinux_test.go2
-rw-r--r--test/e2e/run_test.go2
-rw-r--r--test/e2e/run_volume_test.go2
-rw-r--r--test/e2e/runlabel_test.go3
-rw-r--r--test/e2e/secret_test.go3
-rw-r--r--test/e2e/systemd_test.go8
-rw-r--r--test/e2e/toolbox_test.go12
-rw-r--r--test/e2e/volume_create_test.go3
25 files changed, 121 insertions, 135 deletions
diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go
index cc827a453..318e3617e 100644
--- a/test/e2e/checkpoint_test.go
+++ b/test/e2e/checkpoint_test.go
@@ -1019,6 +1019,9 @@ var _ = Describe("Podman checkpoint", func() {
"podman checkpoint and restore container out of and into pod (%s)",
share,
)
+
+ share := share // copy into local scope, for use inside function
+
It(testName, func() {
if !criu.CheckForCriu(criu.PodCriuVersion) {
Skip("CRIU is missing or too old.")
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go
index 6180343a7..63cb4f091 100644
--- a/test/e2e/common_test.go
+++ b/test/e2e/common_test.go
@@ -24,7 +24,6 @@ import (
"github.com/containers/storage/pkg/reexec"
"github.com/containers/storage/pkg/stringid"
jsoniter "github.com/json-iterator/go"
- "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
@@ -33,16 +32,14 @@ import (
)
var (
- PODMAN_BINARY string
- CONMON_BINARY string
- CNI_CONFIG_DIR string
- RUNC_BINARY string
- INTEGRATION_ROOT string
- CGROUP_MANAGER = "systemd"
- ARTIFACT_DIR = "/tmp/.artifacts"
- RESTORE_IMAGES = []string{ALPINE, BB, nginx}
+ //lint:ignore ST1003
+ PODMAN_BINARY string //nolint:golint,stylecheck
+ INTEGRATION_ROOT string //nolint:golint,stylecheck
+ CGROUP_MANAGER = "systemd" //nolint:golint,stylecheck
+ ARTIFACT_DIR = "/tmp/.artifacts" //nolint:golint,stylecheck
+ RESTORE_IMAGES = []string{ALPINE, BB, nginx} //nolint:golint,stylecheck
defaultWaitTimeout = 90
- CGROUPSV2, _ = cgroups.IsCgroup2UnifiedMode()
+ CGROUPSV2, _ = cgroups.IsCgroup2UnifiedMode() //nolint:golint,stylecheck
)
// PodmanTestIntegration struct for command line options
@@ -74,8 +71,6 @@ type testResult struct {
length float64
}
-var noCache = "Cannot run nocache with remote"
-
type testResultsSorted []testResult
func (a testResultsSorted) Len() int { return len(a) }
@@ -475,7 +470,7 @@ func (p *PodmanTestIntegration) PodmanPID(args []string) (*PodmanSessionIntegrat
if err != nil {
Fail(fmt.Sprintf("unable to run podman command: %s", strings.Join(podmanOptions, " ")))
}
- podmanSession := &PodmanSession{session}
+ podmanSession := &PodmanSession{Session: session}
return &PodmanSessionIntegration{podmanSession}, command.Process.Pid
}
@@ -597,9 +592,9 @@ func (p *PodmanTestIntegration) RunHealthCheck(cid string) error {
return errors.Errorf("unable to detect %s as running", cid)
}
-func (p *PodmanTestIntegration) CreateSeccompJson(in []byte) (string, error) {
+func (p *PodmanTestIntegration) CreateSeccompJSON(in []byte) (string, error) {
jsonFile := filepath.Join(p.TempDir, "seccomp.json")
- err := WriteJsonFile(in, jsonFile)
+ err := WriteJSONFile(in, jsonFile)
if err != nil {
return "", err
}
@@ -622,14 +617,14 @@ func SkipIfRootlessCgroupsV1(reason string) {
func SkipIfRootless(reason string) {
checkReason(reason)
if os.Geteuid() != 0 {
- ginkgo.Skip("[rootless]: " + reason)
+ Skip("[rootless]: " + reason)
}
}
func SkipIfNotRootless(reason string) {
checkReason(reason)
if os.Geteuid() == 0 {
- ginkgo.Skip("[notRootless]: " + reason)
+ Skip("[notRootless]: " + reason)
}
}
@@ -640,7 +635,7 @@ func SkipIfSystemdNotRunning(reason string) {
err := cmd.Run()
if err != nil {
if _, ok := err.(*exec.Error); ok {
- ginkgo.Skip("[notSystemd]: not running " + reason)
+ Skip("[notSystemd]: not running " + reason)
}
Expect(err).ToNot(HaveOccurred())
}
@@ -649,14 +644,14 @@ func SkipIfSystemdNotRunning(reason string) {
func SkipIfNotSystemd(manager, reason string) {
checkReason(reason)
if manager != "systemd" {
- ginkgo.Skip("[notSystemd]: " + reason)
+ Skip("[notSystemd]: " + reason)
}
}
func SkipIfNotFedora() {
info := GetHostDistributionInfo()
if info.Distribution != "fedora" {
- ginkgo.Skip("Test can only run on Fedora")
+ Skip("Test can only run on Fedora")
}
}
@@ -684,10 +679,7 @@ func SkipIfCgroupV2(reason string) {
func isContainerized() bool {
// This is set to "podman" by podman automatically
- if os.Getenv("container") != "" {
- return true
- }
- return false
+ return os.Getenv("container") != ""
}
func SkipIfContainerized(reason string) {
@@ -702,7 +694,7 @@ func SkipIfRemote(reason string) {
if !IsRemote() {
return
}
- ginkgo.Skip("[remote]: " + reason)
+ Skip("[remote]: " + reason)
}
// SkipIfInContainer skips a test if the test is run inside a container
@@ -872,10 +864,10 @@ func (p *PodmanTestIntegration) removeCNINetwork(name string) {
Expect(session.ExitCode()).To(BeNumerically("<=", 1), "Exit code must be 0 or 1")
}
-func (p *PodmanSessionIntegration) jq(jqCommand string) (string, error) {
+func (s *PodmanSessionIntegration) jq(jqCommand string) (string, error) {
var out bytes.Buffer
cmd := exec.Command("jq", jqCommand)
- cmd.Stdin = strings.NewReader(p.OutputToString())
+ cmd.Stdin = strings.NewReader(s.OutputToString())
cmd.Stdout = &out
err := cmd.Run()
return strings.TrimRight(out.String(), "\n"), err
diff --git a/test/e2e/config_amd64.go b/test/e2e/config_amd64.go
index 3607bdc30..9293fdd44 100644
--- a/test/e2e/config_amd64.go
+++ b/test/e2e/config_amd64.go
@@ -1,16 +1,16 @@
package integration
var (
- STORAGE_FS = "vfs"
- STORAGE_OPTIONS = "--storage-driver vfs"
- ROOTLESS_STORAGE_FS = "vfs"
- ROOTLESS_STORAGE_OPTIONS = "--storage-driver vfs"
- CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, nginx, redis, registry, infra, labels, healthcheck, ubi_init, ubi_minimal, fedoraToolbox}
+ STORAGE_FS = "vfs" //nolint:golint,stylecheck
+ STORAGE_OPTIONS = "--storage-driver vfs" //nolint:golint,stylecheck
+ ROOTLESS_STORAGE_FS = "vfs" //nolint:golint,stylecheck
+ ROOTLESS_STORAGE_OPTIONS = "--storage-driver vfs" //nolint:golint,stylecheck
+ CACHE_IMAGES = []string{ALPINE, BB, fedoraMinimal, nginx, redis, registry, infra, labels, healthcheck, UBI_INIT, UBI_MINIMAL, fedoraToolbox} //nolint:golint,stylecheck
nginx = "quay.io/libpod/alpine_nginx:latest"
- BB_GLIBC = "docker.io/library/busybox:glibc"
+ BB_GLIBC = "docker.io/library/busybox:glibc" //nolint:golint,stylecheck
registry = "quay.io/libpod/registry:2.6"
labels = "quay.io/libpod/alpine_labels:latest"
- ubi_minimal = "registry.access.redhat.com/ubi8-minimal"
- ubi_init = "registry.access.redhat.com/ubi8-init"
+ UBI_MINIMAL = "registry.access.redhat.com/ubi8-minimal" //nolint:golint,stylecheck
+ UBI_INIT = "registry.access.redhat.com/ubi8-init" //nolint:golint,stylecheck
cirros = "quay.io/libpod/cirros:latest"
)
diff --git a/test/e2e/container_create_volume_test.go b/test/e2e/container_create_volume_test.go
index 001698239..0dac96a5e 100644
--- a/test/e2e/container_create_volume_test.go
+++ b/test/e2e/container_create_volume_test.go
@@ -28,7 +28,7 @@ VOLUME %s/`, data, dest, dest)
func createContainersConfFile(pTest *PodmanTestIntegration) {
configPath := filepath.Join(pTest.TempDir, "containers.conf")
- containersConf := []byte(fmt.Sprintf("[containers]\nprepare_volume_on_create = true\n"))
+ containersConf := []byte("[containers]\nprepare_volume_on_create = true\n")
err := ioutil.WriteFile(configPath, containersConf, os.ModePerm)
Expect(err).To(BeNil())
diff --git a/test/e2e/containers_conf_test.go b/test/e2e/containers_conf_test.go
index 6a760da17..6bc230aae 100644
--- a/test/e2e/containers_conf_test.go
+++ b/test/e2e/containers_conf_test.go
@@ -407,7 +407,7 @@ var _ = Describe("Podman run", func() {
configPath := filepath.Join(podmanTest.TempDir, "containers.conf")
os.Setenv("CONTAINERS_CONF", configPath)
- containersConf := []byte(fmt.Sprintf("[engine]\nimage_copy_tmp_dir=\"/foobar\""))
+ containersConf := []byte("[engine]\nimage_copy_tmp_dir=\"/foobar\"")
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
Expect(err).To(BeNil())
@@ -420,7 +420,7 @@ var _ = Describe("Podman run", func() {
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(Equal("/foobar"))
- containersConf = []byte(fmt.Sprintf("[engine]\nimage_copy_tmp_dir=\"storage\""))
+ containersConf = []byte("[engine]\nimage_copy_tmp_dir=\"storage\"")
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
Expect(err).To(BeNil())
if IsRemote() {
@@ -432,7 +432,7 @@ var _ = Describe("Podman run", func() {
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(ContainSubstring("containers/storage/tmp"))
- containersConf = []byte(fmt.Sprintf("[engine]\nimage_copy_tmp_dir=\"storage1\""))
+ containersConf = []byte("[engine]\nimage_copy_tmp_dir=\"storage1\"")
err = ioutil.WriteFile(configPath, containersConf, os.ModePerm)
Expect(err).To(BeNil())
if IsRemote() {
diff --git a/test/e2e/image_scp_test.go b/test/e2e/image_scp_test.go
index 63276e57f..6c6c85bc3 100644
--- a/test/e2e/image_scp_test.go
+++ b/test/e2e/image_scp_test.go
@@ -62,7 +62,7 @@ var _ = Describe("podman image scp", func() {
})
It("podman image scp root to rootless transfer", func() {
- SkipIfNotRootless("this is a rootless only test, transfering from root to rootless using PodmanAsUser")
+ SkipIfNotRootless("this is a rootless only test, transferring from root to rootless using PodmanAsUser")
if IsRemote() {
Skip("this test is only for non-remote")
}
diff --git a/test/e2e/libpod_suite_remote_test.go b/test/e2e/libpod_suite_remote_test.go
index 1fa29daa1..2ecbd0eab 100644
--- a/test/e2e/libpod_suite_remote_test.go
+++ b/test/e2e/libpod_suite_remote_test.go
@@ -111,7 +111,6 @@ func (p *PodmanTestIntegration) StopRemoteService() {
if _, err := remoteSession.Wait(); err != nil {
fmt.Fprintf(os.Stderr, "error on remote stop-wait %q", err)
}
-
} else {
parentPid := fmt.Sprintf("%d", p.RemoteSession.Pid)
pgrep := exec.Command("pgrep", "-P", parentPid)
diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go
index d901dde5c..2558af0eb 100644
--- a/test/e2e/logs_test.go
+++ b/test/e2e/logs_test.go
@@ -20,10 +20,7 @@ func isEventBackendJournald(podmanTest *PodmanTestIntegration) bool {
}
info := podmanTest.Podman([]string{"info", "--format", "{{.Host.EventLogger}}"})
info.WaitWithDefaultTimeout()
- if info.OutputToString() == "journald" {
- return true
- }
- return false
+ return info.OutputToString() == "journald"
}
var _ = Describe("Podman logs", func() {
diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go
index 953380335..734a45bca 100644
--- a/test/e2e/network_test.go
+++ b/test/e2e/network_test.go
@@ -185,7 +185,7 @@ var _ = Describe("Podman network", func() {
Expect(session).Should(Exit(0))
})
- rm_func := func(rm string) {
+ rmFunc := func(rm string) {
It(fmt.Sprintf("podman network %s no args", rm), func() {
session := podmanTest.Podman([]string{"network", rm})
session.WaitWithDefaultTimeout()
@@ -213,8 +213,8 @@ var _ = Describe("Podman network", func() {
})
}
- rm_func("rm")
- rm_func("remove")
+ rmFunc("rm")
+ rmFunc("remove")
It("podman network inspect no args", func() {
session := podmanTest.Podman([]string{"network", "inspect"})
diff --git a/test/e2e/play_build_test.go b/test/e2e/play_build_test.go
index 564735e07..9bdf9d06b 100644
--- a/test/e2e/play_build_test.go
+++ b/test/e2e/play_build_test.go
@@ -95,6 +95,7 @@ LABEL marge=mom
// Setup
yamlDir := filepath.Join(tempdir, RandomString(12))
err := os.Mkdir(yamlDir, 0755)
+ Expect(err).To(BeNil(), "mkdir "+yamlDir)
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
Expect(err).To(BeNil())
app1Dir := filepath.Join(yamlDir, "foobar")
@@ -131,6 +132,7 @@ LABEL marge=mom
// Setup
yamlDir := filepath.Join(tempdir, RandomString(12))
err := os.Mkdir(yamlDir, 0755)
+ Expect(err).To(BeNil(), "mkdir "+yamlDir)
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
Expect(err).To(BeNil())
app1Dir := filepath.Join(yamlDir, "foobar")
@@ -167,6 +169,7 @@ LABEL marge=mom
// Setup
yamlDir := filepath.Join(tempdir, RandomString(12))
err := os.Mkdir(yamlDir, 0755)
+ Expect(err).To(BeNil(), "mkdir "+yamlDir)
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
Expect(err).To(BeNil())
@@ -213,6 +216,7 @@ LABEL marge=mom
// Setup
yamlDir := filepath.Join(tempdir, RandomString(12))
err := os.Mkdir(yamlDir, 0755)
+ Expect(err).To(BeNil(), "os.Mkdir "+yamlDir)
err = writeYaml(testYAML, filepath.Join(yamlDir, "top.yaml"))
Expect(err).To(BeNil())
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go
index 1a3b5f8df..fc939711f 100644
--- a/test/e2e/play_kube_test.go
+++ b/test/e2e/play_kube_test.go
@@ -4,8 +4,6 @@ import (
"bytes"
"context"
"fmt"
- "github.com/containers/podman/v3/pkg/bindings"
- "github.com/containers/podman/v3/pkg/bindings/play"
"io/ioutil"
"net"
"net/url"
@@ -17,6 +15,8 @@ import (
"time"
"github.com/containers/podman/v3/libpod/define"
+ "github.com/containers/podman/v3/pkg/bindings"
+ "github.com/containers/podman/v3/pkg/bindings/play"
"github.com/containers/podman/v3/pkg/util"
. "github.com/containers/podman/v3/test/utils"
"github.com/containers/storage/pkg/stringid"
@@ -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 }}
@@ -479,16 +479,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 }}
@@ -820,12 +820,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
@@ -866,8 +860,8 @@ type Ctr struct {
Image string
Cmd []string
Arg []string
- CpuRequest string
- CpuLimit string
+ CPURequest string
+ CPULimit string
MemoryRequest string
MemoryLimit string
SecurityContext bool
@@ -947,15 +941,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
}
}
@@ -1848,7 +1842,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.")
@@ -1861,7 +1855,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))
@@ -1875,7 +1869,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.")
@@ -1888,7 +1882,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))
@@ -2348,19 +2342,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),
)))))
@@ -2372,6 +2366,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 }}
@@ -2379,7 +2374,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))
}
@@ -2391,12 +2386,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())
@@ -2406,6 +2401,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()
@@ -3054,6 +3050,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())
diff --git a/test/e2e/pod_rm_test.go b/test/e2e/pod_rm_test.go
index 7dc3dfa7f..d9b0761fa 100644
--- a/test/e2e/pod_rm_test.go
+++ b/test/e2e/pod_rm_test.go
@@ -132,11 +132,11 @@ var _ = Describe("Podman pod rm", func() {
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
fmt.Printf("Started container running in one pod")
- num_pods := podmanTest.NumberOfPods()
- Expect(num_pods).To(Equal(2))
+ numPods := podmanTest.NumberOfPods()
+ Expect(numPods).To(Equal(2))
ps := podmanTest.Podman([]string{"pod", "ps"})
ps.WaitWithDefaultTimeout()
- fmt.Printf("Current %d pod(s):\n%s\n", num_pods, ps.OutputToString())
+ fmt.Printf("Current %d pod(s):\n%s\n", numPods, ps.OutputToString())
fmt.Printf("Removing all empty pods\n")
result := podmanTest.Podman([]string{"pod", "rm", "-a"})
@@ -145,11 +145,11 @@ var _ = Describe("Podman pod rm", func() {
foundExpectedError, _ := result.ErrorGrepString("cannot be removed")
Expect(foundExpectedError).To(Equal(true))
- num_pods = podmanTest.NumberOfPods()
+ numPods = podmanTest.NumberOfPods()
ps = podmanTest.Podman([]string{"pod", "ps"})
ps.WaitWithDefaultTimeout()
- fmt.Printf("Final %d pod(s):\n%s\n", num_pods, ps.OutputToString())
- Expect(num_pods).To(Equal(1))
+ fmt.Printf("Final %d pod(s):\n%s\n", numPods, ps.OutputToString())
+ Expect(numPods).To(Equal(1))
// Confirm top container still running inside remaining pod
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
})
diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go
index 666b70b09..c0b0e0aa6 100644
--- a/test/e2e/ps_test.go
+++ b/test/e2e/ps_test.go
@@ -443,11 +443,10 @@ var _ = Describe("Podman ps", func() {
// sanity check in case an oddly formatted size appears
if len(matches1) < 2 || len(matches2) < 2 {
return sortedArr[i] < sortedArr[j]
- } else {
- size1, _ := units.FromHumanSize(matches1[1])
- size2, _ := units.FromHumanSize(matches2[1])
- return size1 < size2
}
+ size1, _ := units.FromHumanSize(matches1[1])
+ size2, _ := units.FromHumanSize(matches2[1])
+ return size1 < size2
})).To(BeTrue())
})
diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go
index fdb1b0c57..b2474b223 100644
--- a/test/e2e/pull_test.go
+++ b/test/e2e/pull_test.go
@@ -279,7 +279,7 @@ var _ = Describe("Podman pull", func() {
// Pulling a multi-image archive without further specifying
// which image _must_ error out. Pulling is restricted to one
// image.
- session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/docker-two-images.tar.xz")})
+ session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(125))
expectedError := "Unexpected tar manifest.json: expected 1 item, got 2"
@@ -288,31 +288,31 @@ var _ = Describe("Podman pull", func() {
// Now pull _one_ image from a multi-image archive via the name
// and index syntax.
- session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/docker-two-images.tar.xz:@0")})
+ session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz:@0"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/docker-two-images.tar.xz:example.com/empty:latest")})
+ session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz:example.com/empty:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/docker-two-images.tar.xz:@1")})
+ session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz:@1"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/docker-two-images.tar.xz:example.com/empty/but:different")})
+ session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz:example.com/empty/but:different"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
// Now check for some errors.
- session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/docker-two-images.tar.xz:foo.com/does/not/exist:latest")})
+ session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz:foo.com/does/not/exist:latest"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(125))
expectedError = "Tag \"foo.com/does/not/exist:latest\" not found"
found, _ = session.ErrorGrepString(expectedError)
Expect(found).To(Equal(true))
- session = podmanTest.Podman([]string{"pull", fmt.Sprintf("docker-archive:./testdata/docker-two-images.tar.xz:@2")})
+ session = podmanTest.Podman([]string{"pull", "docker-archive:./testdata/docker-two-images.tar.xz:@2"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(125))
expectedError = "Invalid source index @2, only 2 manifest items available"
@@ -391,7 +391,7 @@ var _ = Describe("Podman pull", func() {
setup := podmanTest.Podman([]string{"images", ALPINE, "-q", "--no-trunc"})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
- shortImageId := strings.Split(setup.OutputToString(), ":")[1]
+ shortImageID := strings.Split(setup.OutputToString(), ":")[1]
rmi := podmanTest.Podman([]string{"rmi", ALPINE})
rmi.WaitWithDefaultTimeout()
@@ -401,7 +401,7 @@ var _ = Describe("Podman pull", func() {
pull.WaitWithDefaultTimeout()
Expect(pull).Should(Exit(0))
- Expect(pull.OutputToString()).To(ContainSubstring(shortImageId))
+ Expect(pull.OutputToString()).To(ContainSubstring(shortImageID))
})
It("podman pull check all tags", func() {
diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go
index 196d8879d..4f6d974fd 100644
--- a/test/e2e/rmi_test.go
+++ b/test/e2e/rmi_test.go
@@ -97,19 +97,19 @@ var _ = Describe("Podman rmi", func() {
setup := podmanTest.Podman([]string{"images", "-q", cirros})
setup.WaitWithDefaultTimeout()
Expect(setup).Should(Exit(0))
- cirrosId := setup.OutputToString()
+ cirrosID := setup.OutputToString()
session := podmanTest.Podman([]string{"tag", "cirros", "foo:bar", "foo"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
// Trying without --force should fail
- result := podmanTest.Podman([]string{"rmi", cirrosId})
+ result := podmanTest.Podman([]string{"rmi", cirrosID})
result.WaitWithDefaultTimeout()
Expect(result).To(ExitWithError())
// With --force it should work
- resultForce := podmanTest.Podman([]string{"rmi", "-f", cirrosId})
+ resultForce := podmanTest.Podman([]string{"rmi", "-f", cirrosID})
resultForce.WaitWithDefaultTimeout()
Expect(resultForce).Should(Exit(0))
})
diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go
index e2004c8e0..5898cc38d 100644
--- a/test/e2e/run_networking_test.go
+++ b/test/e2e/run_networking_test.go
@@ -789,7 +789,7 @@ EXPOSE 2004-2005/tcp`, ALPINE)
Expect(run.OutputToString()).ToNot(ContainSubstring("127.0.0.1 %s", hostname))
})
- ping_test := func(netns string) {
+ pingTest := func(netns string) {
hostname := "testctr"
run := podmanTest.Podman([]string{"run", netns, "--hostname", hostname, ALPINE, "ping", "-c", "1", hostname})
run.WaitWithDefaultTimeout()
@@ -801,11 +801,11 @@ EXPOSE 2004-2005/tcp`, ALPINE)
}
It("podman attempt to ping container name and hostname --net=none", func() {
- ping_test("--net=none")
+ pingTest("--net=none")
})
It("podman attempt to ping container name and hostname --net=private", func() {
- ping_test("--net=private")
+ pingTest("--net=private")
})
It("podman run check dnsname plugin", func() {
diff --git a/test/e2e/run_privileged_test.go b/test/e2e/run_privileged_test.go
index d793a01f8..321bf27ac 100644
--- a/test/e2e/run_privileged_test.go
+++ b/test/e2e/run_privileged_test.go
@@ -21,18 +21,18 @@ func containerCapMatchesHost(ctrCap string, hostCap string) {
if isRootless() {
return
}
- ctrCap_n, err := strconv.ParseUint(ctrCap, 16, 64)
+ ctrCapN, err := strconv.ParseUint(ctrCap, 16, 64)
Expect(err).NotTo(HaveOccurred(), "Error parsing %q as hex", ctrCap)
- hostCap_n, err := strconv.ParseUint(hostCap, 16, 64)
+ hostCapN, err := strconv.ParseUint(hostCap, 16, 64)
Expect(err).NotTo(HaveOccurred(), "Error parsing %q as hex", hostCap)
// host caps can never be zero (except rootless).
// and host caps must always be a superset (inclusive) of container
- Expect(hostCap_n).To(BeNumerically(">", 0), "host cap %q should be nonzero", hostCap)
- Expect(hostCap_n).To(BeNumerically(">=", ctrCap_n), "host cap %q should never be less than container cap %q", hostCap, ctrCap)
- hostCap_masked := hostCap_n & (1<<len(capability.List()) - 1)
- Expect(ctrCap_n).To(Equal(hostCap_masked), "container cap %q is not a subset of host cap %q", ctrCap, hostCap)
+ Expect(hostCapN).To(BeNumerically(">", 0), "host cap %q should be nonzero", hostCap)
+ Expect(hostCapN).To(BeNumerically(">=", ctrCapN), "host cap %q should never be less than container cap %q", hostCap, ctrCap)
+ hostCapMasked := hostCapN & (1<<len(capability.List()) - 1)
+ Expect(ctrCapN).To(Equal(hostCapMasked), "container cap %q is not a subset of host cap %q", ctrCap, hostCap)
}
var _ = Describe("Podman privileged container tests", func() {
diff --git a/test/e2e/run_selinux_test.go b/test/e2e/run_selinux_test.go
index cf63760cc..a6672d45e 100644
--- a/test/e2e/run_selinux_test.go
+++ b/test/e2e/run_selinux_test.go
@@ -320,7 +320,7 @@ var _ = Describe("Podman run", func() {
})
It("podman test init labels", func() {
- session := podmanTest.Podman([]string{"create", ubi_init, "/sbin/init"})
+ session := podmanTest.Podman([]string{"create", UBI_INIT, "/sbin/init"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
cid := session.OutputToString()
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go
index aa9037e56..7b08c48c3 100644
--- a/test/e2e/run_test.go
+++ b/test/e2e/run_test.go
@@ -318,7 +318,7 @@ var _ = Describe("Podman run", func() {
forbidGetCWDSeccompProfile := func() string {
in := []byte(`{"defaultAction":"SCMP_ACT_ALLOW","syscalls":[{"name":"getcwd","action":"SCMP_ACT_ERRNO"}]}`)
- jsonFile, err := podmanTest.CreateSeccompJson(in)
+ jsonFile, err := podmanTest.CreateSeccompJSON(in)
if err != nil {
fmt.Println(err)
Skip("Failed to prepare seccomp.json for test.")
diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go
index 967cf4a7c..196c5778a 100644
--- a/test/e2e/run_volume_test.go
+++ b/test/e2e/run_volume_test.go
@@ -151,6 +151,7 @@ var _ = Describe("Podman run with volumes", func() {
Expect(err).To(BeNil())
testFile := filepath.Join(mountPath, "test1")
f, err := os.Create(testFile)
+ Expect(err).To(BeNil(), "os.Create(testfile)")
f.Close()
Expect(err).To(BeNil())
session := podmanTest.Podman([]string{"run", "-v", fmt.Sprintf("%s:/data", mountPath), redis, "ls", "/data/test1"})
@@ -550,6 +551,7 @@ VOLUME /test/`, ALPINE)
os.Mkdir(mountPath, 0755)
testFile := filepath.Join(mountPath, "test1")
f, err := os.Create(testFile)
+ Expect(err).To(BeNil(), "os.Create "+testFile)
f.Close()
// Make sure host directory gets mounted in to container as overlay
diff --git a/test/e2e/runlabel_test.go b/test/e2e/runlabel_test.go
index 656eaaceb..e473119b2 100644
--- a/test/e2e/runlabel_test.go
+++ b/test/e2e/runlabel_test.go
@@ -105,7 +105,8 @@ var _ = Describe("podman container runlabel", func() {
})
It("podman container runlabel global options", func() {
- Skip("Test nonfunctional for podman-in-podman testing")
+ fmt.Printf("FIXME: for lint. Remove when you fix this test: %s", GlobalDockerfile)
+ Skip("FIXME: $GLOBAL_OPTS does not work at all, #12436")
image := "podman-global-test:ls"
podmanTest.BuildImage(GlobalDockerfile, image, "false")
result := podmanTest.Podman([]string{"--syslog", "--log-level", "debug", "container", "runlabel", "RUN", image})
diff --git a/test/e2e/secret_test.go b/test/e2e/secret_test.go
index 8bbc889d7..df0cd24d0 100644
--- a/test/e2e/secret_test.go
+++ b/test/e2e/secret_test.go
@@ -208,7 +208,6 @@ var _ = Describe("Podman secret", func() {
// no env variable set, should fail
session := podmanTest.Podman([]string{"secret", "create", "--env", "a", "MYENVVAR"})
session.WaitWithDefaultTimeout()
- secrID := session.OutputToString()
Expect(session).To(ExitWithError())
os.Setenv("MYENVVAR", "somedata")
@@ -218,7 +217,7 @@ var _ = Describe("Podman secret", func() {
session = podmanTest.Podman([]string{"secret", "create", "--env", "a", "MYENVVAR"})
session.WaitWithDefaultTimeout()
- secrID = session.OutputToString()
+ secrID := session.OutputToString()
Expect(session).Should(Exit(0))
inspect := podmanTest.Podman([]string{"secret", "inspect", "--format", "{{.ID}}", secrID})
diff --git a/test/e2e/systemd_test.go b/test/e2e/systemd_test.go
index 32c2cd1b8..6b4df939c 100644
--- a/test/e2e/systemd_test.go
+++ b/test/e2e/systemd_test.go
@@ -50,8 +50,8 @@ WantedBy=multi-user.target
SkipIfRootless("rootless can not write to /etc")
SkipIfContainerized("test does not have systemd as pid 1")
- sys_file := ioutil.WriteFile("/etc/systemd/system/redis.service", []byte(systemdUnitFile), 0644)
- Expect(sys_file).To(BeNil())
+ sysFile := ioutil.WriteFile("/etc/systemd/system/redis.service", []byte(systemdUnitFile), 0644)
+ Expect(sysFile).To(BeNil())
defer func() {
stop := SystemExec("bash", []string{"-c", "systemctl stop redis"})
os.Remove("/etc/systemd/system/redis.service")
@@ -78,7 +78,7 @@ WantedBy=multi-user.target
It("podman run container with systemd PID1", func() {
ctrName := "testSystemd"
- run := podmanTest.Podman([]string{"run", "--name", ctrName, "-t", "-i", "-d", ubi_init, "/sbin/init"})
+ run := podmanTest.Podman([]string{"run", "--name", ctrName, "-t", "-i", "-d", UBI_INIT, "/sbin/init"})
run.WaitWithDefaultTimeout()
Expect(run).Should(Exit(0))
@@ -118,7 +118,7 @@ WantedBy=multi-user.target
It("podman create container with systemd entrypoint triggers systemd mode", func() {
ctrName := "testCtr"
- run := podmanTest.Podman([]string{"create", "--name", ctrName, "--entrypoint", "/sbin/init", ubi_init})
+ run := podmanTest.Podman([]string{"create", "--name", ctrName, "--entrypoint", "/sbin/init", UBI_INIT})
run.WaitWithDefaultTimeout()
Expect(run).Should(Exit(0))
diff --git a/test/e2e/toolbox_test.go b/test/e2e/toolbox_test.go
index e1fe44675..40db5180a 100644
--- a/test/e2e/toolbox_test.go
+++ b/test/e2e/toolbox_test.go
@@ -66,9 +66,7 @@ var _ = Describe("Toolbox-specific testing", func() {
})
It("podman run --dns=none - allows self-management of /etc/resolv.conf", func() {
- var session *PodmanSessionIntegration
-
- session = podmanTest.Podman([]string{"run", "--dns", "none", ALPINE, "sh", "-c",
+ session := podmanTest.Podman([]string{"run", "--dns", "none", ALPINE, "sh", "-c",
"rm -f /etc/resolv.conf; touch -d '1970-01-01 00:02:03' /etc/resolv.conf; stat -c %s:%Y /etc/resolv.conf"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
@@ -76,9 +74,7 @@ var _ = Describe("Toolbox-specific testing", func() {
})
It("podman run --no-hosts - allows self-management of /etc/hosts", func() {
- var session *PodmanSessionIntegration
-
- session = podmanTest.Podman([]string{"run", "--no-hosts", ALPINE, "sh", "-c",
+ session := podmanTest.Podman([]string{"run", "--no-hosts", ALPINE, "sh", "-c",
"rm -f /etc/hosts; touch -d '1970-01-01 00:02:03' /etc/hosts; stat -c %s:%Y /etc/hosts"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
@@ -164,9 +160,7 @@ var _ = Describe("Toolbox-specific testing", func() {
})
It("podman create --userns=keep-id --user root:root - entrypoint - entrypoint is executed as root", func() {
- var session *PodmanSessionIntegration
-
- session = podmanTest.Podman([]string{"run", "--userns=keep-id", "--user", "root:root", ALPINE,
+ session := podmanTest.Podman([]string{"run", "--userns=keep-id", "--user", "root:root", ALPINE,
"id"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
diff --git a/test/e2e/volume_create_test.go b/test/e2e/volume_create_test.go
index d1f769724..90a9bfb0b 100644
--- a/test/e2e/volume_create_test.go
+++ b/test/e2e/volume_create_test.go
@@ -97,13 +97,12 @@ var _ = Describe("Podman volume create", func() {
session = podmanTest.Podman([]string{"volume", "create", "my_vol2"})
session.WaitWithDefaultTimeout()
- volName = session.OutputToString()
Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"volume", "import", "my_vol2", "hello.tar"})
session.WaitWithDefaultTimeout()
- volName = session.OutputToString()
Expect(session).Should(Exit(0))
+ Expect(session.OutputToString()).To(Equal(""), "output of volume import")
session = podmanTest.Podman([]string{"run", "--volume", "my_vol2:/data", ALPINE, "cat", "/data/test"})
session.WaitWithDefaultTimeout()