mirror of https://github.com/containers/podman.git
Merge pull request #21107 from fj-tsubasa/e2e-systemd_test-journald
e2e: Skip journalctl if journald is unavailable
This commit is contained in:
commit
4419924150
|
|
@ -851,17 +851,21 @@ type journaldTests struct {
|
||||||
|
|
||||||
var journald journaldTests
|
var journald journaldTests
|
||||||
|
|
||||||
func SkipIfJournaldUnavailable() {
|
// Check if journalctl is unavailable
|
||||||
|
func checkAvailableJournald() {
|
||||||
f := func() {
|
f := func() {
|
||||||
journald.journaldSkip = false
|
journald.journaldSkip = false
|
||||||
|
|
||||||
// Check if journalctl is unavailable
|
|
||||||
cmd := exec.Command("journalctl", "-n", "1")
|
cmd := exec.Command("journalctl", "-n", "1")
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
journald.journaldSkip = true
|
journald.journaldSkip = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
journald.journaldOnce.Do(f)
|
journald.journaldOnce.Do(f)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SkipIfJournaldUnavailable() {
|
||||||
|
checkAvailableJournald()
|
||||||
|
|
||||||
// In container, journalctl does not return an error even if
|
// In container, journalctl does not return an error even if
|
||||||
// journald is unavailable
|
// journald is unavailable
|
||||||
|
|
|
||||||
|
|
@ -64,8 +64,11 @@ WantedBy=default.target
|
||||||
start := SystemExec("systemctl", []string{dashWhat, "start", serviceName})
|
start := SystemExec("systemctl", []string{dashWhat, "start", serviceName})
|
||||||
Expect(start).Should(ExitCleanly())
|
Expect(start).Should(ExitCleanly())
|
||||||
|
|
||||||
logs := SystemExec("journalctl", []string{dashWhat, "-n", "20", "-u", serviceName})
|
checkAvailableJournald()
|
||||||
Expect(logs).Should(ExitCleanly())
|
if !journald.journaldSkip {
|
||||||
|
logs := SystemExec("journalctl", []string{dashWhat, "-n", "20", "-u", serviceName})
|
||||||
|
Expect(logs).Should(ExitCleanly())
|
||||||
|
}
|
||||||
|
|
||||||
status := SystemExec("systemctl", []string{dashWhat, "status", serviceName})
|
status := SystemExec("systemctl", []string{dashWhat, "status", serviceName})
|
||||||
Expect(status.OutputToString()).To(ContainSubstring("active (running)"))
|
Expect(status.OutputToString()).To(ContainSubstring("active (running)"))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue