Added delta-sync history based tests#416
Conversation
There was a problem hiding this comment.
Pull request overview
Adds new upgrade-flow replication tests focused on delta-sync history behavior, and refactors the existing upgrade replication suite to share a common harness.
Changes:
- Added
tests/QE/test_replication_upgrade_delta_sync.pyto cover delta-sync history scenarios (including anxfailtracking an SGW bug). - Introduced
client/src/cbltest/api/upgrade_test_helpers.pyto centralize upgrade test environment setup + replication driver logic. - Refactored
tests/dev_e2e/test_replication_upgrade.pyto use the shared helpers (de-duplication).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/QE/test_replication_upgrade_delta_sync.py | New QE tests for delta-sync history behavior during upgrade-related replication flows. |
| client/src/cbltest/api/upgrade_test_helpers.py | New shared helper module for upgrade env setup and replication execution/validation. |
| tests/dev_e2e/test_replication_upgrade.py | Updated to use the shared helper functions/types instead of local duplicated scaffolding. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
borrrden
left a comment
There was a problem hiding this comment.
For TDK API of course this is fine since now very little has changed 😄
gregns1
left a comment
There was a problem hiding this comment.
Looks good from my end too. SGW fix for this will be coming next week.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
gregns1
left a comment
There was a problem hiding this comment.
Did some work on getting trace logs for the above this morning, test case 2 (the test using doc ID nonconflict_2) is not actually sending the rev as a delta as it stands. This is because the backup revision for rev 1 is not present. I think this is because of the way the test is setup which is pre seeding the bucket with legacy revs and the backup revs may not be getting seeded with the legacy revisions. For this particular test case to work as intended we need to be able to have a backup revision in the bucket for rev 1 for SGW to calculate a delta from.
2026-05-26T11:27:30.317+01:00 [DBG] CRUD+: c:[17f680c5] db:upgrade col:_default No old revision "<ud>nonconflict_2</ud>" / "1-e643a00fb9cad8cf87ee4d2c4e2383f6ecf118c0"
2026-05-26T11:27:30.317+01:00 [DBG] Sync+: c:[17f680c5] db:upgrade col:_default Falling back to full body replication. Couldn't get delta from 1-e643a00fb9cad8cf87ee4d2c4e2383f6ecf118c0 to 2-36a2cfe8544956ad3c5b6491cbfc7d94 for key <ud>nonconflict_2</ud> - err: 404 missing
....
2026-05-26T11:27:30.317+01:00 [TRC] Sync+: c:[17f680c5] db:upgrade col:_default Sending revision <ud>nonconflict_2</ud>/2-36a2cfe8544956ad3c5b6491cbfc7d94, body:<ud>{"channels":["numbers"],"number":2}</ud>, properties: <ud>map[history:1-e643a00fb9cad8cf87ee4d2c4e2383f6ecf118c0 sequence:6]</ud>, attDigests: [] -- db.(*BlipSyncContext).sendRevisionWithProperties() at blip_sync_context.go:456
As you can see above its falling back to send the revision as a full revision in this case so the delta sync code pathway isn't being executed properly in the test.
I'm not sure what the best way to solve this is in the TDK, we may need to look into how the revs are being populated in the bucket.
As for test case 1 (test using nonconflict_3 doc) I can see the revision is being sent as delta and the history is in fact empty:
2026-05-26T11:25:26.923+01:00 [TRC] Sync+: c:[51984a3e] db:upgrade col:_default docID: <ud>nonconflict_3</ud> - delta: <ud>{"updated_by":"delta_sync_history_test"}</ud> -- db.(*BlipSyncContext).sendRevAsDelta() at blip_handler.go:976
2026-05-26T11:25:26.923+01:00 [DBG] Sync+: c:[51984a3e] db:upgrade col:_default Sending rev "<ud>nonconflict_3</ud>" 18b316999d570000@q9I8PBb+Xkq2c5XWHt+rIA as delta. DeltaSrc:2-509dc0903869f6b103fd1266b169e73876b80d27
2026-05-26T11:25:26.923+01:00 [TRC] Sync+: c:[51984a3e] db:upgrade col:_default Sending revision <ud>nonconflict_3</ud>/18b316999d570000@q9I8PBb+Xkq2c5XWHt+rIA, body:<ud>{"updated_by":"delta_sync_history_test"}</ud>, properties: <ud>map[Content-Type:application/json Profile:rev collection:0 deltaSrc:2-509dc0903869f6b103fd1266b169e73876b80d27 history: id:nonconflict_3 rev:18b316999d570000@q9I8PBb+Xkq2c5XWHt+rIA sequence:34]</ud> -- db.(*BlipSyncContext).sendBLIPMessage() at blip_sync_context.go:626
I am guessing that because we send the delta source ID CBL is using that to identify its not a conflict, I will need to check up on this. Either way I can see the history is empty and it shouldn't be so I can get a fix together for that soon.
CBG-5388
Summary
test_delta_sync_history_pull_post_upgrade_sgw_mutation— pull of a 4.x SGW mutation (revtree + fresh HLV) into a client holding a revtree-only ancestor. Markedxfail(strict=True)to track the open SGW delta-sync history bug where the rev message'shistoryfield comes back empty.test_delta_sync_history_pull_pre_upgrade_sgw_two_revs— pull of a revtree-only rev that exists on both sides, verifying the local side resolves to an RTE-encoded HLV while SGW's HLV remains absent.setup_upgrade_env(...)— version/dataset skip checks, SGupgradeDB teardown, CBS bucket restore, local DB reset.do_upgrade_replication_test(...)— replicator setup, optional doc-event waiting, pre/post snapshot logging, optionalcompare_local_and_remote, and an injectableDocValidator.DocSnapshot/DocValidatorexposed as module-level types.tests/dev_e2e/test_replication_upgrade.pyto consume the shared helpers — pure de-duplication, no behavior change for the existingnonconflict_*cases.Motivation
The existing
TestReplicationUpgradeclass duplicated all of its environment-setup and replicator-driver logic inside the test class itself. The new delta-sync history tests need exactly the same scaffolding (4.0 dataset,upgradeSG DB, revid/HLV snapshots, custom validators), but with a different SG database config (delta_sync enabled) and an explicit SGW write step before replication. Promoting the helpers tocbltest.api.upgrade_test_helperslets both suites share the harness without copy-paste, and unblocks adding more upgrade-history scenarios.