Skip to content

Commit 902c003

Browse files
whummerclaude
andcommitted
Add connection retries to ParadeDB test helper
PostgreSQL may not be ready to accept queries immediately after the TCP port becomes reachable (Docker port forwarding opens the port before PostgreSQL finishes initialization). Retry the connection to handle this timing window. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a4d08d6 commit 902c003

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

paradedb/tests/test_extension.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import boto3
22
import psycopg2
33
from localstack.utils.strings import short_uid
4+
from localstack.utils.sync import retry
45

56

67
# Connection details for ParadeDB
@@ -13,14 +14,16 @@
1314

1415

1516
def get_connection():
16-
"""Create a connection to ParadeDB."""
17-
return psycopg2.connect(
18-
host=HOST,
19-
port=PORT,
20-
user=USER,
21-
password=PASSWORD,
22-
database=DATABASE,
23-
)
17+
"""Create a connection to ParadeDB, retrying until the server is ready."""
18+
def _connect():
19+
return psycopg2.connect(
20+
host=HOST,
21+
port=PORT,
22+
user=USER,
23+
password=PASSWORD,
24+
database=DATABASE,
25+
)
26+
return retry(_connect, retries=15, sleep=2.0)
2427

2528

2629
def test_connect_to_paradedb():

0 commit comments

Comments
 (0)