From 909a89b201f93cd14bb8a5570c25223eeb82005b Mon Sep 17 00:00:00 2001 From: Gregory Newman-Smith Date: Wed, 27 Sep 2023 15:33:15 +0100 Subject: [PATCH 1/3] CBG-2579: test flake fix idea --- rest/replicatortest/replicator_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rest/replicatortest/replicator_test.go b/rest/replicatortest/replicator_test.go index 84f1c7def7..ccfe959061 100644 --- a/rest/replicatortest/replicator_test.go +++ b/rest/replicatortest/replicator_test.go @@ -7954,14 +7954,14 @@ func TestReplicatorCheckpointOnStop(t *testing.T) { // interval during the running of the test defer reduceTestCheckpointInterval(9999 * time.Hour)() - rev, doc, err := activeRT.GetSingleTestDatabaseCollectionWithUser().Put(activeCtx, "test", db.Body{}) + _, doc, err := activeRT.GetSingleTestDatabaseCollectionWithUser().Put(activeCtx, "test", db.Body{}) require.NoError(t, err) seq := strconv.FormatUint(doc.Sequence, 10) activeRT.CreateReplication(t.Name(), remoteURL, db.ActiveReplicatorTypePush, nil, true, db.ConflictResolverDefault) activeRT.WaitForReplicationStatus(t.Name(), db.ReplicationStateRunning) - err = passiveRT.WaitForRev("test", rev) + _, err = passiveRT.WaitForChanges(1, "/{{.keyspace}}/_changes", "", true) require.NoError(t, err) // stop active replicator explicitly From a76f83f478034cc58e91e59f18a4d85287ac9929 Mon Sep 17 00:00:00 2001 From: Gregory Newman-Smith Date: Wed, 27 Sep 2023 15:54:05 +0100 Subject: [PATCH 2/3] revert original changes due to different solution --- rest/replicatortest/replicator_test.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rest/replicatortest/replicator_test.go b/rest/replicatortest/replicator_test.go index ccfe959061..a3dad7e6e1 100644 --- a/rest/replicatortest/replicator_test.go +++ b/rest/replicatortest/replicator_test.go @@ -7954,18 +7954,25 @@ func TestReplicatorCheckpointOnStop(t *testing.T) { // interval during the running of the test defer reduceTestCheckpointInterval(9999 * time.Hour)() - _, doc, err := activeRT.GetSingleTestDatabaseCollectionWithUser().Put(activeCtx, "test", db.Body{}) + rev, doc, err := activeRT.GetSingleTestDatabaseCollectionWithUser().Put(activeCtx, "test", db.Body{}) require.NoError(t, err) seq := strconv.FormatUint(doc.Sequence, 10) activeRT.CreateReplication(t.Name(), remoteURL, db.ActiveReplicatorTypePush, nil, true, db.ConflictResolverDefault) activeRT.WaitForReplicationStatus(t.Name(), db.ReplicationStateRunning) - _, err = passiveRT.WaitForChanges(1, "/{{.keyspace}}/_changes", "", true) + err = passiveRT.WaitForRev("test", rev) require.NoError(t, err) - // stop active replicator explicitly + // assert on the processed seq list being updated before stopping the active replicator ar, ok := activeRT.GetDatabase().SGReplicateMgr.GetLocalActiveReplicatorForTest(t, t.Name()) + pullCheckpointer := ar.Push.GetSingleCollection(t).Checkpointer + _, ok = base.WaitForStat(t, func() int64 { + return pullCheckpointer.Stats().ProcessedSequenceCount + }, 1) + require.True(t, ok) + + // stop active replicator explicitly assert.True(t, ok) require.NoError(t, ar.Stop()) From 8163db3ae39191a88a2e27e5ff766c4effb67970 Mon Sep 17 00:00:00 2001 From: Gregory Newman-Smith Date: Wed, 27 Sep 2023 15:56:17 +0100 Subject: [PATCH 3/3] fix lint error --- rest/replicatortest/replicator_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest/replicatortest/replicator_test.go b/rest/replicatortest/replicator_test.go index a3dad7e6e1..3e36f376fd 100644 --- a/rest/replicatortest/replicator_test.go +++ b/rest/replicatortest/replicator_test.go @@ -7966,6 +7966,7 @@ func TestReplicatorCheckpointOnStop(t *testing.T) { // assert on the processed seq list being updated before stopping the active replicator ar, ok := activeRT.GetDatabase().SGReplicateMgr.GetLocalActiveReplicatorForTest(t, t.Name()) + assert.True(t, ok) pullCheckpointer := ar.Push.GetSingleCollection(t).Checkpointer _, ok = base.WaitForStat(t, func() int64 { return pullCheckpointer.Stats().ProcessedSequenceCount @@ -7973,7 +7974,6 @@ func TestReplicatorCheckpointOnStop(t *testing.T) { require.True(t, ok) // stop active replicator explicitly - assert.True(t, ok) require.NoError(t, ar.Stop()) // Check checkpoint document was wrote to bucket with correct status