Skip to content

Commit ec8a639

Browse files
Separate e2e tests by etna activation (#3268)
1 parent 7e985b5 commit ec8a639

File tree

4 files changed

+99
-4
lines changed

4 files changed

+99
-4
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
- name: fuzz_test
4949
shell: bash
5050
run: ./scripts/build_fuzz.sh 10 # Run each fuzz test 10 seconds
51-
e2e:
51+
e2e_pre_etna:
5252
runs-on: ubuntu-latest
5353
steps:
5454
- uses: actions/checkout@v4
@@ -68,7 +68,28 @@ jobs:
6868
uses: ./.github/actions/upload-tmpnet-artifact
6969
if: always()
7070
with:
71-
name: e2e-tmpnet-data
71+
name: e2e-pre-etna-tmpnet-data
72+
e2e_post_etna:
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v4
76+
- uses: ./.github/actions/setup-go-for-project
77+
- name: Build AvalancheGo Binary
78+
shell: bash
79+
run: ./scripts/build.sh -r
80+
- name: Run e2e tests
81+
uses: ./.github/actions/run-monitored-tmpnet-cmd
82+
with:
83+
run: E2E_SERIAL=1 ./scripts/tests.e2e.sh --delay-network-shutdown --activate-etna
84+
prometheus_id: ${{ secrets.PROMETHEUS_ID || '' }}
85+
prometheus_password: ${{ secrets.PROMETHEUS_PASSWORD || '' }}
86+
loki_id: ${{ secrets.LOKI_ID || '' }}
87+
loki_password: ${{ secrets.LOKI_PASSWORD || '' }}
88+
- name: Upload tmpnet network dir
89+
uses: ./.github/actions/upload-tmpnet-artifact
90+
if: always()
91+
with:
92+
name: e2e-post-etna-tmpnet-data
7293
e2e_existing_network:
7394
runs-on: ubuntu-latest
7495
steps:

tests/e2e/e2e_test.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,26 @@
44
package e2e_test
55

66
import (
7+
"encoding/base64"
8+
"encoding/json"
79
"testing"
810

11+
"github.com/stretchr/testify/require"
12+
913
// ensure test packages are scanned by ginkgo
1014
_ "github.com/ava-labs/avalanchego/tests/e2e/banff"
1115
_ "github.com/ava-labs/avalanchego/tests/e2e/c"
16+
_ "github.com/ava-labs/avalanchego/tests/e2e/etna"
1217
_ "github.com/ava-labs/avalanchego/tests/e2e/faultinjection"
1318
_ "github.com/ava-labs/avalanchego/tests/e2e/p"
1419
_ "github.com/ava-labs/avalanchego/tests/e2e/x"
1520
_ "github.com/ava-labs/avalanchego/tests/e2e/x/transfer"
1621

22+
"github.com/ava-labs/avalanchego/config"
1723
"github.com/ava-labs/avalanchego/tests/e2e/vms"
1824
"github.com/ava-labs/avalanchego/tests/fixture/e2e"
1925
"github.com/ava-labs/avalanchego/tests/fixture/tmpnet"
26+
"github.com/ava-labs/avalanchego/upgrade"
2027

2128
ginkgo "github.com/onsi/ginkgo/v2"
2229
)
@@ -34,13 +41,30 @@ func init() {
3441
var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
3542
// Run only once in the first ginkgo process
3643

44+
tc := e2e.NewTestContext()
45+
3746
nodes := tmpnet.NewNodesOrPanic(flagVars.NodeCount())
3847
subnets := vms.XSVMSubnetsOrPanic(nodes...)
48+
49+
upgrades := upgrade.Default
50+
if flagVars.ActivateEtna() {
51+
upgrades.EtnaTime = upgrade.InitiallyActiveTime
52+
} else {
53+
upgrades.EtnaTime = upgrade.UnscheduledActivationTime
54+
}
55+
56+
upgradeJSON, err := json.Marshal(upgrades)
57+
require.NoError(tc, err)
58+
59+
upgradeBase64 := base64.StdEncoding.EncodeToString(upgradeJSON)
3960
return e2e.NewTestEnvironment(
40-
e2e.NewTestContext(),
61+
tc,
4162
flagVars,
4263
&tmpnet.Network{
43-
Owner: "avalanchego-e2e",
64+
Owner: "avalanchego-e2e",
65+
DefaultFlags: tmpnet.FlagsMap{
66+
config.UpgradeFileContentKey: upgradeBase64,
67+
},
4468
Nodes: nodes,
4569
Subnets: subnets,
4670
},

tests/e2e/etna/suites.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
2+
// See the file LICENSE for licensing terms.
3+
4+
// Implements tests for the etna network upgrade.
5+
package etna
6+
7+
import (
8+
"time"
9+
10+
"github.com/stretchr/testify/require"
11+
12+
"github.com/ava-labs/avalanchego/api/info"
13+
"github.com/ava-labs/avalanchego/tests/fixture/e2e"
14+
15+
ginkgo "github.com/onsi/ginkgo/v2"
16+
)
17+
18+
var _ = ginkgo.Describe("[Etna]", func() {
19+
tc := e2e.NewTestContext()
20+
require := require.New(tc)
21+
22+
ginkgo.It("can detect if Etna is activated",
23+
func() {
24+
env := e2e.GetEnv(tc)
25+
infoClient := info.NewClient(env.GetRandomNodeURI().URI)
26+
27+
tc.By("get upgrade config")
28+
upgrades, err := infoClient.Upgrades(tc.DefaultContext())
29+
require.NoError(err)
30+
31+
now := time.Now()
32+
if !upgrades.IsEtnaActivated(now) {
33+
tc.Outf("{{green}}Etna is not activated{{/}}: %s (now) < %s (EtnaTime)\n", now, upgrades.EtnaTime)
34+
return
35+
}
36+
37+
tc.Outf("{{green}}Etna is activated{{/}}: %s (now) >= %s (EtnaTime)\n", now, upgrades.EtnaTime)
38+
})
39+
})

tests/fixture/e2e/flags.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type FlagVars struct {
2020
delayNetworkShutdown bool
2121
stopNetwork bool
2222
nodeCount int
23+
activateEtna bool
2324
}
2425

2526
func (v *FlagVars) AvalancheGoExecPath() string {
@@ -61,6 +62,10 @@ func (v *FlagVars) NodeCount() int {
6162
return v.nodeCount
6263
}
6364

65+
func (v *FlagVars) ActivateEtna() bool {
66+
return v.activateEtna
67+
}
68+
6469
func RegisterFlags() *FlagVars {
6570
vars := FlagVars{}
6671
flag.StringVar(
@@ -105,6 +110,12 @@ func RegisterFlags() *FlagVars {
105110
tmpnet.DefaultNodeCount,
106111
"number of nodes the network should initially consist of",
107112
)
113+
flag.BoolVar(
114+
&vars.activateEtna,
115+
"activate-etna",
116+
false,
117+
"[optional] activate the etna upgrade",
118+
)
108119

109120
return &vars
110121
}

0 commit comments

Comments
 (0)