Skip to content

Commit

Permalink
Fix potential race condition in testing
Browse files Browse the repository at this point in the history
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: containers#6518

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Dec 1, 2020
1 parent 429d949 commit c734c13
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/bindings/test/containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
Expand Down

0 comments on commit c734c13

Please sign in to comment.