aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/e2e/events_test.go4
-rw-r--r--test/e2e/generate_kube_test.go2
-rw-r--r--test/e2e/run_device_test.go12
-rw-r--r--test/e2e/run_volume_test.go89
-rw-r--r--test/system/015-help.bats21
-rw-r--r--test/system/helpers.bash10
6 files changed, 122 insertions, 16 deletions
diff --git a/test/e2e/events_test.go b/test/e2e/events_test.go
index 93c51098f..9b527b88e 100644
--- a/test/e2e/events_test.go
+++ b/test/e2e/events_test.go
@@ -136,6 +136,7 @@ var _ = Describe("Podman events", func() {
Expect(ec).To(Equal(0))
test := podmanTest.Podman([]string{"events", "--stream=false", "--format", "json"})
test.WaitWithDefaultTimeout()
+ Expect(test.ExitCode()).To(BeZero())
jsonArr := test.OutputToStringArray()
Expect(len(jsonArr)).To(Not(BeZero()))
eventsMap := make(map[string]string)
@@ -143,10 +144,10 @@ var _ = Describe("Podman events", func() {
Expect(err).To(BeNil())
_, exist := eventsMap["Status"]
Expect(exist).To(BeTrue())
- Expect(test.ExitCode()).To(BeZero())
test = podmanTest.Podman([]string{"events", "--stream=false", "--format", "{{json.}}"})
test.WaitWithDefaultTimeout()
+ Expect(test.ExitCode()).To(BeZero())
jsonArr = test.OutputToStringArray()
Expect(len(jsonArr)).To(Not(BeZero()))
eventsMap = make(map[string]string)
@@ -154,6 +155,5 @@ var _ = Describe("Podman events", func() {
Expect(err).To(BeNil())
_, exist = eventsMap["Status"]
Expect(exist).To(BeTrue())
- Expect(test.ExitCode()).To(BeZero())
})
})
diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go
index 987e4779c..577a7562b 100644
--- a/test/e2e/generate_kube_test.go
+++ b/test/e2e/generate_kube_test.go
@@ -254,8 +254,6 @@ var _ = Describe("Podman generate kube", func() {
})
It("podman generate with user and reimport kube on pod", func() {
- // This test fails on ubuntu due to https://github.com/seccomp/containers-golang/pull/27
- SkipIfNotFedora()
podName := "toppod"
_, rc, _ := podmanTest.CreatePod(podName)
Expect(rc).To(Equal(0))
diff --git a/test/e2e/run_device_test.go b/test/e2e/run_device_test.go
index a5e1e0269..b1a4c9cb2 100644
--- a/test/e2e/run_device_test.go
+++ b/test/e2e/run_device_test.go
@@ -75,11 +75,17 @@ var _ = Describe("Podman run device", func() {
It("podman run device host device and container device parameter are directories", func() {
SkipIfRootless()
- SystemExec("mkdir", []string{"/dev/foodevdir"})
- SystemExec("mknod", []string{"/dev/foodevdir/null", "c", "1", "3"})
- session := podmanTest.Podman([]string{"run", "-q", "--device", "/dev/foodevdir:/dev/bar", ALPINE, "ls", "/dev/bar/null"})
+ Expect(os.MkdirAll("/dev/foodevdir", os.ModePerm)).To(BeNil())
+ defer os.RemoveAll("/dev/foodevdir")
+
+ mknod := SystemExec("mknod", []string{"/dev/foodevdir/null", "c", "1", "3"})
+ mknod.WaitWithDefaultTimeout()
+ Expect(mknod.ExitCode()).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"run", "-q", "--device", "/dev/foodevdir:/dev/bar", ALPINE, "stat", "-c%t:%T", "/dev/bar/null"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).To(Equal("1:3"))
})
It("podman run device host device with --privileged", func() {
diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go
index 92988ff87..2b806ac2b 100644
--- a/test/e2e/run_volume_test.go
+++ b/test/e2e/run_volume_test.go
@@ -9,6 +9,7 @@ import (
"path/filepath"
"strings"
+ "github.com/containers/libpod/v2/pkg/rootless"
. "github.com/containers/libpod/v2/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -450,4 +451,92 @@ VOLUME /test/`
Expect(data[0].Mounts[0].Source).To(Equal("/tmp"))
Expect(data[0].Mounts[0].Destination).To(Equal("/test"))
})
+
+ It("podman run with overlay volume flag", func() {
+ if os.Getenv("container") != "" {
+ Skip("Overlay mounts not supported when running in a container")
+ }
+ if rootless.IsRootless() {
+ if _, err := exec.LookPath("fuse_overlay"); err != nil {
+ Skip("Fuse-Overlayfs required for rootless overlay mount test")
+ }
+ }
+ mountPath := filepath.Join(podmanTest.TempDir, "secrets")
+ os.Mkdir(mountPath, 0755)
+ testFile := filepath.Join(mountPath, "test1")
+ f, err := os.Create(testFile)
+ f.Close()
+
+ // Make sure host directory gets mounted in to container as overlay
+ session := podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/run/test:O", mountPath), ALPINE, "grep", "/run/test", "/proc/self/mountinfo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ found, matches := session.GrepString("/run/test")
+ Expect(found).Should(BeTrue())
+ Expect(matches[0]).To(ContainSubstring("overlay"))
+
+ // Make sure host files show up in the container
+ session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/run/test:O", mountPath), ALPINE, "ls", "/run/test/test1"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Make sure modifications in container do not show up on host
+ session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:/run/test:O", mountPath), ALPINE, "touch", "/run/test/container"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ _, err = os.Stat(filepath.Join(mountPath, "container"))
+ Expect(err).To(Not(BeNil()))
+
+ // Make sure modifications in container disappear when container is stopped
+ session = podmanTest.Podman([]string{"create", "-d", "-v", fmt.Sprintf("%s:/run/test:O", mountPath), ALPINE, "top"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"start", "-l"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"exec", "-l", "touch", "/run/test/container"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"exec", "-l", "ls", "/run/test/container"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"stop", "-l"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"start", "-l"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"exec", "-l", "ls", "/run/test/container"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+ })
+
+ It("overlay volume conflicts with named volume and mounts", func() {
+ mountPath := filepath.Join(podmanTest.TempDir, "secrets")
+ os.Mkdir(mountPath, 0755)
+ testFile := filepath.Join(mountPath, "test1")
+ f, err := os.Create(testFile)
+ Expect(err).To(BeNil())
+ f.Close()
+ mountSrc := filepath.Join(podmanTest.TempDir, "vol-test1")
+ err = os.MkdirAll(mountSrc, 0755)
+ Expect(err).To(BeNil())
+ mountDest := "/run/test"
+ volName := "myvol"
+
+ session := podmanTest.Podman([]string{"volume", "create", volName})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // overlay and named volume destinations conflict
+ session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:%s:O", mountPath, mountDest), "-v", fmt.Sprintf("%s:%s", volName, mountDest), ALPINE})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+ // overlay and bind mount destinations conflict
+ session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:%s:O", mountPath, mountDest), "--mount", fmt.Sprintf("type=bind,src=%s,target=%s", mountSrc, mountDest), ALPINE})
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+ // overlay and tmpfs mount destinations conflict
+ session = podmanTest.Podman([]string{"run", "--rm", "-v", fmt.Sprintf("%s:%s:O", mountPath, mountDest), "--mount", fmt.Sprintf("type=tmpfs,target=%s", mountDest), ALPINE})
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+ })
})
diff --git a/test/system/015-help.bats b/test/system/015-help.bats
index 3d05b44fe..76d29d22c 100644
--- a/test/system/015-help.bats
+++ b/test/system/015-help.bats
@@ -78,7 +78,8 @@ function check_help() {
if ! expr "$usage" : '.*[A-Z]' >/dev/null; then
if [ "$cmd" != "help" ]; then
dprint "$command_string invalid-arg"
- run_podman 125 "$@" $cmd invalid-arg
+ run_podman '?' "$@" $cmd invalid-arg
+ is "$status" 125 "'$command_string invalid-arg' - exit status"
is "$output" "Error: .* takes no arguments" \
"'$command_string' with extra (invalid) arguments"
fi
@@ -104,7 +105,8 @@ function check_help() {
# The </dev/null protects us from 'podman login' which will
# try to read username/password from stdin.
dprint "$command_string (without required args)"
- run_podman 125 "$@" $cmd </dev/null
+ run_podman '?' "$@" $cmd </dev/null
+ is "$status" 125 "'$command_string' with no arguments - exit status"
is "$output" "Error:.* \(require\|specif\|must\|provide\|need\|choose\|accepts\)" \
"'$command_string' without required arg"
@@ -126,7 +128,8 @@ function check_help() {
local rhs=$(sed -e 's/^[^A-Z]\+[A-Z]/X/' -e 's/ | /-or-/g' <<<"$usage")
local n_args=$(wc -w <<<"$rhs")
- run_podman 125 "$@" $cmd $(seq --format='x%g' 0 $n_args)
+ run_podman '?' "$@" $cmd $(seq --format='x%g' 0 $n_args)
+ is "$status" 125 "'$command_string' with >$n_args arguments - exit status"
is "$output" "Error:.* \(takes no arguments\|requires exactly $n_args arg\|accepts at most\|too many arguments\|accepts $n_args arg(s), received\|accepts between .* and .* arg(s), received \)" \
"'$command_string' with >$n_args arguments"
@@ -140,13 +143,17 @@ function check_help() {
# Any command that takes subcommands, must throw error if called
# without one.
dprint "podman $@"
- run_podman 125 "$@"
- is "$output" "Error: missing command .*$@ COMMAND"
+ run_podman '?' "$@"
+ is "$status" 125 "'podman $*' without any subcommand - exit status"
+ is "$output" "Error: missing command .*$@ COMMAND" \
+ "'podman $*' without any subcommand - expected error message"
# Assume that 'NoSuchCommand' is not a command
dprint "podman $@ NoSuchCommand"
- run_podman 125 "$@" NoSuchCommand
- is "$output" "Error: unrecognized command .*$@ NoSuchCommand"
+ run_podman '?' "$@" NoSuchCommand
+ is "$status" 125 "'podman $* NoSuchCommand' - exit status"
+ is "$output" "Error: unrecognized command .*$@ NoSuchCommand" \
+ "'podman $* NoSuchCommand' - expected error message"
# This can happen if the output of --help changes, such as between
# the old command parser and cobra.
diff --git a/test/system/helpers.bash b/test/system/helpers.bash
index 4239ef876..abca91739 100644
--- a/test/system/helpers.bash
+++ b/test/system/helpers.bash
@@ -404,7 +404,13 @@ function find_exec_pid_files() {
#
# This obviously screws us up when we look at output results.
#
-# This function removes the warning from $output and $lines
+# This function removes the warning from $output and $lines. We don't
+# do a full string match because there's another variant of that message:
+#
+# WARNING: Creating device "/dev/null" with same type, major and minor as existing "/dev/foodevdir/null".
+#
+# (We should never again see that precise error ever again, but we could
+# see variants of it).
#
function remove_same_dev_warning() {
# No input arguments. We operate in-place on $output and $lines
@@ -412,7 +418,7 @@ function remove_same_dev_warning() {
local i=0
local -a new_lines=()
while [[ $i -lt ${#lines[@]} ]]; do
- if expr "${lines[$i]}" : 'WARNING: .* same type, major.* multiple' >/dev/null; then
+ if expr "${lines[$i]}" : 'WARNING: .* same type, major' >/dev/null; then
:
else
new_lines+=("${lines[$i]}")