From eb9f11e16c5126b466bb5ad694162d6661206f78 Mon Sep 17 00:00:00 2001 From: Ferenc Szabo Date: Wed, 20 Feb 2019 12:48:26 +0100 Subject: [PATCH] swarm: run TestSwarmNetwork with fewer nodes with -race As otherwise we always get test failure with `network_test.go:374: context deadline exceeded` even with raised `Timeout`. --- swarm/network_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/swarm/network_test.go b/swarm/network_test.go index d1843e0d87..3221b852b6 100644 --- a/swarm/network_test.go +++ b/swarm/network_test.go @@ -28,6 +28,8 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/swarm/testutil" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" @@ -102,6 +104,9 @@ func TestSwarmNetwork(t *testing.T) { if *longrunning { tests = append(tests, longRunningCases()...) + } else if testutil.RaceEnabled { + tests = shortCaseForRace() + } for _, tc := range tests { @@ -240,6 +245,23 @@ func longRunningCases() []testSwarmNetworkCase { } } +func shortCaseForRace() []testSwarmNetworkCase { + // As for now, Travis with -race can only run 8 nodes + return []testSwarmNetworkCase{ + { + name: "8_nodes", + steps: []testSwarmNetworkStep{ + { + nodeCount: 8, + }, + }, + options: &testSwarmNetworkOptions{ + Timeout: 1 * time.Minute, + }, + }, + } +} + // file represents the file uploaded on a particular node. type file struct { addr storage.Address @@ -262,6 +284,7 @@ type check struct { // - May wait for Kademlia on every node to be healthy. // - Checking if a file is retrievable from all nodes. func testSwarmNetwork(t *testing.T, o *testSwarmNetworkOptions, steps ...testSwarmNetworkStep) { + t.Helper() if o == nil { o = new(testSwarmNetworkOptions)