zeromq / goczmq

goczmq is a golang wrapper for CZMQ.
Mozilla Public License 2.0
591 stars 94 forks source link

Problem: pub/sub channeler tests randomly fail with timeout #287

Closed tarmo closed 4 years ago

tarmo commented 4 years ago

Solution: fix tests by confirming subscription before sending message

I noticed the tests failed for https://github.com/zeromq/goczmq/pull/286 . Same tests I also saw randomly failing locally. These tests failed because they have a race: they publish a message potentially before a subscription has reached the pub socket.

I solved this by switching to XPub socket and explicitly checking that said socket received the expected amount of subscription messages. This makes the tests solid with repeated go clean -cache; make test runs.