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

tests: wait for index refresh before getting document count #70

Merged

Conversation

rursprung
Copy link
Collaborator

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:

  • add refresh=true in the migrations
  • execute an index refresh before querying the count

as 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.

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:
* add `refresh=true` in the migrations
* execute an index refresh before querying the count

as 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.
@filipelautert filipelautert merged commit f643e92 into liquibase:master Nov 18, 2024
11 of 12 checks passed
@rursprung rursprung deleted the wait-for-index-refresh-in-tests branch November 18, 2024 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants