cmd/swarm: use same cluster across ACT and SwarmUp tests

This commit is contained in:
Anton Evangelatov 2018-11-18 13:28:13 +01:00
parent 3722447fae
commit eb0c5cf630
3 changed files with 19 additions and 14 deletions

View file

@ -28,7 +28,9 @@ import (
gorand "math/rand"
"net/http"
"os"
"runtime"
"strings"
"sync"
"testing"
"time"
@ -48,11 +50,24 @@ const (
var DefaultCurve = crypto.S256()
var cluster *testCluster
const clusterSize = 3
var clusteronce sync.Once
var cluster *testCluster
func initCluster(t *testing.T) {
clusteronce.Do(func() {
cluster = newTestCluster(t, clusterSize)
})
}
func TestACT(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip()
}
initCluster(t)
cases := []struct {
name string
f func(t *testing.T)
@ -63,9 +78,6 @@ func TestACT(t *testing.T) {
{"ACTWithBogus", testACTWithBogus},
}
cluster = newTestCluster(t, clusterSize)
defer cluster.Shutdown()
for _, tc := range cases {
t.Run(tc.name, tc.f)
}

View file

@ -29,14 +29,8 @@ import (
"time"
"github.com/ethereum/go-ethereum/log"
colorable "github.com/mattn/go-colorable"
)
func init() {
log.PrintOrigins(true)
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*loglevel), log.StreamHandler(colorable.NewColorableStderr(), log.TerminalFormat(true))))
}
type testFile struct {
filePath string
content string

View file

@ -46,6 +46,8 @@ func TestSwarmUp(t *testing.T) {
t.Skip()
}
initCluster(t)
cases := []struct {
name string
f func(t *testing.T)
@ -57,9 +59,6 @@ func TestSwarmUp(t *testing.T) {
{"DefaultPathAll", testDefaultPathAll},
}
cluster = newTestCluster(t, clusterSize)
defer cluster.Shutdown()
for _, tc := range cases {
t.Run(tc.name, tc.f)
}