From 6909158933b5a7b691ced7d279039bf2bc8ed2d5 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Tue, 14 Sep 2021 10:44:30 -0400 Subject: [PATCH] e2e: reduce load pressure (#6939) --- test/e2e/runner/load.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/test/e2e/runner/load.go b/test/e2e/runner/load.go index f22be525e..b16df5ed2 100644 --- a/test/e2e/runner/load.go +++ b/test/e2e/runner/load.go @@ -105,13 +105,27 @@ func loadGenerate(ctx context.Context, chTx chan<- types.Tx, size int64) { case chTx <- tx: // sleep for a bit before sending the // next transaction. - waitTime := (50 * time.Millisecond) + time.Duration(rand.Int63n(int64(time.Second))) // nolint: gosec - timer.Reset(waitTime) + timer.Reset(loadGenerateWaitTime(size)) } } } +func loadGenerateWaitTime(size int64) time.Duration { + const ( + min = int64(100 * time.Millisecond) + max = int64(time.Second) + ) + + var ( + baseJitter = rand.Int63n(max-min+1) + min // nolint: gosec + sizeFactor = size * int64(time.Millisecond) + sizeJitter = rand.Int63n(sizeFactor-min+1) + min // nolint: gosec + ) + + return time.Duration(baseJitter + sizeJitter) +} + // loadProcess processes transactions func loadProcess(ctx context.Context, testnet *e2e.Testnet, chTx <-chan types.Tx, chSuccess chan<- int) { // Each worker gets its own client to each usable node, which