Skip to content

Commit

Permalink
e2e: reduce load pressure (#6939)
Browse files Browse the repository at this point in the history
  • Loading branch information
tychoish authored Sep 14, 2021
1 parent de2cffe commit 6909158
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions test/e2e/runner/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6909158

Please sign in to comment.