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

Separate e2e tests by etna activation #3268

Merged
merged 3 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 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:
marun marked this conversation as resolved.
Show resolved Hide resolved
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
24 changes: 23 additions & 1 deletion tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@
package e2e_test

import (
"encoding/base64"
"encoding/json"
"testing"

// 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 @@ -36,11 +41,28 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {

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)
if err != nil {
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
panic(err)
}

upgradeBase64 := base64.StdEncoding.EncodeToString(upgradeJSON)
return e2e.NewTestEnvironment(
e2e.NewTestContext(),
flagVars,
&tmpnet.Network{
Owner: "avalanchego-e2e",
Owner: "avalanchego-e2e",
DefaultFlags: tmpnet.FlagsMap{
config.UpgradeFileContentKey: upgradeBase64,
},
Nodes: nodes,
Subnets: subnets,
},
Expand Down
43 changes: 43 additions & 0 deletions tests/e2e/etna/suites.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

// Implements tests for the banff network upgrade.
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
package banff

import (
"time"

"github.com/stretchr/testify/require"

"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/tests/fixture/e2e"
"github.com/ava-labs/avalanchego/upgrade"

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)

var upgrades *upgrade.Config
tc.By("get upgrade config", func() {
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
var err error
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
}
Loading