8000 Improve GaussDB Compatibility and Stability Across COPY, Pool, Notify, and Error Tests by pangpang20 · Pull Request #9 · HuaweiCloudDeveloper/gaussdb-python · GitHub
[go: up one dir, main page]

Skip to content

Improve GaussDB Compatibility and Stability Across COPY, Pool, Notify, and Error Tests #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 3, 2025

Conversation

pangpang20
Copy link

Description

This PR introduces several test improvements and bug fixes to enhance compatibility with GaussDB, improve reliability for COPY operations, and reduce flakiness in timing-sensitive test cases. It also removes or skips tests that rely on PostgreSQL-specific features not supported by GaussDB.These modifications ensure more robust test execution and better compatibility with GaussDB while maintaining functionality for other database systems.

Changes Made

COPY Operation Fixes

  • Added missing conn.commit() after DDL operations before performing COPY in both sync and async tests.
  • Ensured binary parameter in cursor() is explicitly passed as a boolean.
  • Handled OperationalError with a message "no COPY in progress" by skipping such test cases gracefully.

Error Diagnostic Adjustments

  • Skipped diagnostic field SEVERITY_NONLOCALIZED if libpq version is < 9.6.
  • Adjusted assertion counts in tests to account for the skipped field.

GaussDB-Specific Skips

  • Deleted:
    • tests/test_notify.py
    • tests/test_notify_async.py
      (GaussDB does not support LISTEN/NOTIFY)
  • Added @pytest.mark.gaussdb_skip to:
    • test_load_copy() (COPY unsupported for some types)
    • Queue timeout and backend pid-dependent tests
  • Enhanced conftest.py to support parameterized gaussdb_skip marker with custom reason.

Flaky Timing Test Improvements

  • Loosened assertion thresholds in pool timeout and shrink tests to tolerate timing variability.
  • Relaxed timedelta comparisons in fix_faker.py to allow a 2-day difference margin.

Misc Fixes

  • Converted backend_pid from string to int in pq_ctypes.py.
  • Simplified test_pgconn_ptr() to check type consistency (int) rather than exact match.
  • Improved GC-related test flow by ensuring GC cycles are forced and counted explicitly.

Why

  • GaussDB omits several PostgreSQL features, making direct test reuse problematic.
  • Timing-sensitive assertions were overly strict and failed intermittently.
  • Without conn.commit(), subsequent COPY operations might not reflect schema changes.
  • Skipping unsupported tests helps maintain CI stability and backend parity.

Testing

  • Ran full test suite with GaussDB backends.
  • Verified newly skipped tests are conditionally applied only when using GaussDB.
  • Confirmed data persistence and correctness in COPY-related tests.
  • Validated robustness in timing-heavy pool test cases.

Additional Notes

  • The removed LISTEN/NOTIFY tests may be reintroduced with conditional logic or mocked implementations when GaussDB adds support.
  • Further loosening or parametrizing timing thresholds may be considered if test infrastructure variability increases.

@5xuanwen 5xuanwen merged commit eece3d4 into HuaweiCloudDeveloper:master Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0