2019-02-04 20:37:46 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information
|
|
|
|
|
|
|
|
package testplanet
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2019-02-14 21:55:21 +00:00
|
|
|
"go.uber.org/zap"
|
2019-02-04 20:37:46 +00:00
|
|
|
"go.uber.org/zap/zaptest"
|
|
|
|
|
2019-12-27 11:48:47 +00:00
|
|
|
"storj.io/common/testcontext"
|
2019-02-04 20:37:46 +00:00
|
|
|
"storj.io/storj/satellite"
|
2019-10-10 19:06:26 +01:00
|
|
|
"storj.io/storj/satellite/metainfo"
|
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
|
2019-10-04 15:12:21 +01:00
|
|
|
t.Run(satelliteDB.MasterDB.Name, func(t *testing.T) {
|
2019-02-05 19:44:00 +00:00
|
|
|
t.Parallel()
|
|
|
|
|
2019-02-04 20:37:46 +00:00
|
|
|
ctx := testcontext.New(t)
|
|
|
|
defer ctx.Cleanup()
|
|
|
|
|
2019-10-04 15:12:21 +01:00
|
|
|
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
|
2019-02-14 21:55:21 +00:00
|
|
|
planetConfig.Reconfigure.NewSatelliteDB = func(log *zap.Logger, index int) (satellite.DB, error) {
|
2020-01-13 13:18:48 +00:00
|
|
|
return satellitedbtest.CreateMasterDB(ctx, t, "S", index, satelliteDB.MasterDB)
|
2019-02-04 20:37:46 +00:00
|
|
|
}
|
|
|
|
|
2019-10-04 15:12:21 +01:00
|
|
|
if satelliteDB.PointerDB.URL != "" {
|
2019-10-10 19:06:26 +01:00
|
|
|
planetConfig.Reconfigure.NewSatellitePointerDB = func(log *zap.Logger, index int) (metainfo.PointerDB, error) {
|
2020-01-13 13:18:48 +00:00
|
|
|
return satellitedbtest.CreatePointerDB(ctx, t, "P", index, satelliteDB.PointerDB)
|
2019-10-04 15:12:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-04 20:37:46 +00:00
|
|
|
planet, err := NewCustom(zaptest.NewLogger(t), planetConfig)
|
|
|
|
if err != nil {
|
2020-02-10 18:58:17 +00:00
|
|
|
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)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|