From 6d159445437aab536c0776196b228b3ff150aead Mon Sep 17 00:00:00 2001 From: Fabio Barone Date: Fri, 1 Mar 2019 12:12:46 -0500 Subject: [PATCH] swarm/network: fixed longrunning tests --- p2p/simulations/network.go | 3 ++- swarm/network/stream/snapshot_retrieval_test.go | 9 +++------ swarm/network/stream/snapshot_sync_test.go | 3 +-- swarm/network/stream/streamer_test.go | 16 ++++++++++------ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/p2p/simulations/network.go b/p2p/simulations/network.go index c02c9e2546..3c95cb227b 100644 --- a/p2p/simulations/network.go +++ b/p2p/simulations/network.go @@ -840,7 +840,8 @@ func (net *Network) snapshot(addServices []string, removeServices []string) (*Sn return snap, nil } -var snapshotLoadTimeout = 6000 * time.Second +// longrunning tests may need a longer timeout +var snapshotLoadTimeout = 7200 * time.Second // Load loads a network snapshot func (net *Network) Load(snap *Snapshot) error { diff --git a/swarm/network/stream/snapshot_retrieval_test.go b/swarm/network/stream/snapshot_retrieval_test.go index 2e73dc480d..5e24a39f57 100644 --- a/swarm/network/stream/snapshot_retrieval_test.go +++ b/swarm/network/stream/snapshot_retrieval_test.go @@ -53,8 +53,7 @@ func TestFileRetrieval(t *testing.T) { nodeCount = []int{16} if *longrunning { - //nodeCount = append(nodeCount, 32, 64, 128) - nodeCount = append(nodeCount, 48) + nodeCount = append(nodeCount, 32, 64, 128) } else if testutil.RaceEnabled { nodeCount = []int{4} } @@ -87,10 +86,8 @@ func TestRetrieval(t *testing.T) { chnkCnt := []int{32} if *longrunning { - //nodeCnt = []int{16, 32, 128} - nodeCnt = []int{32, 48} - chnkCnt = []int{64, 128} - //chnkCnt = []int{4, 32, 256} + nodeCnt = []int{16, 32, 128} + chnkCnt = []int{4, 32, 256} } else if testutil.RaceEnabled { nodeCnt = []int{4} chnkCnt = []int{4} diff --git a/swarm/network/stream/snapshot_sync_test.go b/swarm/network/stream/snapshot_sync_test.go index 303950414b..2766d4ddab 100644 --- a/swarm/network/stream/snapshot_sync_test.go +++ b/swarm/network/stream/snapshot_sync_test.go @@ -95,8 +95,7 @@ func TestSyncingViaGlobalSync(t *testing.T) { //run more test combinations if *longrunning { chunkCounts = []int{64, 128} - //nodeCounts = []int{16, 32, 64, 128, 256} - nodeCounts = []int{32, 48} + nodeCounts = []int{64, 128} } for _, chunkCount := range chunkCounts { diff --git a/swarm/network/stream/streamer_test.go b/swarm/network/stream/streamer_test.go index 755b745373..56e5e89032 100644 --- a/swarm/network/stream/streamer_test.go +++ b/swarm/network/stream/streamer_test.go @@ -1188,12 +1188,13 @@ func TestGetSubscriptionsRPC(t *testing.T) { // arbitrarily set to 4 nodeCount := 4 + // set the syncUpdateDelay for sync registrations to start + syncUpdateDelay := 200 * time.Millisecond // run with more nodes if `longrunning` flag is set if *longrunning { nodeCount = 64 + syncUpdateDelay = 10 * time.Second } - // set the syncUpdateDelay for sync registrations to start - syncUpdateDelay := 200 * time.Millisecond // holds the msg code for SubscribeMsg var subscribeMsgCode uint64 var ok bool @@ -1241,7 +1242,7 @@ func TestGetSubscriptionsRPC(t *testing.T) { }) defer sim.Close() - ctx, cancelSimRun := context.WithTimeout(context.Background(), 1*time.Minute) + ctx, cancelSimRun := context.WithTimeout(context.Background(), 3*time.Minute) defer cancelSimRun() // upload a snapshot @@ -1267,6 +1268,9 @@ func TestGetSubscriptionsRPC(t *testing.T) { go func() { //for long running sims, waiting 1 sec will not be enough waitDuration := time.Duration(nodeCount/16) * time.Second + if *longrunning { + waitDuration = syncUpdateDelay + } for { select { case <-ctx.Done(): @@ -1328,11 +1332,11 @@ func TestGetSubscriptionsRPC(t *testing.T) { } } } + log.Debug("All node streams counted", "realCount", realCount) } - // every node is mutually subscribed to each other, so the actual count is half of it emc := expectedMsgCount.count() - if realCount/2 != emc { - return fmt.Errorf("Real subscriptions and expected amount don't match; real: %d, expected: %d", realCount/2, emc) + if realCount != emc { + return fmt.Errorf("Real subscriptions and expected amount don't match; real: %d, expected: %d", realCount, emc) } return nil })