Skip to content

Commit

Permalink
Merge pull request #23650 from Luap99/e2e-systemd-rm
Browse files Browse the repository at this point in the history
test/e2e: rm systemd start test
  • Loading branch information
openshift-merge-bot[bot] authored Aug 19, 2024
2 parents 8fd0d90 + 57016f5 commit 8068bb2
Showing 1 changed file with 0 additions and 61 deletions.
61 changes: 0 additions & 61 deletions test/e2e/systemd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,67 +16,6 @@ import (

var _ = Describe("Podman systemd", func() {

var systemdUnitFile string

BeforeEach(func() {
podmanCmd := fmt.Sprintf("%s %s", podmanTest.PodmanBinary, strings.Join(podmanTest.MakeOptions(nil, false, false), " "))
systemdUnitFile = fmt.Sprintf(`[Unit]
Description=redis container
[Service]
Restart=always
ExecStart=%s start -a redis
ExecStop=%s stop -t 10 redis
KillMode=process
[Install]
WantedBy=default.target
`, podmanCmd, podmanCmd)
})

It("podman start container by systemd", func() {
SkipIfRemote("cannot create unit file on remote host")
SkipIfContainerized("test does not have systemd as pid 1")

dashWhat := "--system"
unitDir := "/run/systemd/system"
if isRootless() {
dashWhat = "--user"
unitDir = fmt.Sprintf("%s/systemd/user", os.Getenv("XDG_RUNTIME_DIR"))
}
err := os.MkdirAll(unitDir, 0700)
Expect(err).ToNot(HaveOccurred())

serviceName := "redis-" + RandomString(10)
sysFilePath := filepath.Join(unitDir, serviceName+".service")
sysFile := os.WriteFile(sysFilePath, []byte(systemdUnitFile), 0644)
Expect(sysFile).ToNot(HaveOccurred())
defer func() {
stop := SystemExec("systemctl", []string{dashWhat, "stop", serviceName})
os.Remove(sysFilePath)
SystemExec("systemctl", []string{dashWhat, "daemon-reload"})
Expect(stop).Should(ExitCleanly())
}()

create := podmanTest.Podman([]string{"create", "--name", "redis", REDIS_IMAGE})
create.WaitWithDefaultTimeout()
Expect(create).Should(ExitCleanly())

enable := SystemExec("systemctl", []string{dashWhat, "daemon-reload"})
Expect(enable).Should(ExitCleanly())

start := SystemExec("systemctl", []string{dashWhat, "start", serviceName})
Expect(start).Should(ExitCleanly())

checkAvailableJournald()
if !journald.journaldSkip {
// "-q" needed on fc40+ because something creates /run/log/journal/XXX 2750
logs := SystemExec("journalctl", []string{dashWhat, "-q", "-n", "20", "-u", serviceName})
Expect(logs).Should(ExitCleanly())
}

status := SystemExec("systemctl", []string{dashWhat, "status", serviceName})
Expect(status.OutputToString()).To(ContainSubstring("active (running)"))
})

It("podman run container with systemd PID1", func() {
ctrName := "testSystemd"
run := podmanTest.Podman([]string{"run", "--name", ctrName, "-t", "-i", "-d", SYSTEMD_IMAGE, "/sbin/init"})
Expand Down

0 comments on commit 8068bb2

Please sign in to comment.