Skip to content

Commit

Permalink
Compare CV directly
Browse files Browse the repository at this point in the history
  • Loading branch information
torcolvin committed Nov 15, 2024
1 parent 7d200f5 commit 00abd12
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
10 changes: 1 addition & 9 deletions topologytest/couchbase_server_peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (p *CouchbaseServerPeer) waitForDocVersion(dsName sgbucket.DataStoreName, d
}
// have to use p.tb instead of c because of the assert.CollectT doesn't implement TB
version = getDocVersion(p, cas, xattrs)
assert.Equal(c, getCVBeforeImport(expected), getCVBeforeImport(version), "Could not find matching CV on %s for peer %s (sourceID:%s)\nexpected: %+v\nactual: %+v\n body: %+v\n", docID, p, p.SourceID(), expected, version, string(docBytes))
assert.Equal(c, expected.CV(), version.CV(), "Could not find matching CV on %s for peer %s (sourceID:%s)\nexpected: %+v\nactual: %+v\n body: %+v\n", docID, p, p.SourceID(), expected, version, string(docBytes))

}, 5*time.Second, 100*time.Millisecond)
p.tb.Logf("found version %+v for doc %s on %s", version, docID, p)
Expand Down Expand Up @@ -294,11 +294,3 @@ func getBodyAndVersion(peer Peer, collection sgbucket.DataStore, docID string) (
require.NoError(peer.TB(), base.JSONUnmarshal(docBytes, &body))
return getDocVersion(peer, cas, xattrs), body
}

// getFunctionalCV returns a functional version from a DocVersion, which will CV from a DocVersion.
func getCVBeforeImport(version rest.DocVersion) db.Version {
if version.Cas != 0 && version.Mou != nil && version.HLV.CurrentVersionCAS != version.Cas {
return db.Version{SourceID: version.HLV.SourceID, Value: base.HexCasToUint64(version.Mou.PreviousCAS)}
}
return db.Version{SourceID: version.HLV.SourceID, Value: version.HLV.Version}
}
2 changes: 1 addition & 1 deletion topologytest/sync_gateway_peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (p *SyncGatewayPeer) WaitForDocVersion(dsName sgbucket.DataStoreName, docID
// Only assert on CV since RevTreeID might not be present if this was a Couchbase Server write
bodyBytes, err := doc.BodyBytes(ctx)
assert.NoError(c, err)
assert.Equal(c, getCVBeforeImport(expected), getCVBeforeImport(version), "Could not find matching CV on %s for peer %s (sourceID:%s)\nexpected: %+v\nactual: %+v\n body: %+v\n", docID, p, p.SourceID(), expected, version, string(bodyBytes))
assert.Equal(c, expected.CV(), version.CV(), "Could not find matching CV on %s for peer %s (sourceID:%s)\nexpected: %+v\nactual: %+v\n body: %+v\n", docID, p, p.SourceID(), expected, version, string(bodyBytes))
}, 5*time.Second, 100*time.Millisecond)
return doc.Body(ctx)
}
Expand Down

0 comments on commit 00abd12

Please sign in to comment.