Skip to content

Commit

Permalink
Separate e2e tests by etna activation (#3268)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Aug 5, 2024
1 parent 7e985b5 commit ec8a639
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 4 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
28 changes: 26 additions & 2 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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,
},
Expand Down
39 changes: 39 additions & 0 deletions tests/e2e/etna/suites.go
Original file line number Diff line number Diff line change
@@ -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)
})
})
11 changes: 11 additions & 0 deletions tests/fixture/e2e/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type FlagVars struct {
delayNetworkShutdown bool
stopNetwork bool
nodeCount int
activateEtna bool
}

func (v *FlagVars) AvalancheGoExecPath() string {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
}

0 comments on commit ec8a639

Please sign in to comment.