Skip to content

Cover postgres_instance_create_read_replica#177

Open
sdairs wants to merge 1 commit into
md/add-clickpipes-supportfrom
issue-162-postgres-read-replica
Open

Cover postgres_instance_create_read_replica#177
sdairs wants to merge 1 commit into
md/add-clickpipes-supportfrom
issue-162-postgres-read-replica

Conversation

@sdairs
Copy link
Copy Markdown
Collaborator

@sdairs sdairs commented May 15, 2026

Summary

  • Extends integration_postgres_test.rs with a Read Replica phase that exercises postgres_instance_create_read_replica end-to-end (create, poll-to-running, list+get verification including primary reference, explicit delete) before the primary Delete phase.
  • Adds replica-id tracking to CleanupRegistry (register_postgres_replica / unregister_postgres_replica); the cleanup pass deletes registered replicas before registered primaries, since the live API refuses to delete a primary while a replica still references it.
  • Replica is registered in the cleanup registry immediately on create so a panic between create and the in-body teardown cannot leak the replica and break the primary delete.

Cleanup ordering

Two complementary mechanisms keep replicas torn down before primaries:

  1. CleanupRegistry — the cleanup pass iterates postgres_replica_ids to deletion before iterating postgres_ids. Registration happens immediately after the create call returns the id.
  2. Explicit in-body teardown — the Read Replica phase deletes its replica and waits for 404 before the primary Delete phase runs. unregister_postgres_replica keeps the registry tidy on the happy path.

Both paths are documented in code comments (CleanupRegistry doc-comment and the Read Replica phase header in the test).

Test plan

  • cargo build -p clickhouse-cloud-api
  • cargo clippy -p clickhouse-cloud-api --tests -- -D warnings (only pre-existing errors in spec_coverage_test.rs and integration_test.rs remain; nothing in files touched by this PR)
  • cargo test -p clickhouse-cloud-api (86 unit + 6 spec-coverage tests pass; integration_postgres test is #[ignore] per existing suite policy)
  • Live cloud-integration run via PR CI to exercise the new phase end-to-end against production.

Closes #162

🤖 Generated with Claude Code

@sdairs sdairs requested a review from iskakaushik as a code owner May 15, 2026 16:00
@sdairs sdairs temporarily deployed to cloud-integration May 15, 2026 16:00 — with GitHub Actions Inactive
Adds a Read Replica phase to the postgres CRUD lifecycle test that
exercises postgres_instance_create_read_replica end-to-end and verifies
the replica is discoverable via list and get with the expected primary
reference (provider + region, isPrimary=false).

The phase is inserted before the primary Delete phase and tears the
replica down explicitly first, because the live API refuses to delete a
primary while replicas still reference it. To handle mid-test failure
between create and the in-body teardown, CleanupRegistry now tracks
replica ids separately and the cleanup pass deletes them before
primaries.

Closes #162

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sdairs sdairs force-pushed the issue-162-postgres-read-replica branch from ad9159e to 4029c02 Compare May 16, 2026 11:42
@sdairs sdairs changed the base branch from main to md/add-clickpipes-support May 16, 2026 11:42
@sdairs sdairs temporarily deployed to cloud-integration May 16, 2026 11:42 — with GitHub Actions Inactive
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.

Cover postgres_instance_create_read_replica

1 participant