Commit 33f120f
committed
fix flake in test for restarted followers not causing an election
While working on #666, I encountered a test flake caused by a race condition in
`TestRaft_FollowerRemovalNoElection`, which is also obscuring the test
intent. After we restart the follower, typically the `c.ConnectFully` call will
complete quickly enough that the follower never enters a candidate state, so
we're not exercising the intended behavior. But if the `c.ConnectFully` call
takes too long, the follower can miss heartbeats and start an election. This is
expected behavior and its request for an election will be rejected. But in that
case, the follower will not have settled on the leader by the time we check it
and the test will fail when it shouldn't.
Add an extra sleep before we reconnect the cluster to force the restarted
follower to become a candidate so that we're exercising the intent of the test,
but then wait until the follower shows an event that it's got a leader before
continuing to the remaining assertions.1 parent 10dcdbf commit 33f120f
2 files changed
Lines changed: 29 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3106 | 3106 | | |
3107 | 3107 | | |
3108 | 3108 | | |
| 3109 | + | |
| 3110 | + | |
3109 | 3111 | | |
3110 | 3112 | | |
3111 | 3113 | | |
| 3114 | + | |
3112 | 3115 | | |
3113 | | - | |
3114 | | - | |
3115 | 3116 | | |
3116 | | - | |
| 3117 | + | |
| 3118 | + | |
| 3119 | + | |
| 3120 | + | |
| 3121 | + | |
| 3122 | + | |
| 3123 | + | |
| 3124 | + | |
| 3125 | + | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + | |
| 3129 | + | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
| 3134 | + | |
| 3135 | + | |
| 3136 | + | |
| 3137 | + | |
| 3138 | + | |
| 3139 | + | |
3117 | 3140 | | |
3118 | 3141 | | |
3119 | 3142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
| 590 | + | |
590 | 591 | | |
591 | 592 | | |
592 | 593 | | |
| |||
612 | 613 | | |
613 | 614 | | |
614 | 615 | | |
| 616 | + | |
615 | 617 | | |
616 | 618 | | |
617 | 619 | | |
| |||
690 | 692 | | |
691 | 693 | | |
692 | 694 | | |
| 695 | + | |
693 | 696 | | |
694 | 697 | | |
695 | 698 | | |
| |||
0 commit comments