Skip to content

Commit ec13943

Browse files
authored
CBG-4915: Fix flakiness of TestMultiActorLosingConflictUpdateRemovingAttachments (#7923)
1 parent 40ca831 commit ec13943

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

rest/utilities_testing_resttester.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ func (rt *RestTester) WaitForVersionRevIDOnly(docID string, version DocVersion)
237237
rt.WaitForVersion(docID, version)
238238
}
239239

240+
// WaitForCV waits for the document's current version to match the expectedVersion. Fails the test harness. WaitForVersion should be used in the general case to test revtree and and cv behavior.
241+
func (rt *RestTester) WaitForVersionHLVOnly(docID string, version DocVersion) {
242+
version.RevTreeID = ""
243+
rt.WaitForVersion(docID, version)
244+
}
245+
240246
// WaitForTombstone waits for a the document version to exist and be tombstoned. If the document is not found, the test will fail.
241247
func (rt *RestTester) WaitForTombstone(docID string, deleteVersion DocVersion) {
242248
collection, ctx := rt.GetSingleTestDatabaseCollectionWithUser()

xdcr/attachment_test.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,8 @@ func TestMultiActorLosingConflictUpdateRemovingAttachments(t *testing.T) {
7777
rest.RequireStatus(t, attAResp, http.StatusOK)
7878

7979
// wait for doc to replicate to rtB
80-
var rtBVersion rest.DocVersion
81-
require.EventuallyWithT(t, func(c *assert.CollectT) {
82-
rtBVersion, _ = rtB.GetDoc(docID)
83-
assert.Equal(c, rtAVersion.CV.String(), rtBVersion.CV.String())
84-
assert.Equal(c, rtAVersion.RevTreeID, rtBVersion.RevTreeID)
85-
}, time.Second*5, time.Millisecond*100)
80+
rtB.WaitForVersion(docID, rtAVersion)
81+
rtBVersion, _ := rtB.GetDoc(docID)
8682

8783
// wait for XDCR stats to ensure attachment data also made it over
8884
require.EventuallyWithT(t, func(c *assert.CollectT) {
@@ -101,7 +97,7 @@ func TestMultiActorLosingConflictUpdateRemovingAttachments(t *testing.T) {
10197
rest.RequireStatus(t, attBResp, http.StatusOK)
10298

10399
// update doc on A, removing attachment
104-
rtAVersion = rtA.UpdateDoc(docID, rtAVersion, `{"key":"value2"}`)
100+
_ = rtA.UpdateDoc(docID, rtAVersion, `{"key":"value2"}`)
105101

106102
// update doc on B, changing body but keeping attachment stub (twice to ensure MWW resolves this as the winner as well as LWW)
107103
rtBVersion = rtB.UpdateDoc(docID, rtBVersion, `{"key":"value3","_attachments":{"`+attachmentID+`":{"stub":true}}}`)
@@ -133,10 +129,7 @@ func TestMultiActorLosingConflictUpdateRemovingAttachments(t *testing.T) {
133129
}, time.Second*5, time.Millisecond*100)
134130

135131
// wait for doc (resolved conflict) to replicate back to rtA
136-
assert.EventuallyWithT(t, func(c *assert.CollectT) {
137-
currentRtAVersion, _ := rtA.GetDoc(docID)
138-
assert.Equal(c, rtBVersion.CV.String(), currentRtAVersion.CV.String())
139-
}, time.Second*10, time.Millisecond*100)
132+
rtA.WaitForVersionHLVOnly(docID, rtBVersion)
140133

141134
// check attachment metadata exists
142135
docA := rtA.GetDocument(docID)
@@ -151,6 +144,4 @@ func TestMultiActorLosingConflictUpdateRemovingAttachments(t *testing.T) {
151144
attBResp = rtB.SendAdminRequest(http.MethodGet, "/{{.keyspace}}/"+docID+"/"+attachmentID, "")
152145
rest.AssertStatus(t, attBResp, http.StatusOK)
153146

154-
require.NoError(t, xdcrAtoB.Stop(ctx))
155-
require.NoError(t, xdcrBtoA.Stop(ctx))
156147
}

0 commit comments

Comments
 (0)