Skip to content

Enhancements to GaussDB CI and Logical Replication Testing#17

Merged
liubao68 merged 4 commits intoHuaweiCloudDeveloper:masterfrom
pangpang20:master
Aug 27, 2025
Merged

Enhancements to GaussDB CI and Logical Replication Testing#17
liubao68 merged 4 commits intoHuaweiCloudDeveloper:masterfrom
pangpang20:master

Conversation

@pangpang20
Copy link
Collaborator

Description

This pull request introduces several improvements to the GaussDB project, focusing on enhancing the CI pipeline and adding comprehensive testing for logical replication and decoding. The changes include splitting the GitHub Actions workflow into dedicated pipelines for gaussdb, gaussdb_pool, and isort-gaussdb, adding robust pytest-based tests for logical replication, improving the reliability of replication-slot tests, and ensuring proper resource management in the test_details function using a context manager. These updates aim to improve build consistency, test reliability, and maintainability.

Changes

  • CI Workflow Updates:
    • Split the existing release.yml into three separate workflows: release-gaussdb.yml, release-gaussdb-pool.yml, and release-isort-gaussdb.yml.
    • Updated the release-gaussdb-pool.yml (formerly release.yml) to trigger on pool-v*.*.* tags and build only gaussdb_pool.
    • Added release-gaussdb.yml to build gaussdb on v*.*.* tags.
    • Added release-isort-gaussdb.yml to build isort-gaussdb on isort-v*.*.* tags.
  • Logical Replication Testing:
    • Added tests/test_logical_decoding.py with pytest-based tests for logical replication slot creation, data insertion, updates, deletion, and slot removal.
  • Replication-Slot Test Robustness:
    • Enhanced replication-slot tests to ensure consistent slot and schema cleanup using a pytest fixture (setup_env).
    • Made tests stricter by verifying specific change events (insert, update, delete) and their associated data.
  • Test Resource Management:
    • Modified tests/test_column.py to use a context manager for cursor handling in test_details and ensure transaction rollback.

Details

  • CI Workflow Split:
    • The original release.yml was renamed to release-gaussdb-pool.yml and updated to focus on gaussdb_pool builds, triggered by pool-v*.*.* tags. It now only processes the gaussdb_pool/dist/ directory.
    • New workflows (release-gaussdb.yml and release-isort-gaussdb.yml) were added to handle builds for gaussdb (on v*.*.* tags) and isort-gaussdb (on isort-v*.*.* tags), respectively.
    • Each workflow uses Python 3.9, installs build tools (setuptools, wheel, build), builds the respective package, collects artifacts in all_dist/, and uploads to GitHub Releases and PyPI using the PYPI_API_TOKEN.
    • Total changes: 19 in release-gaussdb-pool.yml (4 additions, 15 deletions), 56 additions each in release-gaussdb.yml and release-isort-gaussdb.yml.
  • Logical Replication Tests:
    • Added tests/test_logical_decoding.py with 148 lines of new code.
    • Tests cover:
      • Creation and verification of logical replication slots using pg_create_logical_replication_slot.
      • Capturing and verifying changes (insert, update, delete) using pg_logical_slot_get_changes.
      • Dropping replication slots and verifying their removal.
    • A pytest fixture (setup_env) ensures a clean environment by creating/dropping a schema (my_schema) and table (test01) with REPLICA IDENTITY FULL.
  • Replication-Slot Test Improvements:
    • Tests in test_logical_decoding.py are made robust by:
      • Using _cleanup_slot_and_schema to ensure no leftover slots or schemas interfere with tests.
      • Asserting specific keywords (e.g., "insert", "update", "delete") and data values in change logs.
    • Tests are strict, checking exact slot existence and change contents, reducing flakiness.
  • Context Manager in test_details:
    • Updated tests/test_column.py (8 additions, 3 deletions) to wrap the cursor in a with statement for automatic resource cleanup.
    • Added explicit conn.rollback() within a try-except block to handle transaction cleanup gracefully.

Testing

  • CI Workflow Testing:
    • Simulated tagged pushes (v1.0.0, pool-v1.0.0, isort-v1.0.0) to verify each workflow builds the correct package and uploads to GitHub Releases and PyPI.
    • Checked ls -l output to confirm dist/ directory contents.
  • Logical Replication Tests:
    • Ran pytest tests/test_logical_decoding.py to confirm all tests pass, verifying slot creation, data changes (insert, update, delete), and slot removal.
    • Ensured setup_env fixture isolates tests by cleaning up schemas and tables.
  • Replication-Slot Robustness:
    • Tested with pre-existing slots/schemas to confirm reliable cleanup.
    • Verified strict assertions for change events and data.
  • Context Manager in test_details:
    • Ran pytest tests/test_column.py to validate cursor cleanup and transaction rollback.
    • Tested error cases to ensure try-except block handles exceptions.

@liubao68 liubao68 merged commit b58580a into HuaweiCloudDeveloper:master Aug 27, 2025
3 checks passed
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