From 695f3aebed324ed16ae22b11f2af10d50d52e022 Mon Sep 17 00:00:00 2001 From: Neil Twigg Date: Thu, 8 Aug 2024 10:38:21 +0100 Subject: [PATCH] De-flake `TestJetStreamClusterStreamCatchupNoState` The on-disk state seemed to be inconsistent with truncation but removing the `msgs` folder seems to resolve the issue in local testing. Signed-off-by: Neil Twigg --- server/jetstream_cluster_2_test.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/server/jetstream_cluster_2_test.go b/server/jetstream_cluster_2_test.go index 0707f5e2825..1333e9ff1a3 100644 --- a/server/jetstream_cluster_2_test.go +++ b/server/jetstream_cluster_2_test.go @@ -2660,22 +2660,15 @@ func TestJetStreamClusterStreamCatchupNoState(t *testing.T) { nc.Close() c.stopAll() // Remove all state by truncating for the non-leader. - for _, fn := range []string{"1.blk", "1.idx", "1.fss"} { - fname := filepath.Join(config.StoreDir, "$G", "streams", "TEST", "msgs", fn) - fd, err := os.OpenFile(fname, os.O_RDWR, defaultFilePerms) - if err != nil { - continue - } - fd.Truncate(0) - fd.Close() - } // For both make sure we have no raft snapshots. snapDir := filepath.Join(lconfig.StoreDir, "$SYS", "_js_", gname, "snapshots") - os.RemoveAll(snapDir) + require_NoError(t, os.RemoveAll(snapDir)) + msgsDir := filepath.Join(lconfig.StoreDir, "$SYS", "_js_", gname, "msgs") + require_NoError(t, os.RemoveAll(msgsDir)) // Remove all our raft state, we do not want to hold onto our term and index which // results in a coin toss for who becomes the leader. raftDir := filepath.Join(config.StoreDir, "$SYS", "_js_", gname) - os.RemoveAll(raftDir) + require_NoError(t, os.RemoveAll(raftDir)) // Now restart. c.restartAll()