From 7318d7740efe603f340ca290d99b9c4ccb7dddde Mon Sep 17 00:00:00 2001 From: Neil Twigg Date: Tue, 23 Jul 2024 19:19:36 +0100 Subject: [PATCH] NRG: De-flake `TestNRGSwitchStateClearsQueues` Signed-off-by: Neil Twigg --- server/raft_test.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/server/raft_test.go b/server/raft_test.go index 692d3d518fc..2f2b1014200 100644 --- a/server/raft_test.go +++ b/server/raft_test.go @@ -364,15 +364,14 @@ func TestNRGSwitchStateClearsQueues(t *testing.T) { rg := c.createMemRaftGroup("TEST", 3, newStateAdder) rg.waitOnLeader() - sa := rg.leader().(*stateAdder) - n := sa.node().(*raft) - - for i := 0; i < 10_000; i++ { - sa.proposeDelta(1) - } + rg.lockAll() + defer rg.unlockAll() - n.Lock() - defer n.Unlock() + n := rg.leader().node().(*raft) + n.prop.push(&Entry{}) + n.resp.push(&appendEntryResponse{}) + require_NotEqual(t, n.prop.len(), 0) + require_NotEqual(t, n.resp.len(), 0) n.switchState(Follower) require_Equal(t, n.prop.len(), 0)