Skip to content

Commit 1e3e423

Browse files
committed
Don't setup what we don't need
1 parent 35c69f1 commit 1e3e423

File tree

1 file changed

+54
-54
lines changed
  • integration/test/Testlib

1 file changed

+54
-54
lines changed

integration/test/Testlib/Run.hs

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ runTests tests mXMLOutput cfg shardingGroup = do
132132
-- Although migrations are run on service start up we are running them here before
133133
-- to prevent race conditions between brig and galley
134134
-- which cause flakiness and can make the complete test suite fail
135-
runAppWithEnv env runMigrations
135+
-- runAppWithEnv env runMigrations
136136
-- Currently 4 seems to be stable, more seems to create more timeouts.
137137
report <- fmap mconcat $ pooledForConcurrentlyN 4 tests $ \(qname, _, _, action) -> do
138138
timestamp <- getCurrentTime
@@ -156,7 +156,7 @@ runTests tests mXMLOutput cfg shardingGroup = do
156156
pure (TestSuiteReport [TestCaseReport qname TestSuccess tm])
157157
writeChan output Nothing
158158
wait displayThread
159-
deleteFederationV0AndV1Queues genv
159+
-- deleteFederationV0AndV1Queues genv
160160
printReport report
161161
mapM_ (saveXMLReport report) mXMLOutput
162162
when (any (\testCase -> testCase.result /= TestSuccess) report.cases) $
@@ -168,58 +168,58 @@ runTests tests mXMLOutput cfg shardingGroup = do
168168
e <- mkEnv Nothing g
169169
pure (g, e)
170170

171-
runMigrations :: App ()
172-
runMigrations = do
173-
cwdBase <- asks (.servicesCwdBase)
174-
let brig = "brig"
175-
let (cwd, exe) = case cwdBase of
176-
Nothing -> (Nothing, brig)
177-
Just dir ->
178-
(Just (dir </> brig), "../../dist" </> brig)
179-
getConfig <- readAndUpdateConfig def backendA Brig
180-
config <- liftIO getConfig
181-
tempFile <- liftIO $ writeTempFile "/tmp" "brig-migrations.yaml" (cs $ Yaml.encode config)
182-
dynDomains <- asks (.dynamicDomains)
183-
pool <- asks (.resourcePool)
184-
lowerCodensity $ do
185-
resources <- acquireResources (length dynDomains) pool
186-
let dbnames = [backendA.berPostgresqlDBName, backendB.berPostgresqlDBName] <> map (.berPostgresqlDBName) resources
187-
for_ dbnames $ runMigration exe tempFile cwd
188-
liftIO $ putStrLn "Postgres migrations finished"
189-
where
190-
runMigration :: (MonadIO m) => FilePath -> FilePath -> Maybe FilePath -> String -> m ()
191-
runMigration exe tempFile cwd dbname = do
192-
let cp = (proc exe ["-c", tempFile, "migrate-postgres", "--dbname", dbname]) {cwd}
193-
(_, _, _, ph) <- liftIO $ createProcess cp
194-
void $ liftIO $ waitForProcess ph
195-
196-
deleteFederationV0AndV1Queues :: GlobalEnv -> IO ()
197-
deleteFederationV0AndV1Queues env = do
198-
let testDomains = env.gDomain1 : env.gDomain2 : env.gDynamicDomains
199-
putStrLn "Attempting to delete federation V0 queues..."
200-
(mV0User, mV0Pass) <- readCredsFromEnvWithSuffix "V0"
201-
fromMaybe (putStrLn "No or incomplete credentials for fed V0 RabbitMQ") $
202-
deleteFederationQueues testDomains env.gRabbitMQConfigV0 <$> mV0User <*> mV0Pass
203-
204-
putStrLn "Attempting to delete federation V1 queues..."
205-
(mV1User, mV1Pass) <- readCredsFromEnvWithSuffix "V1"
206-
fromMaybe (putStrLn "No or incomplete credentials for fed V1 RabbitMQ") $
207-
deleteFederationQueues testDomains env.gRabbitMQConfigV1 <$> mV1User <*> mV1Pass
208-
where
209-
readCredsFromEnvWithSuffix :: String -> IO (Maybe Text, Maybe Text)
210-
readCredsFromEnvWithSuffix suffix =
211-
(,)
212-
<$> (fmap fromString <$> lookupEnv ("RABBITMQ_USERNAME_" <> suffix))
213-
<*> (fmap fromString <$> lookupEnv ("RABBITMQ_PASSWORD_" <> suffix))
214-
215-
deleteFederationQueues :: [String] -> RabbitMqAdminOpts -> Text -> Text -> IO ()
216-
deleteFederationQueues testDomains opts username password = do
217-
client <- mkRabbitMqAdminClientEnvWithCreds opts username password
218-
for_ testDomains $ \domain -> do
219-
page <- client.listQueuesByVHost opts.vHost (fromString $ "^backend-notifications\\." <> domain <> "$") True 100 1
220-
for_ page.items $ \queue -> do
221-
putStrLn $ "Deleting queue " <> T.unpack queue.name
222-
void $ deleteQueue client opts.vHost queue.name
171+
-- runMigrations :: App ()
172+
-- runMigrations = do
173+
-- cwdBase <- asks (.servicesCwdBase)
174+
-- let brig = "brig"
175+
-- let (cwd, exe) = case cwdBase of
176+
-- Nothing -> (Nothing, brig)
177+
-- Just dir ->
178+
-- (Just (dir </> brig), "../../dist" </> brig)
179+
-- getConfig <- readAndUpdateConfig def backendA Brig
180+
-- config <- liftIO getConfig
181+
-- tempFile <- liftIO $ writeTempFile "/tmp" "brig-migrations.yaml" (cs $ Yaml.encode config)
182+
-- dynDomains <- asks (.dynamicDomains)
183+
-- pool <- asks (.resourcePool)
184+
-- lowerCodensity $ do
185+
-- resources <- acquireResources (length dynDomains) pool
186+
-- let dbnames = [backendA.berPostgresqlDBName, backendB.berPostgresqlDBName] <> map (.berPostgresqlDBName) resources
187+
-- for_ dbnames $ runMigration exe tempFile cwd
188+
-- liftIO $ putStrLn "Postgres migrations finished"
189+
-- where
190+
-- runMigration :: (MonadIO m) => FilePath -> FilePath -> Maybe FilePath -> String -> m ()
191+
-- runMigration exe tempFile cwd dbname = do
192+
-- let cp = (proc exe ["-c", tempFile, "migrate-postgres", "--dbname", dbname]) {cwd}
193+
-- (_, _, _, ph) <- liftIO $ createProcess cp
194+
-- void $ liftIO $ waitForProcess ph
195+
196+
-- deleteFederationV0AndV1Queues :: GlobalEnv -> IO ()
197+
-- deleteFederationV0AndV1Queues env = do
198+
-- let testDomains = env.gDomain1 : env.gDomain2 : env.gDynamicDomains
199+
-- putStrLn "Attempting to delete federation V0 queues..."
200+
-- (mV0User, mV0Pass) <- readCredsFromEnvWithSuffix "V0"
201+
-- fromMaybe (putStrLn "No or incomplete credentials for fed V0 RabbitMQ") $
202+
-- deleteFederationQueues testDomains env.gRabbitMQConfigV0 <$> mV0User <*> mV0Pass
203+
--
204+
-- putStrLn "Attempting to delete federation V1 queues..."
205+
-- (mV1User, mV1Pass) <- readCredsFromEnvWithSuffix "V1"
206+
-- fromMaybe (putStrLn "No or incomplete credentials for fed V1 RabbitMQ") $
207+
-- deleteFederationQueues testDomains env.gRabbitMQConfigV1 <$> mV1User <*> mV1Pass
208+
-- where
209+
-- readCredsFromEnvWithSuffix :: String -> IO (Maybe Text, Maybe Text)
210+
-- readCredsFromEnvWithSuffix suffix =
211+
-- (,)
212+
-- <$> (fmap fromString <$> lookupEnv ("RABBITMQ_USERNAME_" <> suffix))
213+
-- <*> (fmap fromString <$> lookupEnv ("RABBITMQ_PASSWORD_" <> suffix))
214+
--
215+
-- deleteFederationQueues :: [String] -> RabbitMqAdminOpts -> Text -> Text -> IO ()
216+
-- deleteFederationQueues testDomains opts username password = do
217+
-- client <- mkRabbitMqAdminClientEnvWithCreds opts username password
218+
-- for_ testDomains $ \domain -> do
219+
-- page <- client.listQueuesByVHost opts.vHost (fromString $ "^backend-notifications\\." <> domain <> "$") True 100 1
220+
-- for_ page.items $ \queue -> do
221+
-- putStrLn $ "Deleting queue " <> T.unpack queue.name
222+
-- void $ deleteQueue client opts.vHost queue.name
223223

224224
doListTests :: [(String, String, String, x)] -> IO ()
225225
doListTests tests = for_ tests $ \(qname, _desc, _full, _) -> do

0 commit comments

Comments
 (0)