diff options
Diffstat (limited to 'test/e2e')
-rw-r--r-- | test/e2e/common_test.go | 8 | ||||
-rw-r--r-- | test/e2e/events_test.go | 49 |
2 files changed, 34 insertions, 23 deletions
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 80ee83f44..e12edad49 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -21,6 +21,7 @@ import ( "github.com/containers/storage/pkg/reexec" "github.com/containers/storage/pkg/stringid" jsoniter "github.com/json-iterator/go" + "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" @@ -573,3 +574,10 @@ func (p *PodmanTestIntegration) CreateSeccompJson(in []byte) (string, error) { } return jsonFile, nil } + +func SkipIfNotFedora() { + info := GetHostDistributionInfo() + if info.Distribution != "fedora" { + ginkgo.Skip("Test can only run on Fedora") + } +} diff --git a/test/e2e/events_test.go b/test/e2e/events_test.go index 460554b77..8c496872f 100644 --- a/test/e2e/events_test.go +++ b/test/e2e/events_test.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "strings" + "time" . "github.com/containers/libpod/test/utils" . "github.com/onsi/ginkgo" @@ -24,23 +25,26 @@ var _ = Describe("Podman events", func() { os.Exit(1) } podmanTest = PodmanTestCreate(tempdir) + podmanTest.Setup() podmanTest.SeedImages() }) AfterEach(func() { podmanTest.Cleanup() f := CurrentGinkgoTestDescription() - timedResult := fmt.Sprintf("Test: %s completed in %f seconds", f.TestText, f.Duration.Seconds()) - GinkgoWriter.Write([]byte(timedResult)) - + processTestResult(f) }) // For most, all, of these tests we do not "live" test following a log because it may make a fragile test // system more complex. Instead we run the "events" and then verify that the events are processed correctly. // Perhaps a future version of this test would put events in a go func and send output back over a channel // while events occur. + + // These tests are only known to work on Fedora ATM. Other distributions + // will be skipped. It("podman events", func() { - Skip("need to verify images have correct packages for journald") + SkipIfRootless() + SkipIfNotFedora() _, ec, _ := podmanTest.RunLsContainer("") Expect(ec).To(Equal(0)) result := podmanTest.Podman([]string{"events", "--stream=false"}) @@ -49,7 +53,8 @@ var _ = Describe("Podman events", func() { }) It("podman events with an event filter", func() { - Skip("need to verify images have correct packages for journald") + SkipIfRootless() + SkipIfNotFedora() _, ec, _ := podmanTest.RunLsContainer("") Expect(ec).To(Equal(0)) result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=start"}) @@ -59,11 +64,14 @@ var _ = Describe("Podman events", func() { }) It("podman events with an event filter and container=cid", func() { - Skip("need to verify images have correct packages for journald") + Skip("Does not work on v2") + SkipIfRootless() + SkipIfNotFedora() _, ec, cid := podmanTest.RunLsContainer("") Expect(ec).To(Equal(0)) _, ec2, cid2 := podmanTest.RunLsContainer("") Expect(ec2).To(Equal(0)) + time.Sleep(5 * time.Second) result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "event=start", "--filter", fmt.Sprintf("container=%s", cid)}) result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) @@ -72,7 +80,8 @@ var _ = Describe("Podman events", func() { }) It("podman events with a type and filter container=id", func() { - Skip("need to verify images have correct packages for journald") + SkipIfRootless() + SkipIfNotFedora() _, ec, cid := podmanTest.RunLsContainer("") Expect(ec).To(Equal(0)) result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "type=pod", "--filter", fmt.Sprintf("container=%s", cid)}) @@ -82,7 +91,8 @@ var _ = Describe("Podman events", func() { }) It("podman events with a type", func() { - Skip("need to verify images have correct packages for journald") + SkipIfRootless() + SkipIfNotFedora() setup := podmanTest.Podman([]string{"run", "-dt", "--pod", "new:foobarpod", ALPINE, "top"}) setup.WaitWithDefaultTimeout() stop := podmanTest.Podman([]string{"pod", "stop", "foobarpod"}) @@ -97,7 +107,8 @@ var _ = Describe("Podman events", func() { }) It("podman events --since", func() { - Skip("need to verify images have correct packages for journald") + SkipIfRootless() + SkipIfNotFedora() _, ec, _ := podmanTest.RunLsContainer("") Expect(ec).To(Equal(0)) result := podmanTest.Podman([]string{"events", "--stream=false", "--since", "1m"}) @@ -106,7 +117,8 @@ var _ = Describe("Podman events", func() { }) It("podman events --until", func() { - Skip("need to verify images have correct packages for journald") + SkipIfRootless() + SkipIfNotFedora() _, ec, _ := podmanTest.RunLsContainer("") Expect(ec).To(Equal(0)) test := podmanTest.Podman([]string{"events", "--help"}) @@ -118,37 +130,28 @@ var _ = Describe("Podman events", func() { }) It("podman events format", func() { - Skip(v2remotefail) - info := GetHostDistributionInfo() - if info.Distribution != "fedora" { - Skip("need to verify images have correct packages for journald") - } + SkipIfRootless() + SkipIfNotFedora() _, ec, _ := podmanTest.RunLsContainer("") Expect(ec).To(Equal(0)) test := podmanTest.Podman([]string{"events", "--stream=false", "--format", "json"}) test.WaitWithDefaultTimeout() - fmt.Println(test.OutputToStringArray()) jsonArr := test.OutputToStringArray() Expect(len(jsonArr)).To(Not(BeZero())) eventsMap := make(map[string]string) err := json.Unmarshal([]byte(jsonArr[0]), &eventsMap) - if err != nil { - os.Exit(1) - } + Expect(err).To(BeNil()) _, exist := eventsMap["Status"] Expect(exist).To(BeTrue()) Expect(test.ExitCode()).To(BeZero()) test = podmanTest.Podman([]string{"events", "--stream=false", "--format", "{{json.}}"}) test.WaitWithDefaultTimeout() - fmt.Println(test.OutputToStringArray()) jsonArr = test.OutputToStringArray() Expect(len(jsonArr)).To(Not(BeZero())) eventsMap = make(map[string]string) err = json.Unmarshal([]byte(jsonArr[0]), &eventsMap) - if err != nil { - os.Exit(1) - } + Expect(err).To(BeNil()) _, exist = eventsMap["Status"] Expect(exist).To(BeTrue()) Expect(test.ExitCode()).To(BeZero()) |