storj/private/testplanet/run.go

48 lines
1.1 KiB
Go
Raw Normal View History

2019-02-04 20:37:46 +00:00
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information
package testplanet
import (
"testing"
"go.uber.org/zap/zaptest"
"storj.io/common/testcontext"
2019-02-04 20:37:46 +00:00
"storj.io/storj/satellite/satellitedb/satellitedbtest"
)
// Run runs testplanet in multiple configurations.
func Run(t *testing.T, config Config, test func(t *testing.T, ctx *testcontext.Context, planet *Planet)) {
for _, satelliteDB := range satellitedbtest.Databases() {
2019-02-06 09:16:05 +00:00
satelliteDB := satelliteDB
t.Run(satelliteDB.Name, func(t *testing.T) {
parallel := !config.NonParallel
if parallel {
t.Parallel()
}
2019-02-04 20:37:46 +00:00
ctx := testcontext.New(t)
defer ctx.Cleanup()
if satelliteDB.MasterDB.URL == "" {
t.Skipf("Database %s connection string not provided. %s", satelliteDB.MasterDB.Name, satelliteDB.MasterDB.Message)
2019-02-04 20:37:46 +00:00
}
planetConfig := config
if planetConfig.Name == "" {
planetConfig.Name = t.Name()
}
planet, err := NewCustom(zaptest.NewLogger(t), config, satelliteDB)
2019-02-04 20:37:46 +00:00
if err != nil {
t.Fatalf("%+v", err)
2019-02-04 20:37:46 +00:00
}
defer ctx.Check(planet.Shutdown)
planet.Start(ctx)
2019-04-22 10:07:50 +01:00
2019-02-04 20:37:46 +00:00
test(t, ctx, planet)
})
}
}