summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/attach_test.go5
-rw-r--r--test/e2e/checkpoint_test.go172
-rw-r--r--test/e2e/commit_test.go5
-rw-r--r--test/e2e/create_staticip_test.go88
-rw-r--r--test/e2e/create_test.go95
-rw-r--r--test/e2e/diff_test.go5
-rw-r--r--test/e2e/exec_test.go5
-rw-r--r--test/e2e/exists_test.go117
-rw-r--r--test/e2e/export_test.go5
-rw-r--r--test/e2e/generate_kube_test.go106
-rw-r--r--test/e2e/history_test.go5
-rw-r--r--test/e2e/images_test.go9
-rw-r--r--test/e2e/import_test.go5
-rw-r--r--test/e2e/info_test.go5
-rw-r--r--test/e2e/inspect_test.go5
-rw-r--r--test/e2e/kill_test.go5
-rw-r--r--test/e2e/libpod_suite_test.go488
-rw-r--r--test/e2e/load_test.go9
-rw-r--r--test/e2e/logs_test.go5
-rw-r--r--test/e2e/mount_test.go5
-rw-r--r--test/e2e/namespace_test.go5
-rw-r--r--test/e2e/pause_test.go24
-rw-r--r--test/e2e/pod_create_test.go44
-rw-r--r--test/e2e/pod_infra_container_test.go5
-rw-r--r--test/e2e/pod_inspect_test.go5
-rw-r--r--test/e2e/pod_kill_test.go5
-rw-r--r--test/e2e/pod_pause_test.go5
-rw-r--r--test/e2e/pod_pod_namespaces.go5
-rw-r--r--test/e2e/pod_ps_test.go5
-rw-r--r--test/e2e/pod_restart_test.go5
-rw-r--r--test/e2e/pod_rm_test.go5
-rw-r--r--test/e2e/pod_start_test.go5
-rw-r--r--test/e2e/pod_stats_test.go5
-rw-r--r--test/e2e/pod_stop_test.go5
-rw-r--r--test/e2e/pod_top_test.go5
-rw-r--r--test/e2e/port_test.go5
-rw-r--r--test/e2e/prune_test.go88
-rw-r--r--test/e2e/ps_test.go5
-rw-r--r--test/e2e/pull_test.go13
-rw-r--r--test/e2e/push_test.go45
-rw-r--r--test/e2e/refresh_test.go13
-rw-r--r--test/e2e/restart_test.go7
-rw-r--r--test/e2e/rm_test.go5
-rw-r--r--test/e2e/rmi_test.go26
-rw-r--r--test/e2e/rootless_test.go33
-rw-r--r--test/e2e/run_cgroup_parent_test.go11
-rw-r--r--test/e2e/run_cleanup_test.go9
-rw-r--r--test/e2e/run_cpu_test.go5
-rw-r--r--test/e2e/run_device_test.go5
-rw-r--r--test/e2e/run_dns_test.go5
-rw-r--r--test/e2e/run_entrypoint_test.go5
-rw-r--r--test/e2e/run_exit_test.go5
-rw-r--r--test/e2e/run_memory_test.go5
-rw-r--r--test/e2e/run_networking_test.go44
-rw-r--r--test/e2e/run_ns_test.go11
-rw-r--r--test/e2e/run_passwd_test.go5
-rw-r--r--test/e2e/run_privileged_test.go17
-rw-r--r--test/e2e/run_restart_test.go7
-rw-r--r--test/e2e/run_selinux_test.go5
-rw-r--r--test/e2e/run_signal_test.go23
-rw-r--r--test/e2e/run_staticip_test.go16
-rw-r--r--test/e2e/run_test.go77
-rw-r--r--test/e2e/run_userns_test.go5
-rw-r--r--test/e2e/runlabel_test.go5
-rw-r--r--test/e2e/save_test.go5
-rw-r--r--test/e2e/search_test.go19
-rw-r--r--test/e2e/start_test.go31
-rw-r--r--test/e2e/stats_test.go5
-rw-r--r--test/e2e/stop_test.go19
-rw-r--r--test/e2e/systemd_test.go81
-rw-r--r--test/e2e/tag_test.go5
-rw-r--r--test/e2e/top_test.go5
-rw-r--r--test/e2e/trust_test.go72
-rw-r--r--test/e2e/version_test.go5
-rw-r--r--test/e2e/volume_create_test.go60
-rw-r--r--test/e2e/volume_inspect_test.go77
-rw-r--r--test/e2e/volume_ls_test.go84
-rw-r--r--test/e2e/volume_prune_test.go64
-rw-r--r--test/e2e/volume_rm_test.go91
-rw-r--r--test/e2e/wait_test.go5
80 files changed, 1759 insertions, 651 deletions
diff --git a/test/e2e/attach_test.go b/test/e2e/attach_test.go
index 245ccf649..6bc576461 100644
--- a/test/e2e/attach_test.go
+++ b/test/e2e/attach_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman attach", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman attach", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go
index 928a76324..57322643e 100644
--- a/test/e2e/checkpoint_test.go
+++ b/test/e2e/checkpoint_test.go
@@ -2,9 +2,12 @@ package integration
import (
"fmt"
+ "net"
"os"
+ "strconv"
"github.com/containers/libpod/pkg/criu"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -13,7 +16,7 @@ var _ = Describe("Podman checkpoint", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,11 +24,16 @@ var _ = Describe("Podman checkpoint", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
if !criu.CheckForCriu() {
Skip("CRIU is missing or too old.")
}
+ hostInfo := podmanTest.Host
+ hostDistVer, _ := strconv.Atoi(hostInfo.Version)
+ if hostInfo.Distribution == "fedora" && hostDistVer <= 29 {
+ Skip("Checkpoint tests appear to fail on older (<30) Fedora versions .")
+ }
})
AfterEach(func() {
@@ -125,4 +133,164 @@ var _ = Describe("Podman checkpoint", func() {
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
})
+
+ It("podman checkpoint latest running container", func() {
+ session1 := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "--name", "first", "-d", ALPINE, "top"})
+ session1.WaitWithDefaultTimeout()
+ Expect(session1.ExitCode()).To(Equal(0))
+
+ session2 := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "--name", "second", "-d", ALPINE, "top"})
+ session2.WaitWithDefaultTimeout()
+ Expect(session2.ExitCode()).To(Equal(0))
+
+ result := podmanTest.Podman([]string{"container", "checkpoint", "-l"})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+
+ ps := podmanTest.Podman([]string{"ps", "-q", "--no-trunc"})
+ ps.WaitWithDefaultTimeout()
+ Expect(ps.ExitCode()).To(Equal(0))
+ Expect(ps.LineInOutputContains(session1.OutputToString())).To(BeTrue())
+ Expect(ps.LineInOutputContains(session2.OutputToString())).To(BeFalse())
+
+ result = podmanTest.Podman([]string{"container", "restore", "-l"})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
+ Expect(podmanTest.GetContainerStatus()).To(Not(ContainSubstring("Exited")))
+
+ result = podmanTest.Podman([]string{"rm", "-fa"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ })
+
+ It("podman checkpoint all running container", func() {
+ session1 := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "--name", "first", "-d", ALPINE, "top"})
+ session1.WaitWithDefaultTimeout()
+ Expect(session1.ExitCode()).To(Equal(0))
+
+ session2 := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "--name", "second", "-d", ALPINE, "top"})
+ session2.WaitWithDefaultTimeout()
+ Expect(session2.ExitCode()).To(Equal(0))
+
+ result := podmanTest.Podman([]string{"container", "checkpoint", "-a"})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+
+ ps := podmanTest.Podman([]string{"ps", "-q", "--no-trunc"})
+ ps.WaitWithDefaultTimeout()
+ Expect(ps.ExitCode()).To(Equal(0))
+ Expect(ps.LineInOutputContains(session1.OutputToString())).To(BeFalse())
+ Expect(ps.LineInOutputContains(session2.OutputToString())).To(BeFalse())
+
+ result = podmanTest.Podman([]string{"container", "restore", "-a"})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
+ Expect(podmanTest.GetContainerStatus()).To(Not(ContainSubstring("Exited")))
+
+ result = podmanTest.Podman([]string{"rm", "-fa"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ })
+
+ It("podman checkpoint container with established tcp connections", func() {
+ Skip("Seems to not work (yet) in CI")
+ podmanTest.RestoreArtifact(redis)
+ session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "--network", "host", "-d", redis})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Open a network connection to the redis server
+ conn, err := net.Dial("tcp", "127.0.0.1:6379")
+ if err != nil {
+ os.Exit(1)
+ }
+ // This should fail as the container has established TCP connections
+ result := podmanTest.Podman([]string{"container", "checkpoint", "-l"})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(125))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
+
+ // Now it should work thanks to "--tcp-established"
+ result = podmanTest.Podman([]string{"container", "checkpoint", "-l", "--tcp-established"})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Exited"))
+
+ // Restore should fail as the checkpoint image contains established TCP connections
+ result = podmanTest.Podman([]string{"container", "restore", "-l"})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(125))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Exited"))
+
+ // Now it should work thanks to "--tcp-established"
+ result = podmanTest.Podman([]string{"container", "restore", "-l", "--tcp-established"})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
+
+ result = podmanTest.Podman([]string{"rm", "-fa"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+
+ conn.Close()
+ })
+
+ It("podman checkpoint with --leave-running", func() {
+ session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "seccomp=unconfined", "-d", ALPINE, "top"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ cid := session.OutputToString()
+
+ // Checkpoint container, but leave it running
+ result := podmanTest.Podman([]string{"container", "checkpoint", "--leave-running", cid})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ // Make sure it is still running
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
+
+ // Stop the container
+ result = podmanTest.Podman([]string{"container", "stop", cid})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Exited"))
+
+ // Restore the stopped container from the previous checkpoint
+ result = podmanTest.Podman([]string{"container", "restore", cid})
+ result.WaitWithDefaultTimeout()
+
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up"))
+
+ result = podmanTest.Podman([]string{"rm", "-fa"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ })
+
})
diff --git a/test/e2e/commit_test.go b/test/e2e/commit_test.go
index c0e050da4..4ee5061f0 100644
--- a/test/e2e/commit_test.go
+++ b/test/e2e/commit_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman commit", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman commit", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/create_staticip_test.go b/test/e2e/create_staticip_test.go
new file mode 100644
index 000000000..17ac5cb40
--- /dev/null
+++ b/test/e2e/create_staticip_test.go
@@ -0,0 +1,88 @@
+package integration
+
+import (
+ "fmt"
+ "os"
+
+ . "github.com/containers/libpod/test/utils"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Podman create with --ip flag", func() {
+ var (
+ tempdir string
+ err error
+ podmanTest *PodmanTestIntegration
+ )
+
+ BeforeEach(func() {
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanTestCreate(tempdir)
+ podmanTest.RestoreAllArtifacts()
+ // Cleanup the CNI networks used by the tests
+ os.RemoveAll("/var/lib/cni/networks/podman")
+ })
+
+ AfterEach(func() {
+ podmanTest.Cleanup()
+ f := CurrentGinkgoTestDescription()
+ timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds())
+ GinkgoWriter.Write([]byte(timedResult))
+ })
+
+ It("Podman create --ip with garbage address", func() {
+ result := podmanTest.Podman([]string{"create", "--name", "test", "--ip", "114232346", ALPINE, "ls"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).ToNot(Equal(0))
+ })
+
+ It("Podman create --ip with v6 address", func() {
+ result := podmanTest.Podman([]string{"create", "--name", "test", "--ip", "2001:db8:bad:beef::1", ALPINE, "ls"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).ToNot(Equal(0))
+ })
+
+ It("Podman create --ip with non-allocatable IP", func() {
+ result := podmanTest.Podman([]string{"create", "--name", "test", "--ip", "203.0.113.124", ALPINE, "ls"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+
+ result = podmanTest.Podman([]string{"start", "test"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).ToNot(Equal(0))
+ })
+
+ It("Podman create with specified static IP has correct IP", func() {
+ result := podmanTest.Podman([]string{"create", "--name", "test", "--ip", "10.88.64.128", ALPINE, "ip", "addr"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+
+ result = podmanTest.Podman([]string{"start", "test"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+
+ result = podmanTest.Podman([]string{"logs", "test"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(result.OutputToString()).To(ContainSubstring("10.88.64.128/16"))
+ })
+
+ It("Podman create two containers with the same IP", func() {
+ result := podmanTest.Podman([]string{"create", "--name", "test1", "--ip", "10.88.64.128", ALPINE, "sleep", "999"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ result = podmanTest.Podman([]string{"create", "--name", "test2", "--ip", "10.88.64.128", ALPINE, "ip", "addr"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ result = podmanTest.Podman([]string{"start", "test1"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ result = podmanTest.Podman([]string{"start", "test2"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).ToNot(Equal(0))
+ })
+})
diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go
index c36a8e31f..684a7cd88 100644
--- a/test/e2e/create_test.go
+++ b/test/e2e/create_test.go
@@ -3,7 +3,9 @@ package integration
import (
"fmt"
"os"
+ "path/filepath"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +14,7 @@ var _ = Describe("Podman create", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +22,7 @@ var _ = Describe("Podman create", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -109,4 +111,93 @@ var _ = Describe("Podman create", func() {
Expect(result.ExitCode()).To(Equal(0))
Expect(result.OutputToString()).To(Equal("/bin/foo -c"))
})
+
+ It("podman create --mount flag with multiple mounts", func() {
+ vol1 := filepath.Join(podmanTest.TempDir, "vol-test1")
+ err := os.MkdirAll(vol1, 0755)
+ Expect(err).To(BeNil())
+ vol2 := filepath.Join(podmanTest.TempDir, "vol-test2")
+ err = os.MkdirAll(vol2, 0755)
+ Expect(err).To(BeNil())
+
+ session := podmanTest.Podman([]string{"create", "--name", "test", "--mount", "type=bind,src=" + vol1 + ",target=/myvol1,z", "--mount", "type=bind,src=" + vol2 + ",target=/myvol2,z", ALPINE, "touch", "/myvol2/foo.txt"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"start", "test"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"logs", "test"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).ToNot(ContainSubstring("cannot touch"))
+ })
+
+ It("podman create with --mount flag", func() {
+ if podmanTest.Host.Arch == "ppc64le" {
+ Skip("skip failing test on ppc64le")
+ }
+ mountPath := filepath.Join(podmanTest.TempDir, "secrets")
+ os.Mkdir(mountPath, 0755)
+ session := podmanTest.Podman([]string{"create", "--name", "test", "--rm", "--mount", fmt.Sprintf("type=bind,src=%s,target=/create/test", mountPath), ALPINE, "grep", "/create/test", "/proc/self/mountinfo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"start", "test"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"logs", "test"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).To(ContainSubstring("/create/test rw"))
+
+ session = podmanTest.Podman([]string{"create", "--name", "test_ro", "--rm", "--mount", fmt.Sprintf("type=bind,src=%s,target=/create/test,ro", mountPath), ALPINE, "grep", "/create/test", "/proc/self/mountinfo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"start", "test_ro"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"logs", "test_ro"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).To(ContainSubstring("/create/test ro"))
+
+ session = podmanTest.Podman([]string{"create", "--name", "test_shared", "--rm", "--mount", fmt.Sprintf("type=bind,src=%s,target=/create/test,shared", mountPath), ALPINE, "grep", "/create/test", "/proc/self/mountinfo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"start", "test_shared"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"logs", "test_shared"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ found, matches := session.GrepString("/create/test")
+ Expect(found).Should(BeTrue())
+ Expect(matches[0]).To(ContainSubstring("rw"))
+ Expect(matches[0]).To(ContainSubstring("shared"))
+
+ mountPath = filepath.Join(podmanTest.TempDir, "scratchpad")
+ os.Mkdir(mountPath, 0755)
+ session = podmanTest.Podman([]string{"create", "--name", "test_tmpfs", "--rm", "--mount", "type=tmpfs,target=/create/test", ALPINE, "grep", "/create/test", "/proc/self/mountinfo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"start", "test_tmpfs"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"logs", "test_tmpfs"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).To(ContainSubstring("/create/test rw,nosuid,nodev,noexec,relatime - tmpfs"))
+ })
+
+ It("podman create --pod automatically", func() {
+ session := podmanTest.Podman([]string{"create", "--pod", "new:foobar", ALPINE, "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ check := podmanTest.Podman([]string{"pod", "ps", "--no-trunc"})
+ check.WaitWithDefaultTimeout()
+ match, _ := check.GrepString("foobar")
+ Expect(match).To(BeTrue())
+ })
})
diff --git a/test/e2e/diff_test.go b/test/e2e/diff_test.go
index a83bb14da..2c0060dd5 100644
--- a/test/e2e/diff_test.go
+++ b/test/e2e/diff_test.go
@@ -5,6 +5,7 @@ import (
"os"
"sort"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -13,7 +14,7 @@ var _ = Describe("Podman diff", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,7 +22,7 @@ var _ = Describe("Podman diff", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go
index 250e08704..fec80717f 100644
--- a/test/e2e/exec_test.go
+++ b/test/e2e/exec_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman exec", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman exec", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/exists_test.go b/test/e2e/exists_test.go
new file mode 100644
index 000000000..d9652de4b
--- /dev/null
+++ b/test/e2e/exists_test.go
@@ -0,0 +1,117 @@
+package integration
+
+import (
+ "fmt"
+ "os"
+
+ . "github.com/containers/libpod/test/utils"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Podman image|container exists", func() {
+ var (
+ tempdir string
+ err error
+ podmanTest *PodmanTestIntegration
+ )
+
+ BeforeEach(func() {
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanTestCreate(tempdir)
+ podmanTest.RestoreAllArtifacts()
+ })
+
+ AfterEach(func() {
+ podmanTest.Cleanup()
+ f := CurrentGinkgoTestDescription()
+ timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds())
+ GinkgoWriter.Write([]byte(timedResult))
+
+ })
+ It("podman image exists in local storage by fq name", func() {
+ session := podmanTest.Podman([]string{"image", "exists", ALPINE})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ })
+ It("podman image exists in local storage by short name", func() {
+ session := podmanTest.Podman([]string{"image", "exists", "alpine"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ })
+ It("podman image does not exist in local storage", func() {
+ session := podmanTest.Podman([]string{"image", "exists", "alpine9999"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(1))
+ })
+ It("podman container exists in local storage by name", func() {
+ setup := podmanTest.RunTopContainer("foobar")
+ setup.WaitWithDefaultTimeout()
+ Expect(setup.ExitCode()).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"container", "exists", "foobar"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ })
+ It("podman container exists in local storage by container ID", func() {
+ setup := podmanTest.RunTopContainer("")
+ setup.WaitWithDefaultTimeout()
+ Expect(setup.ExitCode()).To(Equal(0))
+ cid := setup.OutputToString()
+
+ session := podmanTest.Podman([]string{"container", "exists", cid})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ })
+ It("podman container exists in local storage by short container ID", func() {
+ setup := podmanTest.RunTopContainer("")
+ setup.WaitWithDefaultTimeout()
+ Expect(setup.ExitCode()).To(Equal(0))
+ cid := setup.OutputToString()[0:12]
+
+ session := podmanTest.Podman([]string{"container", "exists", cid})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ })
+ It("podman container does not exist in local storage", func() {
+ session := podmanTest.Podman([]string{"container", "exists", "foobar"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(1))
+ })
+
+ It("podman pod exists in local storage by name", func() {
+ setup, rc, _ := podmanTest.CreatePod("foobar")
+ setup.WaitWithDefaultTimeout()
+ Expect(rc).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"pod", "exists", "foobar"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ })
+ It("podman pod exists in local storage by container ID", func() {
+ setup, rc, podID := podmanTest.CreatePod("")
+ setup.WaitWithDefaultTimeout()
+ Expect(rc).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"pod", "exists", podID})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ })
+ It("podman pod exists in local storage by short container ID", func() {
+ setup, rc, podID := podmanTest.CreatePod("")
+ setup.WaitWithDefaultTimeout()
+ Expect(rc).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"pod", "exists", podID[0:12]})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ })
+ It("podman pod does not exist in local storage", func() {
+ session := podmanTest.Podman([]string{"pod", "exists", "foobar"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(1))
+ })
+})
diff --git a/test/e2e/export_test.go b/test/e2e/export_test.go
index c11fd777b..42ea45041 100644
--- a/test/e2e/export_test.go
+++ b/test/e2e/export_test.go
@@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -13,7 +14,7 @@ var _ = Describe("Podman export", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,7 +22,7 @@ var _ = Describe("Podman export", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go
new file mode 100644
index 000000000..0ee078455
--- /dev/null
+++ b/test/e2e/generate_kube_test.go
@@ -0,0 +1,106 @@
+package integration
+
+import (
+ "fmt"
+ "os"
+
+ . "github.com/containers/libpod/test/utils"
+ "github.com/ghodss/yaml"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Podman generate kube", func() {
+ var (
+ tempdir string
+ err error
+ podmanTest *PodmanTestIntegration
+ )
+
+ BeforeEach(func() {
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanTestCreate(tempdir)
+ podmanTest.RestoreAllArtifacts()
+ })
+
+ AfterEach(func() {
+ podmanTest.Cleanup()
+ f := CurrentGinkgoTestDescription()
+ timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds())
+ GinkgoWriter.Write([]byte(timedResult))
+
+ })
+
+ It("podman generate pod kube on bogus object", func() {
+ session := podmanTest.Podman([]string{"generate", "kube", "foobar"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+ })
+
+ It("podman generate service kube on bogus object", func() {
+ session := podmanTest.Podman([]string{"generate", "kube", "-s", "foobar"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+ })
+
+ It("podman generate kube on container", func() {
+ session := podmanTest.RunTopContainer("top")
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ kube := podmanTest.Podman([]string{"generate", "kube", "top"})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ _, err := yaml.Marshal(kube.OutputToString())
+ Expect(err).To(BeNil())
+ })
+
+ It("podman generate service kube on container", func() {
+ session := podmanTest.RunTopContainer("top")
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ kube := podmanTest.Podman([]string{"generate", "kube", "-s", "top"})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ _, err := yaml.Marshal(kube.OutputToString())
+ Expect(err).To(BeNil())
+ })
+
+ It("podman generate kube on pod", func() {
+ _, rc, _ := podmanTest.CreatePod("toppod")
+ Expect(rc).To(Equal(0))
+
+ session := podmanTest.RunTopContainerInPod("topcontainer", "toppod")
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ kube := podmanTest.Podman([]string{"generate", "kube", "toppod"})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ _, err := yaml.Marshal(kube.OutputToString())
+ Expect(err).To(BeNil())
+ })
+
+ It("podman generate service kube on pod", func() {
+ _, rc, _ := podmanTest.CreatePod("toppod")
+ Expect(rc).To(Equal(0))
+
+ session := podmanTest.RunTopContainerInPod("topcontainer", "toppod")
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ kube := podmanTest.Podman([]string{"generate", "kube", "-s", "toppod"})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ _, err := yaml.Marshal(kube.OutputToString())
+ Expect(err).To(BeNil())
+ })
+})
diff --git a/test/e2e/history_test.go b/test/e2e/history_test.go
index d4b5ad5c0..9bec9ad13 100644
--- a/test/e2e/history_test.go
+++ b/test/e2e/history_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman history", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman history", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go
index a8854d08d..af32c032b 100644
--- a/test/e2e/images_test.go
+++ b/test/e2e/images_test.go
@@ -5,6 +5,7 @@ import (
"os"
"sort"
+ . "github.com/containers/libpod/test/utils"
"github.com/docker/go-units"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -14,7 +15,7 @@ var _ = Describe("Podman images", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -22,7 +23,7 @@ var _ = Describe("Podman images", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -62,6 +63,10 @@ var _ = Describe("Podman images", func() {
session.LineInOutputContainsTag("foo", "c")
session.LineInOutputContainsTag("bar", "a")
session.LineInOutputContainsTag("bar", "b")
+ session = podmanTest.Podman([]string{"images", "-qn"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(BeNumerically("==", 2))
})
It("podman images with digests", func() {
diff --git a/test/e2e/import_test.go b/test/e2e/import_test.go
index 80773cf8b..9ed4593c6 100644
--- a/test/e2e/import_test.go
+++ b/test/e2e/import_test.go
@@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -13,7 +14,7 @@ var _ = Describe("Podman import", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,7 +22,7 @@ var _ = Describe("Podman import", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/info_test.go b/test/e2e/info_test.go
index dd8645223..e972c86c8 100644
--- a/test/e2e/info_test.go
+++ b/test/e2e/info_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman Info", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman Info", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
})
AfterEach(func() {
diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go
index bff56189e..87c4db935 100644
--- a/test/e2e/inspect_test.go
+++ b/test/e2e/inspect_test.go
@@ -5,6 +5,7 @@ import (
"os"
"strings"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -13,7 +14,7 @@ var _ = Describe("Podman inspect", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,7 +22,7 @@ var _ = Describe("Podman inspect", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/kill_test.go b/test/e2e/kill_test.go
index fdf42f2b6..913a843cb 100644
--- a/test/e2e/kill_test.go
+++ b/test/e2e/kill_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman kill", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman kill", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go
index ec274cc34..d312124ab 100644
--- a/test/e2e/libpod_suite_test.go
+++ b/test/e2e/libpod_suite_test.go
@@ -1,22 +1,18 @@
package integration
import (
- "bufio"
- "context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
- "runtime"
"strings"
"testing"
- "time"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/inspect"
- "github.com/containers/storage/pkg/parsers/kernel"
+ . "github.com/containers/libpod/test/utils"
"github.com/containers/storage/pkg/reexec"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -35,14 +31,9 @@ var (
defaultWaitTimeout = 90
)
-// PodmanSession wrapps the gexec.session so we can extend it
-type PodmanSession struct {
- *gexec.Session
-}
-
-// PodmanTest struct for command line options
-type PodmanTest struct {
- PodmanBinary string
+// PodmanTestIntegration struct for command line options
+type PodmanTestIntegration struct {
+ PodmanTest
ConmonBinary string
CrioRoot string
CNIConfigDir string
@@ -50,17 +41,13 @@ type PodmanTest struct {
RunRoot string
StorageOptions string
SignaturePolicyPath string
- ArtifactPath string
- TempDir string
CgroupManager string
Host HostOS
}
-// HostOS is a simple struct for the test os
-type HostOS struct {
- Distribution string
- Version string
- Arch string
+// PodmanSessionIntegration sturct for command line session
+type PodmanSessionIntegration struct {
+ *PodmanSession
}
// TestLibpod ginkgo master function
@@ -80,7 +67,7 @@ var _ = BeforeSuite(func() {
//Cache images
cwd, _ := os.Getwd()
INTEGRATION_ROOT = filepath.Join(cwd, "../../")
- podman := PodmanCreate("/tmp")
+ podman := PodmanTestCreate("/tmp")
podman.ArtifactPath = ARTIFACT_DIR
if _, err := os.Stat(ARTIFACT_DIR); os.IsNotExist(err) {
if err = os.Mkdir(ARTIFACT_DIR, 0777); err != nil {
@@ -110,13 +97,8 @@ var _ = BeforeSuite(func() {
}
})
-// CreateTempDirin
-func CreateTempDirInTempDir() (string, error) {
- return ioutil.TempDir("", "podman_test")
-}
-
-// PodmanCreate creates a PodmanTest instance for the tests
-func PodmanCreate(tempDir string) PodmanTest {
+// PodmanTestCreate creates a PodmanTestIntegration instance for the tests
+func PodmanTestCreate(tempDir string) *PodmanTestIntegration {
host := GetHostDistributionInfo()
cwd, _ := os.Getwd()
@@ -127,7 +109,7 @@ func PodmanCreate(tempDir string) PodmanTest {
}
conmonBinary := filepath.Join("/usr/libexec/podman/conmon")
altConmonBinary := "/usr/libexec/crio/conmon"
- if _, err := os.Stat(altConmonBinary); err == nil {
+ if _, err := os.Stat(conmonBinary); os.IsNotExist(err) {
conmonBinary = altConmonBinary
}
if os.Getenv("CONMON_BINARY") != "" {
@@ -157,8 +139,12 @@ func PodmanCreate(tempDir string) PodmanTest {
CNIConfigDir := "/etc/cni/net.d"
- p := PodmanTest{
- PodmanBinary: podmanBinary,
+ p := &PodmanTestIntegration{
+ PodmanTest: PodmanTest{
+ PodmanBinary: podmanBinary,
+ ArtifactPath: ARTIFACT_DIR,
+ TempDir: tempDir,
+ },
ConmonBinary: conmonBinary,
CrioRoot: filepath.Join(tempDir, "crio"),
CNIConfigDir: CNIConfigDir,
@@ -166,73 +152,56 @@ func PodmanCreate(tempDir string) PodmanTest {
RunRoot: filepath.Join(tempDir, "crio-run"),
StorageOptions: storageOptions,
SignaturePolicyPath: filepath.Join(INTEGRATION_ROOT, "test/policy.json"),
- ArtifactPath: ARTIFACT_DIR,
- TempDir: tempDir,
CgroupManager: cgroupManager,
Host: host,
}
// Setup registries.conf ENV variable
p.setDefaultRegistriesConfigEnv()
+ // Rewrite the PodmanAsUser function
+ p.PodmanMakeOptions = p.makeOptions
return p
}
//MakeOptions assembles all the podman main options
-func (p *PodmanTest) MakeOptions() []string {
- return strings.Split(fmt.Sprintf("--root %s --runroot %s --runtime %s --conmon %s --cni-config-dir %s --cgroup-manager %s",
+func (p *PodmanTestIntegration) makeOptions(args []string) []string {
+ podmanOptions := strings.Split(fmt.Sprintf("--root %s --runroot %s --runtime %s --conmon %s --cni-config-dir %s --cgroup-manager %s",
p.CrioRoot, p.RunRoot, p.RunCBinary, p.ConmonBinary, p.CNIConfigDir, p.CgroupManager), " ")
-}
-
-// Podman is the exec call to podman on the filesystem, uid and gid the credentials to use
-func (p *PodmanTest) PodmanAsUser(args []string, uid, gid uint32, env []string) *PodmanSession {
- podmanOptions := p.MakeOptions()
if os.Getenv("HOOK_OPTION") != "" {
podmanOptions = append(podmanOptions, os.Getenv("HOOK_OPTION"))
}
podmanOptions = append(podmanOptions, strings.Split(p.StorageOptions, " ")...)
podmanOptions = append(podmanOptions, args...)
- if env == nil {
- fmt.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " "))
- } else {
- fmt.Printf("Running: (env: %v) %s %s\n", env, p.PodmanBinary, strings.Join(podmanOptions, " "))
- }
- var command *exec.Cmd
-
- if uid != 0 || gid != 0 {
- nsEnterOpts := append([]string{"--userspec", fmt.Sprintf("%d:%d", uid, gid), "/", p.PodmanBinary}, podmanOptions...)
- command = exec.Command("chroot", nsEnterOpts...)
- } else {
- command = exec.Command(p.PodmanBinary, podmanOptions...)
- }
- if env != nil {
- command.Env = env
- }
-
- session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
- if err != nil {
- Fail(fmt.Sprintf("unable to run podman command: %s\n%v", strings.Join(podmanOptions, " "), err))
- }
- return &PodmanSession{session}
+ return podmanOptions
}
// Podman is the exec call to podman on the filesystem
-func (p *PodmanTest) Podman(args []string) *PodmanSession {
- return p.PodmanAsUser(args, 0, 0, nil)
+func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration {
+ podmanSession := p.PodmanBase(args)
+ return &PodmanSessionIntegration{podmanSession}
}
-//WaitForContainer waits on a started container
-func WaitForContainer(p *PodmanTest) bool {
- for i := 0; i < 10; i++ {
- if p.NumberOfRunningContainers() == 1 {
- return true
- }
- time.Sleep(1 * time.Second)
+// PodmanAsUser is the exec call to podman on the filesystem with the specified uid/gid and environment
+func (p *PodmanTestIntegration) PodmanAsUser(args []string, uid, gid uint32, env []string) *PodmanSessionIntegration {
+ podmanSession := p.PodmanAsUserBase(args, uid, gid, env)
+ return &PodmanSessionIntegration{podmanSession}
+}
+
+// PodmanPID execs podman and returns its PID
+func (p *PodmanTestIntegration) PodmanPID(args []string) (*PodmanSessionIntegration, int) {
+ podmanOptions := p.MakeOptions(args)
+ fmt.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " "))
+ command := exec.Command(p.PodmanBinary, podmanOptions...)
+ session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
+ if err != nil {
+ Fail(fmt.Sprintf("unable to run podman command: %s", strings.Join(podmanOptions, " ")))
}
- return false
+ podmanSession := &PodmanSession{session}
+ return &PodmanSessionIntegration{podmanSession}, command.Process.Pid
}
// Cleanup cleans up the temporary store
-func (p *PodmanTest) Cleanup() {
+func (p *PodmanTestIntegration) Cleanup() {
// Remove all containers
stopall := p.Podman([]string{"stop", "-a", "--timeout", "0"})
stopall.WaitWithDefaultTimeout()
@@ -248,7 +217,7 @@ func (p *PodmanTest) Cleanup() {
}
// CleanupPod cleans up the temporary store
-func (p *PodmanTest) CleanupPod() {
+func (p *PodmanTestIntegration) CleanupPod() {
// Remove all containers
session := p.Podman([]string{"pod", "rm", "-fa"})
session.Wait(90)
@@ -258,103 +227,37 @@ func (p *PodmanTest) CleanupPod() {
}
}
-// GrepString takes session output and behaves like grep. it returns a bool
-// if successful and an array of strings on positive matches
-func (s *PodmanSession) GrepString(term string) (bool, []string) {
- var (
- greps []string
- matches bool
- )
-
- for _, line := range strings.Split(s.OutputToString(), "\n") {
- if strings.Contains(line, term) {
- matches = true
- greps = append(greps, line)
- }
+// CleanupVolume cleans up the temporary store
+func (p *PodmanTestIntegration) CleanupVolume() {
+ // Remove all containers
+ session := p.Podman([]string{"volume", "rm", "-fa"})
+ session.Wait(90)
+ // Nuke tempdir
+ if err := os.RemoveAll(p.TempDir); err != nil {
+ fmt.Printf("%q\n", err)
}
- return matches, greps
}
-// Pull Images pulls multiple images
-func (p *PodmanTest) PullImages(images []string) error {
+// PullImages pulls multiple images
+func (p *PodmanTestIntegration) PullImages(images []string) error {
for _, i := range images {
p.PullImage(i)
}
return nil
}
-// Pull Image a single image
+// PullImage pulls a single image
// TODO should the timeout be configurable?
-func (p *PodmanTest) PullImage(image string) error {
+func (p *PodmanTestIntegration) PullImage(image string) error {
session := p.Podman([]string{"pull", image})
session.Wait(60)
Expect(session.ExitCode()).To(Equal(0))
return nil
}
-// OutputToString formats session output to string
-func (s *PodmanSession) OutputToString() string {
- fields := strings.Fields(fmt.Sprintf("%s", s.Out.Contents()))
- return strings.Join(fields, " ")
-}
-
-// OutputToStringArray returns the output as a []string
-// where each array item is a line split by newline
-func (s *PodmanSession) OutputToStringArray() []string {
- var results []string
- output := fmt.Sprintf("%s", s.Out.Contents())
- for _, line := range strings.Split(output, "\n") {
- if line != "" {
- results = append(results, line)
- }
- }
- return results
-}
-
-// ErrorGrepString takes session stderr output and behaves like grep. it returns a bool
-// if successful and an array of strings on positive matches
-func (s *PodmanSession) ErrorGrepString(term string) (bool, []string) {
- var (
- greps []string
- matches bool
- )
-
- for _, line := range strings.Split(s.ErrorToString(), "\n") {
- if strings.Contains(line, term) {
- matches = true
- greps = append(greps, line)
- }
- }
- return matches, greps
-}
-
-// ErrorToString formats session stderr to string
-func (s *PodmanSession) ErrorToString() string {
- fields := strings.Fields(fmt.Sprintf("%s", s.Err.Contents()))
- return strings.Join(fields, " ")
-}
-
-// ErrorToStringArray returns the stderr output as a []string
-// where each array item is a line split by newline
-func (s *PodmanSession) ErrorToStringArray() []string {
- output := fmt.Sprintf("%s", s.Err.Contents())
- return strings.Split(output, "\n")
-}
-
-// IsJSONOutputValid attempts to unmarshal the session buffer
-// and if successful, returns true, else false
-func (s *PodmanSession) IsJSONOutputValid() bool {
- var i interface{}
- if err := json.Unmarshal(s.Out.Contents(), &i); err != nil {
- fmt.Println(err)
- return false
- }
- return true
-}
-
// InspectContainerToJSON takes the session output of an inspect
// container and returns json
-func (s *PodmanSession) InspectContainerToJSON() []inspect.ContainerData {
+func (s *PodmanSessionIntegration) InspectContainerToJSON() []inspect.ContainerData {
var i []inspect.ContainerData
err := json.Unmarshal(s.Out.Contents(), &i)
Expect(err).To(BeNil())
@@ -362,7 +265,7 @@ func (s *PodmanSession) InspectContainerToJSON() []inspect.ContainerData {
}
// InspectPodToJSON takes the sessions output from a pod inspect and returns json
-func (s *PodmanSession) InspectPodToJSON() libpod.PodInspect {
+func (s *PodmanSessionIntegration) InspectPodToJSON() libpod.PodInspect {
var i libpod.PodInspect
err := json.Unmarshal(s.Out.Contents(), &i)
Expect(err).To(BeNil())
@@ -371,30 +274,15 @@ func (s *PodmanSession) InspectPodToJSON() libpod.PodInspect {
// InspectImageJSON takes the session output of an inspect
// image and returns json
-func (s *PodmanSession) InspectImageJSON() []inspect.ImageData {
+func (s *PodmanSessionIntegration) InspectImageJSON() []inspect.ImageData {
var i []inspect.ImageData
err := json.Unmarshal(s.Out.Contents(), &i)
Expect(err).To(BeNil())
return i
}
-func (s *PodmanSession) WaitWithDefaultTimeout() {
- s.Wait(defaultWaitTimeout)
- fmt.Println("output:", s.OutputToString())
-}
-
-// SystemExec is used to exec a system command to check its exit code or output
-func (p *PodmanTest) SystemExec(command string, args []string) *PodmanSession {
- c := exec.Command(command, args...)
- session, err := gexec.Start(c, GinkgoWriter, GinkgoWriter)
- if err != nil {
- Fail(fmt.Sprintf("unable to run command: %s %s", command, strings.Join(args, " ")))
- }
- return &PodmanSession{session}
-}
-
// CreateArtifact creates a cached image in the artifact dir
-func (p *PodmanTest) CreateArtifact(image string) error {
+func (p *PodmanTestIntegration) CreateArtifact(image string) error {
if os.Getenv("NO_TEST_CACHE") != "" {
return nil
}
@@ -415,7 +303,7 @@ func (p *PodmanTest) CreateArtifact(image string) error {
}
// RestoreArtifact puts the cached image into our test store
-func (p *PodmanTest) RestoreArtifact(image string) error {
+func (p *PodmanTestIntegration) RestoreArtifact(image string) error {
fmt.Printf("Restoring %s...\n", image)
dest := strings.Split(image, "/")
destName := fmt.Sprintf("/tmp/%s.tar", strings.Replace(strings.Join(strings.Split(dest[len(dest)-1], "/"), ""), ":", "-", -1))
@@ -425,7 +313,7 @@ func (p *PodmanTest) RestoreArtifact(image string) error {
}
// RestoreAllArtifacts unpacks all cached images
-func (p *PodmanTest) RestoreAllArtifacts() error {
+func (p *PodmanTestIntegration) RestoreAllArtifacts() error {
if os.Getenv("NO_TEST_CACHE") != "" {
return nil
}
@@ -439,7 +327,7 @@ func (p *PodmanTest) RestoreAllArtifacts() error {
// CreatePod creates a pod with no infra container
// it optionally takes a pod name
-func (p *PodmanTest) CreatePod(name string) (*PodmanSession, int, string) {
+func (p *PodmanTestIntegration) CreatePod(name string) (*PodmanSessionIntegration, int, string) {
var podmanArgs = []string{"pod", "create", "--infra=false", "--share", ""}
if name != "" {
podmanArgs = append(podmanArgs, "--name", name)
@@ -451,7 +339,7 @@ func (p *PodmanTest) CreatePod(name string) (*PodmanSession, int, string) {
//RunTopContainer runs a simple container in the background that
// runs top. If the name passed != "", it will have a name
-func (p *PodmanTest) RunTopContainer(name string) *PodmanSession {
+func (p *PodmanTestIntegration) RunTopContainer(name string) *PodmanSessionIntegration {
var podmanArgs = []string{"run"}
if name != "" {
podmanArgs = append(podmanArgs, "--name", name)
@@ -460,7 +348,7 @@ func (p *PodmanTest) RunTopContainer(name string) *PodmanSession {
return p.Podman(podmanArgs)
}
-func (p *PodmanTest) RunTopContainerInPod(name, pod string) *PodmanSession {
+func (p *PodmanTestIntegration) RunTopContainerInPod(name, pod string) *PodmanSessionIntegration {
var podmanArgs = []string{"run", "--pod", pod}
if name != "" {
podmanArgs = append(podmanArgs, "--name", name)
@@ -471,7 +359,7 @@ func (p *PodmanTest) RunTopContainerInPod(name, pod string) *PodmanSession {
//RunLsContainer runs a simple container in the background that
// simply runs ls. If the name passed != "", it will have a name
-func (p *PodmanTest) RunLsContainer(name string) (*PodmanSession, int, string) {
+func (p *PodmanTestIntegration) RunLsContainer(name string) (*PodmanSessionIntegration, int, string) {
var podmanArgs = []string{"run"}
if name != "" {
podmanArgs = append(podmanArgs, "--name", name)
@@ -482,7 +370,7 @@ func (p *PodmanTest) RunLsContainer(name string) (*PodmanSession, int, string) {
return session, session.ExitCode(), session.OutputToString()
}
-func (p *PodmanTest) RunLsContainerInPod(name, pod string) (*PodmanSession, int, string) {
+func (p *PodmanTestIntegration) RunLsContainerInPod(name, pod string) (*PodmanSessionIntegration, int, string) {
var podmanArgs = []string{"run", "--pod", pod}
if name != "" {
podmanArgs = append(podmanArgs, "--name", name)
@@ -493,147 +381,9 @@ func (p *PodmanTest) RunLsContainerInPod(name, pod string) (*PodmanSession, int,
return session, session.ExitCode(), session.OutputToString()
}
-//NumberOfContainersRunning returns an int of how many
-// containers are currently running.
-func (p *PodmanTest) NumberOfContainersRunning() int {
- var containers []string
- ps := p.Podman([]string{"ps", "-q"})
- ps.WaitWithDefaultTimeout()
- Expect(ps.ExitCode()).To(Equal(0))
- for _, i := range ps.OutputToStringArray() {
- if i != "" {
- containers = append(containers, i)
- }
- }
- return len(containers)
-}
-
-// NumberOfContainers returns an int of how many
-// containers are currently defined.
-func (p *PodmanTest) NumberOfContainers() int {
- var containers []string
- ps := p.Podman([]string{"ps", "-aq"})
- ps.WaitWithDefaultTimeout()
- Expect(ps.ExitCode()).To(Equal(0))
- for _, i := range ps.OutputToStringArray() {
- if i != "" {
- containers = append(containers, i)
- }
- }
- return len(containers)
-}
-
-// NumberOfPods returns an int of how many
-// pods are currently defined.
-func (p *PodmanTest) NumberOfPods() int {
- var pods []string
- ps := p.Podman([]string{"pod", "ps", "-q"})
- ps.WaitWithDefaultTimeout()
- Expect(ps.ExitCode()).To(Equal(0))
- for _, i := range ps.OutputToStringArray() {
- if i != "" {
- pods = append(pods, i)
- }
- }
- return len(pods)
-}
-
-// NumberOfRunningContainers returns an int of how many containers are currently
-// running
-func (p *PodmanTest) NumberOfRunningContainers() int {
- var containers []string
- ps := p.Podman([]string{"ps", "-q"})
- ps.WaitWithDefaultTimeout()
- Expect(ps.ExitCode()).To(Equal(0))
- for _, i := range ps.OutputToStringArray() {
- if i != "" {
- containers = append(containers, i)
- }
- }
- return len(containers)
-}
-
-// StringInSlice determines if a string is in a string slice, returns bool
-func StringInSlice(s string, sl []string) bool {
- for _, i := range sl {
- if i == s {
- return true
- }
- }
- return false
-}
-
-//LineInOutputStartsWith returns true if a line in a
-// session output starts with the supplied string
-func (s *PodmanSession) LineInOuputStartsWith(term string) bool {
- for _, i := range s.OutputToStringArray() {
- if strings.HasPrefix(i, term) {
- return true
- }
- }
- return false
-}
-
-//LineInOutputContains returns true if a line in a
-// session output starts with the supplied string
-func (s *PodmanSession) LineInOutputContains(term string) bool {
- for _, i := range s.OutputToStringArray() {
- if strings.Contains(i, term) {
- return true
- }
- }
- return false
-}
-
-//tagOutPutToMap parses each string in imagesOutput and returns
-// a map of repo:tag pairs. Notice, the first array item will
-// be skipped as it's considered to be the header.
-func tagOutputToMap(imagesOutput []string) map[string]string {
- m := make(map[string]string)
- // iterate over output but skip the header
- for _, i := range imagesOutput[1:] {
- tmp := []string{}
- for _, x := range strings.Split(i, " ") {
- if x != "" {
- tmp = append(tmp, x)
- }
- }
- // podman-images(1) return a list like output
- // in the format of "Repository Tag [...]"
- if len(tmp) < 2 {
- continue
- }
- m[tmp[0]] = tmp[1]
- }
- return m
-}
-
-//LineInOutputContainsTag returns true if a line in the
-// session's output contains the repo-tag pair as returned
-// by podman-images(1).
-func (s *PodmanSession) LineInOutputContainsTag(repo, tag string) bool {
- tagMap := tagOutputToMap(s.OutputToStringArray())
- for r, t := range tagMap {
- if repo == r && tag == t {
- return true
- }
- }
- return false
-}
-
-//GetContainerStatus returns the containers state.
-// This function assumes only one container is active.
-func (p *PodmanTest) GetContainerStatus() string {
- var podmanArgs = []string{"ps"}
- podmanArgs = append(podmanArgs, "--all", "--format={{.Status}}")
- session := p.Podman(podmanArgs)
- session.WaitWithDefaultTimeout()
- return session.OutputToString()
-}
-
// BuildImage uses podman build and buildah to build an image
// called imageName based on a string dockerfile
-func (p *PodmanTest) BuildImage(dockerfile, imageName string, layers string) {
+func (p *PodmanTestIntegration) BuildImage(dockerfile, imageName string, layers string) {
dockerfilePath := filepath.Join(p.TempDir, "Dockerfile")
err := ioutil.WriteFile(dockerfilePath, []byte(dockerfile), 0755)
Expect(err).To(BeNil())
@@ -642,34 +392,12 @@ func (p *PodmanTest) BuildImage(dockerfile, imageName string, layers string) {
Expect(session.ExitCode()).To(Equal(0))
}
-//GetHostDistributionInfo returns a struct with its distribution name and version
-func GetHostDistributionInfo() HostOS {
- f, err := os.Open("/etc/os-release")
- defer f.Close()
- if err != nil {
- return HostOS{}
- }
-
- l := bufio.NewScanner(f)
- host := 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)
- }
- if strings.HasPrefix(l.Text(), "VERSION_ID=") {
- host.Version = strings.Replace(strings.TrimSpace(strings.Join(strings.Split(l.Text(), "=")[1:], "")), "\"", "", -1)
- }
- }
- return host
-}
-
-func (p *PodmanTest) setDefaultRegistriesConfigEnv() {
+func (p *PodmanTestIntegration) setDefaultRegistriesConfigEnv() {
defaultFile := filepath.Join(INTEGRATION_ROOT, "test/registries.conf")
os.Setenv("REGISTRIES_CONFIG_PATH", defaultFile)
}
-func (p *PodmanTest) setRegistriesConfigEnv(b []byte) {
+func (p *PodmanTestIntegration) setRegistriesConfigEnv(b []byte) {
outfile := filepath.Join(p.TempDir, "registries.conf")
os.Setenv("REGISTRIES_CONFIG_PATH", outfile)
ioutil.WriteFile(outfile, b, 0644)
@@ -678,81 +406,3 @@ func (p *PodmanTest) setRegistriesConfigEnv(b []byte) {
func resetRegistriesConfigEnv() {
os.Setenv("REGISTRIES_CONFIG_PATH", "")
}
-
-// IsKernelNewThan compares the current kernel version to one provided. If
-// the kernel is equal to or greater, returns true
-func IsKernelNewThan(version string) (bool, error) {
- inputVersion, err := kernel.ParseRelease(version)
- if err != nil {
- return false, err
- }
- kv, err := kernel.GetKernelVersion()
- if err == nil {
- return false, err
- }
- // CompareKernelVersion compares two kernel.VersionInfo structs.
- // Returns -1 if a < b, 0 if a == b, 1 it a > b
- result := kernel.CompareKernelVersion(*kv, *inputVersion)
- if result >= 0 {
- return true, nil
- }
- return false, nil
-
-}
-
-//Wait process or service inside container start, and ready to be used.
-func WaitContainerReady(p *PodmanTest, id string, expStr string, timeout int, step int) bool {
- startTime := time.Now()
- s := p.Podman([]string{"logs", id})
- s.WaitWithDefaultTimeout()
- fmt.Println(startTime)
- for {
- if time.Since(startTime) >= time.Duration(timeout)*time.Second {
- return false
- }
- if strings.Contains(s.OutputToString(), expStr) {
- return true
- }
- time.Sleep(time.Duration(step) * time.Second)
- s = p.Podman([]string{"logs", id})
- s.WaitWithDefaultTimeout()
- }
-}
-
-//IsCommandAvaible check if command exist
-func IsCommandAvailable(command string) bool {
- check := exec.Command("bash", "-c", strings.Join([]string{"command -v", command}, " "))
- err := check.Run()
- if err != nil {
- return false
- }
- return true
-}
-
-// WriteJsonFile write json format data to a json file
-func WriteJsonFile(data []byte, filePath string) error {
- var jsonData map[string]interface{}
- json.Unmarshal(data, &jsonData)
- formatJson, _ := json.MarshalIndent(jsonData, "", " ")
- return ioutil.WriteFile(filePath, formatJson, 0644)
-}
-
-func getTestContext() context.Context {
- return context.Background()
-}
-
-func containerized() bool {
- container := os.Getenv("container")
- if container != "" {
- return true
- }
- b, err := ioutil.ReadFile("/proc/1/cgroup")
- if err != nil {
- // shrug, if we cannot read that file, return false
- return false
- }
- if strings.Index(string(b), "docker") > -1 {
- return true
- }
- return false
-}
diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go
index 21e8a4859..4d7007191 100644
--- a/test/e2e/load_test.go
+++ b/test/e2e/load_test.go
@@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -13,7 +14,7 @@ var _ = Describe("Podman load", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,7 +22,7 @@ var _ = Describe("Podman load", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -55,7 +56,7 @@ var _ = Describe("Podman load", func() {
save.WaitWithDefaultTimeout()
Expect(save.ExitCode()).To(Equal(0))
- compress := podmanTest.SystemExec("gzip", []string{outfile})
+ compress := SystemExec("gzip", []string{outfile})
compress.WaitWithDefaultTimeout()
outfile = outfile + ".gz"
@@ -253,7 +254,7 @@ var _ = Describe("Podman load", func() {
save := podmanTest.Podman([]string{"save", "-o", outfile, BB})
save.WaitWithDefaultTimeout()
Expect(save.ExitCode()).To(Equal(0))
- session := podmanTest.SystemExec("xz", []string{outfile})
+ session := SystemExec("xz", []string{outfile})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go
index 6888863ca..236ddb221 100644
--- a/test/e2e/logs_test.go
+++ b/test/e2e/logs_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman logs", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman logs", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/mount_test.go b/test/e2e/mount_test.go
index fbb0a3eb7..a93a0aa4a 100644
--- a/test/e2e/mount_test.go
+++ b/test/e2e/mount_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman mount", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman mount", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/namespace_test.go b/test/e2e/namespace_test.go
index 017edd231..ebce09f54 100644
--- a/test/e2e/namespace_test.go
+++ b/test/e2e/namespace_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman namespaces", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman namespaces", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/pause_test.go b/test/e2e/pause_test.go
index 1a2eb1a09..e109bc077 100644
--- a/test/e2e/pause_test.go
+++ b/test/e2e/pause_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman pause", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
pausedState := "Paused"
@@ -23,7 +24,7 @@ var _ = Describe("Podman pause", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -91,7 +92,7 @@ var _ = Describe("Podman pause", func() {
})
- It("podman remove a paused container by id", func() {
+ It("podman remove a paused container by id without force", func() {
session := podmanTest.RunTopContainer("")
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@@ -111,25 +112,26 @@ var _ = Describe("Podman pause", func() {
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
Expect(podmanTest.GetContainerStatus()).To(ContainSubstring(pausedState))
- result = podmanTest.Podman([]string{"rm", "--force", cid})
- result.WaitWithDefaultTimeout()
+ })
- Expect(result.ExitCode()).To(Equal(125))
- Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
- Expect(podmanTest.GetContainerStatus()).To(ContainSubstring(pausedState))
+ It("podman remove a paused container by id with force", func() {
+ session := podmanTest.RunTopContainer("")
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ cid := session.OutputToString()
- result = podmanTest.Podman([]string{"unpause", cid})
+ result := podmanTest.Podman([]string{"pause", cid})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
- Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
+ Expect(podmanTest.GetContainerStatus()).To(ContainSubstring(pausedState))
result = podmanTest.Podman([]string{"rm", "--force", cid})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
-
})
It("podman stop a paused container by id", func() {
diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go
index 0ce1e22a8..5abf9613b 100644
--- a/test/e2e/pod_create_test.go
+++ b/test/e2e/pod_create_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman pod create", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman pod create", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -79,4 +80,43 @@ var _ = Describe("Podman pod create", func() {
check.WaitWithDefaultTimeout()
Expect(len(check.OutputToStringArray())).To(Equal(0))
})
+
+ It("podman create pod without network portbindings", func() {
+ name := "test"
+ session := podmanTest.Podman([]string{"pod", "create", "--name", name})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ pod := session.OutputToString()
+
+ webserver := podmanTest.Podman([]string{"run", "--pod", pod, "-dt", nginx})
+ webserver.WaitWithDefaultTimeout()
+ Expect(webserver.ExitCode()).To(Equal(0))
+
+ check := SystemExec("nc", []string{"-z", "localhost", "80"})
+ check.WaitWithDefaultTimeout()
+ Expect(check.ExitCode()).To(Equal(1))
+ })
+
+ It("podman create pod with network portbindings", func() {
+ name := "test"
+ session := podmanTest.Podman([]string{"pod", "create", "--name", name, "-p", "80:80"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ pod := session.OutputToString()
+
+ webserver := podmanTest.Podman([]string{"run", "--pod", pod, "-dt", nginx})
+ webserver.WaitWithDefaultTimeout()
+ Expect(webserver.ExitCode()).To(Equal(0))
+
+ check := SystemExec("nc", []string{"-z", "localhost", "80"})
+ check.WaitWithDefaultTimeout()
+ Expect(check.ExitCode()).To(Equal(0))
+ })
+
+ It("podman create pod with no infra but portbindings should fail", func() {
+ name := "test"
+ session := podmanTest.Podman([]string{"pod", "create", "--infra=false", "--name", name, "-p", "80:80"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(125))
+ })
})
diff --git a/test/e2e/pod_infra_container_test.go b/test/e2e/pod_infra_container_test.go
index f1e2375ce..8c7c09c97 100644
--- a/test/e2e/pod_infra_container_test.go
+++ b/test/e2e/pod_infra_container_test.go
@@ -5,6 +5,7 @@ import (
"os"
"strconv"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -13,7 +14,7 @@ var _ = Describe("Podman pod create", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,7 +22,7 @@ var _ = Describe("Podman pod create", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
podmanTest.RestoreArtifact(infra)
})
diff --git a/test/e2e/pod_inspect_test.go b/test/e2e/pod_inspect_test.go
index 667e59f38..51e95f788 100644
--- a/test/e2e/pod_inspect_test.go
+++ b/test/e2e/pod_inspect_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman pod inspect", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman pod inspect", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/pod_kill_test.go b/test/e2e/pod_kill_test.go
index b29fe1e17..d9cec2cad 100644
--- a/test/e2e/pod_kill_test.go
+++ b/test/e2e/pod_kill_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman pod kill", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman pod kill", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/pod_pause_test.go b/test/e2e/pod_pause_test.go
index 384cbfcb7..8f766d3db 100644
--- a/test/e2e/pod_pause_test.go
+++ b/test/e2e/pod_pause_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman pod pause", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
pausedState := "Paused"
@@ -22,7 +23,7 @@ var _ = Describe("Podman pod pause", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/pod_pod_namespaces.go b/test/e2e/pod_pod_namespaces.go
index 3e84005c3..b1d5abb1c 100644
--- a/test/e2e/pod_pod_namespaces.go
+++ b/test/e2e/pod_pod_namespaces.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman pod create", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman pod create", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
podmanTest.RestoreArtifact(infra)
})
diff --git a/test/e2e/pod_ps_test.go b/test/e2e/pod_ps_test.go
index b48cb9578..9e816bcfa 100644
--- a/test/e2e/pod_ps_test.go
+++ b/test/e2e/pod_ps_test.go
@@ -5,6 +5,7 @@ import (
"os"
"sort"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -13,7 +14,7 @@ var _ = Describe("Podman ps", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,7 +22,7 @@ var _ = Describe("Podman ps", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/pod_restart_test.go b/test/e2e/pod_restart_test.go
index e486f8791..d0964e8de 100644
--- a/test/e2e/pod_restart_test.go
+++ b/test/e2e/pod_restart_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman pod restart", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman pod restart", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/pod_rm_test.go b/test/e2e/pod_rm_test.go
index 09002e954..48767b33f 100644
--- a/test/e2e/pod_rm_test.go
+++ b/test/e2e/pod_rm_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman pod rm", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman pod rm", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/pod_start_test.go b/test/e2e/pod_start_test.go
index 9d2ea9b26..346346425 100644
--- a/test/e2e/pod_start_test.go
+++ b/test/e2e/pod_start_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman pod start", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman pod start", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/pod_stats_test.go b/test/e2e/pod_stats_test.go
index f9c8e06c4..d7b9a8f48 100644
--- a/test/e2e/pod_stats_test.go
+++ b/test/e2e/pod_stats_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman pod stats", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman pod stats", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/pod_stop_test.go b/test/e2e/pod_stop_test.go
index 32f8559ad..6c5319a3d 100644
--- a/test/e2e/pod_stop_test.go
+++ b/test/e2e/pod_stop_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman pod stop", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman pod stop", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/pod_top_test.go b/test/e2e/pod_top_test.go
index f72456307..3dc80ddfb 100644
--- a/test/e2e/pod_top_test.go
+++ b/test/e2e/pod_top_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman top", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman top", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/port_test.go b/test/e2e/port_test.go
index ed15b54ac..09f3ab53a 100644
--- a/test/e2e/port_test.go
+++ b/test/e2e/port_test.go
@@ -5,6 +5,7 @@ import (
"os"
"strings"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -13,7 +14,7 @@ var _ = Describe("Podman port", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,7 +22,7 @@ var _ = Describe("Podman port", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/prune_test.go b/test/e2e/prune_test.go
new file mode 100644
index 000000000..6679a676c
--- /dev/null
+++ b/test/e2e/prune_test.go
@@ -0,0 +1,88 @@
+package integration
+
+import (
+ "fmt"
+ "os"
+
+ . "github.com/containers/libpod/test/utils"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var pruneImage = `
+FROM alpine:latest
+LABEL RUN podman --version
+RUN apk update
+RUN apk add bash`
+
+var _ = Describe("Podman rm", func() {
+ var (
+ tempdir string
+ err error
+ podmanTest *PodmanTestIntegration
+ )
+
+ BeforeEach(func() {
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanTestCreate(tempdir)
+ podmanTest.RestoreAllArtifacts()
+ })
+
+ AfterEach(func() {
+ podmanTest.Cleanup()
+ f := CurrentGinkgoTestDescription()
+ timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds())
+ GinkgoWriter.Write([]byte(timedResult))
+ })
+
+ It("podman container prune containers", func() {
+ top := podmanTest.RunTopContainer("")
+ top.WaitWithDefaultTimeout()
+ Expect(top.ExitCode()).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"run", ALPINE, "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ prune := podmanTest.Podman([]string{"container", "prune"})
+ prune.WaitWithDefaultTimeout()
+ Expect(prune.ExitCode()).To(Equal(0))
+
+ Expect(podmanTest.NumberOfContainers()).To(Equal(1))
+ })
+
+ It("podman image prune none images", func() {
+ podmanTest.BuildImage(pruneImage, "alpine_bash:latest", "true")
+
+ none := podmanTest.Podman([]string{"images", "-a"})
+ none.WaitWithDefaultTimeout()
+ Expect(none.ExitCode()).To(Equal(0))
+ hasNone, _ := none.GrepString("<none>")
+ Expect(hasNone).To(BeTrue())
+
+ prune := podmanTest.Podman([]string{"image", "prune"})
+ prune.WaitWithDefaultTimeout()
+ Expect(prune.ExitCode()).To(Equal(0))
+
+ after := podmanTest.Podman([]string{"images", "-a"})
+ after.WaitWithDefaultTimeout()
+ Expect(none.ExitCode()).To(Equal(0))
+ hasNoneAfter, _ := after.GrepString("<none>")
+ Expect(hasNoneAfter).To(BeFalse())
+ })
+
+ It("podman image prune unused images", func() {
+ prune := podmanTest.Podman([]string{"image", "prune"})
+ prune.WaitWithDefaultTimeout()
+ Expect(prune.ExitCode()).To(Equal(0))
+
+ images := podmanTest.Podman([]string{"images", "-a"})
+ images.WaitWithDefaultTimeout()
+ // all images are unused, so they all should be deleted!
+ Expect(len(images.OutputToStringArray())).To(Equal(0))
+ })
+
+})
diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go
index a873b57bb..9caa6e7f1 100644
--- a/test/e2e/ps_test.go
+++ b/test/e2e/ps_test.go
@@ -6,6 +6,7 @@ import (
"regexp"
"sort"
+ . "github.com/containers/libpod/test/utils"
"github.com/docker/go-units"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -15,7 +16,7 @@ var _ = Describe("Podman ps", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -23,7 +24,7 @@ var _ = Describe("Podman ps", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go
index 606160198..ad8742984 100644
--- a/test/e2e/pull_test.go
+++ b/test/e2e/pull_test.go
@@ -4,6 +4,7 @@ import (
"os"
"fmt"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"strings"
@@ -13,7 +14,7 @@ var _ = Describe("Podman pull", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,7 +22,7 @@ var _ = Describe("Podman pull", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -101,7 +102,7 @@ var _ = Describe("Podman pull", func() {
session = podmanTest.Podman([]string{"rmi", "alpine"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- clean := podmanTest.SystemExec("rm", []string{"/tmp/alp.tar"})
+ clean := SystemExec("rm", []string{"/tmp/alp.tar"})
clean.WaitWithDefaultTimeout()
Expect(clean.ExitCode()).To(Equal(0))
})
@@ -119,12 +120,12 @@ var _ = Describe("Podman pull", func() {
session = podmanTest.Podman([]string{"rmi", "alpine"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- clean := podmanTest.SystemExec("rm", []string{"/tmp/oci-alp.tar"})
+ clean := SystemExec("rm", []string{"/tmp/oci-alp.tar"})
clean.WaitWithDefaultTimeout()
})
It("podman pull from local directory", func() {
- setup := podmanTest.SystemExec("mkdir", []string{"-p", "/tmp/podmantestdir"})
+ setup := SystemExec("mkdir", []string{"-p", "/tmp/podmantestdir"})
setup.WaitWithDefaultTimeout()
session := podmanTest.Podman([]string{"push", "alpine", "dir:/tmp/podmantestdir"})
session.WaitWithDefaultTimeout()
@@ -139,7 +140,7 @@ var _ = Describe("Podman pull", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- clean := podmanTest.SystemExec("rm", []string{"-fr", "/tmp/podmantestdir"})
+ clean := SystemExec("rm", []string{"-fr", "/tmp/podmantestdir"})
clean.WaitWithDefaultTimeout()
})
diff --git a/test/e2e/push_test.go b/test/e2e/push_test.go
index 5e3d3745a..3447cd57e 100644
--- a/test/e2e/push_test.go
+++ b/test/e2e/push_test.go
@@ -6,6 +6,7 @@ import (
"path/filepath"
"strings"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -14,7 +15,7 @@ var _ = Describe("Podman push", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -22,7 +23,7 @@ var _ = Describe("Podman push", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -52,7 +53,7 @@ var _ = Describe("Podman push", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- clean := podmanTest.SystemExec("rm", []string{"-fr", "/tmp/busybox"})
+ clean := SystemExec("rm", []string{"-fr", "/tmp/busybox"})
clean.WaitWithDefaultTimeout()
Expect(clean.ExitCode()).To(Equal(0))
})
@@ -66,7 +67,7 @@ var _ = Describe("Podman push", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- if !WaitContainerReady(&podmanTest, "registry", "listening on", 20, 1) {
+ if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) {
Skip("Can not start docker registry.")
}
@@ -82,20 +83,20 @@ var _ = Describe("Podman push", func() {
authPath := filepath.Join(podmanTest.TempDir, "auth")
os.Mkdir(authPath, os.ModePerm)
os.MkdirAll("/etc/containers/certs.d/localhost:5000", os.ModePerm)
- debug := podmanTest.SystemExec("ls", []string{"-l", podmanTest.TempDir})
+ debug := SystemExec("ls", []string{"-l", podmanTest.TempDir})
debug.WaitWithDefaultTimeout()
cwd, _ := os.Getwd()
certPath := filepath.Join(cwd, "../", "certs")
if IsCommandAvailable("getenforce") {
- ge := podmanTest.SystemExec("getenforce", []string{})
+ ge := SystemExec("getenforce", []string{})
ge.WaitWithDefaultTimeout()
if ge.OutputToString() == "Enforcing" {
- se := podmanTest.SystemExec("setenforce", []string{"0"})
+ se := SystemExec("setenforce", []string{"0"})
se.WaitWithDefaultTimeout()
- defer podmanTest.SystemExec("setenforce", []string{"1"})
+ defer SystemExec("setenforce", []string{"1"})
}
}
podmanTest.RestoreArtifact(registry)
@@ -108,7 +109,7 @@ var _ = Describe("Podman push", func() {
f.WriteString(session.OutputToString())
f.Sync()
- debug = podmanTest.SystemExec("cat", []string{filepath.Join(authPath, "htpasswd")})
+ debug = SystemExec("cat", []string{filepath.Join(authPath, "htpasswd")})
debug.WaitWithDefaultTimeout()
session = podmanTest.Podman([]string{"run", "-d", "-p", "5000:5000", "--name", "registry", "-v",
@@ -119,7 +120,7 @@ var _ = Describe("Podman push", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- if !WaitContainerReady(&podmanTest, "registry", "listening on", 20, 1) {
+ if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) {
Skip("Can not start docker registry.")
}
@@ -134,7 +135,7 @@ var _ = Describe("Podman push", func() {
push.WaitWithDefaultTimeout()
Expect(push.ExitCode()).To(Equal(0))
- setup := podmanTest.SystemExec("cp", []string{filepath.Join(certPath, "domain.crt"), "/etc/containers/certs.d/localhost:5000/ca.crt"})
+ setup := SystemExec("cp", []string{filepath.Join(certPath, "domain.crt"), "/etc/containers/certs.d/localhost:5000/ca.crt"})
setup.WaitWithDefaultTimeout()
defer os.RemoveAll("/etc/containers/certs.d/localhost:5000")
@@ -155,20 +156,20 @@ var _ = Describe("Podman push", func() {
session := podmanTest.Podman([]string{"push", ALPINE, "docker-archive:/tmp/alp:latest"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- clean := podmanTest.SystemExec("rm", []string{"/tmp/alp"})
+ clean := SystemExec("rm", []string{"/tmp/alp"})
clean.WaitWithDefaultTimeout()
Expect(clean.ExitCode()).To(Equal(0))
})
It("podman push to docker daemon", func() {
- setup := podmanTest.SystemExec("bash", []string{"-c", "systemctl status docker 2>&1"})
+ setup := SystemExec("bash", []string{"-c", "systemctl status docker 2>&1"})
setup.WaitWithDefaultTimeout()
if setup.LineInOutputContains("Active: inactive") {
- setup = podmanTest.SystemExec("systemctl", []string{"start", "docker"})
+ setup = SystemExec("systemctl", []string{"start", "docker"})
setup.WaitWithDefaultTimeout()
- defer podmanTest.SystemExec("systemctl", []string{"stop", "docker"})
+ defer SystemExec("systemctl", []string{"stop", "docker"})
} else if setup.ExitCode() != 0 {
Skip("Docker is not available")
}
@@ -177,12 +178,12 @@ var _ = Describe("Podman push", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- check := podmanTest.SystemExec("docker", []string{"images", "--format", "{{.Repository}}:{{.Tag}}"})
+ check := SystemExec("docker", []string{"images", "--format", "{{.Repository}}:{{.Tag}}"})
check.WaitWithDefaultTimeout()
Expect(check.ExitCode()).To(Equal(0))
Expect(check.OutputToString()).To(ContainSubstring("alpine:podmantest"))
- clean := podmanTest.SystemExec("docker", []string{"rmi", "alpine:podmantest"})
+ clean := SystemExec("docker", []string{"rmi", "alpine:podmantest"})
clean.WaitWithDefaultTimeout()
Expect(clean.ExitCode()).To(Equal(0))
})
@@ -191,7 +192,7 @@ var _ = Describe("Podman push", func() {
session := podmanTest.Podman([]string{"push", ALPINE, "oci-archive:/tmp/alp.tar:latest"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- clean := podmanTest.SystemExec("rm", []string{"/tmp/alp.tar"})
+ clean := SystemExec("rm", []string{"/tmp/alp.tar"})
clean.WaitWithDefaultTimeout()
Expect(clean.ExitCode()).To(Equal(0))
})
@@ -204,14 +205,14 @@ var _ = Describe("Podman push", func() {
ostreePath := filepath.Join(podmanTest.TempDir, "ostree/repo")
os.MkdirAll(ostreePath, os.ModePerm)
- setup := podmanTest.SystemExec("ostree", []string{strings.Join([]string{"--repo=", ostreePath}, ""), "init"})
+ setup := SystemExec("ostree", []string{strings.Join([]string{"--repo=", ostreePath}, ""), "init"})
setup.WaitWithDefaultTimeout()
session := podmanTest.Podman([]string{"push", ALPINE, strings.Join([]string{"ostree:alp@", ostreePath}, "")})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- clean := podmanTest.SystemExec("rm", []string{"-rf", ostreePath})
+ clean := SystemExec("rm", []string{"-rf", ostreePath})
clean.WaitWithDefaultTimeout()
Expect(clean.ExitCode()).To(Equal(0))
})
@@ -220,7 +221,7 @@ var _ = Describe("Podman push", func() {
session := podmanTest.Podman([]string{"push", ALPINE, "docker-archive:/tmp/alp"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- clean := podmanTest.SystemExec("rm", []string{"/tmp/alp"})
+ clean := SystemExec("rm", []string{"/tmp/alp"})
clean.WaitWithDefaultTimeout()
Expect(clean.ExitCode()).To(Equal(0))
})
@@ -229,7 +230,7 @@ var _ = Describe("Podman push", func() {
session := podmanTest.Podman([]string{"push", ALPINE, "oci-archive:/tmp/alp-oci"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- clean := podmanTest.SystemExec("rm", []string{"/tmp/alp-oci"})
+ clean := SystemExec("rm", []string{"/tmp/alp-oci"})
clean.WaitWithDefaultTimeout()
Expect(clean.ExitCode()).To(Equal(0))
})
diff --git a/test/e2e/refresh_test.go b/test/e2e/refresh_test.go
index c4a65aa47..bf8fff105 100644
--- a/test/e2e/refresh_test.go
+++ b/test/e2e/refresh_test.go
@@ -5,6 +5,7 @@ import (
"os"
"time"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -13,7 +14,7 @@ var _ = Describe("Podman refresh", func() {
var (
tmpdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,7 +22,7 @@ var _ = Describe("Podman refresh", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tmpdir)
+ podmanTest = PodmanTestCreate(tmpdir)
podmanTest.RestoreAllArtifacts()
})
@@ -43,13 +44,13 @@ var _ = Describe("Podman refresh", func() {
createSession.WaitWithDefaultTimeout()
Expect(createSession.ExitCode()).To(Equal(0))
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
- Expect(podmanTest.NumberOfRunningContainers()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
refreshSession := podmanTest.Podman([]string{"container", "refresh"})
refreshSession.WaitWithDefaultTimeout()
Expect(refreshSession.ExitCode()).To(Equal(0))
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
- Expect(podmanTest.NumberOfRunningContainers()).To(Equal(0))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
})
Specify("Refresh with running container restarts container", func() {
@@ -57,7 +58,7 @@ var _ = Describe("Podman refresh", func() {
createSession.WaitWithDefaultTimeout()
Expect(createSession.ExitCode()).To(Equal(0))
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
- Expect(podmanTest.NumberOfRunningContainers()).To(Equal(1))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
// HACK: ensure container starts before we move on
time.Sleep(1 * time.Second)
@@ -66,6 +67,6 @@ var _ = Describe("Podman refresh", func() {
refreshSession.WaitWithDefaultTimeout()
Expect(refreshSession.ExitCode()).To(Equal(0))
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
- Expect(podmanTest.NumberOfRunningContainers()).To(Equal(1))
+ Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
})
})
diff --git a/test/e2e/restart_test.go b/test/e2e/restart_test.go
index eca2bbcda..30801c272 100644
--- a/test/e2e/restart_test.go
+++ b/test/e2e/restart_test.go
@@ -5,6 +5,7 @@ import (
"os"
"time"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -13,7 +14,7 @@ var _ = Describe("Podman restart", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,7 +22,7 @@ var _ = Describe("Podman restart", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -74,7 +75,7 @@ var _ = Describe("Podman restart", func() {
It("Podman restart running container", func() {
_ = podmanTest.RunTopContainer("test1")
- ok := WaitForContainer(&podmanTest)
+ ok := WaitForContainer(podmanTest)
Expect(ok).To(BeTrue())
startTime := podmanTest.Podman([]string{"inspect", "--format='{{.State.StartedAt}}'", "test1"})
startTime.WaitWithDefaultTimeout()
diff --git a/test/e2e/rm_test.go b/test/e2e/rm_test.go
index cbc03a078..c6a2b61ee 100644
--- a/test/e2e/rm_test.go
+++ b/test/e2e/rm_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman rm", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman rm", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/rmi_test.go b/test/e2e/rmi_test.go
index 2a1a0da77..22bfbbe8c 100644
--- a/test/e2e/rmi_test.go
+++ b/test/e2e/rmi_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman rmi", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman rmi", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -249,4 +250,25 @@ var _ = Describe("Podman rmi", func() {
session2.WaitWithDefaultTimeout()
Expect(session2.ExitCode()).To(Equal(0))
})
+
+ It("podman rmi -a with parent|child images", func() {
+ dockerfile := `FROM docker.io/library/alpine:latest AS base
+RUN touch /1
+ENV LOCAL=/1
+RUN find $LOCAL
+FROM base
+RUN find $LOCAL
+
+`
+ podmanTest.BuildImage(dockerfile, "test", "true")
+ session := podmanTest.Podman([]string{"rmi", "-a"})
+ session.WaitWithDefaultTimeout()
+ fmt.Println(session.OutputToString())
+ Expect(session.ExitCode()).To(Equal(0))
+
+ images := podmanTest.Podman([]string{"images", "--all"})
+ images.WaitWithDefaultTimeout()
+ Expect(images.ExitCode()).To(Equal(0))
+ Expect(len(images.OutputToStringArray())).To(Equal(0))
+ })
})
diff --git a/test/e2e/rootless_test.go b/test/e2e/rootless_test.go
index 876e10969..037af9688 100644
--- a/test/e2e/rootless_test.go
+++ b/test/e2e/rootless_test.go
@@ -9,6 +9,7 @@ import (
"runtime"
"syscall"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -30,7 +31,7 @@ var _ = Describe("Podman rootless", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -38,7 +39,7 @@ var _ = Describe("Podman rootless", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.CgroupManager = "cgroupfs"
podmanTest.StorageOptions = ROOTLESS_STORAGE_OPTIONS
podmanTest.RestoreAllArtifacts()
@@ -55,6 +56,7 @@ var _ = Describe("Podman rootless", func() {
commands := []string{"help", "version"}
for _, v := range commands {
env := os.Environ()
+ env = append(env, "USER=foo")
cmd := podmanTest.PodmanAsUser([]string{v}, 1000, 1000, env)
cmd.WaitWithDefaultTimeout()
Expect(cmd.ExitCode()).To(Equal(0))
@@ -68,7 +70,7 @@ var _ = Describe("Podman rootless", func() {
return os.Lchown(p, 1000, 1000)
}
- type rootlessCB func(test PodmanTest, xdgRuntimeDir string, home string, mountPath string)
+ type rootlessCB func(test *PodmanTestIntegration, xdgRuntimeDir string, home string, mountPath string)
runInRootlessContext := func(cb rootlessCB) {
// Check if we can create an user namespace
@@ -91,7 +93,7 @@ var _ = Describe("Podman rootless", func() {
tempdir, err := CreateTempDirInTempDir()
Expect(err).To(BeNil())
- rootlessTest := PodmanCreate(tempdir)
+ rootlessTest := PodmanTestCreate(tempdir)
rootlessTest.CgroupManager = "cgroupfs"
rootlessTest.StorageOptions = ROOTLESS_STORAGE_OPTIONS
err = filepath.Walk(tempdir, chownFunc)
@@ -116,11 +118,12 @@ var _ = Describe("Podman rootless", func() {
}
It("podman rootless pod", func() {
- f := func(rootlessTest PodmanTest, xdgRuntimeDir string, home string, mountPath string) {
+ f := func(rootlessTest *PodmanTestIntegration, xdgRuntimeDir string, home string, mountPath string) {
env := os.Environ()
env = append(env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", xdgRuntimeDir))
env = append(env, fmt.Sprintf("HOME=%s", home))
env = append(env, "PODMAN_ALLOW_SINGLE_ID_MAPPING_IN_USERNS=1")
+ env = append(env, "USER=foo")
cmd := rootlessTest.PodmanAsUser([]string{"pod", "create", "--infra=false"}, 1000, 1000, env)
cmd.WaitWithDefaultTimeout()
@@ -151,19 +154,21 @@ var _ = Describe("Podman rootless", func() {
env := os.Environ()
env = append(env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", xdgRuntimeDir))
env = append(env, fmt.Sprintf("HOME=%s", home))
+ env = append(env, "USER=foo")
cmd := podmanTest.PodmanAsUser([]string{"search", "docker.io/busybox"}, 1000, 1000, env)
cmd.WaitWithDefaultTimeout()
Expect(cmd.ExitCode()).To(Equal(0))
})
runRootlessHelper := func(args []string) {
- f := func(rootlessTest PodmanTest, xdgRuntimeDir string, home string, mountPath string) {
+ f := func(rootlessTest *PodmanTestIntegration, xdgRuntimeDir string, home string, mountPath string) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
env := os.Environ()
env = append(env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", xdgRuntimeDir))
env = append(env, fmt.Sprintf("HOME=%s", home))
env = append(env, "PODMAN_ALLOW_SINGLE_ID_MAPPING_IN_USERNS=1")
+ env = append(env, "USER=foo")
allArgs := append([]string{"run"}, args...)
allArgs = append(allArgs, "--rootfs", mountPath, "echo", "hello")
@@ -182,6 +187,10 @@ var _ = Describe("Podman rootless", func() {
cmd.WaitWithDefaultTimeout()
Expect(cmd.ExitCode()).To(Equal(0))
+ cmd = rootlessTest.PodmanAsUser([]string{"restart", "-l", "-t", "0"}, 1000, 1000, env)
+ cmd.WaitWithDefaultTimeout()
+ Expect(cmd.ExitCode()).To(Equal(0))
+
canUseExec := canExec()
if canUseExec {
@@ -204,6 +213,10 @@ var _ = Describe("Podman rootless", func() {
cmd.WaitWithDefaultTimeout()
Expect(cmd.ExitCode()).To(Equal(0))
+ cmd = rootlessTest.PodmanAsUser([]string{"inspect", "-l", "--type", "container", "--format", "{{ .State.Status }}"}, 1000, 1000, env)
+ cmd.WaitWithDefaultTimeout()
+ Expect(cmd.LineInOutputContains("exited")).To(BeTrue())
+
cmd = rootlessTest.PodmanAsUser([]string{"start", "-l"}, 1000, 1000, env)
cmd.WaitWithDefaultTimeout()
Expect(cmd.ExitCode()).To(Equal(0))
@@ -216,6 +229,14 @@ var _ = Describe("Podman rootless", func() {
cmd.WaitWithDefaultTimeout()
Expect(cmd.ExitCode()).To(Equal(0))
+ if len(args) == 0 {
+ cmd = rootlessTest.PodmanAsUser([]string{"inspect", "-l"}, 1000, 1000, env)
+ cmd.WaitWithDefaultTimeout()
+ Expect(cmd.ExitCode()).To(Equal(0))
+ data := cmd.InspectContainerToJSON()
+ Expect(data[0].HostConfig.NetworkMode).To(ContainSubstring("slirp4netns"))
+ }
+
if !canUseExec {
Skip("ioctl(NS_GET_PARENT) not supported.")
}
diff --git a/test/e2e/run_cgroup_parent_test.go b/test/e2e/run_cgroup_parent_test.go
index f266fafa4..57b3aa6b1 100644
--- a/test/e2e/run_cgroup_parent_test.go
+++ b/test/e2e/run_cgroup_parent_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreArtifact(fedoraMinimal)
})
@@ -32,7 +33,7 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
})
Specify("valid --cgroup-parent using cgroupfs", func() {
- if !containerized() {
+ if !Containerized() {
Skip("Must be containerized to run this test.")
}
cgroup := "/zzz"
@@ -45,7 +46,7 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
Specify("no --cgroup-parent", func() {
cgroup := "/libpod_parent"
- if !containerized() && podmanTest.CgroupManager != "cgroupfs" {
+ if !Containerized() && podmanTest.CgroupManager != "cgroupfs" {
cgroup = "/machine.slice"
}
run := podmanTest.Podman([]string{"run", fedoraMinimal, "cat", "/proc/self/cgroup"})
@@ -56,7 +57,7 @@ var _ = Describe("Podman run with --cgroup-parent", func() {
})
Specify("valid --cgroup-parent using slice", func() {
- if containerized() || podmanTest.CgroupManager == "cgroupfs" {
+ if Containerized() || podmanTest.CgroupManager == "cgroupfs" {
Skip("Requires Systemd cgroup manager support")
}
cgroup := "aaaa.slice"
diff --git a/test/e2e/run_cleanup_test.go b/test/e2e/run_cleanup_test.go
index 02c70734a..5b60efa86 100644
--- a/test/e2e/run_cleanup_test.go
+++ b/test/e2e/run_cleanup_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman run exit", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman run exit", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -32,14 +33,14 @@ var _ = Describe("Podman run exit", func() {
})
It("podman run -d mount cleanup test", func() {
- mount := podmanTest.SystemExec("mount", nil)
+ mount := SystemExec("mount", nil)
mount.WaitWithDefaultTimeout()
out1 := mount.OutputToString()
result := podmanTest.Podman([]string{"create", "-dt", ALPINE, "echo", "hello"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
- mount = podmanTest.SystemExec("mount", nil)
+ mount = SystemExec("mount", nil)
mount.WaitWithDefaultTimeout()
out2 := mount.OutputToString()
Expect(out1).To(Equal(out2))
diff --git a/test/e2e/run_cpu_test.go b/test/e2e/run_cpu_test.go
index d56dfac64..343fe656c 100644
--- a/test/e2e/run_cpu_test.go
+++ b/test/e2e/run_cpu_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman run cpu", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman run cpu", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/run_device_test.go b/test/e2e/run_device_test.go
index fedd696d1..7f1f7b2d0 100644
--- a/test/e2e/run_device_test.go
+++ b/test/e2e/run_device_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman run device", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman run device", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/run_dns_test.go b/test/e2e/run_dns_test.go
index a617035a1..444c568e0 100644
--- a/test/e2e/run_dns_test.go
+++ b/test/e2e/run_dns_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman run dns", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman run dns", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/run_entrypoint_test.go b/test/e2e/run_entrypoint_test.go
index 5e4ef75e1..227037f92 100644
--- a/test/e2e/run_entrypoint_test.go
+++ b/test/e2e/run_entrypoint_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman run entrypoint", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman run entrypoint", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreArtifact(ALPINE)
})
diff --git a/test/e2e/run_exit_test.go b/test/e2e/run_exit_test.go
index bb38f7222..788cbd8dd 100644
--- a/test/e2e/run_exit_test.go
+++ b/test/e2e/run_exit_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman run exit", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman run exit", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/run_memory_test.go b/test/e2e/run_memory_test.go
index d1768138b..91a311e85 100644
--- a/test/e2e/run_memory_test.go
+++ b/test/e2e/run_memory_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman run memory", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman run memory", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go
index 021825d4b..68b1f06de 100644
--- a/test/e2e/run_networking_test.go
+++ b/test/e2e/run_networking_test.go
@@ -4,15 +4,16 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
-var _ = Describe("Podman rmi", func() {
+var _ = Describe("Podman run networking", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
hostname, _ = os.Hostname()
)
@@ -21,7 +22,7 @@ var _ = Describe("Podman rmi", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -54,7 +55,7 @@ var _ = Describe("Podman rmi", func() {
session := podmanTest.Podman([]string{"run", "-dt", "--expose", "222-223", "-P", ALPINE, "/bin/sh"})
session.Wait(30)
Expect(session.ExitCode()).To(Equal(0))
- results := podmanTest.SystemExec("iptables", []string{"-t", "nat", "-L"})
+ results := SystemExec("iptables", []string{"-t", "nat", "-L"})
results.Wait(30)
Expect(results.ExitCode()).To(Equal(0))
Expect(results.OutputToString()).To(ContainSubstring("222"))
@@ -65,12 +66,12 @@ var _ = Describe("Podman rmi", func() {
session := podmanTest.Podman([]string{"run", "-dt", "-p", "80:8000", ALPINE, "/bin/sh"})
session.Wait(30)
Expect(session.ExitCode()).To(Equal(0))
- results := podmanTest.SystemExec("iptables", []string{"-t", "nat", "-L"})
+ results := SystemExec("iptables", []string{"-t", "nat", "-L"})
results.Wait(30)
Expect(results.ExitCode()).To(Equal(0))
Expect(results.OutputToString()).To(ContainSubstring("8000"))
- ncBusy := podmanTest.SystemExec("nc", []string{"-l", "-p", "80"})
+ ncBusy := SystemExec("nc", []string{"-l", "-p", "80"})
ncBusy.Wait(10)
Expect(ncBusy.ExitCode()).ToNot(Equal(0))
})
@@ -144,4 +145,35 @@ var _ = Describe("Podman rmi", func() {
match, _ := session.GrepString("foobar")
Expect(match).Should(BeTrue())
})
+
+ It("podman run --net container: copies hosts and resolv", func() {
+ ctrName := "ctr1"
+ ctr1 := podmanTest.RunTopContainer(ctrName)
+ ctr1.WaitWithDefaultTimeout()
+ Expect(ctr1.ExitCode()).To(Equal(0))
+
+ // Exec in and modify /etc/resolv.conf and /etc/hosts
+ exec1 := podmanTest.Podman([]string{"exec", ctrName, "sh", "-c", "echo nameserver 192.0.2.1 > /etc/resolv.conf"})
+ exec1.WaitWithDefaultTimeout()
+ Expect(exec1.ExitCode()).To(Equal(0))
+
+ exec2 := podmanTest.Podman([]string{"exec", ctrName, "sh", "-c", "echo 192.0.2.2 test1 > /etc/hosts"})
+ exec2.WaitWithDefaultTimeout()
+ Expect(exec2.ExitCode()).To(Equal(0))
+
+ ctrName2 := "ctr2"
+ ctr2 := podmanTest.Podman([]string{"run", "-d", "--net=container:" + ctrName, "--name", ctrName2, ALPINE, "top"})
+ ctr2.WaitWithDefaultTimeout()
+ Expect(ctr2.ExitCode()).To(Equal(0))
+
+ exec3 := podmanTest.Podman([]string{"exec", "-i", ctrName2, "cat", "/etc/resolv.conf"})
+ exec3.WaitWithDefaultTimeout()
+ Expect(exec3.ExitCode()).To(Equal(0))
+ Expect(exec3.OutputToString()).To(ContainSubstring("nameserver 192.0.2.1"))
+
+ exec4 := podmanTest.Podman([]string{"exec", "-i", ctrName2, "cat", "/etc/hosts"})
+ exec4.WaitWithDefaultTimeout()
+ Expect(exec4.ExitCode()).To(Equal(0))
+ Expect(exec4.OutputToString()).To(ContainSubstring("192.0.2.2 test1"))
+ })
})
diff --git a/test/e2e/run_ns_test.go b/test/e2e/run_ns_test.go
index 88c0b1ad2..e4dcc5adc 100644
--- a/test/e2e/run_ns_test.go
+++ b/test/e2e/run_ns_test.go
@@ -5,6 +5,7 @@ import (
"os"
"strings"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -13,7 +14,7 @@ var _ = Describe("Podman run ns", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,7 +22,7 @@ var _ = Describe("Podman run ns", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreArtifact(fedoraMinimal)
})
@@ -49,7 +50,7 @@ var _ = Describe("Podman run ns", func() {
})
It("podman run ipcns test", func() {
- setup := podmanTest.SystemExec("ls", []string{"--inode", "-d", "/dev/shm"})
+ setup := SystemExec("ls", []string{"--inode", "-d", "/dev/shm"})
setup.WaitWithDefaultTimeout()
Expect(setup.ExitCode()).To(Equal(0))
hostShm := setup.OutputToString()
@@ -61,7 +62,7 @@ var _ = Describe("Podman run ns", func() {
})
It("podman run ipcns ipcmk host test", func() {
- setup := podmanTest.SystemExec("ipcmk", []string{"-M", "1024"})
+ setup := SystemExec("ipcmk", []string{"-M", "1024"})
setup.WaitWithDefaultTimeout()
Expect(setup.ExitCode()).To(Equal(0))
output := strings.Split(setup.OutputToString(), " ")
@@ -70,7 +71,7 @@ var _ = Describe("Podman run ns", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- setup = podmanTest.SystemExec("ipcrm", []string{"-m", ipc})
+ setup = SystemExec("ipcrm", []string{"-m", ipc})
setup.WaitWithDefaultTimeout()
Expect(setup.ExitCode()).To(Equal(0))
})
diff --git a/test/e2e/run_passwd_test.go b/test/e2e/run_passwd_test.go
index 0bea092bb..891f4fbd8 100644
--- a/test/e2e/run_passwd_test.go
+++ b/test/e2e/run_passwd_test.go
@@ -4,6 +4,7 @@ import (
"os"
"fmt"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman run passwd", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman run passwd", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/run_privileged_test.go b/test/e2e/run_privileged_test.go
index 0a62d8505..770ea3e6b 100644
--- a/test/e2e/run_privileged_test.go
+++ b/test/e2e/run_privileged_test.go
@@ -5,6 +5,7 @@ import (
"os"
"strings"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -13,7 +14,7 @@ var _ = Describe("Podman privileged container tests", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,7 +22,7 @@ var _ = Describe("Podman privileged container tests", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -42,7 +43,7 @@ var _ = Describe("Podman privileged container tests", func() {
})
It("podman privileged CapEff", func() {
- cap := podmanTest.SystemExec("grep", []string{"CapEff", "/proc/self/status"})
+ cap := SystemExec("grep", []string{"CapEff", "/proc/self/status"})
cap.WaitWithDefaultTimeout()
Expect(cap.ExitCode()).To(Equal(0))
@@ -53,7 +54,7 @@ var _ = Describe("Podman privileged container tests", func() {
})
It("podman cap-add CapEff", func() {
- cap := podmanTest.SystemExec("grep", []string{"CapEff", "/proc/self/status"})
+ cap := SystemExec("grep", []string{"CapEff", "/proc/self/status"})
cap.WaitWithDefaultTimeout()
Expect(cap.ExitCode()).To(Equal(0))
@@ -87,13 +88,13 @@ var _ = Describe("Podman privileged container tests", func() {
It("run no-new-privileges test", func() {
// Check if our kernel is new enough
- k, err := IsKernelNewThan("4.14")
+ k, err := IsKernelNewerThan("4.14")
Expect(err).To(BeNil())
if !k {
Skip("Kernel is not new enough to test this feature")
}
- cap := podmanTest.SystemExec("grep", []string{"NoNewPrivs", "/proc/self/status"})
+ cap := SystemExec("grep", []string{"NoNewPrivs", "/proc/self/status"})
cap.WaitWithDefaultTimeout()
if cap.ExitCode() != 0 {
Skip("Can't determine NoNewPrivs")
@@ -103,12 +104,12 @@ var _ = Describe("Podman privileged container tests", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- privs := strings.Split(cap.OutputToString(), ":")
+ privs := strings.Split(session.OutputToString(), ":")
session = podmanTest.Podman([]string{"run", "--security-opt", "no-new-privileges", "busybox", "grep", "NoNewPrivs", "/proc/self/status"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- noprivs := strings.Split(cap.OutputToString(), ":")
+ noprivs := strings.Split(session.OutputToString(), ":")
Expect(privs[1]).To(Not(Equal(noprivs[1])))
})
diff --git a/test/e2e/run_restart_test.go b/test/e2e/run_restart_test.go
index a2f0b8b41..018c66b45 100644
--- a/test/e2e/run_restart_test.go
+++ b/test/e2e/run_restart_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman run restart containers", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman run restart containers", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -43,7 +44,7 @@ var _ = Describe("Podman run restart containers", func() {
It("Podman start after signal kill", func() {
_ = podmanTest.RunTopContainer("test1")
- ok := WaitForContainer(&podmanTest)
+ ok := WaitForContainer(podmanTest)
Expect(ok).To(BeTrue())
killSession := podmanTest.Podman([]string{"kill", "-s", "9", "test1"})
diff --git a/test/e2e/run_selinux_test.go b/test/e2e/run_selinux_test.go
index a1a18c780..418382e16 100644
--- a/test/e2e/run_selinux_test.go
+++ b/test/e2e/run_selinux_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/opencontainers/selinux/go-selinux"
@@ -13,7 +14,7 @@ var _ = Describe("Podman run", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,7 +22,7 @@ var _ = Describe("Podman run", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
if !selinux.GetEnabled() {
Skip("SELinux not enabled")
diff --git a/test/e2e/run_signal_test.go b/test/e2e/run_signal_test.go
index 5de17108c..8f7894db8 100644
--- a/test/e2e/run_signal_test.go
+++ b/test/e2e/run_signal_test.go
@@ -4,39 +4,24 @@ import (
"fmt"
"io"
"os"
- "os/exec"
"path/filepath"
"strings"
"syscall"
"time"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/onsi/gomega/gexec"
"golang.org/x/sys/unix"
)
-// PodmanPID execs podman and returns its PID
-func (p *PodmanTest) PodmanPID(args []string) (*PodmanSession, int) {
- podmanOptions := p.MakeOptions()
- podmanOptions = append(podmanOptions, strings.Split(p.StorageOptions, " ")...)
- podmanOptions = append(podmanOptions, args...)
- fmt.Printf("Running: %s %s\n", p.PodmanBinary, strings.Join(podmanOptions, " "))
- command := exec.Command(p.PodmanBinary, podmanOptions...)
- session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
- if err != nil {
- Fail(fmt.Sprintf("unable to run podman command: %s", strings.Join(podmanOptions, " ")))
- }
- return &PodmanSession{session}, command.Process.Pid
-}
-
const sigCatch = "trap \"echo FOO >> /h/fifo \" 8; echo READY >> /h/fifo; while :; do sleep 0.25; done"
var _ = Describe("Podman run with --sig-proxy", func() {
var (
tmpdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -44,7 +29,7 @@ var _ = Describe("Podman run with --sig-proxy", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tmpdir)
+ podmanTest = PodmanTestCreate(tmpdir)
podmanTest.RestoreArtifact(fedoraMinimal)
})
@@ -122,7 +107,7 @@ var _ = Describe("Podman run with --sig-proxy", func() {
signal := syscall.SIGPOLL
session, pid := podmanTest.PodmanPID([]string{"run", "--name", "test2", "--sig-proxy=false", fedoraMinimal, "bash", "-c", sigCatch})
- ok := WaitForContainer(&podmanTest)
+ ok := WaitForContainer(podmanTest)
Expect(ok).To(BeTrue())
// Kill with given signal
diff --git a/test/e2e/run_staticip_test.go b/test/e2e/run_staticip_test.go
index b69d15cee..749835b47 100644
--- a/test/e2e/run_staticip_test.go
+++ b/test/e2e/run_staticip_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman run with --ip flag", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,8 +21,10 @@ var _ = Describe("Podman run with --ip flag", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
+ // Cleanup the CNI networks used by the tests
+ os.RemoveAll("/var/lib/cni/networks/podman")
})
AfterEach(func() {
@@ -55,4 +58,13 @@ var _ = Describe("Podman run with --ip flag", func() {
Expect(result.ExitCode()).To(Equal(0))
Expect(result.OutputToString()).To(ContainSubstring("10.88.64.128/16"))
})
+
+ It("Podman run two containers with the same IP", func() {
+ result := podmanTest.Podman([]string{"run", "-d", "--ip", "10.88.64.128", ALPINE, "sleep", "999"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ result = podmanTest.Podman([]string{"run", "-ti", "--ip", "10.88.64.128", ALPINE, "ip", "addr"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).ToNot(Equal(0))
+ })
})
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go
index 98bf66a67..2104991b2 100644
--- a/test/e2e/run_test.go
+++ b/test/e2e/run_test.go
@@ -3,10 +3,12 @@ package integration
import (
"fmt"
"io/ioutil"
+ "net"
"os"
"path/filepath"
"strings"
+ . "github.com/containers/libpod/test/utils"
"github.com/mrunalp/fileutils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -16,7 +18,7 @@ var _ = Describe("Podman run", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -24,7 +26,7 @@ var _ = Describe("Podman run", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -203,7 +205,7 @@ var _ = Describe("Podman run", func() {
Expect(session.OutputToString()).To(ContainSubstring("/run/test rw,relatime, shared"))
})
- It("podman run with mount flag", func() {
+ It("podman run with --mount flag", func() {
if podmanTest.Host.Arch == "ppc64le" {
Skip("skip failing test on ppc64le")
}
@@ -225,7 +227,6 @@ var _ = Describe("Podman run", func() {
found, matches := session.GrepString("/run/test")
Expect(found).Should(BeTrue())
Expect(matches[0]).To(ContainSubstring("rw"))
- Expect(matches[0]).To(ContainSubstring("relatime"))
Expect(matches[0]).To(ContainSubstring("shared"))
mountPath = filepath.Join(podmanTest.TempDir, "scratchpad")
@@ -287,14 +288,27 @@ var _ = Describe("Podman run", func() {
})
It("podman run notify_socket", func() {
- sock := "/run/notify"
+ host := GetHostDistributionInfo()
+ if host.Distribution != "rhel" && host.Distribution != "centos" && host.Distribution != "fedora" {
+ Skip("this test requires a working runc")
+ }
+ sock := filepath.Join(podmanTest.TempDir, "notify")
+ addr := net.UnixAddr{
+ Name: sock,
+ Net: "unixgram",
+ }
+ socket, err := net.ListenUnixgram("unixgram", &addr)
+ Expect(err).To(BeNil())
+ defer os.Remove(sock)
+ defer socket.Close()
+
os.Setenv("NOTIFY_SOCKET", sock)
+ defer os.Unsetenv("NOTIFY_SOCKET")
+
session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv", "NOTIFY_SOCKET"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- match, _ := session.GrepString(sock)
- Expect(match).Should(BeTrue())
- os.Unsetenv("NOTIFY_SOCKET")
+ Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0))
})
It("podman run log-opt", func() {
@@ -322,7 +336,7 @@ var _ = Describe("Podman run", func() {
hooksDir := tempdir + "/hooks"
os.Mkdir(hooksDir, 0755)
fileutils.CopyFile("hooks/hooks.json", hooksDir)
- os.Setenv("HOOK_OPTION", fmt.Sprintf("--hooks-dir-path=%s", hooksDir))
+ os.Setenv("HOOK_OPTION", fmt.Sprintf("--hooks-dir=%s", hooksDir))
os.Remove(hcheck)
session := podmanTest.Podman([]string{"run", ALPINE, "ls"})
session.Wait(10)
@@ -355,7 +369,7 @@ var _ = Describe("Podman run", func() {
keyFile := filepath.Join(targetDir, "key.pem")
err = ioutil.WriteFile(keyFile, []byte(mountString), 0755)
Expect(err).To(BeNil())
- execSession := podmanTest.SystemExec("ln", []string{"-s", targetDir, filepath.Join(secretsDir, "mysymlink")})
+ execSession := SystemExec("ln", []string{"-s", targetDir, filepath.Join(secretsDir, "mysymlink")})
execSession.WaitWithDefaultTimeout()
Expect(execSession.ExitCode()).To(Equal(0))
@@ -608,7 +622,48 @@ USER mail`
session := podmanTest.Podman([]string{"run", "--volume", vol1 + ":/myvol1:z", "--volume", vol2 + ":/myvol2:shared,z", fedoraMinimal, "findmnt", "-o", "TARGET,PROPAGATION"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- match, _ := session.GrepString("shared")
+ match, shared := session.GrepString("shared")
Expect(match).Should(BeTrue())
+ // make sure it's only shared (and not 'shared,slave')
+ isSharedOnly := !strings.Contains(shared[0], "shared,")
+ Expect(isSharedOnly).Should(BeTrue())
+ })
+
+ It("podman run --pod automatically", func() {
+ session := podmanTest.Podman([]string{"run", "--pod", "new:foobar", ALPINE, "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ check := podmanTest.Podman([]string{"pod", "ps", "--no-trunc"})
+ check.WaitWithDefaultTimeout()
+ match, _ := check.GrepString("foobar")
+ Expect(match).To(BeTrue())
+ })
+
+ It("podman run --rm should work", func() {
+ session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ numContainers := podmanTest.NumberOfContainers()
+ Expect(numContainers).To(Equal(0))
+ })
+
+ It("podman run --rm failed container should delete itself", func() {
+ session := podmanTest.Podman([]string{"run", "--rm", ALPINE, "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+
+ numContainers := podmanTest.NumberOfContainers()
+ Expect(numContainers).To(Equal(0))
+ })
+
+ It("podman run failed container should NOT delete itself", func() {
+ session := podmanTest.Podman([]string{"run", ALPINE, "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+
+ numContainers := podmanTest.NumberOfContainers()
+ Expect(numContainers).To(Equal(1))
})
})
diff --git a/test/e2e/run_userns_test.go b/test/e2e/run_userns_test.go
index f2a9af6bf..b1f3d08b4 100644
--- a/test/e2e/run_userns_test.go
+++ b/test/e2e/run_userns_test.go
@@ -4,6 +4,7 @@ import (
"os"
"fmt"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman UserNS support", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman UserNS support", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/runlabel_test.go b/test/e2e/runlabel_test.go
index 8d10d3c24..93a19ba30 100644
--- a/test/e2e/runlabel_test.go
+++ b/test/e2e/runlabel_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -20,7 +21,7 @@ var _ = Describe("podman container runlabel", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -28,7 +29,7 @@ var _ = Describe("podman container runlabel", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go
index 586215c46..9f64e49a7 100644
--- a/test/e2e/save_test.go
+++ b/test/e2e/save_test.go
@@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -13,7 +14,7 @@ var _ = Describe("Podman save", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -21,7 +22,7 @@ var _ = Describe("Podman save", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go
index 84f1efbca..0167e9062 100644
--- a/test/e2e/search_test.go
+++ b/test/e2e/search_test.go
@@ -5,6 +5,7 @@ import (
"os"
"strconv"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -13,7 +14,7 @@ var _ = Describe("Podman search", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
const regFileContents = `
[registries.search]
@@ -40,7 +41,7 @@ var _ = Describe("Podman search", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -136,7 +137,7 @@ var _ = Describe("Podman search", func() {
fakereg.WaitWithDefaultTimeout()
Expect(fakereg.ExitCode()).To(Equal(0))
- if !WaitContainerReady(&podmanTest, "registry", "listening on", 20, 1) {
+ if !WaitContainerReady(podmanTest, "registry", "listening on", 20, 1) {
Skip("Can not start docker registry.")
}
@@ -159,7 +160,7 @@ var _ = Describe("Podman search", func() {
registry.WaitWithDefaultTimeout()
Expect(registry.ExitCode()).To(Equal(0))
- if !WaitContainerReady(&podmanTest, "registry3", "listening on", 20, 1) {
+ if !WaitContainerReady(podmanTest, "registry3", "listening on", 20, 1) {
Skip("Can not start docker registry.")
}
@@ -182,7 +183,7 @@ var _ = Describe("Podman search", func() {
registry.WaitWithDefaultTimeout()
Expect(registry.ExitCode()).To(Equal(0))
- if !WaitContainerReady(&podmanTest, "registry4", "listening on", 20, 1) {
+ if !WaitContainerReady(podmanTest, "registry4", "listening on", 20, 1) {
Skip("Can not start docker registry.")
}
@@ -214,7 +215,7 @@ var _ = Describe("Podman search", func() {
registry.WaitWithDefaultTimeout()
Expect(registry.ExitCode()).To(Equal(0))
- if !WaitContainerReady(&podmanTest, "registry5", "listening on", 20, 1) {
+ if !WaitContainerReady(podmanTest, "registry5", "listening on", 20, 1) {
Skip("Can not start docker registry.")
}
push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"})
@@ -245,7 +246,7 @@ var _ = Describe("Podman search", func() {
registry.WaitWithDefaultTimeout()
Expect(registry.ExitCode()).To(Equal(0))
- if !WaitContainerReady(&podmanTest, "registry6", "listening on", 20, 1) {
+ if !WaitContainerReady(podmanTest, "registry6", "listening on", 20, 1) {
Skip("Can not start docker registry.")
}
push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:5000/my-alpine"})
@@ -276,7 +277,7 @@ var _ = Describe("Podman search", func() {
registryLocal.WaitWithDefaultTimeout()
Expect(registryLocal.ExitCode()).To(Equal(0))
- if !WaitContainerReady(&podmanTest, "registry7", "listening on", 20, 1) {
+ if !WaitContainerReady(podmanTest, "registry7", "listening on", 20, 1) {
Skip("Can not start docker registry.")
}
@@ -284,7 +285,7 @@ var _ = Describe("Podman search", func() {
registryLocal.WaitWithDefaultTimeout()
Expect(registryLocal.ExitCode()).To(Equal(0))
- if !WaitContainerReady(&podmanTest, "registry8", "listening on", 20, 1) {
+ if !WaitContainerReady(podmanTest, "registry8", "listening on", 20, 1) {
Skip("Can not start docker registry.")
}
push := podmanTest.Podman([]string{"push", "--tls-verify=false", "--remove-signatures", ALPINE, "localhost:6000/my-alpine"})
diff --git a/test/e2e/start_test.go b/test/e2e/start_test.go
index 9218cda69..64245c609 100644
--- a/test/e2e/start_test.go
+++ b/test/e2e/start_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman start", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman start", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -88,4 +89,30 @@ var _ = Describe("Podman start", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(125))
})
+
+ It("podman failed to start with --rm should delete the container", func() {
+ session := podmanTest.Podman([]string{"create", "-it", "--rm", ALPINE, "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ start := podmanTest.Podman([]string{"start", "-l"})
+ start.WaitWithDefaultTimeout()
+ Expect(start.ExitCode()).To(Not(Equal(0)))
+
+ numContainers := podmanTest.NumberOfContainers()
+ Expect(numContainers).To(BeZero())
+ })
+
+ It("podman failed to start without --rm should NOT delete the container", func() {
+ session := podmanTest.Podman([]string{"create", "-it", ALPINE, "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ start := podmanTest.Podman([]string{"start", "-l"})
+ start.WaitWithDefaultTimeout()
+ Expect(start.ExitCode()).To(Not(Equal(0)))
+
+ numContainers := podmanTest.NumberOfContainers()
+ Expect(numContainers).To(Equal(1))
+ })
})
diff --git a/test/e2e/stats_test.go b/test/e2e/stats_test.go
index e456d7114..be00d68b2 100644
--- a/test/e2e/stats_test.go
+++ b/test/e2e/stats_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman stats", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman stats", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/stop_test.go b/test/e2e/stop_test.go
index 9698a3110..5c229b9b4 100644
--- a/test/e2e/stop_test.go
+++ b/test/e2e/stop_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman stop", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman stop", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
@@ -56,6 +57,20 @@ var _ = Describe("Podman stop", func() {
Expect(session.ExitCode()).To(Equal(0))
})
+ It("podman stop stopped container", func() {
+ session := podmanTest.RunTopContainer("test1")
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session2 := podmanTest.Podman([]string{"stop", "test1"})
+ session2.WaitWithDefaultTimeout()
+ Expect(session2.ExitCode()).To(Equal(0))
+
+ session3 := podmanTest.Podman([]string{"stop", "test1"})
+ session3.WaitWithDefaultTimeout()
+ Expect(session3.ExitCode()).To(Equal(0))
+ })
+
It("podman stop all containers", func() {
session := podmanTest.RunTopContainer("test1")
session.WaitWithDefaultTimeout()
diff --git a/test/e2e/systemd_test.go b/test/e2e/systemd_test.go
new file mode 100644
index 000000000..ce67bb469
--- /dev/null
+++ b/test/e2e/systemd_test.go
@@ -0,0 +1,81 @@
+package integration
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+
+ . "github.com/containers/libpod/test/utils"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Podman systemd", func() {
+ var (
+ tempdir string
+ err error
+ podmanTest *PodmanTestIntegration
+ systemd_unit_file string
+ )
+
+ BeforeEach(func() {
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanTestCreate(tempdir)
+ podmanTest.RestoreAllArtifacts()
+ systemd_unit_file = `[Unit]
+Description=redis container
+[Service]
+Restart=always
+ExecStart=/usr/bin/podman start -a redis
+ExecStop=/usr/bin/podman stop -t 10 redis
+KillMode=process
+[Install]
+WantedBy=multi-user.target
+`
+ })
+
+ AfterEach(func() {
+ podmanTest.Cleanup()
+ f := CurrentGinkgoTestDescription()
+ timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds())
+ GinkgoWriter.Write([]byte(timedResult))
+ })
+
+ It("podman start container by systemd", func() {
+ if os.Getenv("SKIP_USERNS") != "" {
+ Skip("Skip userns tests.")
+ }
+
+ sys_file := ioutil.WriteFile("/etc/systemd/system/redis.service", []byte(systemd_unit_file), 0644)
+ Expect(sys_file).To(BeNil())
+
+ create := podmanTest.Podman([]string{"create", "-d", "--name", "redis", "redis"})
+ create.WaitWithDefaultTimeout()
+ Expect(create.ExitCode()).To(Equal(0))
+
+ enable := SystemExec("bash", []string{"-c", "systemctl daemon-reload && systemctl enable --now redis"})
+ enable.WaitWithDefaultTimeout()
+ Expect(enable.ExitCode()).To(Equal(0))
+
+ start := SystemExec("bash", []string{"-c", "systemctl start redis"})
+ start.WaitWithDefaultTimeout()
+
+ logs := SystemExec("bash", []string{"-c", "journalctl -n 20 -u redis"})
+ logs.WaitWithDefaultTimeout()
+
+ status := SystemExec("bash", []string{"-c", "systemctl status redis"})
+ status.WaitWithDefaultTimeout()
+ Expect(status.OutputToString()).To(ContainSubstring("active (running)"))
+
+ cleanup := SystemExec("bash", []string{"-c", "systemctl stop redis && systemctl disable redis"})
+ cleanup.WaitWithDefaultTimeout()
+ Expect(cleanup.ExitCode()).To(Equal(0))
+ os.Remove("/etc/systemd/system/redis.service")
+ sys_clean := SystemExec("bash", []string{"-c", "systemctl daemon-reload"})
+ sys_clean.WaitWithDefaultTimeout()
+ Expect(sys_clean.ExitCode()).To(Equal(0))
+ })
+})
diff --git a/test/e2e/tag_test.go b/test/e2e/tag_test.go
index 1b58fbd30..53896d1a2 100644
--- a/test/e2e/tag_test.go
+++ b/test/e2e/tag_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman tag", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman tag", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/top_test.go b/test/e2e/top_test.go
index 9537c2f50..cfcf2a959 100644
--- a/test/e2e/top_test.go
+++ b/test/e2e/top_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman top", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman top", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})
diff --git a/test/e2e/trust_test.go b/test/e2e/trust_test.go
new file mode 100644
index 000000000..bbf09eca4
--- /dev/null
+++ b/test/e2e/trust_test.go
@@ -0,0 +1,72 @@
+package integration
+
+import (
+ "encoding/json"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+
+ . "github.com/containers/libpod/test/utils"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Podman trust", func() {
+ var (
+ tempdir string
+ err error
+ podmanTest *PodmanTestIntegration
+ )
+
+ BeforeEach(func() {
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanTestCreate(tempdir)
+ podmanTest.RestoreAllArtifacts()
+ })
+
+ AfterEach(func() {
+ podmanTest.Cleanup()
+ f := CurrentGinkgoTestDescription()
+ timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds())
+ GinkgoWriter.Write([]byte(timedResult))
+ })
+
+ It("podman image trust show", func() {
+ path, err := os.Getwd()
+ if err != nil {
+ os.Exit(1)
+ }
+ session := podmanTest.Podman([]string{"image", "trust", "show", "--registrypath", filepath.Dir(path), "--policypath", filepath.Join(filepath.Dir(path), "policy.json")})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ outArray := session.OutputToStringArray()
+ Expect(len(outArray)).To(Equal(3))
+ Expect(outArray[0]).Should(ContainSubstring("accept"))
+ Expect(outArray[1]).Should(ContainSubstring("reject"))
+ Expect(outArray[2]).Should(ContainSubstring("signed"))
+ })
+
+ It("podman image trust set", func() {
+ path, err := os.Getwd()
+ if err != nil {
+ os.Exit(1)
+ }
+ session := podmanTest.Podman([]string{"image", "trust", "set", "--policypath", filepath.Join(filepath.Dir(path), "trust_set_test.json"), "-t", "accept", "default"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ var teststruct map[string][]map[string]string
+ policyContent, err := ioutil.ReadFile(filepath.Join(filepath.Dir(path), "trust_set_test.json"))
+ if err != nil {
+ os.Exit(1)
+ }
+ err = json.Unmarshal(policyContent, &teststruct)
+ if err != nil {
+ os.Exit(1)
+ }
+ Expect(teststruct["default"][0]["type"]).To(Equal("insecureAcceptAnything"))
+ })
+})
diff --git a/test/e2e/version_test.go b/test/e2e/version_test.go
index 6caf0e3dd..68a462bdb 100644
--- a/test/e2e/version_test.go
+++ b/test/e2e/version_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman version", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman version", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
})
AfterEach(func() {
diff --git a/test/e2e/volume_create_test.go b/test/e2e/volume_create_test.go
new file mode 100644
index 000000000..50ee63f2a
--- /dev/null
+++ b/test/e2e/volume_create_test.go
@@ -0,0 +1,60 @@
+package integration
+
+import (
+ "fmt"
+ "os"
+
+ . "github.com/containers/libpod/test/utils"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Podman volume create", func() {
+ var (
+ tempdir string
+ err error
+ podmanTest *PodmanTestIntegration
+ )
+
+ BeforeEach(func() {
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanTestCreate(tempdir)
+ podmanTest.RestoreAllArtifacts()
+ })
+
+ AfterEach(func() {
+ podmanTest.CleanupVolume()
+ f := CurrentGinkgoTestDescription()
+ timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds())
+ GinkgoWriter.Write([]byte(timedResult))
+ })
+
+ It("podman create volume", func() {
+ session := podmanTest.Podman([]string{"volume", "create"})
+ session.WaitWithDefaultTimeout()
+ volName := session.OutputToString()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ check := podmanTest.Podman([]string{"volume", "ls", "-q"})
+ check.WaitWithDefaultTimeout()
+ match, _ := check.GrepString(volName)
+ Expect(match).To(BeTrue())
+ Expect(len(check.OutputToStringArray())).To(Equal(1))
+ })
+
+ It("podman create volume with name", func() {
+ session := podmanTest.Podman([]string{"volume", "create", "myvol"})
+ session.WaitWithDefaultTimeout()
+ volName := session.OutputToString()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ check := podmanTest.Podman([]string{"volume", "ls", "-q"})
+ check.WaitWithDefaultTimeout()
+ match, _ := check.GrepString(volName)
+ Expect(match).To(BeTrue())
+ Expect(len(check.OutputToStringArray())).To(Equal(1))
+ })
+})
diff --git a/test/e2e/volume_inspect_test.go b/test/e2e/volume_inspect_test.go
new file mode 100644
index 000000000..d0d5a601e
--- /dev/null
+++ b/test/e2e/volume_inspect_test.go
@@ -0,0 +1,77 @@
+package integration
+
+import (
+ "fmt"
+ "os"
+
+ . "github.com/containers/libpod/test/utils"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Podman volume inspect", func() {
+ var (
+ tempdir string
+ err error
+ podmanTest *PodmanTestIntegration
+ )
+
+ BeforeEach(func() {
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanTestCreate(tempdir)
+ podmanTest.RestoreAllArtifacts()
+ })
+
+ AfterEach(func() {
+ podmanTest.CleanupVolume()
+ f := CurrentGinkgoTestDescription()
+ timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds())
+ GinkgoWriter.Write([]byte(timedResult))
+ })
+
+ It("podman inspect volume", func() {
+ session := podmanTest.Podman([]string{"volume", "create", "myvol"})
+ session.WaitWithDefaultTimeout()
+ volName := session.OutputToString()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "inspect", volName})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.IsJSONOutputValid()).To(BeTrue())
+ })
+
+ It("podman inspect volume with Go format", func() {
+ session := podmanTest.Podman([]string{"volume", "create", "myvol"})
+ session.WaitWithDefaultTimeout()
+ volName := session.OutputToString()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "inspect", "--format", "{{.Name}}", volName})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).To(Equal(volName))
+ })
+
+ It("podman inspect volume with --all flag", func() {
+ session := podmanTest.Podman([]string{"volume", "create", "myvol1"})
+ session.WaitWithDefaultTimeout()
+ volName1 := session.OutputToString()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "create", "myvol2"})
+ session.WaitWithDefaultTimeout()
+ volName2 := session.OutputToString()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "inspect", "--format", "{{.Name}}", "--all"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(2))
+ Expect(session.OutputToStringArray()[0]).To(Equal(volName1))
+ Expect(session.OutputToStringArray()[1]).To(Equal(volName2))
+ })
+})
diff --git a/test/e2e/volume_ls_test.go b/test/e2e/volume_ls_test.go
new file mode 100644
index 000000000..119d29d9b
--- /dev/null
+++ b/test/e2e/volume_ls_test.go
@@ -0,0 +1,84 @@
+package integration
+
+import (
+ "fmt"
+ "os"
+
+ . "github.com/containers/libpod/test/utils"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Podman volume ls", func() {
+ var (
+ tempdir string
+ err error
+ podmanTest *PodmanTestIntegration
+ )
+
+ BeforeEach(func() {
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanTestCreate(tempdir)
+ podmanTest.RestoreAllArtifacts()
+ })
+
+ AfterEach(func() {
+ podmanTest.CleanupVolume()
+ f := CurrentGinkgoTestDescription()
+ timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds())
+ GinkgoWriter.Write([]byte(timedResult))
+ })
+
+ It("podman ls volume", func() {
+ session := podmanTest.Podman([]string{"volume", "create", "myvol"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(2))
+ })
+
+ It("podman ls volume with JSON format", func() {
+ session := podmanTest.Podman([]string{"volume", "create", "myvol"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "ls", "--format", "json"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.IsJSONOutputValid()).To(BeTrue())
+ })
+
+ It("podman ls volume with Go template", func() {
+ session := podmanTest.Podman([]string{"volume", "create", "myvol"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "ls", "--format", "table {{.Name}} {{.Driver}} {{.Scope}}"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(2))
+ })
+
+ It("podman ls volume with --filter flag", func() {
+ session := podmanTest.Podman([]string{"volume", "create", "--label", "foo=bar", "myvol"})
+ volName := session.OutputToString()
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "create"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "ls", "--filter", "label=foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(2))
+ Expect(session.OutputToStringArray()[1]).To(ContainSubstring(volName))
+ })
+})
diff --git a/test/e2e/volume_prune_test.go b/test/e2e/volume_prune_test.go
new file mode 100644
index 000000000..8c0a10e77
--- /dev/null
+++ b/test/e2e/volume_prune_test.go
@@ -0,0 +1,64 @@
+package integration
+
+import (
+ "fmt"
+ "os"
+
+ . "github.com/containers/libpod/test/utils"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Podman volume prune", func() {
+ var (
+ tempdir string
+ err error
+ podmanTest *PodmanTestIntegration
+ )
+
+ BeforeEach(func() {
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanTestCreate(tempdir)
+ podmanTest.RestoreAllArtifacts()
+ })
+
+ AfterEach(func() {
+ podmanTest.CleanupVolume()
+ f := CurrentGinkgoTestDescription()
+ timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds())
+ GinkgoWriter.Write([]byte(timedResult))
+ })
+
+ It("podman prune volume", func() {
+ session := podmanTest.Podman([]string{"volume", "create"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "create"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"create", "-v", "myvol:/myvol", ALPINE, "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(4))
+
+ session = podmanTest.Podman([]string{"volume", "prune", "--force"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(2))
+
+ podmanTest.Cleanup()
+ })
+})
diff --git a/test/e2e/volume_rm_test.go b/test/e2e/volume_rm_test.go
new file mode 100644
index 000000000..cebb09467
--- /dev/null
+++ b/test/e2e/volume_rm_test.go
@@ -0,0 +1,91 @@
+package integration
+
+import (
+ "fmt"
+ "os"
+
+ . "github.com/containers/libpod/test/utils"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Podman volume rm", func() {
+ var (
+ tempdir string
+ err error
+ podmanTest *PodmanTestIntegration
+ )
+
+ BeforeEach(func() {
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanTestCreate(tempdir)
+ podmanTest.RestoreAllArtifacts()
+ })
+
+ AfterEach(func() {
+ podmanTest.CleanupVolume()
+ f := CurrentGinkgoTestDescription()
+ timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds())
+ GinkgoWriter.Write([]byte(timedResult))
+ })
+
+ It("podman rm volume", func() {
+ session := podmanTest.Podman([]string{"volume", "create", "myvol"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "rm", "myvol"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(0))
+ })
+
+ It("podman rm with --force flag", func() {
+ session := podmanTest.Podman([]string{"create", "-v", "myvol:/myvol", ALPINE, "ls"})
+ cid := session.OutputToString()
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "rm", "myvol"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+ Expect(session.ErrorToString()).To(ContainSubstring(cid))
+
+ session = podmanTest.Podman([]string{"volume", "rm", "-f", "myvol"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(0))
+
+ podmanTest.Cleanup()
+ })
+
+ It("podman rm with --all flag", func() {
+ session := podmanTest.Podman([]string{"volume", "create", "myvol"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "create"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "rm", "-a"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "ls"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(0))
+ })
+})
diff --git a/test/e2e/wait_test.go b/test/e2e/wait_test.go
index 8e7035204..a7e9b4c06 100644
--- a/test/e2e/wait_test.go
+++ b/test/e2e/wait_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ . "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -12,7 +13,7 @@ var _ = Describe("Podman wait", func() {
var (
tempdir string
err error
- podmanTest PodmanTest
+ podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
@@ -20,7 +21,7 @@ var _ = Describe("Podman wait", func() {
if err != nil {
os.Exit(1)
}
- podmanTest = PodmanCreate(tempdir)
+ podmanTest = PodmanTestCreate(tempdir)
podmanTest.RestoreAllArtifacts()
})