From af1f81072d3b5e9048fdcd7b0344b8527a795550 Mon Sep 17 00:00:00 2001 From: Mark Rushakoff Date: Fri, 22 Jul 2022 10:53:34 -0400 Subject: [PATCH] Skip long internal/statesync tests in -short mode I added checks against testing.Short for tests that took longer than about one second on my machine. Running with -short reduces the test time of internal/statesync from about 54s to about 1.5s. --- internal/statesync/block_queue_test.go | 8 ++++++++ internal/statesync/reactor_test.go | 12 ++++++++++++ internal/statesync/syncer_test.go | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/internal/statesync/block_queue_test.go b/internal/statesync/block_queue_test.go index 364a7f5b2..b088e15ea 100644 --- a/internal/statesync/block_queue_test.go +++ b/internal/statesync/block_queue_test.go @@ -126,6 +126,10 @@ func TestBlockQueueWithFailures(t *testing.T) { // Test that when all the blocks are retrieved that the queue still holds on to // it's workers and in the event of failure can still fetch the failed block func TestBlockQueueBlocks(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode") + } + peerID, err := types.NewNodeID("0011223344556677889900112233445566778899") require.NoError(t, err) queue := newBlockQueue(startHeight, stopHeight, 1, stopTime, 2) @@ -176,6 +180,10 @@ loop: } func TestBlockQueueAcceptsNoMoreBlocks(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode") + } + peerID, err := types.NewNodeID("0011223344556677889900112233445566778899") require.NoError(t, err) queue := newBlockQueue(startHeight, stopHeight, 1, stopTime, 1) diff --git a/internal/statesync/reactor_test.go b/internal/statesync/reactor_test.go index b81c1ac2c..427f3bbe2 100644 --- a/internal/statesync/reactor_test.go +++ b/internal/statesync/reactor_test.go @@ -197,6 +197,10 @@ func setup( } func TestReactor_Sync(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode") + } + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) defer cancel() @@ -618,6 +622,10 @@ func TestReactor_StateProviderP2P(t *testing.T) { } func TestReactor_Backfill(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode") + } + ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -626,6 +634,10 @@ func TestReactor_Backfill(t *testing.T) { for _, failureRate := range failureRates { failureRate := failureRate t.Run(fmt.Sprintf("failure rate: %d", failureRate), func(t *testing.T) { + if testing.Short() && failureRate > 0 { + t.Skip("skipping test in short mode") + } + ctx, cancel := context.WithCancel(ctx) defer cancel() diff --git a/internal/statesync/syncer_test.go b/internal/statesync/syncer_test.go index 3fc3f0db4..15beef34b 100644 --- a/internal/statesync/syncer_test.go +++ b/internal/statesync/syncer_test.go @@ -22,6 +22,10 @@ import ( ) func TestSyncer_SyncAny(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode") + } + ctx, cancel := context.WithCancel(context.Background()) defer cancel()