Skip to content

Commit

Permalink
fix tests (hashicorp#391)
Browse files Browse the repository at this point in the history
* fix TestRaft_LeaderLeaseExpire
* fix TestRaft_LeadershipTransferLeaderRejectsClientRequests
  • Loading branch information
hanshasselberg authored Mar 2, 2020
1 parent 2e99741 commit b78b39c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1490,13 +1490,17 @@ func TestRaft_LeaderLeaseExpire(t *testing.T) {
c.Disconnect(follower.localAddr)

// Watch the leaderCh
select {
case v := <-leader.LeaderCh():
if v {
c.FailNowf("should step down as leader")
timeout := time.After(conf.LeaderLeaseTimeout * 2)
LOOP:
for {
select {
case v := <-leader.LeaderCh():
if !v {
break LOOP
}
case <-timeout:
c.FailNowf("timeout stepping down as leader")
}
case <-time.After(conf.LeaderLeaseTimeout * 2):
c.FailNowf("timeout stepping down as leader")
}

// Ensure the last contact of the leader is non-zero
Expand Down Expand Up @@ -2027,7 +2031,6 @@ func TestRaft_LeadershipTransferLeaderRejectsClientRequests(t *testing.T) {
l.Apply([]byte("test"), 0),
l.Barrier(0),
l.DemoteVoter(ServerID(""), 0, 0),
l.GetConfiguration(),

// the API is tested, but here we are making sure we reject any config change.
l.requestConfigChange(configurationChangeRequest{}, 100*time.Millisecond),
Expand Down

0 comments on commit b78b39c

Please sign in to comment.