Skip to content

CBG-4434 enable conflict tests #7688

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

CBG-4434 enable conflict tests #7688

wants to merge 1 commit into from

Conversation

torcolvin
Copy link
Collaborator

@torcolvin torcolvin commented Aug 18, 2025

CBG-4434 enable conflict tests

  • create a Context parameter for BlipTester to make it shorter to read test cases

Relax some assertions:

  • When comparing an HLV on a case where there are conflicts, comparing a full HLV of a CBL version to a full HLV to a version from Couchbase Server will not work. In the case of LWW conflict resolution for XDCR, the HLV is overwritten with the body. In the case of LWW conflict resolution for CBL, the previous versions are preserved.
  • add waitForConvergingTombstones to reflect the fact tombstone replications with XDCR will not get replicated. CBG-4788

Pre-review checklist

  • Removed debug logging (fmt.Print, log.Print, ...)
  • Logging sensitive data? Make sure it's tagged (e.g. base.UD(docID), base.MD(dbName))
  • Updated relevant information in the API specifications (such as endpoint descriptions, schemas, ...) in docs/api

Integration Tests

@torcolvin torcolvin requested a review from adamcfraser August 18, 2025 19:40
@Copilot Copilot AI review requested due to automatic review settings August 18, 2025 19:40
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables previously skipped conflict tests in the topology test suite by addressing issues with Couchbase Lite (CBL) actors in multi-actor conflict scenarios. The main purpose is to allow conflict tests to run with CBL peers by relaxing HLV (Hybrid Logical Vector) assertions and handling differences in conflict resolution behavior between CBL and other peer types.

Key changes include:

  • Removing skip conditions for CBL-related conflict tests
  • Adding context parameter support to BlipTester for improved readability
  • Implementing relaxed assertions that accommodate different conflict resolution behaviors between CBL and non-CBL peers

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
topologytest/multi_actor_conflict_test.go Removes CBL test skips and updates conflict test assertions to use CV-based matching
topologytest/hlv_test.go Adds new assertion functions for handling convergent tombstones and mixed peer type scenarios
topologytest/sync_gateway_peer_test.go Fixes document retrieval to properly handle deleted documents
topologytest/peer_test.go Adds KeySGTest to logging configuration
topologytest/couchbase_lite_mock_peer_test.go Updates BlipTester client creation to use context parameter
rest/utilities_testing_blip_client.go Adds context parameter support throughout BlipTester infrastructure

@@ -74,7 +74,11 @@ func (p *SyncGatewayPeer) GetDocumentIfExists(dsName sgbucket.DataStoreName, doc
return DocMetadata{}, nil, false
}
require.NoError(p.TB(), err)
return DocMetadataFromDocument(doc), base.Ptr(doc.Body(ctx)), true
meta = DocMetadataFromDocument(doc)
Copy link
Preview

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable meta is declared but not used in the original return statement that was removed. This creates a variable assignment without proper initialization in the conditional flow.

Copilot uses AI. Check for mistakes.

@@ -960,7 +962,8 @@ func (btcc *BlipTesterCollectionClient) updateLastReplicatedRev(docID string, ve
rev.message = msg
}

func newBlipTesterReplication(tb testing.TB, id string, btc *BlipTesterClient, skipCollectionsInitialization bool) *BlipTesterReplicator {
// newBlipTesterReplication creates a new BlipTesterReplicator with the given id and BlipTesterClient. Used to instantiate a push or pull replication for the client.
Copy link
Preview

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment should mention that the function now requires a context parameter, which is a breaking change from the previous signature.

Suggested change
// newBlipTesterReplication creates a new BlipTesterReplicator with the given id and BlipTesterClient. Used to instantiate a push or pull replication for the client.
// newBlipTesterReplication creates a new BlipTesterReplicator with the given id and BlipTesterClient.
// Used to instantiate a push or pull replication for the client.
// Note: This function now requires a context.Context parameter, which is a breaking change from the previous signature.

Copilot uses AI. Check for mistakes.

}
assertHLVEqual(c, dsName, docID, peer, version, nil, *nonCBLVersion, topology)
}
// Is there a way to do any assertion on the CBL tombstone versions?
Copy link
Preview

Copilot AI Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This TODO comment should either be resolved with a concrete implementation or converted to a proper TODO/FIXME format with a tracking issue reference.

Suggested change
// Is there a way to do any assertion on the CBL tombstone versions?
// TODO: Investigate whether assertions can be made on the CBL tombstone versions.

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

@adamcfraser adamcfraser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, some minor suggestions about comments/descriptions.

Comment on lines +64 to +66
// This is used when asserting on the full HLV is impossible. If XDCR is running, then asserting on the full HLV for
// non CBL peers is possible. However, conflict resolution on Couchbase Lite means that Couchbase Lite can contain
// previous versions of a document.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// This is used when asserting on the full HLV is impossible. If XDCR is running, then asserting on the full HLV for
// non CBL peers is possible. However, conflict resolution on Couchbase Lite means that Couchbase Lite can contain
// previous versions of a document.
// This is used for scenarios where it's valid for the full HLV to not converge. This includes cases where
// CBL conflict resolution results in additional history in the CBL version of the HLV that may not be pushed
// to CBS (e.g. remote wins)

requireBodyEqual(t, expectedVersion.body, body)
}
}

// waitForConvergingTombstones waits for all peers to have a tombstone document for a given doc ID. A matching HLV import (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what "matching HLV import" means.

// 1. create document on each peer with different contents
// 2. start replications
// 3. wait for documents to exist with hlv sources equal to the number of active peers and the document body is
// equivalent to the last write. The assertion is presently only on CV for Couchbase Lite peers, and full HLV
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove "presently", unless we expect this to change.

@adamcfraser adamcfraser assigned torcolvin and unassigned adamcfraser Aug 18, 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