Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tests: Use mutex-wrapped datastore in storage tests #10846

Merged
merged 1 commit into from
May 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions storage/sealer/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

"github.com/google/uuid"
"github.com/ipfs/go-datastore"
syncds "github.com/ipfs/go-datastore/sync"
logging "github.com/ipfs/go-log/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -143,7 +144,7 @@ func TestSimple(t *testing.T) {
logging.SetAllLoggers(logging.LevelDebug)

ctx := context.Background()
m, lstor, _, _, cleanup := newTestMgr(ctx, t, datastore.NewMapDatastore())
m, lstor, _, _, cleanup := newTestMgr(ctx, t, syncds.MutexWrap(datastore.NewMapDatastore()))
defer cleanup()

localTasks := []sealtasks.TaskType{
Expand Down Expand Up @@ -200,15 +201,15 @@ func (m NullReader) NullBytes() int64 {
func TestSnapDeals(t *testing.T) {
logging.SetAllLoggers(logging.LevelWarn)
ctx := context.Background()
m, lstor, stor, idx, cleanup := newTestMgr(ctx, t, datastore.NewMapDatastore())
m, lstor, stor, idx, cleanup := newTestMgr(ctx, t, syncds.MutexWrap(datastore.NewMapDatastore()))
defer cleanup()

localTasks := []sealtasks.TaskType{
sealtasks.TTAddPiece, sealtasks.TTPreCommit1, sealtasks.TTPreCommit2, sealtasks.TTCommit1, sealtasks.TTCommit2, sealtasks.TTFinalize,
sealtasks.TTFetch, sealtasks.TTReplicaUpdate, sealtasks.TTProveReplicaUpdate1, sealtasks.TTProveReplicaUpdate2, sealtasks.TTUnseal,
sealtasks.TTRegenSectorKey, sealtasks.TTFinalizeUnsealed,
}
wds := datastore.NewMapDatastore()
wds := syncds.MutexWrap(datastore.NewMapDatastore())

w := NewLocalWorker(WorkerConfig{TaskTypes: localTasks}, stor, lstor, idx, m, statestore.New(wds))
err := m.AddWorker(ctx, w)
Expand Down Expand Up @@ -329,15 +330,15 @@ func TestSnapDeals(t *testing.T) {
func TestSnarkPackV2(t *testing.T) {
logging.SetAllLoggers(logging.LevelWarn)
ctx := context.Background()
m, lstor, stor, idx, cleanup := newTestMgr(ctx, t, datastore.NewMapDatastore())
m, lstor, stor, idx, cleanup := newTestMgr(ctx, t, syncds.MutexWrap(datastore.NewMapDatastore()))
defer cleanup()

localTasks := []sealtasks.TaskType{
sealtasks.TTAddPiece, sealtasks.TTPreCommit1, sealtasks.TTPreCommit2, sealtasks.TTCommit1, sealtasks.TTCommit2, sealtasks.TTFinalize,
sealtasks.TTFetch, sealtasks.TTReplicaUpdate, sealtasks.TTProveReplicaUpdate1, sealtasks.TTProveReplicaUpdate2, sealtasks.TTUnseal,
sealtasks.TTRegenSectorKey, sealtasks.TTFinalizeUnsealed,
}
wds := datastore.NewMapDatastore()
wds := syncds.MutexWrap(datastore.NewMapDatastore())

w := NewLocalWorker(WorkerConfig{TaskTypes: localTasks}, stor, lstor, idx, m, statestore.New(wds))
err := m.AddWorker(ctx, w)
Expand Down Expand Up @@ -471,7 +472,7 @@ func TestRedoPC1(t *testing.T) {
logging.SetAllLoggers(logging.LevelDebug)

ctx := context.Background()
m, lstor, _, _, cleanup := newTestMgr(ctx, t, datastore.NewMapDatastore())
m, lstor, _, _, cleanup := newTestMgr(ctx, t, syncds.MutexWrap(datastore.NewMapDatastore()))
defer cleanup()

localTasks := []sealtasks.TaskType{
Expand Down Expand Up @@ -524,7 +525,7 @@ func TestRestartManager(t *testing.T) {
ctx, done := context.WithCancel(context.Background())
defer done()

ds := datastore.NewMapDatastore()
ds := syncds.MutexWrap(datastore.NewMapDatastore())

m, lstor, _, _, cleanup := newTestMgr(ctx, t, ds)
defer cleanup()
Expand Down Expand Up @@ -622,7 +623,7 @@ func TestRestartWorker(t *testing.T) {
ctx, done := context.WithCancel(context.Background())
defer done()

ds := datastore.NewMapDatastore()
ds := syncds.MutexWrap(datastore.NewMapDatastore())

m, lstor, stor, idx, cleanup := newTestMgr(ctx, t, ds)
defer cleanup()
Expand All @@ -631,7 +632,7 @@ func TestRestartWorker(t *testing.T) {
sealtasks.TTAddPiece, sealtasks.TTFetch,
}

wds := datastore.NewMapDatastore()
wds := syncds.MutexWrap(datastore.NewMapDatastore())

arch := make(chan chan apres)
w := newLocalWorker(func() (storiface.Storage, error) {
Expand Down Expand Up @@ -695,7 +696,7 @@ func TestReenableWorker(t *testing.T) {
ctx, done := context.WithCancel(context.Background())
defer done()

ds := datastore.NewMapDatastore()
ds := syncds.MutexWrap(datastore.NewMapDatastore())

m, lstor, stor, idx, cleanup := newTestMgr(ctx, t, ds)
defer cleanup()
Expand Down Expand Up @@ -768,7 +769,7 @@ func TestResUse(t *testing.T) {
ctx, done := context.WithCancel(context.Background())
defer done()

ds := datastore.NewMapDatastore()
ds := syncds.MutexWrap(datastore.NewMapDatastore())

m, lstor, stor, idx, cleanup := newTestMgr(ctx, t, ds)
defer cleanup()
Expand All @@ -777,7 +778,7 @@ func TestResUse(t *testing.T) {
sealtasks.TTAddPiece, sealtasks.TTFetch,
}

wds := datastore.NewMapDatastore()
wds := syncds.MutexWrap(datastore.NewMapDatastore())

arch := make(chan chan apres)
w := newLocalWorker(func() (storiface.Storage, error) {
Expand Down Expand Up @@ -826,7 +827,7 @@ func TestResOverride(t *testing.T) {
ctx, done := context.WithCancel(context.Background())
defer done()

ds := datastore.NewMapDatastore()
ds := syncds.MutexWrap(datastore.NewMapDatastore())

m, lstor, stor, idx, cleanup := newTestMgr(ctx, t, ds)
defer cleanup()
Expand All @@ -835,7 +836,7 @@ func TestResOverride(t *testing.T) {
sealtasks.TTAddPiece, sealtasks.TTFetch,
}

wds := datastore.NewMapDatastore()
wds := syncds.MutexWrap(datastore.NewMapDatastore())

arch := make(chan chan apres)
w := newLocalWorker(func() (storiface.Storage, error) {
Expand Down