|
|
@ -3,7 +3,6 @@ package main |
|
|
|
import ( |
|
|
|
"container/ring" |
|
|
|
"context" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"math/rand" |
|
|
|
"time" |
|
|
@ -58,19 +57,9 @@ func Load(ctx context.Context, testnet *e2e.Testnet) error { |
|
|
|
case numSeen := <-chSuccess: |
|
|
|
success += numSeen |
|
|
|
case <-ctx.Done(): |
|
|
|
// if we couldn't submit any transactions,
|
|
|
|
// that's probably a problem and the test
|
|
|
|
// should error; however, for very short tests
|
|
|
|
// we shouldn't abort.
|
|
|
|
//
|
|
|
|
// The 2s cut off, is a rough guess based on
|
|
|
|
// the expected value of
|
|
|
|
// loadGenerateWaitTime. If the implementation
|
|
|
|
// of that function changes, then this might
|
|
|
|
// also need to change without more
|
|
|
|
// refactoring.
|
|
|
|
if success == 0 && time.Since(started) > 2*time.Second { |
|
|
|
return errors.New("failed to submit any transactions") |
|
|
|
if success == 0 { |
|
|
|
return fmt.Errorf("failed to submit transactions in %s by %d workers", |
|
|
|
time.Since(started), concurrency) |
|
|
|
} |
|
|
|
|
|
|
|
// TODO perhaps allow test networks to
|
|
|
@ -141,9 +130,14 @@ func loadGenerateWaitTime(size int64) time.Duration { |
|
|
|
baseJitter = rand.Int63n(max-min+1) + min // nolint: gosec
|
|
|
|
sizeFactor = size * int64(time.Millisecond) |
|
|
|
sizeJitter = rand.Int63n(sizeFactor-min+1) + min // nolint: gosec
|
|
|
|
waitTime = time.Duration(baseJitter + sizeJitter) |
|
|
|
) |
|
|
|
|
|
|
|
return time.Duration(baseJitter + sizeJitter) |
|
|
|
if size == 1 { |
|
|
|
return waitTime / 2 |
|
|
|
} |
|
|
|
|
|
|
|
return waitTime |
|
|
|
} |
|
|
|
|
|
|
|
// loadProcess processes transactions
|
|
|
|