Improve resilience of api pkg tests #4676
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In other parts of the codebase we have been using waits to avoid running into
missing serfHealth registration
. In those cases we have been usingtestrpc.WaitForTestAgent
, but that function cannot be used in theapi
package because it leads to a dependency cycle.This PR adds a wait for serfHealth to the TestServer that is created for
api
tests.This wait is added to session tests because in
session.Create
we require that all checks be registered.Lastly the test client for semaphore tests is now spun up with Connect disabled, as is done in the lock tests.
After making these changes all semaphore and session tests are passing consistently in the repro environment.
Update
Added some more changes.
From this CI job we can see that running the semaphore/lock tests with Connect disabled isn't enough to make them as robust as we would like.
Under the hood, locks and semaphores create sessions with
session.Create
. To avoid the associated check for serfHealth, this PR creates sessions withsession.CreateNoChecks
and then feeds that in when locks/semaphores are created.In cases where custom semaphore/lock options were already being passed in, there is now a WaitForSerfCheck instead.
Additionally, travis will now log tests as they pass to avoid situations like this one.