Skip to content

Commit

Permalink
Merge pull request #14440 from vsvastey/usr/vsvastey/open-with-max-in…
Browse files Browse the repository at this point in the history
…dex-test-fix-3.5

[release-3.5] testing: fix TestOpenWithMaxIndex cleanup
  • Loading branch information
ahrtr authored Sep 8, 2022
2 parents a5a33cb + eef5e22 commit 16d72c0
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions server/wal/wal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,24 +691,31 @@ func TestOpenWithMaxIndex(t *testing.T) {
}
defer os.RemoveAll(p)
// create WAL
w, err := Create(zap.NewExample(), p, nil)
w1, err := Create(zap.NewExample(), p, nil)
if err != nil {
t.Fatal(err)
}
defer w.Close()
defer func() {
if w1 != nil {
w1.Close()
}
}()

es := []raftpb.Entry{{Index: uint64(math.MaxInt64)}}
if err = w.Save(raftpb.HardState{}, es); err != nil {
if err = w1.Save(raftpb.HardState{}, es); err != nil {
t.Fatal(err)
}
w.Close()
w1.Close()
w1 = nil

w, err = Open(zap.NewExample(), p, walpb.Snapshot{})
w2, err := Open(zap.NewExample(), p, walpb.Snapshot{})
if err != nil {
t.Fatal(err)
}
_, _, _, err = w.ReadAll()
if err == nil || err != ErrSliceOutOfRange {
defer w2.Close()

_, _, _, err = w2.ReadAll()
if err != ErrSliceOutOfRange {
t.Fatalf("err = %v, want ErrSliceOutOfRange", err)
}
}
Expand Down

0 comments on commit 16d72c0

Please sign in to comment.