]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Skip timing-based tests on GitHub Actions MacOS runners
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 28 Jun 2021 23:40:10 +0000 (00:40 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 29 Jun 2021 01:36:33 +0000 (02:36 +0100)
.github/workflows/tests.yml
tests/conftest.py
tests/pool/test_pool.py
tests/pool/test_pool_async.py
tests/pool/test_sched.py
tests/pool/test_sched_async.py
tests/test_concurrency.py
tests/test_concurrency_async.py
tests/test_connection.py
tests/test_connection_async.py

index 8922558206f7ca6839069b7d1383ffdf8fb9c818..cae4ff92e55b3f18224edce85614fd342e0cf09f 100644 (file)
@@ -121,6 +121,9 @@ jobs:
     env:
       PSYCOPG_IMPL: c
       PSYCOPG_TEST_DSN: "host=127.0.0.1 user=runner dbname=postgres"
+      # MacOS on GitHub Actions seems particularly slow.
+      # Don't run timing-based tests as they regularly fail.
+      PYTEST_ADDOPTS: "-m 'not timing'"
 
     steps:
       - uses: actions/checkout@v2
index d83cd42df39709c7c54705a92dc79c150353d738..e42f141aebdbda803a819e8f8669931b98980fed 100644 (file)
@@ -23,6 +23,11 @@ def pytest_configure(config):
         "markers", "subprocess: the test import psycopg after subprocess"
     )
 
+    config.addinivalue_line(
+        "markers",
+        "timing: the test is timing based and can fail on cheese hardware",
+    )
+
 
 def pytest_addoption(parser):
     parser.addoption(
index 427b99ebd56cc0298e3c0730d8377469f24a5bed..39da2d0b41eaedcf542a23df529a60cb9e11a29f 100644 (file)
@@ -82,6 +82,7 @@ def test_connection_not_lost(dsn):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 def test_concurrent_filling(dsn, monkeypatch, retries):
     delay_connection(monkeypatch, 0.1)
 
@@ -106,6 +107,7 @@ def test_concurrent_filling(dsn, monkeypatch, retries):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 def test_wait_ready(dsn, monkeypatch):
     delay_connection(monkeypatch, 0.1)
     with pytest.raises(pool.PoolTimeout):
@@ -267,6 +269,7 @@ def test_reset_broken(dsn, caplog):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 def test_queue(dsn, retries):
     def worker(n):
         t0 = time()
@@ -329,6 +332,7 @@ def test_queue_size(dsn):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 def test_queue_timeout(dsn, retries):
     def worker(n):
         t0 = time()
@@ -361,6 +365,7 @@ def test_queue_timeout(dsn, retries):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 def test_dead_client(dsn):
     def worker(i, timeout):
         try:
@@ -386,6 +391,7 @@ def test_dead_client(dsn):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 def test_queue_timeout_override(dsn, retries):
     def worker(n):
         t0 = time()
@@ -628,6 +634,7 @@ def test_closed_queue(dsn):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 def test_grow(dsn, monkeypatch, retries):
     delay_connection(monkeypatch, 0.1)
 
@@ -657,6 +664,7 @@ def test_grow(dsn, monkeypatch, retries):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 def test_shrink(dsn, monkeypatch):
 
     from psycopg.pool.pool import ShrinkPool
@@ -725,6 +733,7 @@ def test_reconnect(proxy, caplog, monkeypatch):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 def test_reconnect_failure(proxy):
     proxy.start()
 
@@ -779,6 +788,7 @@ def test_uniform_use(dsn, retries):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 def test_resize(dsn):
     def sampler():
         sleep(0.05)  # ensure sampling happens after shrink check
@@ -826,6 +836,7 @@ def test_jitter():
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 def test_max_lifetime(dsn):
     with pool.ConnectionPool(dsn, min_size=1, max_lifetime=0.2) as p:
         sleep(0.1)
@@ -870,6 +881,7 @@ def test_async_pool_not_supported(dsn):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 def test_stats_measures(dsn):
     def worker(n):
         with p.connection() as conn:
@@ -910,6 +922,7 @@ def test_stats_measures(dsn):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 def test_stats_usage(dsn):
     def worker(n):
         try:
index b35f988c1036db7693fe2d40f152a85b5fa61265..c3a6ce95dff4bcc8fe08f9e392d0344c400fb25a 100644 (file)
@@ -92,6 +92,7 @@ async def test_connection_not_lost(dsn):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 async def test_concurrent_filling(dsn, monkeypatch, retries):
     delay_connection(monkeypatch, 0.1)
 
@@ -118,6 +119,7 @@ async def test_concurrent_filling(dsn, monkeypatch, retries):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 async def test_wait_ready(dsn, monkeypatch):
     delay_connection(monkeypatch, 0.1)
     with pytest.raises(pool.PoolTimeout):
@@ -289,6 +291,7 @@ async def test_reset_broken(dsn, caplog):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 async def test_queue(dsn, retries):
     async def worker(n):
         t0 = time()
@@ -349,6 +352,7 @@ async def test_queue_size(dsn):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 async def test_queue_timeout(dsn, retries):
     async def worker(n):
         t0 = time()
@@ -383,6 +387,7 @@ async def test_queue_timeout(dsn, retries):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 async def test_dead_client(dsn):
     async def worker(i, timeout):
         try:
@@ -407,6 +412,7 @@ async def test_dead_client(dsn):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 async def test_queue_timeout_override(dsn, retries):
     async def worker(n):
         t0 = time()
@@ -640,6 +646,7 @@ async def test_closed_queue(dsn):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 async def test_grow(dsn, monkeypatch, retries):
     delay_connection(monkeypatch, 0.1)
 
@@ -669,6 +676,7 @@ async def test_grow(dsn, monkeypatch, retries):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 async def test_shrink(dsn, monkeypatch):
 
     from psycopg.pool.async_pool import ShrinkPool
@@ -742,6 +750,7 @@ async def test_reconnect(proxy, caplog, monkeypatch):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 async def test_reconnect_failure(proxy):
     proxy.start()
 
@@ -796,6 +805,7 @@ async def test_uniform_use(dsn, retries):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 async def test_resize(dsn):
     async def sampler():
         await asyncio.sleep(0.05)  # ensure sampling happens after shrink check
@@ -844,6 +854,7 @@ def test_jitter():
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 async def test_max_lifetime(dsn):
     async with pool.AsyncConnectionPool(
         dsn, min_size=1, max_lifetime=0.2
@@ -880,6 +891,7 @@ async def test_check(dsn, caplog):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 async def test_stats_measures(dsn):
     async def worker(n):
         async with p.connection() as conn:
@@ -918,6 +930,7 @@ async def test_stats_measures(dsn):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 async def test_stats_usage(dsn):
     async def worker(n):
         try:
index e2bb5e126574b501dbaf544cb2357168447e3f60..9e3e1043bc38e45755c9412a5536f6977a5c53ff 100644 (file)
@@ -7,6 +7,8 @@ import pytest
 
 from psycopg.pool.sched import Scheduler
 
+pytestmark = pytest.mark.timing
+
 
 @pytest.mark.slow
 def test_sched():
index bc06fd96026f1e125ccc53efd1e7cd4dd316db4b..0a5ff8f888a2c8313c66ff45a6e57b8ef5a57b54 100644 (file)
@@ -8,7 +8,7 @@ import pytest
 from psycopg.compat import create_task
 from psycopg.pool.sched import AsyncScheduler
 
-pytestmark = pytest.mark.asyncio
+pytestmark = [pytest.mark.asyncio, pytest.mark.timing]
 
 
 @pytest.mark.slow
index 308eaa7278648a05ce45232a8a1eac7622edde1b..28de5e583c1cb7f4f6e4e3d4960c37f8e0eaf796 100644 (file)
@@ -104,6 +104,7 @@ t.join()
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 def test_notifies(conn, dsn):
     nconn = psycopg.connect(dsn, autocommit=True)
     npid = nconn.pgconn.backend_pid
@@ -193,4 +194,4 @@ def test_identify_closure(conn, dsn):
     with pytest.raises(psycopg.OperationalError):
         conn.execute("select 1")
     t1 = time.time()
-    assert 0.3 < t1 - t0 < 0.5
+    assert 0.3 < t1 - t0 < 0.6
index 023d0ab43bfbaced38cb913cbf18e0ac7cc2c77c..3fdab911e762e028a9c11287f81e67d6ae271a4b 100644 (file)
@@ -57,6 +57,7 @@ async def test_concurrent_execution(dsn):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 async def test_notifies(aconn, dsn):
     nconn = await psycopg.AsyncConnection.connect(dsn, autocommit=True)
     npid = nconn.pgconn.backend_pid
@@ -151,4 +152,4 @@ async def test_identify_closure(aconn, dsn):
     with pytest.raises(psycopg.OperationalError):
         await aconn.execute("select 1")
     t1 = time.time()
-    assert 0.3 < t1 - t0 < 0.5
+    assert 0.3 < t1 - t0 < 0.6
index afc2c1ecb6e1da9264572bc5b6a45e352222239f..826dad4341c751e6d4e7f04fa11fc7ec781db5f9 100644 (file)
@@ -38,6 +38,7 @@ def test_connect_bad():
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 @pytest.mark.skipif(sys.platform == "win32", reason="connect() hangs on Win32")
 def test_connect_timeout():
     s = socket.socket(socket.AF_INET)
index 779925f4dcd7392667718f84cf1f5d01ea842ba5..845844d67678086f366e6acf1895094062943a41 100644 (file)
@@ -39,6 +39,7 @@ async def test_connect_str_subclass(dsn):
 
 
 @pytest.mark.slow
+@pytest.mark.timing
 async def test_connect_timeout():
     s = socket.socket(socket.AF_INET)
     s.bind(("", 0))