Skip to content

Commit

Permalink
snapshots: fix flaky tests [o.41-cherry-pick] (#8484)
Browse files Browse the repository at this point in the history
From: #8475
  • Loading branch information
Alessio Treglia authored Feb 4, 2021
1 parent a72c975 commit 2437b66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion snapshots/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"io"
"io/ioutil"
"os"
"testing"
"time"

Expand Down Expand Up @@ -100,7 +101,10 @@ func (m *mockSnapshotter) Snapshot(height uint64, format uint32) (<-chan io.Read
// setupBusyManager creates a manager with an empty store that is busy creating a snapshot at height 1.
// The snapshot will complete when the returned closer is called.
func setupBusyManager(t *testing.T) *snapshots.Manager {
tempdir := t.TempDir()
tempdir, err := ioutil.TempDir("", "")
require.NoError(t, err)
t.Cleanup(func() { _ = os.RemoveAll(tempdir) })

store, err := snapshots.NewStore(db.NewMemDB(), tempdir)
require.NoError(t, err)
hung := newHungSnapshotter()
Expand Down
6 changes: 5 additions & 1 deletion snapshots/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"io"
"io/ioutil"
"os"
"path/filepath"
"testing"
"time"
Expand All @@ -19,7 +20,10 @@ import (
)

func setupStore(t *testing.T) *snapshots.Store {
tempdir := t.TempDir()
tempdir, err := ioutil.TempDir("", "")
require.NoError(t, err)
t.Cleanup(func() { _ = os.RemoveAll(tempdir) })

store, err := snapshots.NewStore(db.NewMemDB(), tempdir)
require.NoError(t, err)

Expand Down

0 comments on commit 2437b66

Please sign in to comment.