From ed961e450b7e1434c3c79868b29ac393849fb291 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Thu, 31 Mar 2022 13:29:11 +0000 Subject: [PATCH] chore(e2e): stress remove global `testTimeout` --- tests/stress/helpers.go | 3 +-- tests/stress/stress_test.go | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/stress/helpers.go b/tests/stress/helpers.go index dc8e51eaa7..d1cf35a00e 100644 --- a/tests/stress/helpers.go +++ b/tests/stress/helpers.go @@ -20,8 +20,7 @@ import ( ) var ( - testTimeout = time.Minute * 3 - logger = log.NewFromGlobal(log.AddContext("pkg", "tests/stress")) + logger = log.NewFromGlobal(log.AddContext("pkg", "tests/stress")) ) // compareChainHeads calls getChainHead for each node in the array diff --git a/tests/stress/stress_test.go b/tests/stress/stress_test.go index e2ff3fc457..c8cfb976c2 100644 --- a/tests/stress/stress_test.go +++ b/tests/stress/stress_test.go @@ -326,23 +326,23 @@ func TestSync_Bench(t *testing.T) { start := time.Now() var end time.Time + const retryWait = time.Second + const syncWaitTimeout = 3 * time.Minute + syncWaitCtx, syncWaitCancel := context.WithTimeout(ctx, syncWaitTimeout) for { - if time.Since(start) >= testTimeout { - t.Fatal("did not sync") - } - - getChainHeadCtx, getChainHeadCancel := context.WithTimeout(ctx, time.Second) + getChainHeadCtx, getChainHeadCancel := context.WithTimeout(syncWaitCtx, time.Second) head, err := rpc.GetChainHead(getChainHeadCtx, bob.GetRPCPort()) getChainHeadCancel() - if err != nil { - continue - } - - if head.Number >= last { + if err == nil && head.Number >= last { end = time.Now() + syncWaitCancel() break } + + retryWaitCtx, retryWaitCancel := context.WithTimeout(syncWaitCtx, retryWait) + <-retryWaitCtx.Done() + retryWaitCancel() } maxTime := time.Second * 85