Skip to content
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

CBG-4303: conflicting writes muti actor tests, skipping failures #7205

Merged
merged 5 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions topologytest/couchbase_lite_mock_peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,24 @@ func (p *CouchbaseLiteMockPeer) getSingleBlipClient() *PeerBlipTesterClient {
}

// CreateDocument creates a document on the peer. The test will fail if the document already exists.
func (p *CouchbaseLiteMockPeer) CreateDocument(dsName sgbucket.DataStoreName, docID string, body []byte) DocMetadata {
func (p *CouchbaseLiteMockPeer) CreateDocument(dsName sgbucket.DataStoreName, docID string, body []byte) BodyAndVersion {
p.t.Logf("%s: Creating document %s", p, docID)
return p.WriteDocument(dsName, docID, body)
}

// WriteDocument writes a document to the peer. The test will fail if the write does not succeed.
func (p *CouchbaseLiteMockPeer) WriteDocument(_ sgbucket.DataStoreName, docID string, body []byte) DocMetadata {
func (p *CouchbaseLiteMockPeer) WriteDocument(dsName sgbucket.DataStoreName, docID string, body []byte) BodyAndVersion {
// this isn't yet collection aware, using single default collection
client := p.getSingleBlipClient()
// set an HLV here.
docVersion, err := client.btcRunner.PushRev(client.ID(), docID, rest.EmptyDocVersion(), body)
require.NoError(client.btcRunner.TB(), err)
return DocMetadataFromDocVersion(docID, docVersion)
docMetadata := DocMetadataFromDocVersion(docID, docVersion)
return BodyAndVersion{
docMeta: docMetadata,
body: body,
updatePeer: p.name,
}
}

// DeleteDocument deletes a document on the peer. The test will fail if the document does not exist.
Expand Down Expand Up @@ -183,11 +188,13 @@ func (r *CouchbaseLiteMockReplication) PassivePeer() Peer {

// Start starts the replication
func (r *CouchbaseLiteMockReplication) Start() {
r.btc.TB().Logf("starting CBL replication")
r.btcRunner.StartPull(r.btc.ID())
}

// Stop halts the replication. The replication can be restarted after it is stopped.
func (r *CouchbaseLiteMockReplication) Stop() {
r.btc.TB().Logf("stopping CBL replication")
_, err := r.btcRunner.UnsubPullChanges(r.btc.ID())
require.NoError(r.btcRunner.TB(), err)
}
22 changes: 17 additions & 5 deletions topologytest/couchbase_server_peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ func (r *CouchbaseServerReplication) PassivePeer() Peer {

// Start starts the replication
func (r *CouchbaseServerReplication) Start() {
r.t.Logf("starting XDCR replication")
require.NoError(r.t, r.manager.Start(r.ctx))
}

// Stop halts the replication. The replication can be restarted after it is stopped.
func (r *CouchbaseServerReplication) Stop() {
r.t.Logf("stopping XDCR replication")
require.NoError(r.t, r.manager.Stop(r.ctx))
}

Expand All @@ -83,34 +85,39 @@ func (p *CouchbaseServerPeer) GetDocument(dsName sgbucket.DataStoreName, docID s
}

// CreateDocument creates a document on the peer. The test will fail if the document already exists.
func (p *CouchbaseServerPeer) CreateDocument(dsName sgbucket.DataStoreName, docID string, body []byte) DocMetadata {
p.tb.Logf("%s: Creating document %s", p, docID)
func (p *CouchbaseServerPeer) CreateDocument(dsName sgbucket.DataStoreName, docID string, body []byte) BodyAndVersion {
p.tb.Logf("%s: Creating document %s in bucket %s", p, docID, p.bucket.GetName())
// create document with xattrs to prevent XDCR from doing a round trip replication in this scenario:
// CBS1: write document (cas1, no _vv)
// CBS1->CBS2: XDCR replication
// CBS2->CBS1: XDCR replication, creates a new _vv
cas, err := p.getCollection(dsName).WriteWithXattrs(p.Context(), docID, 0, 0, body, map[string][]byte{"userxattr": []byte(`{"dummy": "xattr"}`)}, nil, nil)
require.NoError(p.tb, err)
return DocMetadata{
docMetadata := DocMetadata{
DocID: docID,
Cas: cas,
ImplicitCV: &db.Version{
SourceID: p.SourceID(),
Value: cas,
},
}
return BodyAndVersion{
docMeta: docMetadata,
body: body,
updatePeer: p.name,
}
}

// WriteDocument writes a document to the peer. The test will fail if the write does not succeed.
func (p *CouchbaseServerPeer) WriteDocument(dsName sgbucket.DataStoreName, docID string, body []byte) DocMetadata {
func (p *CouchbaseServerPeer) WriteDocument(dsName sgbucket.DataStoreName, docID string, body []byte) BodyAndVersion {
p.tb.Logf("%s: Writing document %s", p, docID)
// write the document LWW, ignoring any in progress writes
callback := func(_ []byte) (updated []byte, expiry *uint32, shouldDelete bool, err error) {
return body, nil, false, nil
}
cas, err := p.getCollection(dsName).Update(docID, 0, callback)
require.NoError(p.tb, err)
return DocMetadata{
docMetadata := DocMetadata{
DocID: docID,
// FIXME: this should actually probably show the HLV persisted, and then also the implicit CV
Cas: cas,
Expand All @@ -119,6 +126,11 @@ func (p *CouchbaseServerPeer) WriteDocument(dsName sgbucket.DataStoreName, docID
Value: cas,
},
}
return BodyAndVersion{
docMeta: docMetadata,
body: body,
updatePeer: p.name,
}
}

// DeleteDocument deletes a document on the peer. The test will fail if the document does not exist.
Expand Down
Loading
Loading