Skip to content

Commit 38f3742

Browse files
authored
fix test flakes (#7682)
1 parent 1190eac commit 38f3742

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Copyright 2025-Present Couchbase, Inc.
2+
#
3+
# Use of this software is governed by the Business Source License included
4+
# in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
5+
# in that file, in accordance with the Business Source License, use of this
6+
# software will be governed by the Apache License, Version 2.0, included in
7+
# the file licenses/APL2.txt.
8+
19
[project] # this isn't a real project, but we need this to make the tools work
210
name = "sgcollect_info"
311
version = "0.0.1"

rest/blip_api_crud_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3601,7 +3601,7 @@ func TestBlipPullConflict(t *testing.T) {
36013601

36023602
require.EventuallyWithT(t, func(c *assert.CollectT) {
36033603
_, _, postConflictCBLVersion := client.GetDoc(docID)
3604-
assert.NotEqual(t, preConflictCBLVersion, postConflictCBLVersion)
3604+
assert.Greater(c, postConflictCBLVersion.CV.Value, preConflictCBLVersion.CV.Value)
36053605
}, time.Second*10, time.Millisecond*10, "Expected sgVersion and cblVersion to be different")
36063606

36073607
postConflictDoc, postConflictHLV, postConflictVersion := client.GetDoc(docID)

rest/blip_legacy_revid_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,9 @@ func TestChangesResponseWithHLVInHistory(t *testing.T) {
662662
rt.WaitForPendingChanges()
663663

664664
receivedChangesRequestWg := sync.WaitGroup{}
665+
receivedChangesRequestWg.Add(2)
665666
revsFinishedWg := sync.WaitGroup{}
667+
revsFinishedWg.Add(1)
666668

667669
bt.blipContext.HandlerForProfile["rev"] = func(request *blip.Message) {
668670
defer revsFinishedWg.Done()
@@ -682,6 +684,7 @@ func TestChangesResponseWithHLVInHistory(t *testing.T) {
682684
}
683685

684686
bt.blipContext.HandlerForProfile["changes"] = func(request *blip.Message) {
687+
defer receivedChangesRequestWg.Done()
685688

686689
log.Printf("got changes message: %+v", request)
687690
body, err := request.Body()
@@ -713,19 +716,13 @@ func TestChangesResponseWithHLVInHistory(t *testing.T) {
713716
require.NoError(t, err)
714717
response.SetBody(emptyResponseValBytes)
715718
}
716-
receivedChangesRequestWg.Done()
717719
}
718720

719721
subChangesRequest := bt.newRequest()
720722
subChangesRequest.SetProfile("subChanges")
721723
subChangesRequest.Properties["continuous"] = "false"
722724
sent := bt.sender.Send(subChangesRequest)
723725
assert.True(t, sent)
724-
// changes will be called again with empty changes so hence the wait group of 2
725-
receivedChangesRequestWg.Add(2)
726-
727-
// expect 1 rev message
728-
revsFinishedWg.Add(1)
729726

730727
subChangesResponse := subChangesRequest.Response()
731728
assert.Equal(t, subChangesRequest.SerialNumber(), subChangesResponse.SerialNumber())

topologytest/couchbase_lite_mock_peer_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ func (p *CouchbaseLiteMockPeer) GetDocumentIfExists(dsName sgbucket.DataStoreNam
7676
if meta == nil {
7777
return DocMetadata{}, nil, false
7878
}
79-
require.NotNil(p.TB(), meta, "docID:%s not found on %s", docID, p)
79+
// document is tombstone
80+
if bodyBytes == nil {
81+
return *meta, nil, true
82+
}
8083
require.NoError(p.TB(), base.JSONUnmarshal(bodyBytes, &body))
8184
return *meta, body, true
8285
}

0 commit comments

Comments
 (0)