@@ -175,6 +175,7 @@ func setupPeerWaitSync(
175
175
176
176
nodeCollections := map [int ][]int {}
177
177
waitIndex := 0
178
+ skipWaitForMerge := true
178
179
for i := startIndex ; i < len (s .testCase .Actions ); i ++ {
179
180
switch action := s .testCase .Actions [i ].(type ) {
180
181
case SubscribeToCollection :
@@ -247,14 +248,18 @@ func setupPeerWaitSync(
247
248
248
249
case WaitForSync :
249
250
waitIndex += 1
251
+ skipWaitForMerge = false
250
252
targetToSourceEvents = append (targetToSourceEvents , 0 )
251
253
sourceToTargetEvents = append (sourceToTargetEvents , 0 )
252
254
}
253
255
}
254
256
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
+ }
258
263
}
259
264
260
265
// collectionSubscribedTo returns true if the collection on the given node
@@ -323,6 +328,7 @@ func setupReplicatorWaitSync(
323
328
docIDsSyncedToSource := map [int ]struct {}{}
324
329
waitIndex := 0
325
330
currentDocID := 0
331
+ skipWaitForMerge := true
326
332
for i := startIndex ; i < len (s .testCase .Actions ); i ++ {
327
333
switch action := s .testCase .Actions [i ].(type ) {
328
334
case CreateDoc :
@@ -360,14 +366,18 @@ func setupReplicatorWaitSync(
360
366
361
367
case WaitForSync :
362
368
waitIndex += 1
369
+ skipWaitForMerge = false
363
370
targetToSourceEvents = append (targetToSourceEvents , 0 )
364
371
sourceToTargetEvents = append (sourceToTargetEvents , 0 )
365
372
}
366
373
}
367
374
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
+ }
371
381
}
372
382
373
383
// subscribeToCollection sets up a collection subscription on the given node/collection.
0 commit comments