diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/apiv2/25-containersMore.at | 28 | ||||
-rw-r--r-- | test/apiv2/80-kube.at | 66 | ||||
-rwxr-xr-x | test/apiv2/test-apiv2 | 4 | ||||
-rw-r--r-- | test/e2e/build/Containerfile.with-platform | 1 | ||||
-rw-r--r-- | test/e2e/run_cpu_test.go | 2 | ||||
-rw-r--r-- | test/e2e/stop_test.go | 42 | ||||
-rw-r--r-- | test/system/090-events.bats | 4 | ||||
-rw-r--r-- | test/system/700-play.bats | 22 |
8 files changed, 127 insertions, 42 deletions
diff --git a/test/apiv2/25-containersMore.at b/test/apiv2/25-containersMore.at index c9fda8c6f..9cdc2a33f 100644 --- a/test/apiv2/25-containersMore.at +++ b/test/apiv2/25-containersMore.at @@ -53,34 +53,6 @@ t POST libpod/containers/foo/unmount 204 t DELETE libpod/containers/foo?force=true 200 -podman run $IMAGE true - -t GET libpod/containers/json?last=1 200 \ - length=1 \ - .[0].Id~[0-9a-f]\\{64\\} \ - .[0].Image=$IMAGE \ - .[0].Command[0]="true" \ - .[0].State~\\\(exited\\\|stopped\\\) \ - .[0].ExitCode=0 \ - .[0].IsInfra=false - -cid=$(jq -r '.[0].Id' <<<"$output") - -t GET libpod/generate/kube?names=$cid 200 -like "$output" ".*apiVersion:.*" "Check generated kube yaml - apiVersion" -like "$output" ".*kind:\\sPod.*" "Check generated kube yaml - kind: Pod" -like "$output" ".*metadata:.*" "Check generated kube yaml - metadata" -like "$output" ".*spec:.*" "Check generated kube yaml - spec" - -t GET "libpod/generate/kube?service=true&names=$cid" 200 -like "$output" ".*apiVersion:.*" "Check generated kube yaml(service=true) - apiVersion" -like "$output" ".*kind:\\sPod.*" "Check generated kube yaml(service=true) - kind: Pod" -like "$output" ".*metadata:.*" "Check generated kube yaml(service=true) - metadata" -like "$output" ".*spec:.*" "Check generated kube yaml(service=true) - spec" -like "$output" ".*kind:\\sService.*" "Check generated kube yaml(service=true) - kind: Service" - -t DELETE libpod/containers/$cid 200 .[0].Id=$cid - # Create 3 stopped containers to test containers prune podman run $IMAGE true podman run $IMAGE true diff --git a/test/apiv2/80-kube.at b/test/apiv2/80-kube.at new file mode 100644 index 000000000..f40a6556e --- /dev/null +++ b/test/apiv2/80-kube.at @@ -0,0 +1,66 @@ +# -*- sh -*- +# +# test more container-related endpoints +# + +podman create $IMAGE true + +t GET libpod/containers/json?last=1 200 \ + length=1 \ + .[0].Id~[0-9a-f]\\{64\\} \ + .[0].Image=$IMAGE \ + .[0].Command[0]="true" \ + .[0].IsInfra=false + +cid=$(jq -r '.[0].Id' <<<"$output") + +# Make sure that generate-kube works + +t GET libpod/generate/kube?names=$cid 200 +like "$output" ".*apiVersion:.*" "Check generated kube yaml - apiVersion" +like "$output" ".*kind:\\sPod.*" "Check generated kube yaml - kind: Pod" +like "$output" ".*metadata:.*" "Check generated kube yaml - metadata" +like "$output" ".*spec:.*" "Check generated kube yaml - spec" + +t GET "libpod/generate/kube?service=true&names=$cid" 200 +like "$output" ".*apiVersion:.*" "Check generated kube yaml(service=true) - apiVersion" +like "$output" ".*kind:\\sPod.*" "Check generated kube yaml(service=true) - kind: Pod" +like "$output" ".*metadata:.*" "Check generated kube yaml(service=true) - metadata" +like "$output" ".*spec:.*" "Check generated kube yaml(service=true) - spec" +like "$output" ".*kind:\\sService.*" "Check generated kube yaml(service=true) - kind: Service" + +TMPD=$(mktemp -d podman-apiv2-test-kube.XXXXXX) +YAML="${TMPD}/kube.yaml" +echo "$output" > $YAML + +t DELETE libpod/containers/$cid 200 .[0].Id=$cid + +# Make sure that kube-play works + +t POST libpod/kube/play $YAML 200 \ + .Pods[0].ID~[0-9a-f]\\{64\\} \ + .Pods[0].ContainerErrors=null \ + .Pods[0].Containers[0]~[0-9a-f]\\{64\\} + +t DELETE libpod/kube/play $YAML 200 \ + .Pods[0].ID~null \ + .Pods[0].ContainerErrors=null \ + .Pods[0].Containers[0]~null + +# Make sure that play-kube works + +t POST libpod/play/kube $YAML 200 \ + .Pods[0].ID~[0-9a-f]\\{64\\} \ + .Pods[0].ContainerErrors=null \ + .Pods[0].Containers[0]~[0-9a-f]\\{64\\} + +t DELETE libpod/play/kube $YAML 200 \ + .Pods[0].ID~null \ + .Pods[0].ContainerErrors=null \ + .Pods[0].Containers[0]~null \ + .StopReport[0].Id~[0-9a-f]\\{64\\} \ + .RmReport[0].Id~[0-9a-f]\\{64\\} + +rm -rf $TMPD + +# vim: filetype=sh diff --git a/test/apiv2/test-apiv2 b/test/apiv2/test-apiv2 index 0fd282854..0c3c6e672 100755 --- a/test/apiv2/test-apiv2 +++ b/test/apiv2/test-apiv2 @@ -252,7 +252,7 @@ function t() { fi # POST and PUT requests may be followed by one or more key=value pairs. # Slurp the command line until we see a 3-digit status code. - if [[ $method = "POST" || $method == "PUT" ]]; then + if [[ $method = "POST" || $method == "PUT" || $method = "DELETE" ]]; then local -a post_args for arg; do case "$arg" in @@ -261,6 +261,8 @@ function t() { *.tar) curl_args+=(--data-binary @$arg); content_type="application/x-tar"; shift;; + *.yaml) curl_args+=(--data-binary @$arg); + shift;; application/*) content_type="$arg"; shift;; [1-9][0-9][0-9]) break;; diff --git a/test/e2e/build/Containerfile.with-platform b/test/e2e/build/Containerfile.with-platform index 3bb585a0a..0b030d13c 100644 --- a/test/e2e/build/Containerfile.with-platform +++ b/test/e2e/build/Containerfile.with-platform @@ -1 +1,2 @@ +ARG TARGETPLATFORM FROM --platform=$TARGETPLATFORM alpine diff --git a/test/e2e/run_cpu_test.go b/test/e2e/run_cpu_test.go index b21be5729..e57eb3b26 100644 --- a/test/e2e/run_cpu_test.go +++ b/test/e2e/run_cpu_test.go @@ -94,7 +94,7 @@ var _ = Describe("Podman run cpu", func() { Expect(result).Should(Exit(0)) Expect(result.OutputToString()).To(Equal("10000")) } else { - result := podmanTest.Podman([]string{"run", "--rm", "--cpu-shares=2", ALPINE, "cat", "/sys/fs/cgroup/cpu/cpu.shares"}) + result := podmanTest.Podman([]string{"run", "--rm", "-c", "2", ALPINE, "cat", "/sys/fs/cgroup/cpu/cpu.shares"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) Expect(result.OutputToString()).To(Equal("2")) diff --git a/test/e2e/stop_test.go b/test/e2e/stop_test.go index 97d8ba701..7a258466a 100644 --- a/test/e2e/stop_test.go +++ b/test/e2e/stop_test.go @@ -1,6 +1,7 @@ package integration import ( + "fmt" "io/ioutil" "os" "strings" @@ -363,4 +364,45 @@ var _ = Describe("Podman stop", func() { Expect(session).Should(Exit(0)) Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) }) + + It("podman stop --filter", func() { + session1 := podmanTest.Podman([]string{"container", "create", ALPINE}) + session1.WaitWithDefaultTimeout() + Expect(session1).Should(Exit(0)) + cid1 := session1.OutputToString() + + session1 = podmanTest.Podman([]string{"container", "create", ALPINE}) + session1.WaitWithDefaultTimeout() + Expect(session1).Should(Exit(0)) + cid2 := session1.OutputToString() + + session1 = podmanTest.Podman([]string{"container", "create", ALPINE}) + session1.WaitWithDefaultTimeout() + Expect(session1).Should(Exit(0)) + cid3 := session1.OutputToString() + shortCid3 := cid3[0:5] + + session1 = podmanTest.Podman([]string{"start", "--all"}) + session1.WaitWithDefaultTimeout() + Expect(session1).Should(Exit(0)) + + session1 = podmanTest.Podman([]string{"stop", cid1, "-f", "status=running"}) + session1.WaitWithDefaultTimeout() + Expect(session1).Should(Exit(125)) + + session1 = podmanTest.Podman([]string{"stop", "-a", "--filter", fmt.Sprintf("id=%swrongid", shortCid3)}) + session1.WaitWithDefaultTimeout() + Expect(session1).Should(Exit(0)) + Expect(session1.OutputToString()).To(HaveLen(0)) + + session1 = podmanTest.Podman([]string{"stop", "-a", "--filter", fmt.Sprintf("id=%s", shortCid3)}) + session1.WaitWithDefaultTimeout() + Expect(session1).Should(Exit(0)) + Expect(session1.OutputToString()).To(BeEquivalentTo(cid3)) + + session1 = podmanTest.Podman([]string{"stop", "-f", fmt.Sprintf("id=%s", cid2)}) + session1.WaitWithDefaultTimeout() + Expect(session1).Should(Exit(0)) + Expect(session1.OutputToString()).To(BeEquivalentTo(cid2)) + }) }) diff --git a/test/system/090-events.bats b/test/system/090-events.bats index 128802360..ceb53ae73 100644 --- a/test/system/090-events.bats +++ b/test/system/090-events.bats @@ -13,11 +13,11 @@ load helpers run_podman run --label $labelname=$labelvalue --name $cname --rm $IMAGE ls expect=".* container start [0-9a-f]\+ (image=$IMAGE, name=$cname,.* ${labelname}=${labelvalue}" - run_podman events --filter type=container --filter container=$cname --filter label=${labelname}=${labelvalue} --filter event=start --stream=false + run_podman events --filter type=container -f container=$cname --filter label=${labelname}=${labelvalue} --filter event=start --stream=false is "$output" "$expect" "filtering by container name and label" # Same thing, but without the container-name filter - run_podman events --filter type=container --filter label=${labelname}=${labelvalue} --filter event=start --stream=false + run_podman events -f type=container --filter label=${labelname}=${labelvalue} --filter event=start --stream=false is "$output" "$expect" "filtering just by label" # Now filter just by container name, no label diff --git a/test/system/700-play.bats b/test/system/700-play.bats index 6c2a8c8b1..72602a9e6 100644 --- a/test/system/700-play.bats +++ b/test/system/700-play.bats @@ -65,12 +65,12 @@ status: {} RELABEL="system_u:object_r:container_file_t:s0" -@test "podman play with stdin" { +@test "podman kube with stdin" { TESTDIR=$PODMAN_TMPDIR/testdir mkdir -p $TESTDIR echo "$testYaml" | sed "s|TESTDIR|${TESTDIR}|g" > $PODMAN_TMPDIR/test.yaml - run_podman play kube - < $PODMAN_TMPDIR/test.yaml + run_podman kube play - < $PODMAN_TMPDIR/test.yaml if [ -e /usr/sbin/selinuxenabled -a /usr/sbin/selinuxenabled ]; then run ls -Zd $TESTDIR is "$output" "${RELABEL} $TESTDIR" "selinux relabel should have happened" @@ -87,6 +87,8 @@ RELABEL="system_u:object_r:container_file_t:s0" } @test "podman play" { + # Testing that the "podman play" cmd still works now that + # "podman kube" is an option. TESTDIR=$PODMAN_TMPDIR/testdir mkdir -p $TESTDIR echo "$testYaml" | sed "s|TESTDIR|${TESTDIR}|g" > $PODMAN_TMPDIR/test.yaml @@ -159,13 +161,13 @@ EOF run_podman 1 container exists $service_container } -@test "podman play --network" { +@test "podman kube --network" { TESTDIR=$PODMAN_TMPDIR/testdir mkdir -p $TESTDIR echo "$testYaml" | sed "s|TESTDIR|${TESTDIR}|g" > $PODMAN_TMPDIR/test.yaml - run_podman 125 play kube --network host $PODMAN_TMPDIR/test.yaml + run_podman 125 kube play --network host $PODMAN_TMPDIR/test.yaml is "$output" ".*invalid value passed to --network: bridge or host networking must be configured in YAML" "podman plan-network should fail with --network host" - run_podman play kube --network slirp4netns:port_handler=slirp4netns $PODMAN_TMPDIR/test.yaml + run_podman kube play --network slirp4netns:port_handler=slirp4netns $PODMAN_TMPDIR/test.yaml run_podman pod inspect --format {{.InfraContainerID}} "${lines[1]}" infraID="$output" run_podman container inspect --format "{{.HostConfig.NetworkMode}}" $infraID @@ -174,7 +176,7 @@ EOF run_podman stop -a -t 0 run_podman pod rm -t 0 -f test_pod - run_podman play kube --network none $PODMAN_TMPDIR/test.yaml + run_podman kube play --network none $PODMAN_TMPDIR/test.yaml run_podman pod inspect --format {{.InfraContainerID}} "${lines[1]}" infraID="$output" run_podman container inspect --format "{{.HostConfig.NetworkMode}}" $infraID @@ -280,12 +282,12 @@ _EOF run_podman rmi -f userimage:latest } -@test "podman play --annotation" { +@test "podman kube --annotation" { TESTDIR=$PODMAN_TMPDIR/testdir RANDOMSTRING=$(random_string 15) mkdir -p $TESTDIR echo "$testYaml" | sed "s|TESTDIR|${TESTDIR}|g" > $PODMAN_TMPDIR/test.yaml - run_podman play kube --annotation "name=$RANDOMSTRING" $PODMAN_TMPDIR/test.yaml + run_podman kube play --annotation "name=$RANDOMSTRING" $PODMAN_TMPDIR/test.yaml run_podman inspect --format "{{ .Config.Annotations }}" test_pod-test is "$output" ".*name:$RANDOMSTRING" "Annotation should be added to pod" @@ -338,7 +340,7 @@ status: {} assert "$output" =~ "invalid annotation \"test\"=\"$RANDOMSTRING\"" "Expected to fail with annotation length greater than 63" } -@test "podman play kube - default log driver" { +@test "podman kube play - default log driver" { TESTDIR=$PODMAN_TMPDIR/testdir mkdir -p $TESTDIR echo "$testYaml" | sed "s|TESTDIR|${TESTDIR}|g" > $PODMAN_TMPDIR/test.yaml @@ -347,7 +349,7 @@ status: {} default_driver=$output # Make sure that the default log driver is used - run_podman play kube $PODMAN_TMPDIR/test.yaml + run_podman kube play $PODMAN_TMPDIR/test.yaml run_podman inspect --format "{{.HostConfig.LogConfig.Type}}" test_pod-test is "$output" "$default_driver" "play kube uses default log driver" |