summaryrefslogtreecommitdiff
path: root/test/e2e/logs_test.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2020-01-07 13:41:56 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2020-01-10 10:35:19 +0100
commit71341a194843fadf836b5460d09f685bb6c465b4 (patch)
tree115b8394df383e81b40d322cabc864f576ed6478 /test/e2e/logs_test.go
parentf3fc10feb42930def6922fc050096ea38bafed7a (diff)
downloadpodman-71341a194843fadf836b5460d09f685bb6c465b4.tar.gz
podman-71341a194843fadf836b5460d09f685bb6c465b4.tar.bz2
podman-71341a194843fadf836b5460d09f685bb6c465b4.zip
log: support --log-opt tag=
support a custom tag to add to each log for the container. It is currently supported only by the journald backend. Closes: https://github.com/containers/libpod/issues/3653 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'test/e2e/logs_test.go')
-rw-r--r--test/e2e/logs_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go
index e25364695..0438a31cb 100644
--- a/test/e2e/logs_test.go
+++ b/test/e2e/logs_test.go
@@ -1,7 +1,9 @@
package integration
import (
+ "fmt"
"os"
+ "os/exec"
"strings"
. "github.com/containers/libpod/test/utils"
@@ -153,6 +155,23 @@ var _ = Describe("Podman logs", func() {
Expect(results.ExitCode()).To(BeZero())
})
+ It("podman journald logs for container with container tag", func() {
+ Skip("need to verify images have correct packages for journald")
+ logc := podmanTest.Podman([]string{"run", "--log-driver", "journald", "--log-opt=tag={{.ImageName}}", "-d", ALPINE, "sh", "-c", "echo podman; sleep 0.1; echo podman; sleep 0.1; echo podman"})
+ logc.WaitWithDefaultTimeout()
+ Expect(logc.ExitCode()).To(Equal(0))
+ cid := logc.OutputToString()
+
+ wait := podmanTest.Podman([]string{"wait", "-l"})
+ wait.WaitWithDefaultTimeout()
+ Expect(wait.ExitCode()).To(BeZero())
+
+ cmd := exec.Command("journalctl", "--no-pager", "-o", "json", "--output-fields=CONTAINER_TAG", "-u", fmt.Sprintf("libpod-conmon-%s.scope", cid))
+ out, err := cmd.CombinedOutput()
+ Expect(err).To(BeNil())
+ Expect(string(out)).To(ContainSubstring("alpine"))
+ })
+
It("podman journald logs for container", func() {
Skip("need to verify images have correct packages for journald")
logc := podmanTest.Podman([]string{"run", "--log-driver", "journald", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"})