From cab10db72562eb2dbc3bfc21972df611d677ec05 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Thu, 4 Mar 2021 00:41:07 +0100 Subject: [PATCH] e2e: adjust timeouts to be dynamic to size of network (#6202) --- test/e2e/runner/rpc.go | 4 ++-- test/e2e/runner/wait.go | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test/e2e/runner/rpc.go b/test/e2e/runner/rpc.go index 3184bb9a2..da94bd911 100644 --- a/test/e2e/runner/rpc.go +++ b/test/e2e/runner/rpc.go @@ -86,7 +86,7 @@ func waitForNode(node *e2e.Node, height int64, timeout time.Duration) (*rpctypes return status, nil } - time.Sleep(200 * time.Millisecond) + time.Sleep(300 * time.Millisecond) } } @@ -97,7 +97,7 @@ func waitForAllNodes(testnet *e2e.Testnet, height int64, timeout time.Duration) if node.Mode == e2e.ModeSeed { continue } - status, err := waitForNode(node, height, 20*time.Second) + status, err := waitForNode(node, height, timeout) if err != nil { return 0, err } diff --git a/test/e2e/runner/wait.go b/test/e2e/runner/wait.go index 8e9030856..232d230d9 100644 --- a/test/e2e/runner/wait.go +++ b/test/e2e/runner/wait.go @@ -20,9 +20,15 @@ func Wait(testnet *e2e.Testnet, blocks int64) error { // WaitUntil waits until a given height has been reached. func WaitUntil(testnet *e2e.Testnet, height int64) error { logger.Info(fmt.Sprintf("Waiting for all nodes to reach height %v...", height)) - _, err := waitForAllNodes(testnet, height, 20*time.Second) + _, err := waitForAllNodes(testnet, height, waitingTime(len(testnet.Nodes))) if err != nil { return err } return nil } + +// waitingTime estimates how long it should take for a node to reach the height. +// More nodes in a network implies we may expect a slower network and may have to wait longer. +func waitingTime(nodes int) time.Duration { + return time.Duration(20+(nodes*2)) * time.Second +}