Skip to content

Commit 3a0cf88

Browse files
Update test workflow to match new example
1 parent 86f8e78 commit 3a0cf88

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

.github/workflows/python-psycopg3-integ-tests.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ jobs:
3434
- name: Checkout code
3535
uses: actions/checkout@v4
3636

37+
- name: Test IPv4 and IPv6 connectivity
38+
env:
39+
CLUSTER_ENDPOINT: ${{ secrets.PYTHON_PSYCOPG3_CLUSTER_ENDPOINT }}
40+
run: |
41+
echo -e "\n=== Testing IPv4 Connection to Cluster ==="
42+
nc -zv -4 $CLUSTER_ENDPOINT 5432 || echo "IPv4 connection to cluster failed"
43+
44+
echo -e "\n=== Testing IPv6 Connection to Cluster ==="
45+
nc -zv -6 $CLUSTER_ENDPOINT 5432 || echo "IPv6 connection to cluster failed"
46+
47+
- name: Configure DNS to prefer IPv4
48+
run: |
49+
echo "precedence ::ffff:0:0/96 100" | sudo tee -a /etc/gai.conf
50+
3751
- name: Set up Python
3852
uses: actions/setup-python@v5
3953
with:
@@ -53,11 +67,13 @@ jobs:
5367
role-to-assume: ${{ secrets.PYTHON_IAM_ROLE }}
5468
aws-region: us-east-1
5569

56-
- name: Configure and run integration for psycopg3
70+
- name: Configure and run integration for psycopg3 - admin
5771
working-directory: ./python/psycopg
5872
env:
73+
CLUSTER_USER: "admin"
5974
CLUSTER_ENDPOINT: ${{ secrets.PYTHON_PSYCOPG3_CLUSTER_ENDPOINT }}
6075
REGION: ${{ secrets.PYTHON_PSYCOPG3_CLUSTER_REGION }}
76+
FORCE_IPV4: "true"
6177
run: |
6278
python3 -m venv psycopg3-integ
6379
source psycopg3-integ/bin/activate

python/psycopg/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
boto3>=1.35.74
2-
psycopg[binary]>=3
2+
psycopg[binary,pool]>=3
33
pytest>=8

python/psycopg/src/example.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import boto3
1515
import psycopg
1616
import os
17+
import socket
1718
import sys
1819

1920

@@ -37,6 +38,15 @@ def create_connection(cluster_user, cluster_endpoint, region):
3738
"password": password_token
3839
}
3940

41+
42+
if os.environ.get("FORCE_IPV4", False):
43+
try:
44+
# Get the IPv4 address for the host
45+
conn_params["hostaddr"] = socket.gethostbyname(cluster_endpoint)
46+
except socket.gaierror:
47+
# If DNS resolution fails, continue without hostaddr
48+
pass
49+
4050
# Make a connection to the cluster
4151
conn = psycopg.connect(**conn_params)
4252

0 commit comments

Comments
 (0)