async def test_diagnose_on_response_delays(client): tmax = client.app[kMAX_AVG_RESP_LATENCY] coros = [client.get(f"/delay/{1.1*tmax}") for _ in range(10)] tic = time.time() resps = await asyncio.gather(*coros) toc = time.time() - tic # should take approx 1.1*tmax assert toc < 1.2 * tmax for resp in resps: await assert_status(resp, web.HTTPOk) # monitoring latency_observed = client.app[kLATENCY_PROBE].value() assert latency_observed > tmax # diagnostics with pytest.raises(HealthError): assert_healthy_app(client.app)
async def test_diagnose_on_response_delays(client): settings: DiagnosticsSettings = client.app[ APP_SETTINGS_KEY].WEBSERVER_DIAGNOSTICS tmax = settings.DIAGNOSTICS_MAX_AVG_LATENCY coros = [client.get(f"/delay/{1.1*tmax}") for _ in range(10)] tic = time.time() resps = await asyncio.gather(*coros) toc = time.time() - tic # should take approx 1.1*tmax assert toc < 1.2 * tmax for resp in resps: await assert_status(resp, web.HTTPOk) # monitoring latency_observed = client.app[kLATENCY_PROBE].value() assert latency_observed > tmax # diagnostics with pytest.raises(HealthError): assert_healthy_app(client.app)
async def test_diagnose_on_failure(client): resp = await client.get("/fail") assert resp.status == web.HTTPServiceUnavailable.status_code assert_healthy_app(client.app)
async def test_diagnose_on_unexpected_error(client): resp = await client.get("/error") assert resp.status == web.HTTPInternalServerError.status_code assert_healthy_app(client.app)