|
11 | 11 |
|
12 | 12 |
|
13 | 13 | @pytest.mark.pgreplay |
14 | | -def test_pgreplay_infrastructure_available(pg_cluster): |
| 14 | +def test_pgreplay_infrastructure_available(pg_cluster): # noqa: ARG001 |
15 | 15 | """Test that pgreplay binary is available and can be invoked.""" |
16 | 16 | pgreplay_bin = shutil.which("pgreplay") |
17 | 17 | assert pgreplay_bin is not None, "pgreplay binary not found in PATH - pgreplay tests require pgreplay to be installed" |
@@ -43,8 +43,8 @@ def _run_pgreplay_replay(pg_cluster, require_csv: bool = False) -> None: |
43 | 43 | try: |
44 | 44 | # Drop any statements captured from prior tests to keep the replay log small. |
45 | 45 | pg_cluster.truncate_log() |
46 | | - source_dsn = pg_cluster.dsn().replace("pg_retry_system_tests", source_db) |
47 | | - target_dsn = pg_cluster.dsn().replace("pg_retry_system_tests", target_db) |
| 46 | + source_dsn = pg_cluster.dsn(dbname=source_db) |
| 47 | + target_dsn = pg_cluster.dsn(dbname=target_db) |
48 | 48 |
|
49 | 49 | # Set up source database with retry operations |
50 | 50 | with psycopg.connect(source_dsn) as conn: |
@@ -142,13 +142,21 @@ def _run_pgreplay_replay(pg_cluster, require_csv: bool = False) -> None: |
142 | 142 | cmd.append(str(log_file)) |
143 | 143 |
|
144 | 144 | timeout_seconds = int(os.getenv("PG_REPLAY_TIMEOUT", "120")) |
145 | | - completed = subprocess.run( |
146 | | - cmd, |
147 | | - env=env, |
148 | | - text=True, |
149 | | - capture_output=True, |
150 | | - timeout=timeout_seconds |
151 | | - ) |
| 145 | + try: |
| 146 | + completed = subprocess.run( |
| 147 | + cmd, |
| 148 | + env=env, |
| 149 | + text=True, |
| 150 | + capture_output=True, |
| 151 | + timeout=timeout_seconds, |
| 152 | + ) |
| 153 | + except subprocess.TimeoutExpired as exc: |
| 154 | + stdout = exc.output or "" |
| 155 | + stderr = exc.stderr or "" |
| 156 | + pytest.fail( |
| 157 | + "pgreplay did not finish within " |
| 158 | + f"{timeout_seconds}s.\nCommand: {cmd}\nSTDOUT:\n{stdout}\nSTDERR:\n{stderr}" |
| 159 | + ) |
152 | 160 |
|
153 | 161 | # pgreplay should successfully replay the logs |
154 | 162 | # Note: pgreplay may return non-zero even on success for some log formats |
@@ -190,7 +198,7 @@ def test_pgreplay_basic_functionality(pg_cluster): |
190 | 198 | conn.execute(f"CREATE DATABASE {test_db}") |
191 | 199 |
|
192 | 200 | try: |
193 | | - test_dsn = pg_cluster.dsn().replace("pg_retry_system_tests", test_db) |
| 201 | + test_dsn = pg_cluster.dsn(dbname=test_db) |
194 | 202 |
|
195 | 203 | # Set up database with basic retry functionality |
196 | 204 | with psycopg.connect(test_dsn) as conn: |
|
0 commit comments