From eb0c5cf63069d7f196776f3412296844e5242091 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Sun, 18 Nov 2018 13:28:13 +0100 Subject: [PATCH] cmd/swarm: use same cluster across ACT and SwarmUp tests --- cmd/swarm/access_test.go | 22 +++++++++++++++++----- cmd/swarm/fs_test.go | 6 ------ cmd/swarm/upload_test.go | 5 ++--- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/cmd/swarm/access_test.go b/cmd/swarm/access_test.go index e7dfd1aacf..499af68c6a 100644 --- a/cmd/swarm/access_test.go +++ b/cmd/swarm/access_test.go @@ -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) } diff --git a/cmd/swarm/fs_test.go b/cmd/swarm/fs_test.go index 3b722515ee..ac4223b661 100644 --- a/cmd/swarm/fs_test.go +++ b/cmd/swarm/fs_test.go @@ -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 diff --git a/cmd/swarm/upload_test.go b/cmd/swarm/upload_test.go index 6ffae77383..616486e37c 100644 --- a/cmd/swarm/upload_test.go +++ b/cmd/swarm/upload_test.go @@ -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) }