diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/apiv2/27-containersEvents.at | 2 | ||||
-rwxr-xr-x | test/buildah-bud/apply-podman-deltas | 3 | ||||
-rw-r--r-- | test/compose/uptwice/docker-compose.yml | 3 | ||||
-rw-r--r-- | test/compose/uptwice/teardown.sh | 3 | ||||
-rw-r--r-- | test/compose/uptwice/tests.sh | 15 | ||||
-rw-r--r-- | test/e2e/config/containers.conf | 1 | ||||
-rw-r--r-- | test/e2e/events_test.go | 12 | ||||
-rw-r--r-- | test/e2e/network_test.go | 4 | ||||
-rw-r--r-- | test/e2e/play_kube_test.go | 6 | ||||
-rw-r--r-- | test/e2e/prune_test.go | 6 | ||||
-rw-r--r-- | test/e2e/secret_test.go | 18 | ||||
-rw-r--r-- | test/e2e/volume_create_test.go | 54 | ||||
-rw-r--r-- | test/e2e/volume_plugin_test.go | 9 | ||||
-rw-r--r-- | test/system/001-basic.bats | 35 | ||||
-rw-r--r-- | test/system/030-run.bats | 33 | ||||
-rw-r--r-- | test/system/070-build.bats | 6 | ||||
-rw-r--r-- | test/system/255-auto-update.bats | 20 | ||||
-rw-r--r-- | test/system/700-play.bats | 34 |
18 files changed, 200 insertions, 64 deletions
diff --git a/test/apiv2/27-containersEvents.at b/test/apiv2/27-containersEvents.at index e0a66e0ac..a5b5b24a3 100644 --- a/test/apiv2/27-containersEvents.at +++ b/test/apiv2/27-containersEvents.at @@ -20,7 +20,7 @@ t GET "libpod/events?stream=false&since=$START" 200 \ t GET "libpod/events?stream=false&since=$START" 200 \ 'select(.status | contains("start")).Action=start' \ - 'select(.status | contains("start")).HealthStatus='\ + 'select(.status | contains("start")).HealthStatus=null'\ # compat api, uses status=die (#12643) t GET "events?stream=false&since=$START" 200 \ diff --git a/test/buildah-bud/apply-podman-deltas b/test/buildah-bud/apply-podman-deltas index 999f36bf9..1ab409359 100755 --- a/test/buildah-bud/apply-podman-deltas +++ b/test/buildah-bud/apply-podman-deltas @@ -70,7 +70,10 @@ function _skip() { for t in "$@"; do if fgrep -qx "@test \"$t\" {" $BUD; then $ECHO "@test \"$t\" : $skip \"$reason\"" + # Escape slash in test name, 'custom files in /run/' t=${t//\//\\/} + # Escape star in test name, 'bud with --dns* flags' + t=${t//\*/\\\*} sed -i -e "/^\@test \"$t\" {/ a \ \ $skip \"$reason\"" $BUD else warn "[$skip] Did not find test \"$t\" in $BUD" diff --git a/test/compose/uptwice/docker-compose.yml b/test/compose/uptwice/docker-compose.yml index e06f9e554..71cc0806c 100644 --- a/test/compose/uptwice/docker-compose.yml +++ b/test/compose/uptwice/docker-compose.yml @@ -2,4 +2,5 @@ version: '3' services: app: build: . - command: sleep 10002 + command: sleep 10001 + stop_signal: SIGKILL # faster shutdown, no reason to wait 10 seconds diff --git a/test/compose/uptwice/teardown.sh b/test/compose/uptwice/teardown.sh new file mode 100644 index 000000000..115c454dc --- /dev/null +++ b/test/compose/uptwice/teardown.sh @@ -0,0 +1,3 @@ +# -*- bash -*- + +mv docker-compose.yml.bak docker-compose.yml diff --git a/test/compose/uptwice/tests.sh b/test/compose/uptwice/tests.sh index 291694d83..013b5a29a 100644 --- a/test/compose/uptwice/tests.sh +++ b/test/compose/uptwice/tests.sh @@ -1,4 +1,17 @@ # -*- bash -*- +CR=$'\r' +NL=$'\n' + +cp docker-compose.yml docker-compose.yml.bak sed -i -e 's/10001/10002/' docker-compose.yml -docker-compose up -d +output=$(docker-compose up -d 2>&1) + +# Horrible output check here but we really want to make sure that there are +# no unexpected warning/errors and the normal messages are send on stderr as +# well so we cannot check for an empty stderr. +expected="Recreating uptwice_app_1 ... ${CR}${NL}Recreating uptwice_app_1 ... done$CR" +if [ "$TEST_FLAVOR" = "compose_v2" ]; then + expected="Container uptwice-app-1 Recreate${NL}Container uptwice-app-1 Recreated${NL}Container uptwice-app-1 Starting${NL}Container uptwice-app-1 Started" +fi +is "$output" "$expected" "no error output in compose up (#15580)" diff --git a/test/e2e/config/containers.conf b/test/e2e/config/containers.conf index 94bb316b1..3cf20268c 100644 --- a/test/e2e/config/containers.conf +++ b/test/e2e/config/containers.conf @@ -76,3 +76,4 @@ testvol6 = "/run/docker/plugins/testvol6.sock" testvol7 = "/run/docker/plugins/testvol7.sock" testvol8 = "/run/docker/plugins/testvol8.sock" testvol9 = "/run/docker/plugins/testvol9.sock" +image = "/run/docker/plugins/image.sock" diff --git a/test/e2e/events_test.go b/test/e2e/events_test.go index bba42c3f4..c76919581 100644 --- a/test/e2e/events_test.go +++ b/test/e2e/events_test.go @@ -212,6 +212,16 @@ var _ = Describe("Podman events", func() { Expect(result).Should(Exit(0)) Expect(result.OutputToStringArray()).To(HaveLen(1)) Expect(result.OutputToString()).To(ContainSubstring("create")) + + ctrName := "testCtr" + run := podmanTest.Podman([]string{"create", "--pod", id, "--name", ctrName, ALPINE, "top"}) + run.WaitWithDefaultTimeout() + Expect(run).Should(Exit(0)) + + result2 := podmanTest.Podman([]string{"events", "--stream=false", "--filter", fmt.Sprintf("container=%s", ctrName), "--since", "30s"}) + result2.WaitWithDefaultTimeout() + Expect(result2).Should(Exit(0)) + Expect(result2.OutputToString()).To(ContainSubstring(fmt.Sprintf("pod_id=%s", id))) }) It("podman events health_status generated", func() { @@ -229,7 +239,7 @@ var _ = Describe("Podman events", func() { time.Sleep(1 * time.Second) } - result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=health_status"}) + result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=health_status", "--since", "1m"}) result.WaitWithDefaultTimeout() Expect(result).Should(Exit(0)) Expect(len(result.OutputToStringArray())).To(BeNumerically(">=", 1), "Number of health_status events") diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go index b2f50ca55..4366d84aa 100644 --- a/test/e2e/network_test.go +++ b/test/e2e/network_test.go @@ -706,7 +706,7 @@ var _ = Describe("Podman network", func() { }) It("podman network prune --filter", func() { - // set custom cni directory to prevent flakes + // set custom network directory to prevent flakes since the dir is shared with all tests by default podmanTest.NetworkConfigDir = tempdir if IsRemote() { podmanTest.RestartRemoteService() @@ -754,7 +754,7 @@ var _ = Describe("Podman network", func() { }) It("podman network prune", func() { - // set custom cni directory to prevent flakes + // set custom network directory to prevent flakes since the dir is shared with all tests by default podmanTest.NetworkConfigDir = tempdir if IsRemote() { podmanTest.RestartRemoteService() diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 67c88953a..651cb1074 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -133,8 +133,6 @@ spec: containers: - name: podnameEqualsContainerNameYaml image: quay.io/libpod/alpine:latest - ports: - - containerPort: 80 ` var podWithoutAName = ` @@ -239,8 +237,6 @@ spec: - "1.5" name: alpine image: quay.io/libpod/alpine:latest - ports: - - containerPort: 80 livenessProbe: exec: command: @@ -274,8 +270,6 @@ spec: - "1.5" name: alpine image: quay.io/libpod/alpine:latest - ports: - - containerPort: 80 livenessProbe: exec: command: diff --git a/test/e2e/prune_test.go b/test/e2e/prune_test.go index 0b1d68aea..e91569231 100644 --- a/test/e2e/prune_test.go +++ b/test/e2e/prune_test.go @@ -259,6 +259,12 @@ var _ = Describe("Podman prune", func() { }) It("podman system prune networks", func() { + // set custom network directory to prevent flakes since the dir is shared with all tests by default + podmanTest.NetworkConfigDir = tempdir + if IsRemote() { + podmanTest.RestartRemoteService() + } + // Create new network. session := podmanTest.Podman([]string{"network", "create", "test"}) session.WaitWithDefaultTimeout() diff --git a/test/e2e/secret_test.go b/test/e2e/secret_test.go index 286815e67..668a4943c 100644 --- a/test/e2e/secret_test.go +++ b/test/e2e/secret_test.go @@ -96,6 +96,23 @@ var _ = Describe("Podman secret", func() { Expect(inspect.OutputToString()).To(Equal(secrID)) }) + It("podman secret inspect with --pretty", func() { + secretFilePath := filepath.Join(podmanTest.TempDir, "secret") + err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) + Expect(err).To(BeNil()) + + session := podmanTest.Podman([]string{"secret", "create", "a", secretFilePath}) + session.WaitWithDefaultTimeout() + secrID := session.OutputToString() + Expect(session).Should(Exit(0)) + + inspect := podmanTest.Podman([]string{"secret", "inspect", "--pretty", secrID}) + inspect.WaitWithDefaultTimeout() + Expect(inspect).Should(Exit(0)) + Expect(inspect.OutputToString()).To(ContainSubstring("Name:")) + Expect(inspect.OutputToString()).To(ContainSubstring(secrID)) + }) + It("podman secret inspect multiple secrets", func() { secretFilePath := filepath.Join(podmanTest.TempDir, "secret") err := os.WriteFile(secretFilePath, []byte("mysecret"), 0755) @@ -125,7 +142,6 @@ var _ = Describe("Podman secret", func() { inspect := podmanTest.Podman([]string{"secret", "inspect", "bogus"}) inspect.WaitWithDefaultTimeout() Expect(inspect).To(ExitWithError()) - }) It("podman secret ls", func() { diff --git a/test/e2e/volume_create_test.go b/test/e2e/volume_create_test.go index 499283cab..5dfa4d0fc 100644 --- a/test/e2e/volume_create_test.go +++ b/test/e2e/volume_create_test.go @@ -162,4 +162,58 @@ var _ = Describe("Podman volume create", func() { Expect(inspectOpts).Should(Exit(0)) Expect(inspectOpts.OutputToString()).To(Equal(optionStrFormatExpect)) }) + + It("image-backed volume basic functionality", func() { + podmanTest.AddImageToRWStore(fedoraMinimal) + volName := "testvol" + volCreate := podmanTest.Podman([]string{"volume", "create", "--driver", "image", "--opt", fmt.Sprintf("image=%s", fedoraMinimal), volName}) + volCreate.WaitWithDefaultTimeout() + Expect(volCreate).Should(Exit(0)) + + runCmd := podmanTest.Podman([]string{"run", "-v", fmt.Sprintf("%s:/test", volName), ALPINE, "cat", "/test/etc/redhat-release"}) + runCmd.WaitWithDefaultTimeout() + Expect(runCmd).Should(Exit(0)) + Expect(runCmd.OutputToString()).To(ContainSubstring("Fedora")) + + rmCmd := podmanTest.Podman([]string{"rmi", "--force", fedoraMinimal}) + rmCmd.WaitWithDefaultTimeout() + Expect(rmCmd).Should(Exit(0)) + + psCmd := podmanTest.Podman([]string{"ps", "-aq"}) + psCmd.WaitWithDefaultTimeout() + Expect(psCmd).Should(Exit(0)) + Expect(psCmd.OutputToString()).To(BeEmpty()) + + volumesCmd := podmanTest.Podman([]string{"volume", "ls", "-q"}) + volumesCmd.WaitWithDefaultTimeout() + Expect(volumesCmd).Should(Exit(0)) + Expect(volumesCmd.OutputToString()).To(Not(ContainSubstring(volName))) + }) + + It("image-backed volume force removal", func() { + podmanTest.AddImageToRWStore(fedoraMinimal) + volName := "testvol" + volCreate := podmanTest.Podman([]string{"volume", "create", "--driver", "image", "--opt", fmt.Sprintf("image=%s", fedoraMinimal), volName}) + volCreate.WaitWithDefaultTimeout() + Expect(volCreate).Should(Exit(0)) + + runCmd := podmanTest.Podman([]string{"run", "-v", fmt.Sprintf("%s:/test", volName), ALPINE, "cat", "/test/etc/redhat-release"}) + runCmd.WaitWithDefaultTimeout() + Expect(runCmd).Should(Exit(0)) + Expect(runCmd.OutputToString()).To(ContainSubstring("Fedora")) + + rmCmd := podmanTest.Podman([]string{"volume", "rm", "--force", volName}) + rmCmd.WaitWithDefaultTimeout() + Expect(rmCmd).Should(Exit(0)) + + psCmd := podmanTest.Podman([]string{"ps", "-aq"}) + psCmd.WaitWithDefaultTimeout() + Expect(psCmd).Should(Exit(0)) + Expect(psCmd.OutputToString()).To(BeEmpty()) + + volumesCmd := podmanTest.Podman([]string{"volume", "ls", "-q"}) + volumesCmd.WaitWithDefaultTimeout() + Expect(volumesCmd).Should(Exit(0)) + Expect(volumesCmd.OutputToString()).To(Not(ContainSubstring(volName))) + }) }) diff --git a/test/e2e/volume_plugin_test.go b/test/e2e/volume_plugin_test.go index 33cdcce5b..00498431e 100644 --- a/test/e2e/volume_plugin_test.go +++ b/test/e2e/volume_plugin_test.go @@ -60,7 +60,8 @@ var _ = Describe("Podman volume plugins", func() { Expect(err).ToNot(HaveOccurred()) // Keep this distinct within tests to avoid multiple tests using the same plugin. - pluginName := "testvol1" + // This one verifies that the "image" plugin uses a volume plugin, not the "image" driver. + pluginName := "image" plugin := podmanTest.Podman([]string{"run", "--security-opt", "label=disable", "-v", "/run/docker/plugins:/run/docker/plugins", "-v", fmt.Sprintf("%v:%v", pluginStatePath, pluginStatePath), "-d", volumeTest, "--sock-name", pluginName, "--path", pluginStatePath}) plugin.WaitWithDefaultTimeout() Expect(plugin).Should(Exit(0)) @@ -77,6 +78,12 @@ var _ = Describe("Podman volume plugins", func() { Expect(arrOutput).To(HaveLen(1)) Expect(arrOutput[0]).To(ContainSubstring(volName)) + // Verify this is not an image volume. + inspect := podmanTest.Podman([]string{"volume", "inspect", volName, "--format", "{{.StorageID}}"}) + inspect.WaitWithDefaultTimeout() + Expect(inspect).Should(Exit(0)) + Expect(inspect.OutputToString()).To(BeEmpty()) + remove := podmanTest.Podman([]string{"volume", "rm", volName}) remove.WaitWithDefaultTimeout() Expect(remove).Should(Exit(0)) diff --git a/test/system/001-basic.bats b/test/system/001-basic.bats index ba6bde4df..f6b4aa1e8 100644 --- a/test/system/001-basic.bats +++ b/test/system/001-basic.bats @@ -215,47 +215,12 @@ See 'podman version --help'" "podman version --remote" run_podman --log-level=warn info assert "$output" !~ " level=" "log-level=warn shows no logs at all" - # Force a warning (local podman only; podman-remote doesn't check versions) - if ! is_remote; then - run_podman --log-level=warn --storage-opt=mount_program=/bin/false info - assert "$output" =~ " level=warning msg=\"Failed to retrieve " \ - "log-level=warn" - - # confirm that default level is "warn", by invoking without --log-level - run_podman --storage-opt=mount_program=/bin/false info - assert "$output" =~ " level=warning msg=\"Failed to retrieve " \ - "default log level includes warning messages" - fi - run_podman --log-level=warning info assert "$output" !~ " level=" "log-level=warning shows no logs at all" run_podman --log-level=error info assert "$output" !~ " level=" "log-level=error shows no logs at all" - # error, fatal, panic: - if is_remote; then - # podman-remote does not grok --runtime; all we can do is test parsing - for level in error fatal panic; do - run_podman --log-level=$level info - assert "$output" !~ " level=" \ - "log-level=$level shows no logs at all" - done - else - # local podman only - run_podman --log-level=error --storage-opt=mount_program=/bin/false --runtime=/bin/false info - assert "$output" =~ " level=error msg=\"Getting info on OCI runtime " \ - "log-level=error shows " - assert "$output" !~ " level=warn" \ - "log-level=error does not show warnings" - - run_podman --log-level=fatal --storage-opt=mount_program=/bin/false --runtime=/bin/false info - assert "$output" !~ " level=" "log-level=fatal shows no logs at all" - - run_podman --log-level=panic --storage-opt=mount_program=/bin/false --runtime=/bin/false info - assert "$output" !~ " level=" "log-level=panic shows no logs at all" - fi - # docker compat run_podman --debug info assert "$output" =~ " level=debug " "podman --debug gives debug output" diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 65a1150a3..6847880ab 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -901,22 +901,35 @@ $IMAGE--c_ok" \ run_podman rm $ctr_name } +# 15895: --privileged + --systemd = hide /dev/ttyNN @test "podman run --privileged as root with systemd will not mount /dev/tty" { skip_if_rootless "this test only makes sense as root" - ctr_name="container-$(random_string 5)" - run_podman run --rm -d --privileged --systemd=always --name "$ctr_name" "$IMAGE" /home/podman/pause + # First, confirm that we _have_ /dev/ttyNN devices on the host. + # ('skip' would be nicer in some sense... but could hide a regression. + # Fedora, RHEL, Debian, Ubuntu, Gentoo, all have /dev/ttyN, so if + # this ever triggers, it means a real problem we should know about.) + assert "$(ls /dev/tty* | grep -vx /dev/tty)" != "" \ + "Expected at least one /dev/ttyN device on host" - TTYs=$(ls /dev/tty*|sed '/^\/dev\/tty$/d') + # Ok now confirm that without --systemd, podman exposes ttyNN devices + run_podman run --rm -d --privileged $IMAGE ./pause + cid="$output" - if [[ $TTYs = "" ]]; then - die "Did not find any /dev/ttyN devices on local host" - else - run_podman exec "$ctr_name" ls /dev/ - assert "$(grep tty <<<$output)" = "tty" "There must be no /dev/ttyN devices in the container" - fi + run_podman exec $cid sh -c 'ls /dev/tty*' + assert "$output" != "/dev/tty" \ + "ls /dev/tty* without systemd; should have lots of ttyN devices" + run_podman stop -t 0 $cid + + # Actual test for 15895: with --systemd, no ttyN devices are passed through + run_podman run --rm -d --privileged --systemd=always $IMAGE ./pause + cid="$output" + + run_podman exec $cid sh -c 'ls /dev/tty*' + assert "$output" = "/dev/tty" \ + "ls /dev/tty* with --systemd=always: should have no ttyN devices" - run_podman stop "$ctr_name" + run_podman stop -t 0 $cid } # vim: filetype=sh diff --git a/test/system/070-build.bats b/test/system/070-build.bats index 87979483e..b392fd8e9 100644 --- a/test/system/070-build.bats +++ b/test/system/070-build.bats @@ -246,7 +246,7 @@ EOF # Now test COPY. That should fail. sed -i -e 's/ADD/COPY/' $tmpdir/Dockerfile run_podman 125 build -t copy_url $tmpdir - is "$output" ".*error building at STEP .*: source can't be a URL for COPY" + is "$output" ".* building at STEP .*: source can't be a URL for COPY" } @@ -853,7 +853,7 @@ EOF run_podman 125 build -t build_test --pull-never $tmpdir is "$output" \ - ".*Error: error creating build container: quay.io/libpod/nosuchimage:nosuchtag: image not known" \ + ".*Error: creating build container: quay.io/libpod/nosuchimage:nosuchtag: image not known" \ "--pull-never fails with expected error message" } @@ -988,7 +988,7 @@ COPY ./ ./ COPY subdir ./ EOF run_podman 125 build -t build_test $tmpdir - is "$output" ".*Error: error building at STEP \"COPY subdir ./\"" ".dockerignore was ignored" + is "$output" ".*Error: building at STEP \"COPY subdir ./\"" ".dockerignore was ignored" } @test "podman build .containerignore and .dockerignore test" { diff --git a/test/system/255-auto-update.bats b/test/system/255-auto-update.bats index 76f6b02e8..6f5113779 100644 --- a/test/system/255-auto-update.bats +++ b/test/system/255-auto-update.bats @@ -133,6 +133,26 @@ function _confirm_update() { die "Timed out waiting for $cname to update; old IID=$old_iid" } +@test "podman auto-update - validate input" { + # Fully-qualified image reference is required + run_podman create --label io.containers.autoupdate=registry $IMAGE + run_podman rm -f "$output" + + # Short name does not work + shortname="shortname:latest" + run_podman image tag $IMAGE $shortname + run_podman 125 create --label io.containers.autoupdate=registry $shortname + is "$output" "Error: short name: auto updates require fully-qualified image reference: \"$shortname\"" + + # Requires docker (or no) transport + archive=$PODMAN_TMPDIR/archive.tar + run_podman save -o $archive $IMAGE + run_podman 125 create --label io.containers.autoupdate=registry docker-archive:$archive + is "$output" ".*Error: auto updates require the docker image transport but image is of transport \"docker-archive\"" + + run_podman rmi $shortname +} + # This test can fail in dev. environment because of SELinux. # quick fix: chcon -t container_runtime_exec_t ./bin/podman @test "podman auto-update - label io.containers.autoupdate=image" { diff --git a/test/system/700-play.bats b/test/system/700-play.bats index bad9544ff..5f3eb1ef2 100644 --- a/test/system/700-play.bats +++ b/test/system/700-play.bats @@ -165,8 +165,14 @@ EOF TESTDIR=$PODMAN_TMPDIR/testdir mkdir -p $TESTDIR echo "$testYaml" | sed "s|TESTDIR|${TESTDIR}|g" > $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 kube play --network host $PODMAN_TMPDIR/test.yaml + is "$output" "Pod:.*" "podman kube play should work with --network host" + + run_podman pod inspect --format "{{.InfraConfig.HostNetwork}}" test_pod + is "$output" "true" ".InfraConfig.HostNetwork" + run_podman stop -a -t 0 + run_podman pod rm -t 0 -f test_pod + run_podman kube play --network slirp4netns:port_handler=slirp4netns $PODMAN_TMPDIR/test.yaml run_podman pod inspect --format {{.InfraContainerID}} "${lines[1]}" infraID="$output" @@ -386,3 +392,27 @@ status: {} run_podman rm -a -f run_podman rm -f -t0 myyaml } + +@test "podman kube play - hostport" { + HOST_PORT=$(random_free_port) + echo " +apiVersion: v1 +kind: Pod +metadata: + labels: + app: test + name: test_pod +spec: + containers: + - name: server + image: $IMAGE + ports: + - name: hostp + containerPort: $HOST_PORT +" > $PODMAN_TMPDIR/testpod.yaml + + run_podman kube play $PODMAN_TMPDIR/testpod.yaml + run_podman pod inspect test_pod --format "{{.InfraConfig.PortBindings}}" + assert "$output" = "map[$HOST_PORT/tcp:[{ $HOST_PORT}]]" + run_podman kube down $PODMAN_TMPDIR/testpod.yaml +} |