diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2020-12-01 14:07:18 -0500 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2020-12-01 14:11:04 -0500 |
commit | c734c13904d40d40c2cc13ec55b8a6397af2db67 (patch) | |
tree | e3ce9ea69cef3f39d451f2ffb0a50b14af61dfd2 | |
parent | 429d9492f85faf4c3a595b9d7b2a38743a4b8e42 (diff) | |
download | podman-c734c13904d40d40c2cc13ec55b8a6397af2db67.tar.gz podman-c734c13904d40d40c2cc13ec55b8a6397af2db67.tar.bz2 podman-c734c13904d40d40c2cc13ec55b8a6397af2db67.zip |
Fix potential race condition in testing
The It("podman wait to pause|unpause condition"... test is
flaking every so often when a messages is sent in the second
function to a channel. It is my believe that in between the time
the first function sends a message to the channel and before it closes
the channel the second errChan=make() has happened. This would mean that
the fist function closes the second errChan, and then when the second
function sends a message to the second errChan, it fails and blows up with
the error you are seeing.
By creating a different variable for the second channel, we eliminate the race.
Fixes: https://github.com/containers/podman/issues/6518
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
-rw-r--r-- | pkg/bindings/test/containers_test.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/pkg/bindings/test/containers_test.go b/pkg/bindings/test/containers_test.go index 0fb677768..15066ff1a 100644 --- a/pkg/bindings/test/containers_test.go +++ b/pkg/bindings/test/containers_test.go @@ -290,17 +290,17 @@ var _ = Describe("Podman containers ", func() { Expect(wait).To(BeNil()) Expect(exitCode).To(BeNumerically("==", -1)) - errChan = make(chan error) + unpauseErrChan := make(chan error) go func() { defer GinkgoRecover() _, waitErr := containers.Wait(bt.conn, name, &running) - errChan <- waitErr - close(errChan) + unpauseErrChan <- waitErr + close(unpauseErrChan) }() err = containers.Unpause(bt.conn, name) Expect(err).To(BeNil()) - unPausewait := <-errChan + unPausewait := <-unpauseErrChan Expect(unPausewait).To(BeNil()) Expect(exitCode).To(BeNumerically("==", -1)) }) |