Browse Source

e2e: tighten timing for load generation (#6990)

pull/6991/head
Sam Kleinman 3 years ago
committed by GitHub
parent
commit
ab8cfb9f57
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 18 deletions
  1. +2
    -2
      .github/workflows/e2e-nightly-master.yml
  2. +9
    -15
      test/e2e/runner/load.go
  3. +15
    -1
      test/e2e/runner/main.go

+ 2
- 2
.github/workflows/e2e-nightly-master.yml View File

@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
p2p: ['legacy', 'new', 'hybrid']
group: ['00', '01']
group: ['00', '01', '02', '03']
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
@ -35,7 +35,7 @@ jobs:
- name: Generate testnets
working-directory: test/e2e
# When changing -g, also change the matrix groups above
run: ./build/generator -g 2 -d networks/nightly/${{ matrix.p2p }} -p ${{ matrix.p2p }}
run: ./build/generator -g 4 -d networks/nightly/${{ matrix.p2p }} -p ${{ matrix.p2p }}
- name: Run ${{ matrix.p2p }} p2p testnets in group ${{ matrix.group }}
working-directory: test/e2e


+ 9
- 15
test/e2e/runner/load.go View File

@ -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


+ 15
- 1
test/e2e/runner/main.go View File

@ -5,6 +5,7 @@ import (
"fmt"
"os"
"strconv"
"time"
"github.com/spf13/cobra"
@ -75,7 +76,7 @@ func NewCLI() *CLI {
go func() {
chLoadResult <- Load(lctx, cli.testnet)
}()
startAt := time.Now()
if err = Start(ctx, cli.testnet); err != nil {
return err
}
@ -102,6 +103,19 @@ func NewCLI() *CLI {
}
}
// to help make sure that we don't run into
// situations where 0 transactions have
// happened on quick cases, we make sure that
// it's been at least 10s before canceling the
// load generator.
//
// TODO allow the load generator to report
// successful transactions to avoid needing
// this sleep.
if rest := time.Since(startAt); rest < 15*time.Second {
time.Sleep(15*time.Second - rest)
}
loadCancel()
if err = <-chLoadResult; err != nil {


Loading…
Cancel
Save