Skip to content

Commit

Permalink
testutil: fixed smoke test (#3332)
Browse files Browse the repository at this point in the history
This addresses two issues:
1. The broken Smoke Test with lodestar, it refuses accepting network config for dev network.
2. Re-enabled previously disabled compatibility test.

category: test
ticket: #3004
  • Loading branch information
pinebit authored Oct 10, 2024
1 parent 6f9863c commit 92dc3c0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 39 deletions.
74 changes: 37 additions & 37 deletions testutil/compose/smoke/smoke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/stretchr/testify/require"

"github.com/obolnetwork/charon/app/version"
"github.com/obolnetwork/charon/testutil"
"github.com/obolnetwork/charon/testutil/compose"
)
Expand Down Expand Up @@ -84,26 +85,26 @@ func TestSmoke(t *testing.T) {
},
Timeout: time.Minute * 2,
},
// TODO: https://github.com/ObolNetwork/charon/issues/3004
// {
// Name: "run_version_matrix_with_dkg",
// PrintYML: true,
// ConfigFunc: func(conf *compose.Config) {
// conf.KeyGen = compose.KeyGenDKG
// // NOTE: Add external VCs when supported versions include minimal preset.
// conf.VCs = []compose.VCType{compose.VCMock}
// },
// DefineTmplFunc: func(data *compose.TmplData) {
// // Use oldest supported version for cluster lock
// pegImageTag(data.Nodes, 0, last(version.Supported()[1:])+"-rc")
// },
// RunTmplFunc: func(data *compose.TmplData) {
// // Node 0 is local build
// pegImageTag(data.Nodes, 1, nth(version.Supported(), 0)+"-dev") // Node 1 is previous commit on this branch (v0.X-dev/rc) Note this will fail for first commit on new branch version.
// pegImageTag(data.Nodes, 2, nth(version.Supported()[1:], 1)+"-rc")
// pegImageTag(data.Nodes, 3, nth(version.Supported()[1:], 2)+"-rc")
// },
// },
{
Name: "run_version_matrix_with_dkg",
PrintYML: true,
ConfigFunc: func(conf *compose.Config) {
conf.KeyGen = compose.KeyGenDKG
// NOTE: Add external VCs when supported versions include minimal preset.
conf.VCs = []compose.VCType{compose.VCMock}
},
DefineTmplFunc: func(data *compose.TmplData) {
// Use oldest supported version for cluster lock
pegImageTag(data.Nodes, 0, last(version.Supported()[1:])+".0-rc1")
},
RunTmplFunc: func(data *compose.TmplData) {
// Node 0 is local build
// Nodeы 1-3 use the previous release; ensure better diversity in the matrix when more releases are added.
pegImageTag(data.Nodes, 1, nth(version.Supported(), 1)+".0-rc1")
pegImageTag(data.Nodes, 2, nth(version.Supported(), 1)+".0-rc1")
pegImageTag(data.Nodes, 3, nth(version.Supported(), 1)+".0-rc1")
},
},
{
Name: "teku_versions",
ConfigFunc: func(conf *compose.Config) {
Expand Down Expand Up @@ -171,8 +172,7 @@ func TestSmoke(t *testing.T) {

for _, test := range tests {
t.Run(test.Name, func(t *testing.T) {
dir, err := os.MkdirTemp("", "")
require.NoError(t, err)
dir := t.TempDir()

conf := compose.NewDefaultConfig()
conf.Monitoring = false
Expand Down Expand Up @@ -204,25 +204,25 @@ func TestSmoke(t *testing.T) {
autoConfig.LogFile = path.Join(*logDir, test.Name+".log")
}

err = compose.Auto(context.Background(), autoConfig)
err := compose.Auto(context.Background(), autoConfig)
testutil.RequireNoError(t, err)
})
}
}

// pegImageTag pegs the charon docker image tag for one of the nodes.
// It overrides the default that uses locally built latest version.
// func pegImageTag(nodes []compose.TmplNode, index int, imageTag string) {
// nodes[index].ImageTag = imageTag
// nodes[index].Entrypoint = "/usr/local/bin/charon" // Use contains binary, not locally built latest version.
// }

// // last returns the last element of a slice.
// func last(s []version.SemVer) string {
// return s[len(s)-1].String()
// }

// // nth returns the nth element of a slice, wrapping if n > len(s).
// func nth(s []version.SemVer, n int) string {
// return s[n%len(s)].String()
// }
func pegImageTag(nodes []compose.TmplNode, index int, imageTag string) {
nodes[index].ImageTag = imageTag
nodes[index].Entrypoint = "/usr/local/bin/charon" // Use contains binary, not locally built latest version.
}

// last returns the last element of a slice.
func last(s []version.SemVer) string {
return s[len(s)-1].String()
}

// nth returns the nth element of a slice, wrapping if n > len(s).
func nth(s []version.SemVer, n int) string {
return s[n%len(s)].String()
}
2 changes: 0 additions & 2 deletions testutil/compose/static/lodestar/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ echo "Imported all keys"

node /usr/app/packages/cli/bin/lodestar validator \
--network="dev" \
--presetFile="/tmp/testnet/config.yaml" \
--paramsFile="/tmp/testnet/config.yaml" \
--metrics=true \
--metrics.address="0.0.0.0" \
--metrics.port=5064 \
Expand Down

0 comments on commit 92dc3c0

Please sign in to comment.