@@ -68,31 +68,39 @@ func TestNodesExchangeCorrectBinIndexes(t *testing.T) {
68
68
t .Fatal (err )
69
69
}
70
70
71
- result := sim .Run (ctx , func (ctx context.Context , sim * simulation.Simulation ) error {
71
+ result := sim .Run (ctx , func (ctx context.Context , sim * simulation.Simulation ) ( err error ) {
72
72
nodeIDs := sim .UpNodeIDs ()
73
73
if len (nodeIDs ) != nodeCount {
74
74
return errors .New ("not enough nodes up" )
75
75
}
76
76
77
- // wait for the nodes to exchange StreamInfo messages
78
- time .Sleep (100 * time .Millisecond )
77
+ // periodically check for cursors
78
+ for i := 0 ; i < 100 ; i ++ {
79
+ // wait for the nodes to exchange StreamInfo messages
80
+ time .Sleep (10 * time .Millisecond )
79
81
80
- idOne := nodeIDs [0 ]
81
- idOther := nodeIDs [1 ]
82
- onesCursors := nodeRegistry (sim , idOne ).getPeer (idOther ).getCursorsCopy ()
83
- othersCursors := nodeRegistry (sim , idOther ).getPeer (idOne ).getCursorsCopy ()
82
+ idOne := nodeIDs [0 ]
83
+ idOther := nodeIDs [1 ]
84
+ onesCursors := nodeRegistry (sim , idOne ).getPeer (idOther ).getCursorsCopy ()
85
+ othersCursors := nodeRegistry (sim , idOther ).getPeer (idOne ).getCursorsCopy ()
84
86
85
- onesBins := nodeInitialBinIndexes (sim , idOne )
86
- othersBins := nodeInitialBinIndexes (sim , idOther )
87
+ onesBins := nodeInitialBinIndexes (sim , idOne )
88
+ othersBins := nodeInitialBinIndexes (sim , idOther )
87
89
88
- if err := compareNodeBinsToStreams (t , onesCursors , othersBins ); err != nil {
89
- return err
90
- }
91
- if err := compareNodeBinsToStreams (t , othersCursors , onesBins ); err != nil {
92
- return err
90
+ err1 := compareNodeBinsToStreams (t , onesCursors , othersBins )
91
+ if err1 != nil {
92
+ err = err1 // set the resulting error when the loop is done
93
+ }
94
+ err2 := compareNodeBinsToStreams (t , othersCursors , onesBins )
95
+ if err2 != nil {
96
+ err = err2 // set the resulting error when the loop is done
97
+ }
98
+ if err1 == nil && err2 == nil {
99
+ return nil
100
+ }
93
101
}
94
102
95
- return nil
103
+ return err
96
104
})
97
105
if result .Error != nil {
98
106
t .Fatal (result .Error )
0 commit comments