Skip to content

Commit 92f9ac2

Browse files
authored
Merge pull request #28 from pangpang20/master
Fix test failures, improve CI diagnostics & bump package versions
2 parents ee976a2 + 6fca281 commit 92f9ac2

File tree

14 files changed

+92
-13
lines changed

14 files changed

+92
-13
lines changed

.github/workflows/tests-ssl.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,29 @@ jobs:
226226
run: |
227227
mkdir -p reports
228228
229+
- name: Print DNS and Python environment
230+
run: |
231+
source venv/bin/activate
232+
python - << 'EOF'
233+
import asyncio
234+
import dns
235+
import dns.version
236+
import dns.asyncresolver
237+
238+
print("Python version:")
239+
import sys; print(sys.version)
240+
241+
print("\nEvent loop policy:")
242+
print(asyncio.get_event_loop_policy())
243+
244+
print("\nDnspython version:")
245+
print(dns.version.version)
246+
247+
print("\nAsync resolver instance:")
248+
r = dns.asyncresolver.Resolver()
249+
print(r)
250+
EOF
251+
229252
- name: Run tests
230253
env:
231254
PYTHONPATH: ./gaussdb:./gaussdb_pool

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
GAUSSDB_TEST_DSN: "host=127.0.0.1 port=5432 dbname=test user=root password=Passwd@123 "
9797
run: |
9898
source venv/bin/activate
99-
pytest -s -v
99+
pytest -s -v -W ignore::pytest.PytestUnraisableExceptionWarning
100100
101101
- name: Cleanup
102102
if: always()

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This project is a **fork** of `psycopg`, originally developed by the Psycopg Tea
3434

3535
**gaussdb** inherits the same license. All modifications are distributed under the **LGPL v3**.
3636

37-
See the full license text in the :download:`LICENSE.txt` file.
37+
See the full license text in the `LICENSE.txt` file.
3838

3939
.. note::
4040

@@ -134,7 +134,7 @@ Now hack away! You can run the tests using on GaussDB::
134134

135135
# Set the Python import path to include your local GaussDB Python project
136136
# Replace your_path with actual values
137-
export PYTHONPATH=/your_path/gaussdb-python
137+
export PYTHONPATH="/your_path/gaussdb-python/gaussdb:/your_path/gaussdb-python/gaussdb_pool"
138138

139139
# Select the pure-Python implementation of the GaussDB adapter
140140
export PSYCOPG_IMPL=python
@@ -183,7 +183,7 @@ Recommended Steps to Run OpenGauss with Python GaussDB Driver Testing (Assuming
183183

184184
# Set the Python import path to include your local GaussDB Python project
185185
# Replace your_path with actual values
186-
export PYTHONPATH=/your_path/gaussdb-python
186+
export PYTHONPATH="/your_path/gaussdb-python/gaussdb:/your_path/gaussdb-python/gaussdb_pool"
187187

188188
# Select the pure-Python implementation of the GaussDB adapter
189189
export PSYCOPG_IMPL=python
@@ -207,7 +207,7 @@ Steps to Run OpenGauss(SSL) with Python GaussDB Driver Testing (Assuming Docker
207207
208208
# Set the Python import path to include your local GaussDB Python project
209209
# Replace your_path with actual values
210-
export PYTHONPATH=/your_path/gaussdb-python
210+
export PYTHONPATH="/your_path/gaussdb-python/gaussdb:/your_path/gaussdb-python/gaussdb_pool"
211211

212212
# Select the pure-Python implementation of the GaussDB adapter
213213
export PSYCOPG_IMPL=python

gaussdb/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ This project is a **fork** of `psycopg <https://www.psycopg.org/>`_, originally
4545

4646
**gaussdb** inherits the same license. All modifications are distributed under the **LGPL v3**.
4747

48-
See the full license text in the :download:`LICENSE.txt` file.
48+
See the full license text in the `LICENSE.txt` file.
4949

5050
.. note::
5151

gaussdb/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "gaussdb"
77
description = "GaussDB database adapter for Python"
88

99
# STOP AND READ! if you change:
10-
version = "1.0.3"
10+
version = "1.0.4"
1111
# also change:
1212
# - `docs/news.rst` to declare this as the current version or an unreleased one;
1313
# - `gaussdb_c/pyproject.toml` to the same version;

gaussdb_pool/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This project is a **fork** of `psycopg <https://www.psycopg.org/>`_, originally
2727

2828
**gaussdb_pool** inherits the same license. All modifications are distributed under the **LGPL v3**.
2929

30-
See the full license text in the :download:`LICENSE.txt` file.
30+
See the full license text in the `LICENSE.txt` file.
3131

3232
.. note::
3333

gaussdb_pool/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "gaussdb-pool"
77
description = "Connection Pool for GaussDB"
88

99
# STOP AND READ! if you change:
10-
version = "1.0.3"
10+
version = "1.0.4"
1111
# also change:
1212
# - `docs/news_pool.rst` to declare this version current or unreleased
1313

tests/conftest.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,39 @@ def get_database_type():
146146
return ""
147147

148148

149+
def get_wal_level():
150+
dsn = os.getenv("DSN") or os.getenv("GAUSSDB_TEST_DSN")
151+
if not dsn:
152+
print("DSN environment variable not set")
153+
return ""
154+
155+
try:
156+
conn = pq.PGconn.connect(dsn.encode("utf-8"))
157+
if conn.status != pq.ConnStatus.OK:
158+
print(f"Connection failed: {conn.error_message.decode()}")
159+
conn.finish()
160+
return ""
161+
162+
res = conn.exec_(b"SHOW wal_level;")
163+
if res.status != pq.ExecStatus.TUPLES_OK:
164+
print(f"Query failed: {conn.error_message.decode()}")
165+
res.clear()
166+
conn.finish()
167+
return ""
168+
169+
raw_wal_level = res.get_value(0, 0)
170+
wal_level = ""
171+
if raw_wal_level:
172+
wal_level = raw_wal_level.decode().lower()
173+
174+
res.clear()
175+
conn.finish()
176+
return wal_level
177+
except Exception as e:
178+
print(f"Failed to get wal_level: {e}")
179+
return ""
180+
181+
149182
def pytest_collection_modifyitems(config, items):
150183
res = get_database_type()
151184
print(f"Database type: {res}")

tests/fix_faker.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ def example(self, spec):
315315
def match_any(self, spec, got, want):
316316
if spec == dt.timedelta:
317317
assert abs((got - want).total_seconds()) < 86400 * 2
318+
elif spec in (bytes, bytearray, memoryview):
319+
if want in (b"", bytearray(b"")) or want is None:
320+
assert got in (None, b"", bytearray(b""), memoryview(b""))
321+
else:
322+
assert got == want
318323
else:
319324
assert got == want
320325

tests/test_logical_decoding.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
import pytest
22

3+
from .conftest import get_wal_level
4+
35
SLOT_NAME = "slot_test"
46
SCHEMA = "my_schema"
57
TABLE = "test01"
68

79

10+
@pytest.fixture(scope="session", autouse=True)
11+
def check_wal_level():
12+
"""Check if wal_level is set to logical, skip tests if not."""
13+
wal_level = get_wal_level()
14+
if wal_level != "logical":
15+
pytest.skip(f"wal_level={wal_level!r}, expected 'logical'")
16+
17+
818
def _slot_exists(conn, slot_name):
919
cur = conn.cursor()
1020
cur.execute(
@@ -37,7 +47,7 @@ def _cleanup_slot_and_schema(conn):
3747

3848

3949
@pytest.fixture(scope="function")
40-
def setup_env(conn):
50+
def setup_env(conn, check_wal_level):
4151
"""Ensure clean environment for each test."""
4252
_cleanup_slot_and_schema(conn)
4353
cur = conn.cursor()

0 commit comments

Comments
 (0)