e2e: reduce load pressure (#6939)

This commit is contained in:
Sam Kleinman
2021-09-14 10:44:30 -04:00
committed by GitHub
parent de2cffe7a4
commit 6909158933
+16 -2
View File
@@ -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