From 03573853318c583adea54f485af0a8eb59926d1e Mon Sep 17 00:00:00 2001 From: Keenan Nemetz Date: Wed, 12 Jun 2024 19:30:13 -0700 Subject: [PATCH] skip waitForMerge when no waitForSync present --- tests/integration/p2p.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/integration/p2p.go b/tests/integration/p2p.go index cd1dbd3b5c..7a2d22a9ef 100644 --- a/tests/integration/p2p.go +++ b/tests/integration/p2p.go @@ -175,6 +175,7 @@ func setupPeerWaitSync( nodeCollections := map[int][]int{} waitIndex := 0 + skipWaitForMerge := true for i := startIndex; i < len(s.testCase.Actions); i++ { switch action := s.testCase.Actions[i].(type) { case SubscribeToCollection: @@ -247,14 +248,18 @@ func setupPeerWaitSync( case WaitForSync: waitIndex += 1 + skipWaitForMerge = false targetToSourceEvents = append(targetToSourceEvents, 0) sourceToTargetEvents = append(sourceToTargetEvents, 0) } } - nodeSynced := make(chan struct{}) - go waitForMerge(s, cfg.SourceNodeID, cfg.TargetNodeID, sourceToTargetEvents, targetToSourceEvents, nodeSynced) - s.syncChans = append(s.syncChans, nodeSynced) + // skip waiting for a merge if we aren't interested in waiting for a sync to complete + if !skipWaitForMerge { + nodeSynced := make(chan struct{}) + go waitForMerge(s, cfg.SourceNodeID, cfg.TargetNodeID, sourceToTargetEvents, targetToSourceEvents, nodeSynced) + s.syncChans = append(s.syncChans, nodeSynced) + } } // collectionSubscribedTo returns true if the collection on the given node @@ -323,6 +328,7 @@ func setupReplicatorWaitSync( docIDsSyncedToSource := map[int]struct{}{} waitIndex := 0 currentDocID := 0 + skipWaitForMerge := true for i := startIndex; i < len(s.testCase.Actions); i++ { switch action := s.testCase.Actions[i].(type) { case CreateDoc: @@ -360,14 +366,18 @@ func setupReplicatorWaitSync( case WaitForSync: waitIndex += 1 + skipWaitForMerge = false targetToSourceEvents = append(targetToSourceEvents, 0) sourceToTargetEvents = append(sourceToTargetEvents, 0) } } - nodeSynced := make(chan struct{}) - go waitForMerge(s, cfg.SourceNodeID, cfg.TargetNodeID, sourceToTargetEvents, targetToSourceEvents, nodeSynced) - s.syncChans = append(s.syncChans, nodeSynced) + // skip waiting for a merge if we aren't interested in waiting for a sync to complete + if !skipWaitForMerge { + nodeSynced := make(chan struct{}) + go waitForMerge(s, cfg.SourceNodeID, cfg.TargetNodeID, sourceToTargetEvents, targetToSourceEvents, nodeSynced) + s.syncChans = append(s.syncChans, nodeSynced) + } } // subscribeToCollection sets up a collection subscription on the given node/collection.