Skip to content

Commit 0357385

Browse files
committed
skip waitForMerge when no waitForSync present
1 parent cfa0ef9 commit 0357385

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

tests/integration/p2p.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ func setupPeerWaitSync(
175175

176176
nodeCollections := map[int][]int{}
177177
waitIndex := 0
178+
skipWaitForMerge := true
178179
for i := startIndex; i < len(s.testCase.Actions); i++ {
179180
switch action := s.testCase.Actions[i].(type) {
180181
case SubscribeToCollection:
@@ -247,14 +248,18 @@ func setupPeerWaitSync(
247248

248249
case WaitForSync:
249250
waitIndex += 1
251+
skipWaitForMerge = false
250252
targetToSourceEvents = append(targetToSourceEvents, 0)
251253
sourceToTargetEvents = append(sourceToTargetEvents, 0)
252254
}
253255
}
254256

255-
nodeSynced := make(chan struct{})
256-
go waitForMerge(s, cfg.SourceNodeID, cfg.TargetNodeID, sourceToTargetEvents, targetToSourceEvents, nodeSynced)
257-
s.syncChans = append(s.syncChans, nodeSynced)
257+
// skip waiting for a merge if we aren't interested in waiting for a sync to complete
258+
if !skipWaitForMerge {
259+
nodeSynced := make(chan struct{})
260+
go waitForMerge(s, cfg.SourceNodeID, cfg.TargetNodeID, sourceToTargetEvents, targetToSourceEvents, nodeSynced)
261+
s.syncChans = append(s.syncChans, nodeSynced)
262+
}
258263
}
259264

260265
// collectionSubscribedTo returns true if the collection on the given node
@@ -323,6 +328,7 @@ func setupReplicatorWaitSync(
323328
docIDsSyncedToSource := map[int]struct{}{}
324329
waitIndex := 0
325330
currentDocID := 0
331+
skipWaitForMerge := true
326332
for i := startIndex; i < len(s.testCase.Actions); i++ {
327333
switch action := s.testCase.Actions[i].(type) {
328334
case CreateDoc:
@@ -360,14 +366,18 @@ func setupReplicatorWaitSync(
360366

361367
case WaitForSync:
362368
waitIndex += 1
369+
skipWaitForMerge = false
363370
targetToSourceEvents = append(targetToSourceEvents, 0)
364371
sourceToTargetEvents = append(sourceToTargetEvents, 0)
365372
}
366373
}
367374

368-
nodeSynced := make(chan struct{})
369-
go waitForMerge(s, cfg.SourceNodeID, cfg.TargetNodeID, sourceToTargetEvents, targetToSourceEvents, nodeSynced)
370-
s.syncChans = append(s.syncChans, nodeSynced)
375+
// skip waiting for a merge if we aren't interested in waiting for a sync to complete
376+
if !skipWaitForMerge {
377+
nodeSynced := make(chan struct{})
378+
go waitForMerge(s, cfg.SourceNodeID, cfg.TargetNodeID, sourceToTargetEvents, targetToSourceEvents, nodeSynced)
379+
s.syncChans = append(s.syncChans, nodeSynced)
380+
}
371381
}
372382

373383
// subscribeToCollection sets up a collection subscription on the given node/collection.

0 commit comments

Comments
 (0)