Skip to content

Commit

Permalink
integration: Print more information when a dynamic backend fails to s…
Browse files Browse the repository at this point in the history
…tart (#4402)
  • Loading branch information
akshaymankar authored Jan 8, 2025
1 parent 657a46a commit 5c8273f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions integration/test/Testlib/ModService.hs
Original file line number Diff line number Diff line change
Expand Up @@ -452,14 +452,14 @@ withProcess resource overrides service = do

startNginzLocalIO <- lift $ appToIO $ startNginzLocal resource

let prefix = "[" <> execName <> "@" <> domain <> maybe "" (":" <>) env.currentTestName <> "] "
let initProcess = case (service, cwd) of
(Nginz, Nothing) -> startNginzK8s domain sm
(Nginz, Just _) -> startNginzLocalIO
_ -> do
config <- getConfig
tempFile <- writeTempFile "/tmp" (execName <> "-" <> domain <> "-" <> ".yaml") (cs $ Yaml.encode config)
(_, Just stdoutHdl, Just stderrHdl, ph) <- createProcess (proc exe ["-c", tempFile]) {cwd = cwd, std_out = CreatePipe, std_err = CreatePipe}
let prefix = "[" <> execName <> "@" <> domain <> maybe "" (":" <>) env.currentTestName <> "] "
let colorize = fromMaybe id (lookup execName processColors)
void $ forkIO $ logToConsole colorize prefix stdoutHdl
void $ forkIO $ logToConsole colorize prefix stderrHdl
Expand All @@ -469,7 +469,9 @@ withProcess resource overrides service = do
iok <- appToIOKleisli k
liftIO $ E.bracket initProcess cleanupService iok

lift $ waitUntilServiceIsUp domain service
lift $
addFailureContext ("Waiting for service: " <> prefix) $
waitUntilServiceIsUp domain service

logToConsole :: (String -> String) -> String -> Handle -> IO ()
logToConsole colorize prefix hdl = do
Expand All @@ -489,7 +491,7 @@ retryRequestUntil reqAction err = do
(\_ isUp -> pure (not isUp))
(const reqAction)
unless isUp $
failApp ("Timed out waiting for service " <> err <> " to come up")
assertFailure ("Timed out waiting for service " <> err <> " to come up")

startNginzK8s :: String -> ServiceMap -> IO ServiceInstance
startNginzK8s domain sm = do
Expand Down

0 comments on commit 5c8273f

Please sign in to comment.