From ec8a639aad0b60265d0ceb023655d982a06fb9b7 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Mon, 5 Aug 2024 12:26:33 -0400 Subject: [PATCH] Separate e2e tests by etna activation (#3268) --- .github/workflows/ci.yml | 25 ++++++++++++++++++++++-- tests/e2e/e2e_test.go | 28 +++++++++++++++++++++++++-- tests/e2e/etna/suites.go | 39 ++++++++++++++++++++++++++++++++++++++ tests/fixture/e2e/flags.go | 11 +++++++++++ 4 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 tests/e2e/etna/suites.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e80f83272ef..e2d2a87d719 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: - name: fuzz_test shell: bash run: ./scripts/build_fuzz.sh 10 # Run each fuzz test 10 seconds - e2e: + e2e_pre_etna: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -68,7 +68,28 @@ jobs: uses: ./.github/actions/upload-tmpnet-artifact if: always() with: - name: e2e-tmpnet-data + name: e2e-pre-etna-tmpnet-data + e2e_post_etna: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup-go-for-project + - name: Build AvalancheGo Binary + shell: bash + run: ./scripts/build.sh -r + - name: Run e2e tests + uses: ./.github/actions/run-monitored-tmpnet-cmd + with: + run: E2E_SERIAL=1 ./scripts/tests.e2e.sh --delay-network-shutdown --activate-etna + prometheus_id: ${{ secrets.PROMETHEUS_ID || '' }} + prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }} + loki_id: ${{ secrets.LOKI_ID || '' }} + loki_password: ${{ secrets.LOKI_PASSWORD || '' }} + - name: Upload tmpnet network dir + uses: ./.github/actions/upload-tmpnet-artifact + if: always() + with: + name: e2e-post-etna-tmpnet-data e2e_existing_network: runs-on: ubuntu-latest steps: diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index cd43e9a80b3..eb2dbb6e7e6 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -4,19 +4,26 @@ package e2e_test import ( + "encoding/base64" + "encoding/json" "testing" + "github.com/stretchr/testify/require" + // ensure test packages are scanned by ginkgo _ "github.com/ava-labs/avalanchego/tests/e2e/banff" _ "github.com/ava-labs/avalanchego/tests/e2e/c" + _ "github.com/ava-labs/avalanchego/tests/e2e/etna" _ "github.com/ava-labs/avalanchego/tests/e2e/faultinjection" _ "github.com/ava-labs/avalanchego/tests/e2e/p" _ "github.com/ava-labs/avalanchego/tests/e2e/x" _ "github.com/ava-labs/avalanchego/tests/e2e/x/transfer" + "github.com/ava-labs/avalanchego/config" "github.com/ava-labs/avalanchego/tests/e2e/vms" "github.com/ava-labs/avalanchego/tests/fixture/e2e" "github.com/ava-labs/avalanchego/tests/fixture/tmpnet" + "github.com/ava-labs/avalanchego/upgrade" ginkgo "github.com/onsi/ginkgo/v2" ) @@ -34,13 +41,30 @@ func init() { var _ = ginkgo.SynchronizedBeforeSuite(func() []byte { // Run only once in the first ginkgo process + tc := e2e.NewTestContext() + nodes := tmpnet.NewNodesOrPanic(flagVars.NodeCount()) subnets := vms.XSVMSubnetsOrPanic(nodes...) + + upgrades := upgrade.Default + if flagVars.ActivateEtna() { + upgrades.EtnaTime = upgrade.InitiallyActiveTime + } else { + upgrades.EtnaTime = upgrade.UnscheduledActivationTime + } + + upgradeJSON, err := json.Marshal(upgrades) + require.NoError(tc, err) + + upgradeBase64 := base64.StdEncoding.EncodeToString(upgradeJSON) return e2e.NewTestEnvironment( - e2e.NewTestContext(), + tc, flagVars, &tmpnet.Network{ - Owner: "avalanchego-e2e", + Owner: "avalanchego-e2e", + DefaultFlags: tmpnet.FlagsMap{ + config.UpgradeFileContentKey: upgradeBase64, + }, Nodes: nodes, Subnets: subnets, }, diff --git a/tests/e2e/etna/suites.go b/tests/e2e/etna/suites.go new file mode 100644 index 00000000000..f78d561f9b9 --- /dev/null +++ b/tests/e2e/etna/suites.go @@ -0,0 +1,39 @@ +// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +// Implements tests for the etna network upgrade. +package etna + +import ( + "time" + + "github.com/stretchr/testify/require" + + "github.com/ava-labs/avalanchego/api/info" + "github.com/ava-labs/avalanchego/tests/fixture/e2e" + + ginkgo "github.com/onsi/ginkgo/v2" +) + +var _ = ginkgo.Describe("[Etna]", func() { + tc := e2e.NewTestContext() + require := require.New(tc) + + ginkgo.It("can detect if Etna is activated", + func() { + env := e2e.GetEnv(tc) + infoClient := info.NewClient(env.GetRandomNodeURI().URI) + + tc.By("get upgrade config") + upgrades, err := infoClient.Upgrades(tc.DefaultContext()) + require.NoError(err) + + now := time.Now() + if !upgrades.IsEtnaActivated(now) { + tc.Outf("{{green}}Etna is not activated{{/}}: %s (now) < %s (EtnaTime)\n", now, upgrades.EtnaTime) + return + } + + tc.Outf("{{green}}Etna is activated{{/}}: %s (now) >= %s (EtnaTime)\n", now, upgrades.EtnaTime) + }) +}) diff --git a/tests/fixture/e2e/flags.go b/tests/fixture/e2e/flags.go index 9e55d0cda16..4b489d5c133 100644 --- a/tests/fixture/e2e/flags.go +++ b/tests/fixture/e2e/flags.go @@ -20,6 +20,7 @@ type FlagVars struct { delayNetworkShutdown bool stopNetwork bool nodeCount int + activateEtna bool } func (v *FlagVars) AvalancheGoExecPath() string { @@ -61,6 +62,10 @@ func (v *FlagVars) NodeCount() int { return v.nodeCount } +func (v *FlagVars) ActivateEtna() bool { + return v.activateEtna +} + func RegisterFlags() *FlagVars { vars := FlagVars{} flag.StringVar( @@ -105,6 +110,12 @@ func RegisterFlags() *FlagVars { tmpnet.DefaultNodeCount, "number of nodes the network should initially consist of", ) + flag.BoolVar( + &vars.activateEtna, + "activate-etna", + false, + "[optional] activate the etna upgrade", + ) return &vars }