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
"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(
@pytest.mark.slow
+@pytest.mark.timing
def test_concurrent_filling(dsn, monkeypatch, retries):
delay_connection(monkeypatch, 0.1)
@pytest.mark.slow
+@pytest.mark.timing
def test_wait_ready(dsn, monkeypatch):
delay_connection(monkeypatch, 0.1)
with pytest.raises(pool.PoolTimeout):
@pytest.mark.slow
+@pytest.mark.timing
def test_queue(dsn, retries):
def worker(n):
t0 = time()
@pytest.mark.slow
+@pytest.mark.timing
def test_queue_timeout(dsn, retries):
def worker(n):
t0 = time()
@pytest.mark.slow
+@pytest.mark.timing
def test_dead_client(dsn):
def worker(i, timeout):
try:
@pytest.mark.slow
+@pytest.mark.timing
def test_queue_timeout_override(dsn, retries):
def worker(n):
t0 = time()
@pytest.mark.slow
+@pytest.mark.timing
def test_grow(dsn, monkeypatch, retries):
delay_connection(monkeypatch, 0.1)
@pytest.mark.slow
+@pytest.mark.timing
def test_shrink(dsn, monkeypatch):
from psycopg.pool.pool import ShrinkPool
@pytest.mark.slow
+@pytest.mark.timing
def test_reconnect_failure(proxy):
proxy.start()
@pytest.mark.slow
+@pytest.mark.timing
def test_resize(dsn):
def sampler():
sleep(0.05) # ensure sampling happens after shrink check
@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)
@pytest.mark.slow
+@pytest.mark.timing
def test_stats_measures(dsn):
def worker(n):
with p.connection() as conn:
@pytest.mark.slow
+@pytest.mark.timing
def test_stats_usage(dsn):
def worker(n):
try:
@pytest.mark.slow
+@pytest.mark.timing
async def test_concurrent_filling(dsn, monkeypatch, retries):
delay_connection(monkeypatch, 0.1)
@pytest.mark.slow
+@pytest.mark.timing
async def test_wait_ready(dsn, monkeypatch):
delay_connection(monkeypatch, 0.1)
with pytest.raises(pool.PoolTimeout):
@pytest.mark.slow
+@pytest.mark.timing
async def test_queue(dsn, retries):
async def worker(n):
t0 = time()
@pytest.mark.slow
+@pytest.mark.timing
async def test_queue_timeout(dsn, retries):
async def worker(n):
t0 = time()
@pytest.mark.slow
+@pytest.mark.timing
async def test_dead_client(dsn):
async def worker(i, timeout):
try:
@pytest.mark.slow
+@pytest.mark.timing
async def test_queue_timeout_override(dsn, retries):
async def worker(n):
t0 = time()
@pytest.mark.slow
+@pytest.mark.timing
async def test_grow(dsn, monkeypatch, retries):
delay_connection(monkeypatch, 0.1)
@pytest.mark.slow
+@pytest.mark.timing
async def test_shrink(dsn, monkeypatch):
from psycopg.pool.async_pool import ShrinkPool
@pytest.mark.slow
+@pytest.mark.timing
async def test_reconnect_failure(proxy):
proxy.start()
@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
@pytest.mark.slow
+@pytest.mark.timing
async def test_max_lifetime(dsn):
async with pool.AsyncConnectionPool(
dsn, min_size=1, max_lifetime=0.2
@pytest.mark.slow
+@pytest.mark.timing
async def test_stats_measures(dsn):
async def worker(n):
async with p.connection() as conn:
@pytest.mark.slow
+@pytest.mark.timing
async def test_stats_usage(dsn):
async def worker(n):
try:
from psycopg.pool.sched import Scheduler
+pytestmark = pytest.mark.timing
+
@pytest.mark.slow
def test_sched():
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
@pytest.mark.slow
+@pytest.mark.timing
def test_notifies(conn, dsn):
nconn = psycopg.connect(dsn, autocommit=True)
npid = nconn.pgconn.backend_pid
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
@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
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
@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)
@pytest.mark.slow
+@pytest.mark.timing
async def test_connect_timeout():
s = socket.socket(socket.AF_INET)
s.bind(("", 0))