summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/e2e/checkpoint_test.go6
-rw-r--r--test/e2e/libpod_suite_test.go2
-rw-r--r--test/e2e/run_networking_test.go33
-rw-r--r--test/e2e/run_test.go27
-rw-r--r--test/e2e/start_test.go26
-rw-r--r--test/e2e/systemd_test.go81
6 files changed, 171 insertions, 4 deletions
diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go
index fe614e911..57322643e 100644
--- a/test/e2e/checkpoint_test.go
+++ b/test/e2e/checkpoint_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"net"
"os"
+ "strconv"
"github.com/containers/libpod/pkg/criu"
. "github.com/containers/libpod/test/utils"
@@ -29,8 +30,9 @@ var _ = Describe("Podman checkpoint", func() {
Skip("CRIU is missing or too old.")
}
hostInfo := podmanTest.Host
- if hostInfo.Distribution == "fedora" && hostInfo.Version == "29" {
- Skip("Checkpoint tests appear to fail on F29.")
+ hostDistVer, _ := strconv.Atoi(hostInfo.Version)
+ if hostInfo.Distribution == "fedora" && hostDistVer <= 29 {
+ Skip("Checkpoint tests appear to fail on older (<30) Fedora versions .")
}
})
diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go
index 268db5aa1..d312124ab 100644
--- a/test/e2e/libpod_suite_test.go
+++ b/test/e2e/libpod_suite_test.go
@@ -109,7 +109,7 @@ func PodmanTestCreate(tempDir string) *PodmanTestIntegration {
}
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") != "" {
diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go
index 1b05ac031..68b1f06de 100644
--- a/test/e2e/run_networking_test.go
+++ b/test/e2e/run_networking_test.go
@@ -9,7 +9,7 @@ import (
. "github.com/onsi/gomega"
)
-var _ = Describe("Podman rmi", func() {
+var _ = Describe("Podman run networking", func() {
var (
tempdir string
err error
@@ -145,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_test.go b/test/e2e/run_test.go
index 4a9bd4e46..2104991b2 100644
--- a/test/e2e/run_test.go
+++ b/test/e2e/run_test.go
@@ -639,4 +639,31 @@ USER mail`
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/start_test.go b/test/e2e/start_test.go
index c11511d1f..64245c609 100644
--- a/test/e2e/start_test.go
+++ b/test/e2e/start_test.go
@@ -89,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/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))
+ })
+})