tests: wait for index refresh before getting document count #70
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.
i've several times observed flaky tests which seem to boil down to the fact that the index hadn't been refreshed yet before we queried the count.
this happens because writing a document does not make it immediately available for querying, unless you specify the
refresh=true
parameter in the request.thus there were now two ways of fixing this:
refresh=true
in the migrationsas the test files might be used as templates by other users i decided to go for the second approach, as this way the executions run faster (not relevant if you add a single document, but very relevant when you do larger migrations).
as we currently only rely on index creation (no refresh needed) and document count (the modified function) there's only a single place which had to be extended with this. if we ever add tests which use other metrics relying on the content of an index we'll have to add the same there.