Skip to content

Commit

Permalink
De-flake TestNRGSwitchStateClearsQueues (#5707)
Browse files Browse the repository at this point in the history
Signed-off-by: Neil Twigg <neil@nats.io>
  • Loading branch information
derekcollison authored Jul 27, 2024
2 parents eedd412 + 80668e8 commit a8c1946
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server/raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,26 @@ func TestNRGSwitchStateClearsQueues(t *testing.T) {
rg := c.createMemRaftGroup("TEST", 3, newStateAdder)
rg.waitOnLeader()

// Ensure there are no other nodes running that could
// send something into our IP queues or it may break the
// below assertions.
for _, n := range rg {
if !n.node().Leader() {
n.stop()
}
}

rg.lockAll()
defer rg.unlockAll()

n := rg.leader().node().(*raft)
require_Equal(t, n.prop.len(), 0)
require_Equal(t, n.resp.len(), 0)

n.prop.push(&Entry{})
n.resp.push(&appendEntryResponse{})
require_Equal(t, n.prop.len(), 1)
require_Equal(t, n.resp.len(), 1)

n.switchState(Follower)
require_Equal(t, n.prop.len(), 0)
Expand Down

0 comments on commit a8c1946

Please sign in to comment.