From 92dc3c03c94fbd3fda5517edf5964134a64572dd Mon Sep 17 00:00:00 2001 From: Andrei Smirnov Date: Thu, 10 Oct 2024 17:56:01 +0300 Subject: [PATCH] testutil: fixed smoke test (#3332) 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 --- testutil/compose/smoke/smoke_test.go | 74 ++++++++++++------------- testutil/compose/static/lodestar/run.sh | 2 - 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/testutil/compose/smoke/smoke_test.go b/testutil/compose/smoke/smoke_test.go index 449634b48..b4a921e42 100644 --- a/testutil/compose/smoke/smoke_test.go +++ b/testutil/compose/smoke/smoke_test.go @@ -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" ) @@ -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) { @@ -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 @@ -204,7 +204,7 @@ 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) }) } @@ -212,17 +212,17 @@ func TestSmoke(t *testing.T) { // 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() +} diff --git a/testutil/compose/static/lodestar/run.sh b/testutil/compose/static/lodestar/run.sh index b5b1c12ed..ea04d5b97 100755 --- a/testutil/compose/static/lodestar/run.sh +++ b/testutil/compose/static/lodestar/run.sh @@ -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 \