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

[WPB-15037] fix flaky test migration to new index #4382

Merged
merged 16 commits into from
Dec 19, 2024
Merged
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
Loading