From ad7ff86d34c6ec8ab67871d4589f2a1977cd429b Mon Sep 17 00:00:00 2001 From: Maurice van Veen Date: Sun, 10 Nov 2024 17:02:36 +0100 Subject: [PATCH] De-flake TestJetStreamClusterInterestLeakOnDisableJetStream, RAFT groups close asynchronously Signed-off-by: Maurice van Veen --- server/jetstream_cluster_3_test.go | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/server/jetstream_cluster_3_test.go b/server/jetstream_cluster_3_test.go index ed6e265220d..deb5adf1a48 100644 --- a/server/jetstream_cluster_3_test.go +++ b/server/jetstream_cluster_3_test.go @@ -3347,20 +3347,23 @@ func TestJetStreamClusterInterestLeakOnDisableJetStream(t *testing.T) { server.DisableJetStream() - var sublist []*subscription - account.sl.localSubs(&sublist, false) - - var danglingJSC, danglingRaft int - for _, sub := range sublist { - if strings.HasPrefix(string(sub.subject), "$JSC.") { - danglingJSC++ - } else if strings.HasPrefix(string(sub.subject), "$NRG.") { - danglingRaft++ + checkFor(t, 2*time.Second, 100*time.Millisecond, func() error { + var sublist []*subscription + account.sl.localSubs(&sublist, false) + + var danglingJSC, danglingRaft int + for _, sub := range sublist { + if strings.HasPrefix(string(sub.subject), "$JSC.") { + danglingJSC++ + } else if strings.HasPrefix(string(sub.subject), "$NRG.") { + danglingRaft++ + } } - } - if danglingJSC > 0 || danglingRaft > 0 { - t.Fatalf("unexpected dangling interests for JetStream assets after shutdown (%d $JSC, %d $NRG)", danglingJSC, danglingRaft) - } + if danglingJSC > 0 || danglingRaft > 0 { + return fmt.Errorf("unexpected dangling interests for JetStream assets after shutdown (%d $JSC, %d $NRG)", danglingJSC, danglingRaft) + } + return nil + }) } func TestJetStreamClusterNoLeadersDuringLameDuck(t *testing.T) {