diff --git a/test/basic_test.go b/test/basic_test.go index f260b4d6..c873f8a7 100644 --- a/test/basic_test.go +++ b/test/basic_test.go @@ -25,6 +25,10 @@ import ( "go.uber.org/zap/zapcore" ) +const ( + realViewChangeTimeout = 90 * time.Second +) + func TestBasic(t *testing.T) { t.Parallel() network := NewNetwork() @@ -2675,7 +2679,7 @@ func TestViewChangeAfterTryingToFork(t *testing.T) { nodes[4].Connect() // Waiting for a real change of leader and view - fail = time.After(1 * time.Minute) + fail = time.After(realViewChangeTimeout) for i := 0; i < 7; i++ { select { case <-realViewChangeCh: @@ -2687,12 +2691,14 @@ func TestViewChangeAfterTryingToFork(t *testing.T) { data := make([]*AppRecord, 0, 7) storeI := -1 fail = time.After(1 * time.Minute) +ExternalLoop: for i := 0; i < numberOfNodes; i++ { select { case d := <-nodes[i].Delivered: data = append(data, d) case <-fail: storeI = i + break ExternalLoop } } @@ -2973,7 +2979,7 @@ func TestLeaderStopSendHeartbeat(t *testing.T) { nodes[2].Connect() nodes[3].Connect() - fail = time.After(1 * time.Minute) + fail = time.After(realViewChangeTimeout) for i := 0; i < 4; i++ { select { case <-realViewChangeCh: @@ -3240,7 +3246,7 @@ func TestTryCommittedSequenceTwice(t *testing.T) { nodes[4].Connect() // Waiting for a real change of leader and view - fail = time.After(1 * time.Minute) + fail = time.After(realViewChangeTimeout) for i := 0; i < 7; i++ { select { case <-realViewChangeCh: @@ -3252,12 +3258,14 @@ func TestTryCommittedSequenceTwice(t *testing.T) { data := make([]*AppRecord, 0, 7) storeI := -1 fail = time.After(1 * time.Minute) +ExternalLoop: for i := 0; i < numberOfNodes; i++ { select { case d := <-nodes[i].Delivered: data = append(data, d) case <-fail: storeI = i + break ExternalLoop } }