Skip to content

Add some retry delay logic to Search integration tests to hopefully deflake them#1774

Closed
jschaul wants to merge 1 commit intodevelopfrom
perhaps-deflake-search-tests
Closed

Add some retry delay logic to Search integration tests to hopefully deflake them#1774
jschaul wants to merge 1 commit intodevelopfrom
perhaps-deflake-search-tests

Conversation

@jschaul
Copy link
Member

@jschaul jschaul commented Sep 15, 2021

Another flaky instance of this test was seen on the CI run from #1770, quoted here

Perhaps using retry over a maximum of 4 seconds alleviates this problem somewhat. We care about eventual consistency I suppose, not immediate consistency.

Checklist

  • The PR Title explains the impact of the change.
  • The PR description provides context as to why the change should occur and what the code contributes to that effect. This could also be a link to a JIRA ticket or a Github issue, if there is one.
  • changelog.d contains the following bits of information:
    • A file with the changelog entry in one or more suitable sub-sections. The sub-sections are marked by directories inside changelog.d

Comment on lines -285 to +293
results <- searchResults <$> executeSearch brig searcher searchedWord
let resultUIds = map contactQualifiedId results
let expectedOrder = [handleMatch, handlePrefixMatch]
let dbg = "results: " <> show results <> "\nsearchedWord: " <> cs searchedWord
-- possibly there is some delay in refreshing of the index writes being
-- visible for subsequent reads, so we try this a few times.
results <- aFewTimes 12 (toIds <$> executeSearch brig searcher searchedWord) (== expectedOrder)
liftIO $
assertEqual
("Expected order: handle match, handle prefix match.\n\nSince this test fails sporadically for unknown reasons here here is some debug info:\n" <> dbg)
"If this test fails again, maybe we should consider deleting it and living with some more uncertainty"
expectedOrder
resultUIds
results
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is not broken anymore. The comment is stale.

Comment on lines +267 to +274
-- possibly there is some delay in refreshing of the index writes being
-- visible for subsequent reads, so we try this a few times.
results <- aFewTimes 12 (toIds <$> executeSearch brig searcher searchedWord) (== expectedOrder)
liftIO $
assertEqual
("Expected order: name match, name prefix match.\n\nSince this test fails sporadically for unknown reasons here is some debug info:\n" <> dbg)
"If this test fails again, maybe we should consider deleting it and living with some more uncertainty"
expectedOrder
resultUIds
results
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't actually fix the test. The problem is in the production code. So, if you really want to fix it by running again, you should generate the name again.

pcapriotti added a commit that referenced this pull request Sep 16, 2021
This sorts the result list after the fact by putting exact handle and
name searches at the beginning, so we don't have to rely on ES being
precise with the ordering of exact matches.

Hopefully this fixes the flakyness of the `order-name` integration test,
and makes #1774 unnecessary.
@jschaul
Copy link
Member Author

jschaul commented Sep 16, 2021

Fair enough 😄 , closing this in favour of #1776

@jschaul jschaul closed this Sep 16, 2021
@pcapriotti pcapriotti mentioned this pull request Sep 21, 2021
4 tasks
@elland elland deleted the perhaps-deflake-search-tests branch October 10, 2023 09:52
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.

3 participants