Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/tests-ssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,29 @@ jobs:
run: |
mkdir -p reports

- name: Print DNS and Python environment
run: |
source venv/bin/activate
python - << 'EOF'
import asyncio
import dns
import dns.version
import dns.asyncresolver

print("Python version:")
import sys; print(sys.version)

print("\nEvent loop policy:")
print(asyncio.get_event_loop_policy())

print("\nDnspython version:")
print(dns.version.version)

print("\nAsync resolver instance:")
r = dns.asyncresolver.Resolver()
print(r)
EOF

- name: Run tests
env:
PYTHONPATH: ./gaussdb:./gaussdb_pool
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
GAUSSDB_TEST_DSN: "host=127.0.0.1 port=5432 dbname=test user=root password=Passwd@123 "
run: |
source venv/bin/activate
pytest -s -v
pytest -s -v -W ignore::pytest.PytestUnraisableExceptionWarning
- name: Cleanup
if: always()
Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This project is a **fork** of `psycopg`, originally developed by the Psycopg Tea

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

See the full license text in the :download:`LICENSE.txt` file.
See the full license text in the `LICENSE.txt` file.

.. note::

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

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

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

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

# Select the pure-Python implementation of the GaussDB adapter
export PSYCOPG_IMPL=python
Expand All @@ -207,7 +207,7 @@ Steps to Run OpenGauss(SSL) with Python GaussDB Driver Testing (Assuming Docker

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

# Select the pure-Python implementation of the GaussDB adapter
export PSYCOPG_IMPL=python
Expand Down
2 changes: 1 addition & 1 deletion gaussdb/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ This project is a **fork** of `psycopg <https://www.psycopg.org/>`_, originally

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

See the full license text in the :download:`LICENSE.txt` file.
See the full license text in the `LICENSE.txt` file.

.. note::

Expand Down
2 changes: 1 addition & 1 deletion gaussdb/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "gaussdb"
description = "GaussDB database adapter for Python"

# STOP AND READ! if you change:
version = "1.0.3"
version = "1.0.4"
# also change:
# - `docs/news.rst` to declare this as the current version or an unreleased one;
# - `gaussdb_c/pyproject.toml` to the same version;
Expand Down
2 changes: 1 addition & 1 deletion gaussdb_pool/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This project is a **fork** of `psycopg <https://www.psycopg.org/>`_, originally

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

See the full license text in the :download:`LICENSE.txt` file.
See the full license text in the `LICENSE.txt` file.

.. note::

Expand Down
2 changes: 1 addition & 1 deletion gaussdb_pool/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "gaussdb-pool"
description = "Connection Pool for GaussDB"

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

Expand Down
33 changes: 33 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,39 @@ def get_database_type():
return ""


def get_wal_level():
dsn = os.getenv("DSN") or os.getenv("GAUSSDB_TEST_DSN")
if not dsn:
print("DSN environment variable not set")
return ""

try:
conn = pq.PGconn.connect(dsn.encode("utf-8"))
if conn.status != pq.ConnStatus.OK:
print(f"Connection failed: {conn.error_message.decode()}")
conn.finish()
return ""

res = conn.exec_(b"SHOW wal_level;")
if res.status != pq.ExecStatus.TUPLES_OK:
print(f"Query failed: {conn.error_message.decode()}")
res.clear()
conn.finish()
return ""

raw_wal_level = res.get_value(0, 0)
wal_level = ""
if raw_wal_level:
wal_level = raw_wal_level.decode().lower()

res.clear()
conn.finish()
return wal_level
except Exception as e:
print(f"Failed to get wal_level: {e}")
return ""


def pytest_collection_modifyitems(config, items):
res = get_database_type()
print(f"Database type: {res}")
Expand Down
5 changes: 5 additions & 0 deletions tests/fix_faker.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ def example(self, spec):
def match_any(self, spec, got, want):
if spec == dt.timedelta:
assert abs((got - want).total_seconds()) < 86400 * 2
elif spec in (bytes, bytearray, memoryview):
if want in (b"", bytearray(b"")) or want is None:
assert got in (None, b"", bytearray(b""), memoryview(b""))
else:
assert got == want
else:
assert got == want

Expand Down
12 changes: 11 additions & 1 deletion tests/test_logical_decoding.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import pytest

from .conftest import get_wal_level

SLOT_NAME = "slot_test"
SCHEMA = "my_schema"
TABLE = "test01"


@pytest.fixture(scope="session", autouse=True)
def check_wal_level():
"""Check if wal_level is set to logical, skip tests if not."""
wal_level = get_wal_level()
if wal_level != "logical":
pytest.skip(f"wal_level={wal_level!r}, expected 'logical'")


def _slot_exists(conn, slot_name):
cur = conn.cursor()
cur.execute(
Expand Down Expand Up @@ -37,7 +47,7 @@ def _cleanup_slot_and_schema(conn):


@pytest.fixture(scope="function")
def setup_env(conn):
def setup_env(conn, check_wal_level):
"""Ensure clean environment for each test."""
_cleanup_slot_and_schema(conn)
cur = conn.cursor()
Expand Down
4 changes: 4 additions & 0 deletions tests/types/test_composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from gaussdb.types.composite import register_composite

from ..utils import eur
from ..conftest import get_database_type
from ..fix_crdb import crdb_skip_message, is_crdb
from ..test_adapt import StrNoneBinaryDumper, StrNoneDumper

Expand Down Expand Up @@ -162,6 +163,9 @@ def test_load_record_binary(conn, want, rec):
def testcomp(svcconn):
if is_crdb(svcconn):
pytest.skip(crdb_skip_message("composite"))
res = get_database_type()
if res == "gaussdb":
pytest.skip("gaussdb not support.")
cur = svcconn.cursor()
cur.execute(
"""
Expand Down
6 changes: 5 additions & 1 deletion tests/types/test_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from gaussdb.types.range import Range, RangeInfo, register_range

from ..utils import eur
from ..conftest import get_database_type
from ..fix_crdb import crdb_skip_message, is_crdb
from ..test_adapt import StrNoneBinaryDumper, StrNoneDumper

Expand Down Expand Up @@ -268,11 +269,14 @@ def create_test_range(conn):
if is_crdb(conn):
pytest.skip(crdb_skip_message("range"))

res = get_database_type()
if res == "gaussdb":
pytest.skip("gaussdb not support.")

conn.execute(
"""
drop schema if exists testschema cascade;
create schema testschema;

drop type if exists testrange cascade;
drop type if exists testschema.testrange cascade;

Expand Down
2 changes: 1 addition & 1 deletion tools/isort-gaussdb/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ This project is a **fork** of `psycopg <https://www.psycopg.org/>`_, originally

**isort-gaussdb** inherits the same license. All modifications are distributed under the **LGPL v3**.

See the full license text in the :download:`LICENSE.txt` file.
See the full license text in the `LICENSE.txt` file.

.. note::

Expand Down
2 changes: 1 addition & 1 deletion tools/isort-gaussdb/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description = "isort plug-in to sort imports by module length first"
# Note: to release a new version:
# python -m build -o dist --wheel .
# twine upload dist/isort_gaussdb-*-py3-none-any.whl
version = "0.0.5"
version = "0.0.6"

[project.urls]
Homepage = "https://github.com/HuaweiCloudDeveloper/gaussdb-python/"
Expand Down
Loading