Skip to content

Commit

Permalink
[TT-1209] use the same CL node config in k8s as in docker (#13411)
Browse files Browse the repository at this point in the history
* play around

* remove hardcoded configs for k8s, use TOML test config instead

* adjust Makefile

* fix ocr forwarders panic

* add function for getting correct ocr config for soak tests

* lower chainlink node funding to something reasonable

* warn when no events were collected

* disable forwarder ocr soak tests until fixed

---------

Co-authored-by: Anirudh Warrier <[email protected]>
  • Loading branch information
Tofel and anirudhwarrier authored Jun 25, 2024
1 parent 9176a6e commit e61d256
Show file tree
Hide file tree
Showing 28 changed files with 742 additions and 367 deletions.
31 changes: 21 additions & 10 deletions integration-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,35 @@ test_node_migrations_simulated_verbose:
go test -timeout 1h -count=1 -v $(args) ./migration

# Soak
.PHONY: test_soak_ocr
test_soak_ocr:
.PHONY: test_soak_ocr1
test_soak_ocr1:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run ^TestOCRSoak$$ ./soak
go test -v -count=1 -run TestOCRv1Soak ./soak

.PHONY: test_soak_ocr2
test_soak_ocr2:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run TestOCRv2Soak ./soak

.PHONY: test_soak_forwarder_ocr1
test_soak_forwarder_ocr1:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run TestForwarderOCRv1Soak ./soak

.PHONY: test_soak_forwarder_ocr2
test_soak_forwarder_ocr2:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run TestForwarderOCRv2Soak ./soak

.PHONY: test_soak_ocr_reorg_1
test_soak_ocr_reorg_1:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run ^TestOCRSoak_GethReorgBelowFinality_FinalityTagDisabled$$ ./soak
go test -v -count=1 -run ^TestOCRSoak_GethReorgBelowFinality_FinalityTagDisabled$$ ./soak

.PHONY: test_soak_ocr_reorg_2
test_soak_ocr_reorg_2:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run ^TestOCRSoak_GethReorgBelowFinality_FinalityTagEnabled$$ ./soak
go test -v -count=1 -run ^TestOCRSoak_GethReorgBelowFinality_FinalityTagEnabled$$ ./soak

.PHONY: test_soak_ocr_gas_spike
test_soak_ocr_gas_spike:
Expand All @@ -178,10 +193,6 @@ test_soak_ocr_rpc_down_half_cl_nodes:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run ^TestOCRSoak_RPCDownForHalfCLNodes$$ ./soak

.PHONY: test_soak_forwarder_ocr
test_soak_forwarder_ocr:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run TestForwarderOCRSoak ./soak

.PHONY: test_soak_automation
test_soak_automation:
Expand Down Expand Up @@ -226,4 +237,4 @@ run_test_with_local_image: build_docker_image
# removes all occurrences of .run.id file in current folder and it's subdirectories
# before making any changes lists all file locations and awaits user confirmation
remove_test_execution_artefacts:
./scripts/search_and_delete.sh .run.id
./scripts/search_and_delete.sh .run.id
39 changes: 36 additions & 3 deletions integration-tests/actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"testing"
"time"

"github.com/pelletier/go-toml/v2"

geth "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/rpc"
Expand All @@ -22,12 +24,13 @@ import (
"github.com/smartcontractkit/chainlink-testing-framework/testreporters"
"github.com/smartcontractkit/chainlink-testing-framework/utils/conversions"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
"github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum"
ethContracts "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum"

"github.com/ethereum/go-ethereum/accounts/abi"

"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"

"github.com/rs/zerolog"

"github.com/ethereum/go-ethereum/common"
Expand All @@ -39,8 +42,11 @@ import (
"github.com/test-go/testify/require"
"math"

ctfconfig "github.com/smartcontractkit/chainlink-testing-framework/config"
"github.com/smartcontractkit/chainlink-testing-framework/utils/testcontext"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/types/config/node"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/link_token_interface"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/operator_factory"
)
Expand Down Expand Up @@ -1069,7 +1075,7 @@ func SendLinkFundsToDeploymentAddresses(

// GenerateUpkeepReport generates a report of performed, successful, reverted and stale upkeeps for a given registry contract based on transaction logs. In case of test failure it can help us
// to triage the issue by providing more context.
func GenerateUpkeepReport(t *testing.T, chainClient *seth.Client, startBlock, endBlock *big.Int, instance contracts.KeeperRegistry, registryVersion ethereum.KeeperRegistryVersion) (performedUpkeeps, successfulUpkeeps, revertedUpkeeps, staleUpkeeps int, err error) {
func GenerateUpkeepReport(t *testing.T, chainClient *seth.Client, startBlock, endBlock *big.Int, instance contracts.KeeperRegistry, registryVersion ethContracts.KeeperRegistryVersion) (performedUpkeeps, successfulUpkeeps, revertedUpkeeps, staleUpkeeps int, err error) {
registryLogs := []gethtypes.Log{}
l := logging.GetTestLogger(t)

Expand Down Expand Up @@ -1150,7 +1156,7 @@ func GenerateUpkeepReport(t *testing.T, chainClient *seth.Client, startBlock, en
return
}

func GetStalenessReportCleanupFn(t *testing.T, logger zerolog.Logger, chainClient *seth.Client, startBlock uint64, registry contracts.KeeperRegistry, registryVersion ethereum.KeeperRegistryVersion) func() {
func GetStalenessReportCleanupFn(t *testing.T, logger zerolog.Logger, chainClient *seth.Client, startBlock uint64, registry contracts.KeeperRegistry, registryVersion ethContracts.KeeperRegistryVersion) func() {
return func() {
if t.Failed() {
endBlock, err := chainClient.Client.BlockNumber(context.Background())
Expand All @@ -1166,3 +1172,30 @@ func GetStalenessReportCleanupFn(t *testing.T, logger zerolog.Logger, chainClien
}
}
}

func BuildTOMLNodeConfigForK8s(testConfig ctfconfig.GlobalTestConfig, testNetwork blockchain.EVMNetwork) (string, error) {
nodeConfigInToml := testConfig.GetNodeConfig()

nodeConfig, _, err := node.BuildChainlinkNodeConfig(
[]blockchain.EVMNetwork{testNetwork},
nodeConfigInToml.BaseConfigTOML,
nodeConfigInToml.CommonChainConfigTOML,
nodeConfigInToml.ChainConfigTOMLByChainID,
)

if err != nil {
return "", err
}

if testConfig.GetPyroscopeConfig() != nil && *testConfig.GetPyroscopeConfig().Enabled {
nodeConfig.Pyroscope.Environment = testConfig.GetPyroscopeConfig().Environment
nodeConfig.Pyroscope.ServerAddress = testConfig.GetPyroscopeConfig().ServerUrl
}

asStr, err := toml.Marshal(nodeConfig)
if err != nil {
return "", err
}

return string(asStr), nil
}
8 changes: 3 additions & 5 deletions integration-tests/actions/vrf/common/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,17 @@ import (
"testing"
"time"

seth_utils "github.com/smartcontractkit/chainlink-testing-framework/utils/seth"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/go-resty/resty/v2"

"github.com/ethereum/go-ethereum/common"
"github.com/google/uuid"
"github.com/rs/zerolog"

"github.com/smartcontractkit/seth"

ctf_test_env "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env"
"github.com/smartcontractkit/chainlink-testing-framework/utils/conversions"
seth_utils "github.com/smartcontractkit/chainlink-testing-framework/utils/seth"

"github.com/smartcontractkit/chainlink/integration-tests/actions"
"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
Expand Down
36 changes: 4 additions & 32 deletions integration-tests/benchmark/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,6 @@ import (
)

var (
keeperBenchmarkBaseTOML = `[Feature]
LogPoller = true
[OCR2]
Enabled = true
[P2P]
[P2P.V2]
Enabled = true
AnnounceAddresses = ["0.0.0.0:6690"]
ListenAddresses = ["0.0.0.0:6690"]
[Keeper]
TurnLookBack = 0
[WebServer]
HTTPWriteTimeout = '1h'`

simulatedEVMNonDevTOML = `
Enabled = true
FinalityDepth = 50
LogPollInterval = '1s'
[EVM.HeadTracker]
HistoryDepth = 100
[EVM.GasEstimator]
Mode = 'FixedPrice'
LimitDefault = 5_000_000`

performanceChainlinkResources = map[string]interface{}{
"resources": map[string]interface{}{
"requests": map[string]interface{}{
Expand Down Expand Up @@ -322,8 +294,6 @@ func SetupAutomationBenchmarkEnv(t *testing.T, keeperTestConfig types.KeeperBenc
l := logging.GetTestLogger(t)
testNetwork := networks.MustGetSelectedNetworkConfig(keeperTestConfig.GetNetworkConfig())[0] // Environment currently being used to run benchmark test on
blockTime := "1"
networkDetailTOML := `MinIncomingConfirmations = 1`

numberOfNodes := *keeperTestConfig.GetKeeperConfig().Common.NumberOfNodes

if strings.Contains(*keeperTestConfig.GetKeeperConfig().Common.RegistryToTest, "2_") {
Expand Down Expand Up @@ -355,7 +325,6 @@ func SetupAutomationBenchmarkEnv(t *testing.T, keeperTestConfig types.KeeperBenc

// Test can run on simulated, simulated-non-dev, testnets
if testNetwork.Name == networks.SimulatedEVMNonDev.Name {
networkDetailTOML = simulatedEVMNonDevTOML
testEnvironment.
AddHelm(reorg.New(&reorg.Props{
NetworkName: testNetwork.Name,
Expand Down Expand Up @@ -447,8 +416,11 @@ func SetupAutomationBenchmarkEnv(t *testing.T, keeperTestConfig types.KeeperBenc
ctf_config.MightConfigOverridePyroscopeKey(keeperTestConfig.GetPyroscopeConfig(), target)
}

tomlConfig, err := actions.BuildTOMLNodeConfigForK8s(keeperTestConfig, testNetwork)
require.NoError(t, err, "Error building TOML config")

cd := chainlink.NewWithOverride(i, map[string]any{
"toml": networks.AddNetworkDetailedConfig(keeperBenchmarkBaseTOML, keeperTestConfig.GetPyroscopeConfig(), networkDetailTOML, testNetwork),
"toml": tomlConfig,
"chainlink": chainlinkResources,
"db": dbResources,
}, keeperTestConfig.GetChainlinkImageConfig(), overrideFn)
Expand Down
27 changes: 12 additions & 15 deletions integration-tests/chaos/ocr2vrf_chaos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,25 @@ import (
"github.com/smartcontractkit/chainlink/integration-tests/actions/ocr2vrf_actions"
"github.com/smartcontractkit/chainlink/integration-tests/actions/ocr2vrf_actions/ocr2vrf_constants"
"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/config"
tc "github.com/smartcontractkit/chainlink/integration-tests/testconfig"
)

func TestOCR2VRFChaos(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)
testconfig, err := tc.GetConfig("Chaos", tc.OCR2VRF)
testConfig, err := tc.GetConfig("Chaos", tc.OCR2VRF)
if err != nil {
t.Fatal(err)
}

loadedNetwork := networks.MustGetSelectedNetworkConfig(testconfig.Network)[0]
loadedNetwork := networks.MustGetSelectedNetworkConfig(testConfig.Network)[0]

tomlConfig, err := actions.BuildTOMLNodeConfigForK8s(&testConfig, loadedNetwork)
require.NoError(t, err, "Error building TOML config")

defaultOCR2VRFSettings := map[string]interface{}{
"replicas": 6,
"toml": networks.AddNetworkDetailedConfig(
config.BaseOCR2Config,
testconfig.Pyroscope,
config.DefaultOCR2VRFNetworkDetailTomlConfig,
loadedNetwork,
),
"toml": tomlConfig,
}

defaultOCR2VRFEthereumSettings := &ethereum.Props{
Expand All @@ -57,11 +54,11 @@ func TestOCR2VRFChaos(t *testing.T) {
}

var overrideFn = func(_ interface{}, target interface{}) {
ctf_config.MustConfigOverrideChainlinkVersion(testconfig.GetChainlinkImageConfig(), target)
ctf_config.MightConfigOverridePyroscopeKey(testconfig.GetPyroscopeConfig(), target)
ctf_config.MustConfigOverrideChainlinkVersion(testConfig.GetChainlinkImageConfig(), target)
ctf_config.MightConfigOverridePyroscopeKey(testConfig.GetPyroscopeConfig(), target)
}

chainlinkCfg := chainlink.NewWithOverride(0, defaultOCR2VRFSettings, testconfig.ChainlinkImage, overrideFn)
chainlinkCfg := chainlink.NewWithOverride(0, defaultOCR2VRFSettings, testConfig.ChainlinkImage, overrideFn)

testCases := map[string]struct {
networkChart environment.ConnectedChart
Expand Down Expand Up @@ -134,7 +131,7 @@ func TestOCR2VRFChaos(t *testing.T) {
testCase := tc
t.Run(fmt.Sprintf("OCR2VRF_%s", testCaseName), func(t *testing.T) {
t.Parallel()
testNetwork := networks.MustGetSelectedNetworkConfig(testconfig.Network)[0] // Need a new copy of the network for each test
testNetwork := networks.MustGetSelectedNetworkConfig(testConfig.Network)[0] // Need a new copy of the network for each test
testEnvironment := environment.
New(&environment.Config{
NamespacePrefix: fmt.Sprintf(
Expand All @@ -156,7 +153,7 @@ func TestOCR2VRFChaos(t *testing.T) {
require.NoError(t, err)

testNetwork = seth_utils.MustReplaceSimulatedNetworkUrlWithK8(l, testNetwork, *testEnvironment)
chainClient, err := seth_utils.GetChainClientWithConfigFunction(testconfig, testNetwork, seth_utils.OneEphemeralKeysLiveTestnetCheckFn)
chainClient, err := seth_utils.GetChainClientWithConfigFunction(testConfig, testNetwork, seth_utils.OneEphemeralKeysLiveTestnetCheckFn)
require.NoError(t, err, "Error creating seth client")

chainlinkNodes, err := client.ConnectChainlinkNodes(testEnvironment)
Expand All @@ -165,7 +162,7 @@ func TestOCR2VRFChaos(t *testing.T) {
require.NoError(t, err, "Retrieving on-chain wallet addresses for chainlink nodes shouldn't fail")

t.Cleanup(func() {
err := actions.TeardownSuite(t, chainClient, testEnvironment, chainlinkNodes, nil, zapcore.PanicLevel, &testconfig)
err := actions.TeardownSuite(t, chainClient, testEnvironment, chainlinkNodes, nil, zapcore.PanicLevel, &testConfig)
require.NoError(t, err, "Error tearing down environment")
})

Expand Down
12 changes: 6 additions & 6 deletions integration-tests/chaos/ocr_chaos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ var (
chaosEndRound int64 = 4
)

func getDefaultOcrSettings(config *tc.TestConfig) map[string]interface{} {
defaultOCRSettings["toml"] = networks.AddNetworksConfig(baseTOML, config.Pyroscope, networks.MustGetSelectedNetworkConfig(config.Network)[0])
return defaultAutomationSettings
}

func TestOCRChaos(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)
Expand All @@ -67,7 +62,12 @@ func TestOCRChaos(t *testing.T) {
ctf_config.MightConfigOverridePyroscopeKey(config.GetPyroscopeConfig(), target)
}

chainlinkCfg := chainlink.NewWithOverride(0, getDefaultOcrSettings(&config), config.ChainlinkImage, overrideFn)
tomlConfig, err := actions.BuildTOMLNodeConfigForK8s(&config, networks.MustGetSelectedNetworkConfig(config.Network)[0])
require.NoError(t, err, "Error building TOML config")

defaultOCRSettings["toml"] = tomlConfig

chainlinkCfg := chainlink.NewWithOverride(0, defaultOCRSettings, config.ChainlinkImage, overrideFn)

testCases := map[string]struct {
networkChart environment.ConnectedChart
Expand Down
Loading

0 comments on commit e61d256

Please sign in to comment.