Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race condition in NATS transport tests #705

Merged
merged 2 commits into from
Apr 27, 2018
Merged

Fix race condition in NATS transport tests #705

merged 2 commits into from
Apr 27, 2018

Conversation

nussjustin
Copy link
Contributor

@nussjustin nussjustin commented Apr 27, 2018

The tests for PR #680 have a small race that leads to sporadic test failures (https://travis-ci.org/go-kit/kit/jobs/372140473#L1732).

Closing subscriptions and connections is asynchronous, so when the next test runs and tries to receive messages there may still be an old connection subscribed to the same topic used by the next test.

Since the tests are using queue subscriptions only one client will ever get a message, meaning that a message may never arrive on the newer connection.

This PR refactors the logic for opening and closing the connections to check for open subscriptions before opening new connections and, if there are any, waiting a bit before failing.

Other options are to use different topic or queue names or even not using queue subscriptions, but checking the server seemed safer to me and requires less changes to the tests.

@peterbourgon
Copy link
Member

Hehe thanks

@peterbourgon peterbourgon merged commit 72f9852 into go-kit:master Apr 27, 2018
@nussjustin nussjustin deleted the nats-test-race-condition branch April 28, 2018 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants