summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-08-05 15:53:44 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-08-28 09:28:49 -0400
commit63d989a3449050e8cf0a168145baa512e7493772 (patch)
treed1801f462833785577479c99cadfe8036fc7140e /test/e2e
parent8b09b07b19126c60876aaee6c1a4250a38cdd48c (diff)
downloadpodman-63d989a3449050e8cf0a168145baa512e7493772.tar.gz
podman-63d989a3449050e8cf0a168145baa512e7493772.tar.bz2
podman-63d989a3449050e8cf0a168145baa512e7493772.zip
Add an integration test for systemd in a container
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/systemd_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/e2e/systemd_test.go b/test/e2e/systemd_test.go
index 91604867d..994e99cec 100644
--- a/test/e2e/systemd_test.go
+++ b/test/e2e/systemd_test.go
@@ -5,6 +5,8 @@ package integration
import (
"io/ioutil"
"os"
+ "strings"
+ "time"
. "github.com/containers/libpod/test/utils"
. "github.com/onsi/ginkgo"
@@ -77,4 +79,43 @@ WantedBy=multi-user.target
status := SystemExec("bash", []string{"-c", "systemctl status redis"})
Expect(status.OutputToString()).To(ContainSubstring("active (running)"))
})
+
+ It("podman run container with systemd PID1", func() {
+ systemdImage := "fedora"
+ pull := podmanTest.Podman([]string{"pull", systemdImage})
+ pull.WaitWithDefaultTimeout()
+ Expect(pull.ExitCode()).To(Equal(0))
+
+ ctrName := "testSystemd"
+ run := podmanTest.Podman([]string{"run", "--name", ctrName, "-t", "-i", "-d", systemdImage, "init"})
+ run.WaitWithDefaultTimeout()
+ Expect(run.ExitCode()).To(Equal(0))
+ ctrID := run.OutputToString()
+
+ logs := podmanTest.Podman([]string{"logs", ctrName})
+ logs.WaitWithDefaultTimeout()
+ Expect(logs.ExitCode()).To(Equal(0))
+
+ // Give container 10 seconds to start
+ started := false
+ for i := 0; i < 10; i++ {
+ runningCtrs := podmanTest.Podman([]string{"ps", "-q", "--no-trunc"})
+ runningCtrs.WaitWithDefaultTimeout()
+ Expect(runningCtrs.ExitCode()).To(Equal(0))
+
+ if strings.Contains(runningCtrs.OutputToString(), ctrID) {
+ started = true
+ break
+ }
+
+ time.Sleep(1 * time.Second)
+ }
+
+ Expect(started).To(BeTrue())
+
+ systemctl := podmanTest.Podman([]string{"exec", "-t", "-i", ctrName, "systemctl", "status", "--no-pager"})
+ systemctl.WaitWithDefaultTimeout()
+ Expect(systemctl.ExitCode()).To(Equal(0))
+ Expect(strings.Contains(systemctl.OutputToString(), "State:")).To(BeTrue())
+ })
})