Skip to content

Commit

Permalink
Sometimes there isn't enough time to wait for an event. (#569)
Browse files Browse the repository at this point in the history
* Sometimes there isn't enough time to wait for an event. Increased the time.

Fixed working with break operator

Signed-off-by: Fedor Partanskiy <pfi79@mail.ru>

* add constant for real view change timeout

Signed-off-by: Fedor Partanskiy <pfi79@mail.ru>

---------

Signed-off-by: Fedor Partanskiy <pfi79@mail.ru>
Co-authored-by: C0rWin <artem@bargr.net>
  • Loading branch information
pfi79 and C0rWin authored Dec 6, 2023
1 parent d074a62 commit f8b15a2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (
"go.uber.org/zap/zapcore"
)

const (
realViewChangeTimeout = 90 * time.Second
)

func TestBasic(t *testing.T) {
t.Parallel()
network := NewNetwork()
Expand Down Expand Up @@ -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:
Expand All @@ -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
}
}

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
}
}

Expand Down

0 comments on commit f8b15a2

Please sign in to comment.