diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-07-21 10:55:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-21 10:55:40 -0400 |
commit | f8e2a3500e3daadf21137d1647cabf9ef20b2114 (patch) | |
tree | a4825917b192332599841cdcc41096af39a4b474 /pkg/bindings | |
parent | 644b5bc8a35760654824c46cad8618e0d6e634bc (diff) | |
parent | dea93c27d2809cd5a04563d27cf00a8e682884c8 (diff) | |
download | podman-f8e2a3500e3daadf21137d1647cabf9ef20b2114.tar.gz podman-f8e2a3500e3daadf21137d1647cabf9ef20b2114.tar.bz2 podman-f8e2a3500e3daadf21137d1647cabf9ef20b2114.zip |
Merge pull request #6902 from vrothberg/events-endpoint
events endpoint: fix panic and race condition
Diffstat (limited to 'pkg/bindings')
-rw-r--r-- | pkg/bindings/test/system_test.go | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/pkg/bindings/test/system_test.go b/pkg/bindings/test/system_test.go index 93141400b..430184f4a 100644 --- a/pkg/bindings/test/system_test.go +++ b/pkg/bindings/test/system_test.go @@ -1,6 +1,7 @@ package test_bindings import ( + "sync" "time" "github.com/containers/libpod/v2/pkg/bindings" @@ -38,22 +39,28 @@ var _ = Describe("Podman system", func() { }) It("podman events", func() { - eChan := make(chan entities.Event, 1) - var messages []entities.Event - cancelChan := make(chan bool, 1) + var name = "top" + _, err := bt.RunTopContainer(&name, bindings.PFalse, nil) + Expect(err).To(BeNil()) + + filters := make(map[string][]string) + filters["container"] = []string{name} + + binChan := make(chan entities.Event) + done := sync.Mutex{} + done.Lock() + eventCounter := 0 go func() { - for e := range eChan { - messages = append(messages, e) + defer done.Unlock() + for range binChan { + eventCounter++ } }() - go func() { - system.Events(bt.conn, eChan, cancelChan, nil, nil, nil, bindings.PFalse) - }() - _, err := bt.RunTopContainer(nil, nil, nil) + err = system.Events(bt.conn, binChan, nil, nil, nil, filters, bindings.PFalse) Expect(err).To(BeNil()) - cancelChan <- true - Expect(len(messages)).To(BeNumerically("==", 5)) + done.Lock() + Expect(eventCounter).To(BeNumerically(">", 0)) }) It("podman system prune - pod,container stopped", func() { |