Skip to content

Commit

Permalink
[WPB-15037] fix flaky test for migration to new index (#4382)
Browse files Browse the repository at this point in the history
  • Loading branch information
supersven authored Dec 19, 2024
1 parent 682bdd2 commit 3d700f9
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 149 deletions.
1 change: 1 addition & 0 deletions changelog.d/5-internal/stabilize-es-migration-test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Stabilize `index migration` tests by fixing a race on index names.
2 changes: 1 addition & 1 deletion services/brig/src/Brig/API/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ getVerificationCode uid action = runMaybeT do

internalSearchIndexAPI :: forall r. ServerT BrigIRoutes.ISearchIndexAPI (Handler r)
internalSearchIndexAPI =
Named @"indexRefresh" (NoContent <$ lift (wrapClient Search.refreshIndex))
Named @"indexRefresh" (NoContent <$ lift (wrapClient Search.refreshIndexes))

enterpriseLoginApi :: (Member EnterpriseLoginSubsystem r) => ServerT BrigIRoutes.EnterpriseLoginApi (Handler r)
enterpriseLoginApi =
Expand Down
10 changes: 7 additions & 3 deletions services/brig/src/Brig/User/Search/Index.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module Brig.User.Search.Index
createIndex,
createIndexIfNotPresent,
resetIndex,
refreshIndex,
refreshIndexes,
updateMapping,

-- * Re-exports
Expand Down Expand Up @@ -122,10 +122,14 @@ instance MonadHttp IndexIO where
--------------------------------------------------------------------------------
-- Administrative

refreshIndex :: (MonadIndexIO m) => m ()
refreshIndex = liftIndexIO $ do
-- | Refresh ElasticSearch index and the additional one if it's configured
-- Only used in tests. In production, the addtional index is used write-only.
refreshIndexes :: (MonadIndexIO m) => m ()
refreshIndexes = liftIndexIO $ do
idx <- asks idxName
void $ ES.refreshIndex idx
mbAddIdx <- asks idxAdditionalName
mapM_ ES.refreshIndex mbAddIdx

createIndexIfNotPresent ::
(MonadIndexIO m) =>
Expand Down
Loading

0 comments on commit 3d700f9

Please sign in to comment.