Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2e to tmpnet x #1104

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:

env:
tmpnet_data_path: ~/.tmpnet/networks/1000

jobs:
lint_test:
name: Lint
Expand Down Expand Up @@ -88,7 +91,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: subnet-evm-e2e-logs-precompile
path: /tmp/network-runner-root-data*/
path: /tmp/e2e-test/precompile-data
retention-days: 5
e2e_warp:
name: e2e warp tests
Expand Down Expand Up @@ -124,14 +127,14 @@ jobs:
run: ./scripts/build.sh /tmp/e2e-test/avalanchego/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy
- name: Run Warp E2E Tests
shell: bash
run: AVALANCHEGO_BUILD_PATH=/tmp/e2e-test/avalanchego DATA_DIR=/tmp/e2e-test/warp-data ./scripts/run_ginkgo_warp.sh
- name: Upload Artifact
run: AVALANCHEGO_BUILD_PATH=/tmp/e2e-test/avalanchego ./scripts/run_ginkgo_warp.sh
- name: Upload tmpnet network dir for warp testing
if: always()
uses: actions/upload-artifact@v4
with:
name: subnet-evm-e2e-logs-warp
path: /tmp/network-runner-root-data*/
retention-days: 5
name: warp-tmpnet-data
path: ${{ env.tmpnet_data_path }}
if-no-files-found: error
e2e_load:
name: e2e load tests
runs-on: ubuntu-latest
Expand All @@ -153,14 +156,14 @@ jobs:
run: ./scripts/build.sh /tmp/e2e-test/avalanchego/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy
- name: Run E2E Load Tests
shell: bash
run: AVALANCHEGO_BUILD_PATH=/tmp/e2e-test/avalanchego DATA_DIR=/tmp/e2e-test/load-data ./scripts/run_ginkgo_load.sh
- name: Upload Artifact
run: AVALANCHEGO_BUILD_PATH=/tmp/e2e-test/avalanchego ./scripts/run_ginkgo_load.sh
- name: Upload tmpnet network dir for load testing
if: always()
uses: actions/upload-artifact@v4
with:
name: subnet-evm-e2e-logs-load
path: /tmp/network-runner-root-data*/
retention-days: 5
name: load-tmpnet-data
path: ${{ env.tmpnet_data_path }}
if-no-files-found: error

build_image:
name: Build Docker Image
Expand Down
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.21

require (
github.com/VictoriaMetrics/fastcache v1.10.0
github.com/ava-labs/avalanche-network-runner v1.7.6
github.com/ava-labs/avalanchego v1.11.1
github.com/cespare/cp v0.1.0
github.com/davecgh/go-spew v1.1.1
Expand Down Expand Up @@ -100,7 +99,6 @@ require (
github.com/mitchellh/pointerstructure v1.2.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d // indirect
github.com/otiai10/copy v1.11.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pires/go-proxyproto v0.6.2 // indirect
Expand Down Expand Up @@ -131,7 +129,6 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/tools v0.16.0 // indirect
Expand Down
8 changes: 0 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanche-network-runner v1.7.6 h1:2yXa2Zq099t900ffpn0RG9D5dca98fs3l+/hF7AumIY=
github.com/ava-labs/avalanche-network-runner v1.7.6/go.mod h1:+Br4mCjreTMtnDiUDNXJba500fnchMk0Ygu5qWVj6A4=
github.com/ava-labs/avalanchego v1.11.1 h1:NSelfZ/Di8uGCsRoFK32HOR262eHlpUFmAu8pbfg0Jo=
github.com/ava-labs/avalanchego v1.11.1/go.mod h1:+UpgT8X2fNN93+iE100efkZL7ePfBRfRdmpJ/i3YnyY=
github.com/ava-labs/coreth v0.13.0-rc.0 h1:V2l3qj2ek3geKDJAnF2M94mYJK8kg2kePixujfJ0bmk=
Expand Down Expand Up @@ -465,10 +463,6 @@ github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAl
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg=
github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
github.com/otiai10/copy v1.11.0 h1:OKBD80J/mLBrwnzXqGtFCzprFSGioo30JcmR4APsNwc=
github.com/otiai10/copy v1.11.0/go.mod h1:rSaLseMUsZFFbsFGc7wCJnnkTAvdc5L6VWxPE4308Ww=
github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks=
github.com/otiai10/mint v1.5.1/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
Expand Down Expand Up @@ -538,8 +532,6 @@ github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobt
github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
Expand Down
11 changes: 7 additions & 4 deletions scripts/run_ginkgo_load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ source "$SUBNET_EVM_PATH"/scripts/versions.sh
# to install the ginkgo binary (required for test build and run)
go install -v github.com/onsi/ginkgo/v2/ginkgo@"${GINKGO_VERSION}"

ACK_GINKGO_RC=true ginkgo build ./tests/load
EXTRA_ARGS=()
AVALANCHEGO_BUILD_PATH="${AVALANCHEGO_BUILD_PATH:-}"
if [[ -n "${AVALANCHEGO_BUILD_PATH}" ]]; then
EXTRA_ARGS=("--avalanchego-path=${AVALANCHEGO_BUILD_PATH}/avalanchego" "--plugin-dir=${AVALANCHEGO_BUILD_PATH}/plugins")
echo "Running with extra args:" "${EXTRA_ARGS[@]}"
fi

./tests/load/load.test \
--ginkgo.vv \
--ginkgo.label-filter="${GINKGO_LABEL_FILTER:-""}"
ginkgo -vv --label-filter="${GINKGO_LABEL_FILTER:-}" ./tests/load -- "${EXTRA_ARGS[@]}"
16 changes: 10 additions & 6 deletions scripts/run_ginkgo_warp.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -e

set -euo pipefail

# This script assumes that an AvalancheGo and Subnet-EVM binaries are available in the standard location
# within the $GOPATH
Expand All @@ -17,10 +18,13 @@ source "$SUBNET_EVM_PATH"/scripts/versions.sh

# Build ginkgo
# to install the ginkgo binary (required for test build and run)
go install -v "github.com/onsi/ginkgo/v2/ginkgo@${GINKGO_VERSION}"
go install -v github.com/onsi/ginkgo/v2/ginkgo@"${GINKGO_VERSION}"

ACK_GINKGO_RC=true ginkgo build ./tests/warp
EXTRA_ARGS=()
AVALANCHEGO_BUILD_PATH="${AVALANCHEGO_BUILD_PATH:-}"
if [[ -n "${AVALANCHEGO_BUILD_PATH}" ]]; then
EXTRA_ARGS=("--avalanchego-path=${AVALANCHEGO_BUILD_PATH}/avalanchego" "--plugin-dir=${AVALANCHEGO_BUILD_PATH}/plugins")
echo "Running with extra args:" "${EXTRA_ARGS[@]}"
fi

./tests/warp/warp.test \
--ginkgo.vv \
--ginkgo.label-filter="${GINKGO_LABEL_FILTER:-""}"
ginkgo -vv --label-filter="${GINKGO_LABEL_FILTER:-}" ./tests/warp -- "${EXTRA_ARGS[@]}"
31 changes: 31 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Developing with tmpnet

The `load/` and `warp/` paths contain end-to-end (e2e) tests that use
the [tmpnet
fixture](https://github.com/ava-labs/avalanchego/blob/master/tests/fixture/tmpnet/README.md). By
default both test suites use the tmpnet fixture to create a temporary
network that exists for only the duration of their execution.

It is possible to create a temporary network that can be reused across
test runs to minimize the setup cost involved:

```bash
# From the root of a clone of avalanchego, build the tmpnetctl cli
$ ./scripts/build_tmpnetctl.sh

# Start a new temporary network configured with subnet-evm's default plugin path
$ ./build/tmpnetctl start-network \
--avalanche-path=./build/avalanchego
--plugin-dir=$GOPATH/src/github.com/ava-labs/avalanchego/build/plugins

# From the root of a clone of subnet-evm, execute the warp test suite against the existing network
$ ginkgo -vv ./tests/warp -- --use-existing-network --network-dir=$HOME/.tmpnet/networks/latest

# To stop the temporary network when no longer needed, execute the following from the root of the clone of avalanchego
$ ./build/tmpnetctl stop-network --network-dir=$HOME/.tmpnet/networks/latest
```

The network started by `tmpnetctl` won't come with subnets configured,
so the test suite will add them to the network the first time it
runs. Subsequent test runs will be able to reuse those subnets without
having to set them up.
22 changes: 22 additions & 0 deletions tests/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ package tests
import (
"fmt"
"math/big"
"os"
"sort"
"strings"

"github.com/ava-labs/subnet-evm/params"
"github.com/ava-labs/subnet-evm/utils"
Expand Down Expand Up @@ -215,3 +217,23 @@ type UnsupportedForkError struct {
func (e UnsupportedForkError) Error() string {
return fmt.Sprintf("unsupported fork %q", e.Name)
}

func GetRepoRootPath(suffix string) string {
// - When executed via a test binary, the working directory will be wherever
// the binary is executed from, but scripts should require execution from
// the repo root.
//
// - When executed via ginkgo (nicer for development + supports
// parallel execution) the working directory will always be the
// target path (e.g. [repo root]./tests/warp) and getting the repo
// root will require stripping the target path suffix.
//
// TODO(marun) Avoid relying on the current working directory to find test
// dependencies by embedding data where possible (e.g. for genesis) and
// explicitly configuring paths for execution.
cwd, err := os.Getwd()
if err != nil {
panic(err)
}
return strings.TrimSuffix(cwd, suffix)
}
84 changes: 73 additions & 11 deletions tests/load/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,43 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"

"github.com/ava-labs/subnet-evm/tests/utils/runner"
"github.com/ethereum/go-ethereum/log"
ginkgo "github.com/onsi/ginkgo/v2"

"github.com/onsi/gomega"

"github.com/stretchr/testify/require"

"github.com/ethereum/go-ethereum/log"

"github.com/ava-labs/avalanchego/config"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/tests/fixture/e2e"
"github.com/ava-labs/avalanchego/tests/fixture/tmpnet"
"github.com/ava-labs/avalanchego/utils/set"

"github.com/ava-labs/subnet-evm/tests"
"github.com/ava-labs/subnet-evm/tests/utils"
)

const (
// The load test requires 5 nodes
nodeCount = 5

subnetAName = "load-subnet-a"
)

var getSubnet func() *runner.Subnet
var (
flagVars *e2e.FlagVars
repoRootPath = tests.GetRepoRootPath("tests/load")
)

func init() {
getSubnet = runner.RegisterFiveNodeSubnetRun()
// Configures flags used to configure tmpnet
flagVars = e2e.RegisterFlags()
}

func TestE2E(t *testing.T) {
Expand All @@ -28,25 +52,63 @@ func TestE2E(t *testing.T) {
}

var _ = ginkgo.Describe("[Load Simulator]", ginkgo.Ordered, func() {
require := require.New(ginkgo.GinkgoT())

var env *e2e.TestEnvironment

ginkgo.BeforeAll(func() {
genesisPath := filepath.Join(repoRootPath, "tests/load/genesis/genesis.json")

// The load tests are allergic to high levels of evm logging, so leave it at
// the default level instead of raising it to debug (as the warp testing does).
chainConfig := tmpnet.FlagsMap{
"log-level": "debug",
}

nodes := utils.NewTmpnetNodes(nodeCount)

env = e2e.NewTestEnvironment(
flagVars,
utils.NewTmpnetNetwork(
nodes,
tmpnet.FlagsMap{
// The default tmpnet log level (info/debug) induces too much overhead for load testing.
config.LogDisplayLevelKey: "info",
config.LogLevelKey: "info",
},
utils.NewTmpnetSubnet(subnetAName, genesisPath, chainConfig, nodes...),
),
)
})

ginkgo.It("basic subnet load test", ginkgo.Label("load"), func() {
subnetDetails := getSubnet()
blockchainID := subnetDetails.BlockchainID
network := env.GetNetwork()

subnet := network.GetSubnet(subnetAName)
require.NotNil(subnet)
blockchainID := subnet.Chains[0].ChainID

nodeURIs := subnetDetails.ValidatorURIs
nodeURIs := tmpnet.GetNodeURIs(network.Nodes)
validatorIDs := set.Set[ids.NodeID]{}
validatorIDs.Add(subnet.ValidatorIDs...)
rpcEndpoints := make([]string, 0, len(nodeURIs))
for _, uri := range nodeURIs {
rpcEndpoints = append(rpcEndpoints, fmt.Sprintf("%s/ext/bc/%s/rpc", uri, blockchainID))
for _, nodeURI := range nodeURIs {
if !validatorIDs.Contains(nodeURI.NodeID) {
continue
}
rpcEndpoints = append(rpcEndpoints, fmt.Sprintf("%s/ext/bc/%s/rpc", nodeURI.URI, blockchainID))
}
commaSeparatedRPCEndpoints := strings.Join(rpcEndpoints, ",")
err := os.Setenv("RPC_ENDPOINTS", commaSeparatedRPCEndpoints)
gomega.Expect(err).Should(gomega.BeNil())
require.NoError(err)

log.Info("Running load simulator...", "rpcEndpoints", commaSeparatedRPCEndpoints)
cmd := exec.Command("./scripts/run_simulator.sh")
cmd.Dir = repoRootPath
log.Info("Running load simulator script", "cmd", cmd.String())

out, err := cmd.CombinedOutput()
fmt.Printf("\nCombined output:\n\n%s\n", string(out))
gomega.Expect(err).Should(gomega.BeNil())
require.NoError(err)
})
})
4 changes: 0 additions & 4 deletions tests/utils/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,3 @@ const (

DefaultLocalNodeURI = "http://127.0.0.1:9650"
)

var (
NodeURIs = []string{DefaultLocalNodeURI, "http://127.0.0.1:9652", "http://127.0.0.1:9654", "http://127.0.0.1:9656", "http://127.0.0.1:9658"}
)
Loading
Loading