From f8b15a205b36e307b7107df8030195ffd916b5b0 Mon Sep 17 00:00:00 2001 From: pfi79 Date: Wed, 6 Dec 2023 11:34:57 +0300 Subject: [PATCH] Sometimes there isn't enough time to wait for an event. (#569) * Sometimes there isn't enough time to wait for an event. Increased the time. Fixed working with break operator Signed-off-by: Fedor Partanskiy * add constant for real view change timeout Signed-off-by: Fedor Partanskiy --------- Signed-off-by: Fedor Partanskiy Co-authored-by: C0rWin --- test/basic_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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 } }