MCPcopy
hub / github.com/psycopg/psycopg / test_stats_connect

Function test_stats_connect

tests/pool/test_pool.py:868–885  ·  view source on GitHub ↗
(proxy, monkeypatch)

Source from the content-addressed store, hash-verified

866@pytest.mark.slow
867@skip_free_threaded("timing not accurate under the free-threaded build")
868def test_stats_connect(proxy, monkeypatch):
869 proxy.start()
870 delay_connection(monkeypatch, 0.2)
871 with pool.ConnectionPool(proxy.client_dsn, min_size=3) as p:
872 p.wait()
873 stats = p.get_stats()
874 assert stats["connections_num"] == 3
875 assert stats.get("connections_errors", 0) == 0
876 assert stats.get("connections_lost", 0) == 0
877 assert 580 <= stats["connections_ms"] < 1200
878
879 proxy.stop()
880 p.check()
881 sleep(0.1)
882 stats = p.get_stats()
883 assert stats["connections_num"] > 3
884 assert stats["connections_errors"] > 0
885 assert stats["connections_lost"] == 3
886
887
888@pytest.mark.crdb_skip("pg_terminate_backend")

Callers

nothing calls this directly

Calls 7

get_statsMethod · 0.80
delay_connectionFunction · 0.70
startMethod · 0.45
waitMethod · 0.45
getMethod · 0.45
stopMethod · 0.45
checkMethod · 0.45

Tested by

no test coverage detected