summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/apiv2/01-basic.at2
-rw-r--r--test/e2e/common_test.go4
-rw-r--r--test/e2e/container_clone_test.go2
-rw-r--r--test/e2e/generate_kube_test.go10
-rw-r--r--test/e2e/images_test.go4
-rw-r--r--test/e2e/load_test.go2
-rw-r--r--test/e2e/namespace_test.go2
-rw-r--r--test/e2e/play_kube_test.go19
-rw-r--r--test/e2e/pod_initcontainers_test.go2
-rw-r--r--test/e2e/run_cgroup_parent_test.go6
-rw-r--r--test/e2e/run_signal_test.go4
-rw-r--r--test/e2e/run_volume_test.go4
-rw-r--r--test/system/700-play.bats45
-rw-r--r--test/utils/utils.go8
14 files changed, 83 insertions, 31 deletions
diff --git a/test/apiv2/01-basic.at b/test/apiv2/01-basic.at
index 2747ccbd4..e4348a9a7 100644
--- a/test/apiv2/01-basic.at
+++ b/test/apiv2/01-basic.at
@@ -19,7 +19,7 @@ for i in /version version; do
t GET $i 200 \
.Components[0].Name="Podman Engine" \
.Components[0].Details.APIVersion~4[0-9.-]\\+ \
- .Components[0].Details.MinAPIVersion=3.1.0 \
+ .Components[0].Details.MinAPIVersion=4.0.0 \
.Components[0].Details.Os=linux \
.ApiVersion=1.40 \
.MinAPIVersion=1.24 \
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go
index 6846a5677..59252fcb0 100644
--- a/test/e2e/common_test.go
+++ b/test/e2e/common_test.go
@@ -212,7 +212,7 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
podmanRemoteBinary = os.Getenv("PODMAN_REMOTE_BINARY")
}
- conmonBinary := filepath.Join("/usr/libexec/podman/conmon")
+ conmonBinary := "/usr/libexec/podman/conmon"
altConmonBinary := "/usr/bin/conmon"
if _, err := os.Stat(conmonBinary); os.IsNotExist(err) {
conmonBinary = altConmonBinary
@@ -344,7 +344,7 @@ func imageTarPath(image string) string {
}
// e.g., registry.com/fubar:latest -> registry.com-fubar-latest.tar
- imageCacheName := strings.Replace(strings.Replace(image, ":", "-", -1), "/", "-", -1) + ".tar"
+ imageCacheName := strings.ReplaceAll(strings.ReplaceAll(image, ":", "-"), "/", "-") + ".tar"
return filepath.Join(cacheDir, imageCacheName)
}
diff --git a/test/e2e/container_clone_test.go b/test/e2e/container_clone_test.go
index 1ff4b3b5f..42b477da0 100644
--- a/test/e2e/container_clone_test.go
+++ b/test/e2e/container_clone_test.go
@@ -184,7 +184,7 @@ var _ = Describe("Podman container clone", func() {
Expect(checkCreate).Should(Exit(0))
createArray := checkCreate.OutputToStringArray()
- Expect(cloneArray).To(ContainElements(createArray[:]))
+ Expect(cloneArray).To(ContainElements(createArray))
ctrInspect := podmanTest.Podman([]string{"inspect", clone.OutputToString()})
ctrInspect.WaitWithDefaultTimeout()
diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go
index 9c99c3d93..1e9d725b7 100644
--- a/test/e2e/generate_kube_test.go
+++ b/test/e2e/generate_kube_test.go
@@ -75,7 +75,7 @@ var _ = Describe("Podman generate kube", func() {
numContainers := 0
for range pod.Spec.Containers {
- numContainers = numContainers + 1
+ numContainers++
}
Expect(numContainers).To(Equal(1))
})
@@ -169,7 +169,7 @@ var _ = Describe("Podman generate kube", func() {
numContainers := 0
for range pod.Spec.Containers {
- numContainers = numContainers + 1
+ numContainers++
}
Expect(numContainers).To(Equal(1))
})
@@ -478,11 +478,11 @@ var _ = Describe("Podman generate kube", func() {
// for k8s
Expect(port.Protocol).To(BeEmpty())
if port.HostPort == 4000 {
- foundPort4000 = foundPort4000 + 1
+ foundPort4000++
} else if port.HostPort == 5000 {
- foundPort5000 = foundPort5000 + 1
+ foundPort5000++
} else {
- foundOtherPort = foundOtherPort + 1
+ foundOtherPort++
}
}
}
diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go
index d34c911ad..fc1c48c15 100644
--- a/test/e2e/images_test.go
+++ b/test/e2e/images_test.go
@@ -438,7 +438,7 @@ RUN > file2
Expect(result).Should(Exit(0))
Expect(result.OutputToStringArray()).To(HaveLen(1))
- //check if really abc is removed
+ // check if really abc is removed
result = podmanTest.Podman([]string{"image", "list", "--filter", "label=abc"})
Expect(result.OutputToStringArray()).To(BeEmpty())
@@ -459,7 +459,7 @@ RUN > file2
Expect(result).Should(Exit(0))
Expect(result.OutputToStringArray()).To(HaveLen(1))
- //check if really abc is removed
+ // check if really abc is removed
result = podmanTest.Podman([]string{"image", "list", "--filter", "label=abc"})
Expect(result.OutputToStringArray()).To(BeEmpty())
diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go
index 8e9f0ad13..1e3f9089a 100644
--- a/test/e2e/load_test.go
+++ b/test/e2e/load_test.go
@@ -64,7 +64,7 @@ var _ = Describe("Podman load", func() {
compress := SystemExec("gzip", []string{outfile})
Expect(compress).Should(Exit(0))
- outfile = outfile + ".gz"
+ outfile += ".gz"
rmi := podmanTest.Podman([]string{"rmi", ALPINE})
rmi.WaitWithDefaultTimeout()
diff --git a/test/e2e/namespace_test.go b/test/e2e/namespace_test.go
index c3e0e2d23..bc9db4cd9 100644
--- a/test/e2e/namespace_test.go
+++ b/test/e2e/namespace_test.go
@@ -51,7 +51,7 @@ var _ = Describe("Podman namespaces", func() {
numCtrs := 0
for _, outputLine := range output {
if outputLine != "" {
- numCtrs = numCtrs + 1
+ numCtrs++
}
}
Expect(numCtrs).To(Equal(0))
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go
index 4dd05c755..46a8e88bc 100644
--- a/test/e2e/play_kube_test.go
+++ b/test/e2e/play_kube_test.go
@@ -2779,11 +2779,7 @@ MemoryReservation: {{ .HostConfig.MemoryReservation }}`})
})
It("podman play kube test with HostNetwork", func() {
- if !strings.Contains(podmanTest.OCIRuntime, "crun") {
- Skip("Test only works on crun")
- }
-
- pod := getPod(withHostNetwork())
+ pod := getPod(withHostNetwork(), withCtr(getCtr(withCmd([]string{"readlink", "/proc/self/ns/net"}), withArg(nil))))
err := generateKubeYaml("pod", pod, kubeYaml)
Expect(err).To(BeNil())
@@ -2795,6 +2791,17 @@ MemoryReservation: {{ .HostConfig.MemoryReservation }}`})
inspect.WaitWithDefaultTimeout()
Expect(inspect).Should(Exit(0))
Expect(inspect.OutputToString()).To(Equal("true"))
+
+ ns := SystemExec("readlink", []string{"/proc/self/ns/net"})
+ ns.WaitWithDefaultTimeout()
+ Expect(ns).Should(Exit(0))
+ netns := ns.OutputToString()
+ Expect(netns).ToNot(BeEmpty())
+
+ logs := podmanTest.Podman([]string{"logs", getCtrNameInPod(pod)})
+ logs.WaitWithDefaultTimeout()
+ Expect(logs).Should(Exit(0))
+ Expect(logs.OutputToString()).To(Equal(netns))
})
It("podman play kube persistentVolumeClaim", func() {
@@ -2995,7 +3002,7 @@ invalid kube kind
It("podman play kube with auto update annotations for all containers", func() {
ctr01Name := "ctr01"
- ctr02Name := "ctr02"
+ ctr02Name := "infra"
podName := "foo"
autoUpdateRegistry := "io.containers.autoupdate"
autoUpdateRegistryValue := "registry"
diff --git a/test/e2e/pod_initcontainers_test.go b/test/e2e/pod_initcontainers_test.go
index a99e24908..cefaa3dc1 100644
--- a/test/e2e/pod_initcontainers_test.go
+++ b/test/e2e/pod_initcontainers_test.go
@@ -114,7 +114,7 @@ var _ = Describe("Podman init containers", func() {
check := podmanTest.Podman([]string{"container", "exists", initContainerID})
check.WaitWithDefaultTimeout()
// Container was rm'd
- //Expect(check).Should(Exit(1))
+ // Expect(check).Should(Exit(1))
Expect(check.ExitCode()).To(Equal(1), "I dont understand why the other way does not work")
// Lets double check with a stop and start
stopPod := podmanTest.Podman([]string{"pod", "stop", "foobar"})
diff --git a/test/e2e/run_cgroup_parent_test.go b/test/e2e/run_cgroup_parent_test.go
index 0aba367f3..34715be22 100644
--- a/test/e2e/run_cgroup_parent_test.go
+++ b/test/e2e/run_cgroup_parent_test.go
@@ -84,12 +84,12 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
exec.WaitWithDefaultTimeout()
Expect(exec).Should(Exit(0))
- containerCgroup := strings.TrimRight(strings.Replace(exec.OutputToString(), "0::", "", -1), "\n")
+ containerCgroup := strings.TrimRight(strings.ReplaceAll(exec.OutputToString(), "0::", ""), "\n")
// Move the container process to a sub cgroup
content, err := ioutil.ReadFile(filepath.Join(cgroupRoot, containerCgroup, "cgroup.procs"))
Expect(err).To(BeNil())
- oldSubCgroupPath := filepath.Join(filepath.Join(cgroupRoot, containerCgroup, "old-container"))
+ oldSubCgroupPath := filepath.Join(cgroupRoot, containerCgroup, "old-container")
err = os.MkdirAll(oldSubCgroupPath, 0755)
Expect(err).To(BeNil())
err = ioutil.WriteFile(filepath.Join(oldSubCgroupPath, "cgroup.procs"), content, 0644)
@@ -102,7 +102,7 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
run = podmanTest.Podman([]string{"--cgroup-manager=cgroupfs", "run", "--rm", "--cgroupns=host", fmt.Sprintf("--cgroup-parent=%s", newCgroup), fedoraMinimal, "cat", "/proc/self/cgroup"})
run.WaitWithDefaultTimeout()
Expect(run).Should(Exit(0))
- cgroupEffective := strings.TrimRight(strings.Replace(run.OutputToString(), "0::", "", -1), "\n")
+ cgroupEffective := strings.TrimRight(strings.ReplaceAll(run.OutputToString(), "0::", ""), "\n")
Expect(newCgroup).To(Equal(filepath.Dir(cgroupEffective)))
})
diff --git a/test/e2e/run_signal_test.go b/test/e2e/run_signal_test.go
index 71efa770a..d40a5a1b4 100644
--- a/test/e2e/run_signal_test.go
+++ b/test/e2e/run_signal_test.go
@@ -66,7 +66,7 @@ var _ = Describe("Podman run with --sig-proxy", func() {
counter := 0
for {
buf := make([]byte, 1024)
- n, err := uds.Read(buf[:])
+ n, err := uds.Read(buf)
if err != nil && err != io.EOF {
fmt.Println(err)
return
@@ -92,7 +92,7 @@ var _ = Describe("Podman run with --sig-proxy", func() {
counter = 0
for {
buf := make([]byte, 1024)
- n, err := uds.Read(buf[:])
+ n, err := uds.Read(buf)
if err != nil {
fmt.Println(err)
return
diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go
index 0be84e11b..a31c1959e 100644
--- a/test/e2e/run_volume_test.go
+++ b/test/e2e/run_volume_test.go
@@ -226,7 +226,7 @@ var _ = Describe("Podman run with volumes", func() {
mountPath := filepath.Join(podmanTest.TempDir, "secrets")
os.Mkdir(mountPath, 0755)
- //Container should be able to start with custom overlay volume
+ // Container should be able to start with custom overlay volume
session := podmanTest.Podman([]string{"run", "--rm", "-v", mountPath + ":/data:O", "--workdir=/data", ALPINE, "echo", "hello"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
@@ -729,7 +729,7 @@ VOLUME /test/`, ALPINE)
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(ContainSubstring("888:888"))
- vol = vol + ",O"
+ vol += ",O"
session = podmanTest.Podman([]string{"run", "--rm", "--user", "888:888", "--userns", "keep-id", "-v", vol, ALPINE, "stat", "-c", "%u:%g", dest})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
diff --git a/test/system/700-play.bats b/test/system/700-play.bats
index 8af4cd25b..b0624cbf2 100644
--- a/test/system/700-play.bats
+++ b/test/system/700-play.bats
@@ -233,3 +233,48 @@ _EOF
run_podman stop -a -t 0
run_podman pod rm -t 0 -f test_pod
}
+
+@test "podman play --annotation > Max" {
+ TESTDIR=$PODMAN_TMPDIR/testdir
+ RANDOMSTRING=$(random_string 65)
+ mkdir -p $TESTDIR
+ echo "$testYaml" | sed "s|TESTDIR|${TESTDIR}|g" > $PODMAN_TMPDIR/test.yaml
+ run_podman 125 play kube --annotation "name=$RANDOMSTRING" $PODMAN_TMPDIR/test.yaml
+ assert "$output" =~ "annotation exceeds maximum size, 63, of kubernetes annotation:" "Expected to fail with Length greater than 63"
+}
+
+@test "podman play Yaml with annotation > Max" {
+ RANDOMSTRING=$(random_string 65)
+ testBadYaml="
+apiVersion: v1
+kind: Pod
+metadata:
+ annotations:
+ test: ${RANDOMSTRING}
+ labels:
+ app: test
+ name: test_pod
+spec:
+ containers:
+ - command:
+ - id
+ env:
+ - name: PATH
+ value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ - name: TERM
+ value: xterm
+ - name: container
+
+ value: podman
+ image: quay.io/libpod/userimage
+ name: test
+ resources: {}
+status: {}
+"
+ TESTDIR=$PODMAN_TMPDIR/testdir
+ mkdir -p $TESTDIR
+ echo "$testBadYaml" | sed "s|TESTDIR|${TESTDIR}|g" > $PODMAN_TMPDIR/test.yaml
+
+ run_podman 125 play kube - < $PODMAN_TMPDIR/test.yaml
+ assert "$output" =~ "invalid annotation \"test\"=\"$RANDOMSTRING\"" "Expected to fail with annotation length greater than 63"
+}
diff --git a/test/utils/utils.go b/test/utils/utils.go
index 0867570c1..f3e14c784 100644
--- a/test/utils/utils.go
+++ b/test/utils/utils.go
@@ -108,8 +108,8 @@ func (p *PodmanTest) PodmanAsUserBase(args []string, uid, gid uint32, cwd string
timeCmd := append([]string{"/usr/bin/time"}, timeArgs...)
wrapper = append(timeCmd, wrapper...)
}
-
- runCmd := append(wrapper, podmanBinary)
+ runCmd := wrapper
+ runCmd = append(runCmd, podmanBinary)
if !p.RemoteTest && p.NetworkBackend == Netavark {
runCmd = append(runCmd, []string{"--network-backend", "netavark"}...)
}
@@ -449,10 +449,10 @@ func GetHostDistributionInfo() HostOS {
host.Arch = runtime.GOARCH
for l.Scan() {
if strings.HasPrefix(l.Text(), "ID=") {
- host.Distribution = strings.Replace(strings.TrimSpace(strings.Join(strings.Split(l.Text(), "=")[1:], "")), "\"", "", -1)
+ host.Distribution = strings.ReplaceAll(strings.TrimSpace(strings.Join(strings.Split(l.Text(), "=")[1:], "")), "\"", "")
}
if strings.HasPrefix(l.Text(), "VERSION_ID=") {
- host.Version = strings.Replace(strings.TrimSpace(strings.Join(strings.Split(l.Text(), "=")[1:], "")), "\"", "", -1)
+ host.Version = strings.ReplaceAll(strings.TrimSpace(strings.Join(strings.Split(l.Text(), "=")[1:], "")), "\"", "")
}
}
return host