Skip to content

Commit

Permalink
skip waitForMerge when no waitForSync present
Browse files Browse the repository at this point in the history
  • Loading branch information
nasdf committed Jun 13, 2024
1 parent cfa0ef9 commit 0357385
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tests/integration/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 0357385

Please sign in to comment.