From: Martin Weinelt Date: Mon, 23 Oct 2023 22:54:18 +0000 (+0200) Subject: Mark test_identify_closure as timing-sensitive X-Git-Tag: pool-3.1.9~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0de152cd902e1dfe4573fdf577bc8621ff04c73;p=thirdparty%2Fpsycopg.git Mark test_identify_closure as timing-sensitive ``` ____________________________ test_identify_closure _____________________________ conn_cls = , dsn = 'host=127.0.0.1 user=psycopg' @pytest.mark.crdb_skip("pg_terminate_backend") @pytest.mark.slow def test_identify_closure(conn_cls, dsn): def closer(): time.sleep(0.2) conn2.execute("select pg_terminate_backend(%s)", [conn.pgconn.backend_pid]) conn = conn_cls.connect(dsn) conn2 = conn_cls.connect(dsn) try: t = threading.Thread(target=closer) t.start() t0 = time.time() try: with pytest.raises(psycopg.OperationalError): conn.execute("select pg_sleep(1.0)") t1 = time.time() > assert 0.2 < t1 - t0 < 0.4 E assert 0.2 < (1697715164.8614173 - 1697715164.6617775) tests/test_concurrency.py:231: AssertionError ``` --- diff --git a/tests/crdb/test_connection.py b/tests/crdb/test_connection.py index b2a69ef53..c45c801e8 100644 --- a/tests/crdb/test_connection.py +++ b/tests/crdb/test_connection.py @@ -64,6 +64,7 @@ def test_broken(conn): @pytest.mark.slow +@pytest.mark.timing def test_identify_closure(conn_cls, dsn): with conn_cls.connect(dsn, autocommit=True) as conn: with conn_cls.connect(dsn, autocommit=True) as conn2: diff --git a/tests/crdb/test_connection_async.py b/tests/crdb/test_connection_async.py index 9cd73ddd7..020ca5f64 100644 --- a/tests/crdb/test_connection_async.py +++ b/tests/crdb/test_connection_async.py @@ -64,6 +64,7 @@ async def test_broken(aconn): @pytest.mark.slow +@pytest.mark.timing async def test_identify_closure(aconn_cls, dsn): async with await aconn_cls.connect(dsn) as conn: async with await aconn_cls.connect(dsn) as conn2: diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py index 3dcc2fbeb..c059f0de3 100644 --- a/tests/test_concurrency.py +++ b/tests/test_concurrency.py @@ -213,6 +213,7 @@ def test_cancel_stream(conn): @pytest.mark.crdb_skip("pg_terminate_backend") @pytest.mark.slow +@pytest.mark.timing def test_identify_closure(conn_cls, dsn): def closer(): time.sleep(0.2) diff --git a/tests/test_concurrency_async.py b/tests/test_concurrency_async.py index 017bbd79e..b87fb5023 100644 --- a/tests/test_concurrency_async.py +++ b/tests/test_concurrency_async.py @@ -162,6 +162,7 @@ async def test_cancel_stream(aconn): @pytest.mark.slow +@pytest.mark.timing @pytest.mark.crdb_skip("pg_terminate_backend") async def test_identify_closure(aconn_cls, dsn): async def closer():