Skip to content

Commit

Permalink
De-flake TestJetStreamClusterStreamCatchupNoState
Browse files Browse the repository at this point in the history
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 <neil@nats.io>
  • Loading branch information
neilalexander committed Aug 8, 2024
1 parent 0a8f982 commit 695f3ae
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions server/jetstream_cluster_2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 695f3ae

Please sign in to comment.