From ab8cfb9f57eba4c53290eb7533bd375c4aa95b82 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Fri, 24 Sep 2021 12:28:51 -0400 Subject: [PATCH] e2e: tighten timing for load generation (#6990) --- .github/workflows/e2e-nightly-master.yml | 4 ++-- test/e2e/runner/load.go | 24 +++++++++--------------- test/e2e/runner/main.go | 16 +++++++++++++++- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/.github/workflows/e2e-nightly-master.yml b/.github/workflows/e2e-nightly-master.yml index 029fee6bb..5f5ed9706 100644 --- a/.github/workflows/e2e-nightly-master.yml +++ b/.github/workflows/e2e-nightly-master.yml @@ -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 diff --git a/test/e2e/runner/load.go b/test/e2e/runner/load.go index d66d7770e..5e6e04f89 100644 --- a/test/e2e/runner/load.go +++ b/test/e2e/runner/load.go @@ -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 diff --git a/test/e2e/runner/main.go b/test/e2e/runner/main.go index c6d2ad7b7..194e4c6e4 100644 --- a/test/e2e/runner/main.go +++ b/test/e2e/runner/main.go @@ -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 {