Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5-internal/deflake-metrics
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deflake integration test: metrics
9 changes: 3 additions & 6 deletions services/brig/test/integration/API/Metrics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ testPrometheusMetrics brig = do
-- Should contain the request duration metric in its output
const (Just "TYPE http_request_duration_seconds histogram") =~= responseBody

-- | This test runs in `withSettingsOverrides` to ensure that only this test is
-- accessing brig, if we target the real brig, some other test running
-- in-parallel could make this test fail.
testMetricsEndpoint :: Opt.Opts -> Brig -> Http ()
testMetricsEndpoint opts brig0 = withSettingsOverrides opts $ do
let brig = apiVersion "v1" . brig0
Expand All @@ -71,11 +68,11 @@ testMetricsEndpoint opts brig0 = withSettingsOverrides opts $ do
_ <- post (brig . path p3 . contentJson . queryItem "persist" "true" . json (defEmailLogin email) . expect2xx)
_ <- post (brig . path p3 . contentJson . queryItem "persist" "true" . json (defEmailLogin email) . expect2xx)
countSelf <- getCount "/self" "GET"
liftIO $ assertEqual "/self was called once" (beforeSelf + 1) countSelf
liftIO $ assertBool "/self was called at least once" ((beforeSelf + 1) <= countSelf)
countClients <- getCount "/users/:uid/clients" "GET"
liftIO $ assertEqual "/users/:uid/clients was called twice" (beforeClients + 2) countClients
liftIO $ assertBool "/users/:uid/clients was called at least twice" ((beforeClients + 2) <= countClients)
countProperties <- getCount "/login" "POST"
liftIO $ assertEqual "/login was called twice" (beforeProperties + 2) countProperties
liftIO $ assertBool "/login was called at least twice" ((beforeProperties + 2) <= countProperties)
where
getCount endpoint m = do
rsp <- responseBody <$> get (brig0 . path "i/metrics")
Expand Down