CBG-5792: Wait for the changes feed before starting a replicator - #517
CBG-5792: Wait for the changes feed before starting a replicator#517torcolvin wants to merge 3 commits into
Conversation
test_pull_resurrected_doc failed because an on demand import does not prime the caching feed before a one shot replication - Add an opt-in `wait_for_caching_feed` to the Sync Gateway write and read helpers, factored out of the readback update_document already did. - Update call sites that require wait_for_caching_feed that do not rely on import, which will be fixed separately.
|
@bbrks I'm interested in your feedback if there's a way we can fold this into a framework in a better way. I propose committing this temporarily to hide this flake but then come up with better strategies for avoiding the flakes in the first place. |
There was a problem hiding this comment.
🟢 Approval recommended
The changes are additive/opt-in and consistently applied at relevant call sites, with only minor doc/test-step wording nits noted.
Pull request overview
This PR hardens replication tests against Sync Gateway channel-cache timing by optionally waiting for written/imported revisions to appear in a request_plus _changes feed before starting a replicator, reducing flakes like test_pull_resurrected_doc.
Changes:
- Added
wait_for_caching_feedopt-in behavior to Sync Gateway helpers (update_documents,delete_document,get_document) and factored the “read-back from changes feed” logic into a shared helper. - Added
SyncGatewayCluster.wait_for_sequence(...)to ensure all SGW nodes’ channel caches have caught up to a known sequence. - Updated several QE/dev_e2e tests to use
wait_for_caching_feed=Trueat write/read points where immediate replication previously raced the cache/import pipeline.
File summaries
| File | Description |
|---|---|
| tests/QE/test_replication_upgrade_delta_sync.py | Uses wait_for_caching_feed=True after SGW mutation to avoid cache-race before subsequent replication/validation. |
| tests/QE/test_replication_functional.py | Waits for the caching feed after initial document creation to prevent role/channel replication races. |
| tests/dev_e2e/test_replication_filter.py | Waits for the caching feed after creating a public-channel doc so the pull replicator sees it deterministically. |
| tests/dev_e2e/test_replication_behavior.py | Reworks flake-prone steps to wait for cache/import visibility (including cluster-wide sequence catch-up) before replication. |
| tests/dev_e2e/test_replication_auto_purge.py | Waits for caching feed after document creation to avoid timing-dependent replication behavior. |
| client/src/cbltest/api/syncgatewaycluster.py | Adds a cluster-level helper to wait for a specific sequence across all SGW nodes. |
| client/src/cbltest/api/syncgateway.py | Adds since support to get_changes, introduces _wait_for_caching_feed, and extends write/read helpers with wait_for_caching_feed. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
CBG-5792: Wait for the changes feed before starting a replicator
Fix
test_pull_resurrected_docflakes:test_pull_resurrected_doc failed because an on demand import does not prime the caching feed before a one shot replication
wait_for_caching_feedto the Sync Gateway write and read helpers, factored out of the readback update_document already did.