Fix Collection and ConfigureIndex tests #79
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.
Problem
Currently,
CollectionTest, andConfigureIndexTestare very flakey. Collections tests take a long while to run due to the need to spin up a collection, wait until it's ready, and then creating an index and waiting until that's ready.ConfigureIndexTestdeletes the index as a part of the final@Testin the file, but it doesn't seem like the order of execution is guaranteed, so deleting an index like this may cause issues: https://www.baeldung.com/junit-5-test-orderSolution
CollectionTestto create a single collection from the initial index that's shared across both tests. Previously we were creating a collection for each test, which is not ultimately necessary and is very time-consuming. Also, useassertWithRetry()to retry upserting and describing index stats. These calls seemingly have a tendency to flake when made against a newly created index. Retrying a few times if we have an error on the initial pass seems to help here.ConfigureIndexTesthas afinallyclause in the last@Testin the file deletes the index. Given we set up with@BeforeAlland the execution order is not guaranteed unless we specify, it feels like it makes more sense to clean things up in@AfterAll, which seems to resolve the issue with the test itself.Type of Change
Test Plan
Validate integration runs in CI. Runs should overall be a few minutes faster, and less prone to failing on these specific tests.