Skip to content

Commit

Permalink
synced changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Mar 2, 2024
1 parent 92cd617 commit 64db9a3
Show file tree
Hide file tree
Showing 22 changed files with 2,530 additions and 1,773 deletions.
2 changes: 1 addition & 1 deletion integration-tests/ccip-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set_config:
@echo "export TEST_BASE64_CCIP_SECRETS_CONFIG=$$(base64 -i $(secret_toml))" >> ./testconfig/override/.env


# example usage: make test_load_ccip testimage=chainlink-ccip-tests:latest testname=TestLoadCCIPStableRequestTriggeringWithNetworkChaos override_toml=../testconfig/override/config.toml secret_toml=./testconfig/tomls/secrets.toml
# example usage: make test_load_ccip testimage=chainlink-ccip-tests:latest testname=TestLoadCCIPStableRPS override_toml=./testconfig/override/config.toml secret_toml=./testconfig/tomls/secrets.toml
.PHONY: test_load_ccip
test_load_ccip: set_config
source ./testconfig/override/.env && \
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/ccip-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Here lives the integration tests for ccip, utilizing our [chainlink-testing-fram
In order to run the tests the first step is to set up the test inputs. Here are the steps to set your test input -
1. Default test input - set via TOML - If no specific input is set; the tests will run with default inputs mentioned in [default.toml](./testconfig/tomls/default.toml).
Please refer to [default.toml](./testconfig/tomls/default.toml) for the list of parameters that can be set through TOML. We do not recommend changing this file.
2. Overriding the default input - If you want to run your test with different test input, you can override the default inputs. For that you need to set an env var `BASE64_TEST_CONFIG_OVERRIDE` containing the base64 encoded TOML file content with updated test input parameters.
2. Overriding the default input - If you want to run your test with different test input, you can override the default inputs. For that you need to set an env var `BASE64_CCIP_CONFIG_OVERRIDE` containing the base64 encoded TOML file content with updated test input parameters.
For example, if you want to override the `Network` input in test and want to run your test on `avalanche testnet` and `arbitrum goerli` network, you need to -
1. create a TOML file with the following content:
```toml
Expand Down Expand Up @@ -40,9 +40,9 @@ Please refer to [default.toml](./testconfig/tomls/default.toml) for the list of
[CCIP]
[CCIP.Env]
# ChainlinkImage is mandatory for all tests.
[CCIP.Env.Chainlink]
[CCIP.Env.Chainlink.Common]
[CCIP.Env.Chainlink.Common.ChainlinkImage]
[CCIP.Env.NewCLCluster]
[CCIP.Env.NewCLCluster.Common]
[CCIP.Env.NewCLCluster.Common.ChainlinkImage]
image = "chainlink-ccip"
version = "latest"
```
Expand Down
233 changes: 138 additions & 95 deletions integration-tests/ccip-tests/actions/ccip_helpers.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions integration-tests/ccip-tests/chaos/ccip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ func TestChaosCCIP(t *testing.T) {
lane := setUpArgs.Lanes[0].ForwardLane

tearDown := setUpArgs.TearDown
testEnvironment := lane.TestEnv.K8Env
testSetup := lane.TestEnv
testEnvironment := setUpArgs.Env.K8Env
testSetup := setUpArgs.Env

testSetup.ChaosLabelForGeth(t, lane.SourceChain.GetNetworkName(), lane.DestChain.GetNetworkName())
testSetup.ChaosLabelForCLNodes(t)
Expand Down
1,026 changes: 612 additions & 414 deletions integration-tests/ccip-tests/contracts/laneconfig/contracts-1.2.json

Large diffs are not rendered by default.

44 changes: 41 additions & 3 deletions integration-tests/ccip-tests/load/ccip_loadgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import (
"github.com/stretchr/testify/require"
"go.uber.org/atomic"

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"

"github.com/smartcontractkit/chainlink/integration-tests/ccip-tests/contracts"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/testhelpers"
Expand All @@ -27,9 +30,18 @@ import (
"github.com/smartcontractkit/chainlink/integration-tests/ccip-tests/testreporters"
)

type CCIPLaneOptimized struct {
Logger zerolog.Logger
SourceNetworkName string
DestNetworkName string
Source *actions.SourceCCIPModule
Dest *actions.DestCCIPModule
Reports *testreporters.CCIPLaneStats
}

type CCIPE2ELoad struct {
t *testing.T
Lane *actions.CCIPLane
Lane *CCIPLaneOptimized
NoOfReq int64 // approx no of Request fired
CurrentMsgSerialNo *atomic.Int64 // current msg serial number in the load sequence
CallTimeOut time.Duration // max time to wait for various on-chain events
Expand All @@ -41,9 +53,18 @@ type CCIPE2ELoad struct {
}

func NewCCIPLoad(t *testing.T, lane *actions.CCIPLane, timeout time.Duration, noOfReq int64) *CCIPE2ELoad {
// to avoid holding extra data
loadLane := &CCIPLaneOptimized{
Logger: lane.Logger,
SourceNetworkName: lane.SourceNetworkName,
DestNetworkName: lane.DestNetworkName,
Source: lane.Source,
Dest: lane.Dest,
Reports: lane.Reports,
}
return &CCIPE2ELoad{
t: t,
Lane: lane,
Lane: loadLane,
CurrentMsgSerialNo: atomic.NewInt64(1),
CallTimeOut: timeout,
NoOfReq: noOfReq,
Expand Down Expand Up @@ -110,6 +131,23 @@ func (c *CCIPE2ELoad) BeforeAllCall(msgType string, gasLimit *big.Int) {

sourceCCIP.Common.ChainClient.ParallelTransactions(false)
destCCIP.Common.ChainClient.ParallelTransactions(false)
// delete all pools as we don't need it anymore
// this is just to free up memory space for scalability tests with high number of token and pools
sourceCCIP.Common.BridgeTokenPools = []*contracts.TokenPool{}
destCCIP.Common.BridgeTokenPools = []*contracts.TokenPool{}
// close all header subscriptions for dest chains
queuedEvents := destCCIP.Common.ChainClient.GetHeaderSubscriptions()
for subName := range queuedEvents {
destCCIP.Common.ChainClient.DeleteHeaderEventSubscription(subName)
}
// close all header subscriptions for source chains except for finalized header
queuedEvents = sourceCCIP.Common.ChainClient.GetHeaderSubscriptions()
for subName := range queuedEvents {
if subName == blockchain.FinalizedHeaderKey {
continue
}
sourceCCIP.Common.ChainClient.DeleteHeaderEventSubscription(subName)
}
}

func (c *CCIPE2ELoad) CCIPMsg() (router.ClientEVM2AnyMessage, *testreporters.RequestStat) {
Expand Down Expand Up @@ -145,7 +183,7 @@ func (c *CCIPE2ELoad) Call(_ *wasp.Generator) *wasp.Response {
msgSerialNo := stats.ReqNo
lggr := c.Lane.Logger.With().Int64("msg Number", stats.ReqNo).Logger()

defer c.Lane.Reports.UpdatePhaseStatsForReq(stats)
//defer c.Lane.Reports.UpdatePhaseStatsForReq(stats)
feeToken := sourceCCIP.Common.FeeToken.EthAddress
// initiate the transfer
lggr.Debug().Str("triggeredAt", time.Now().GoString()).Msg("triggering transfer")
Expand Down
16 changes: 10 additions & 6 deletions integration-tests/ccip-tests/load/ccip_multicall_loadgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,27 @@ type MultiCallReturnValues struct {

func NewMultiCallLoadGenerator(testCfg *testsetups.CCIPTestConfig, lanes []*actions.CCIPLane, noOfRequestsPerUnitTime int64, labels map[string]string) (*CCIPMultiCallLoadGenerator, error) {
// check if all lanes are from same network
source := lanes[0].SourceChain.GetChainID()
source := lanes[0].Source.Common.ChainClient.GetChainID()
multiCall := lanes[0].SrcNetworkLaneCfg.Multicall
if multiCall == "" {
return nil, fmt.Errorf("multicall address cannot be empty")
}
for i := 1; i < len(lanes); i++ {
if source.String() != lanes[i].SourceChain.GetChainID().String() {
return nil, fmt.Errorf("all lanes should be from same network; expected %s, got %s", source, lanes[i].SourceChain.GetChainID())
if source.String() != lanes[i].Source.Common.ChainClient.GetChainID().String() {
return nil, fmt.Errorf("all lanes should be from same network; expected %s, got %s", source, lanes[i].Source.Common.ChainClient.GetChainID())
}
if lanes[i].SrcNetworkLaneCfg.Multicall != multiCall {
return nil, fmt.Errorf("multicall address should be same for all lanes")
}
}
client := lanes[0].SourceChain
client := lanes[0].Source.Common.ChainClient
lggr := logging.GetTestLogger(testCfg.Test).With().Str("Source Network", client.GetNetworkName()).Logger()
ls := wasp.LabelsMapToModel(labels)
if err := ls.Validate(); err != nil {
return nil, err
}
loki, err := wasp.NewLokiClient(wasp.NewEnvLokiConfig())
lokiConfig := testCfg.EnvInput.Logging.Loki
loki, err := wasp.NewLokiClient(wasp.NewLokiConfig(lokiConfig.Endpoint, lokiConfig.TenantId, nil, nil))
if err != nil {
return nil, err
}
Expand All @@ -86,6 +87,9 @@ func NewMultiCallLoadGenerator(testCfg *testsetups.CCIPTestConfig, lanes []*acti
}
for _, lane := range lanes {
ccipLoad := NewCCIPLoad(testCfg.Test, lane, testCfg.TestGroupInput.PhaseTimeout.Duration(), 100000)
// for multicall load generator, we don't want to send max data intermittently, it might
// cause oversized data for multicall
ccipLoad.SendMaxDataIntermittently = false
ccipLoad.BeforeAllCall(testCfg.TestGroupInput.MsgType, big.NewInt(*testCfg.TestGroupInput.DestGasLimit))
m.E2ELoads[fmt.Sprintf("%s-%s", lane.SourceNetworkName, lane.DestNetworkName)] = ccipLoad
}
Expand Down Expand Up @@ -207,7 +211,7 @@ func (m *CCIPMultiCallLoadGenerator) Call(_ *wasp.Generator) *wasp.Response {
return res
}

lggr = lggr.With().Str("Source Network", c.Lane.SourceChain.GetNetworkName()).Str("Dest Network", c.Lane.DestChain.GetNetworkName()).Logger()
lggr = lggr.With().Str("Source Network", c.Lane.Source.Common.ChainClient.GetNetworkName()).Str("Dest Network", c.Lane.Dest.Common.ChainClient.GetNetworkName()).Logger()
stats := rValues.Stats
txConfirmationTime := txConfirmationTime
sendTx := sendTx
Expand Down
70 changes: 43 additions & 27 deletions integration-tests/ccip-tests/load/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ type LoadArgs struct {
TestSetupArgs *testsetups.CCIPTestSetUpOutputs
ChaosExps []ChaosConfig
LoadgenTearDowns []func()
Labels map[string]string
}

func (l *LoadArgs) SetReportParams() {
var qParams []string
for k, v := range l.Labels {
qParams = append(qParams, fmt.Sprintf("var-%s=%s", k, v))
}
// add one of the source and destination network to the grafana query params
if len(l.TestSetupArgs.Lanes) > 0 {
qParams = append(qParams, fmt.Sprintf("var-source_chain=%s", l.TestSetupArgs.Lanes[0].ForwardLane.SourceNetworkName))
qParams = append(qParams, fmt.Sprintf("var-dest_chain=%s", l.TestSetupArgs.Lanes[0].ForwardLane.DestNetworkName))
}
err := l.TestSetupArgs.Reporter.AddToGrafanaDashboardQueryParams(qParams...)
require.NoError(l.t, err, "failed to set grafana query params")
}

func (l *LoadArgs) Setup() {
Expand All @@ -50,6 +65,18 @@ func (l *LoadArgs) Setup() {
envName = "ccip-runner"
}
l.TestSetupArgs = testsetups.CCIPDefaultTestSetUp(l.TestCfg.Test, lggr, envName, nil, l.TestCfg)
namespace := l.TestCfg.TestGroupInput.TestRunName
if l.TestSetupArgs.Env != nil && l.TestSetupArgs.Env.K8Env != nil && l.TestSetupArgs.Env.K8Env.Cfg != nil {
namespace = l.TestSetupArgs.Env.K8Env.Cfg.Namespace
}
l.Labels = map[string]string{
"test_group": "load",
"cluster": "sdlc",
"test_id": "ccip",
"namespace": namespace,
}
l.TestSetupArgs.Reporter.SetGrafanaURLProvider(l.TestCfg.EnvInput)
l.SetReportParams()
}

func (l *LoadArgs) setSchedule() {
Expand Down Expand Up @@ -87,7 +114,6 @@ func (l *LoadArgs) SanityCheck() {
func (l *LoadArgs) TriggerLoadByLane() {
l.setSchedule()
l.TestSetupArgs.Reporter.SetDuration(l.TestCfg.TestGroupInput.TestDuration.Duration())
namespace := l.TestCfg.TestGroupInput.ExistingEnv

// start load for a lane
startLoad := func(lane *actions.CCIPLane) {
Expand All @@ -98,10 +124,13 @@ func (l *LoadArgs) TriggerLoadByLane() {

ccipLoad := NewCCIPLoad(l.TestCfg.Test, lane, l.TestCfg.TestGroupInput.PhaseTimeout.Duration(), 100000)
ccipLoad.BeforeAllCall(l.TestCfg.TestGroupInput.MsgType, big.NewInt(*l.TestCfg.TestGroupInput.DestGasLimit))
if lane.TestEnv != nil && lane.TestEnv.K8Env != nil && lane.TestEnv.K8Env.Cfg != nil {
namespace = lane.TestEnv.K8Env.Cfg.Namespace
lokiConfig := l.TestCfg.EnvInput.Logging.Loki
labels := make(map[string]string)
for k, v := range l.Labels {
labels[k] = v
}

labels["source_chain"] = lane.SourceNetworkName
labels["dest_chain"] = lane.DestNetworkName
loadRunner, err := wasp.NewGenerator(&wasp.Config{
T: l.TestCfg.Test,
GenName: fmt.Sprintf("lane %s-> %s", lane.SourceNetworkName, lane.DestNetworkName),
Expand All @@ -113,22 +142,16 @@ func (l *LoadArgs) TriggerLoadByLane() {
Gun: ccipLoad,
Logger: ccipLoad.Lane.Logger,
SharedData: l.TestCfg.TestGroupInput.MsgType,
LokiConfig: wasp.NewEnvLokiConfig(),
Labels: map[string]string{
"test_group": "load",
"cluster": "sdlc",
"namespace": namespace,
"test_id": "ccip",
"source_chain": lane.SourceNetworkName,
"dest_chain": lane.DestNetworkName,
},
FailOnErr: true,
LokiConfig: wasp.NewLokiConfig(lokiConfig.Endpoint, lokiConfig.TenantId, nil, nil),
Labels: labels,
FailOnErr: true,
})
require.NoError(l.TestCfg.Test, err, "initiating loadgen for lane %s --> %s",
lane.SourceNetworkName, lane.DestNetworkName)
loadRunner.Run(false)
l.AddToRunnerGroup(loadRunner)
}

for _, lane := range l.TestSetupArgs.Lanes {
lane := lane
l.LoadStarterWg.Add(1)
Expand Down Expand Up @@ -213,8 +236,6 @@ func (l *LoadArgs) TriggerLoadBySource() {
require.NotNil(l.t, l.TestCfg.TestGroupInput.TestDuration, "test duration input is nil")
require.GreaterOrEqual(l.t, 1, len(l.TestCfg.TestGroupInput.RequestPerUnitTime), "time unit input must be specified")
l.TestSetupArgs.Reporter.SetDuration(l.TestCfg.TestGroupInput.TestDuration.Duration())
namespace := l.TestCfg.TestGroupInput.ExistingEnv

var laneBySource = make(map[string][]*actions.CCIPLane)
for _, lane := range l.TestSetupArgs.Lanes {
laneBySource[lane.ForwardLane.SourceNetworkName] = append(laneBySource[lane.ForwardLane.SourceNetworkName], lane.ForwardLane)
Expand All @@ -231,19 +252,14 @@ func (l *LoadArgs) TriggerLoadBySource() {
l.lggr.Info().
Str("Source Network", source).
Msg("Starting load for source")
if lanes[0].TestEnv != nil && lanes[0].TestEnv.K8Env != nil && lanes[0].TestEnv.K8Env.Cfg != nil {
namespace = lanes[0].TestEnv.K8Env.Cfg.Namespace
}
allLabels := map[string]string{
"test_group": "load",
"cluster": "sdlc",
"namespace": namespace,
"test_id": "ccip",
"source_chain": source,
allLabels := make(map[string]string)
for k, v := range l.Labels {
allLabels[k] = v
}
allLabels["source_chain"] = source
multiCallGen, err := NewMultiCallLoadGenerator(l.TestCfg, lanes, l.TestCfg.TestGroupInput.RequestPerUnitTime[0], allLabels)
require.NoError(l.t, err)

lokiConfig := l.TestCfg.EnvInput.Logging.Loki
loadRunner, err := wasp.NewGenerator(&wasp.Config{
T: l.TestCfg.Test,
GenName: fmt.Sprintf("Source %s", source),
Expand All @@ -254,7 +270,7 @@ func (l *LoadArgs) TriggerLoadBySource() {
CallTimeout: (l.TestCfg.TestGroupInput.PhaseTimeout.Duration()) * 5,
Gun: multiCallGen,
Logger: multiCallGen.logger,
LokiConfig: wasp.NewEnvLokiConfig(),
LokiConfig: wasp.NewLokiConfig(lokiConfig.Endpoint, lokiConfig.TenantId, nil, nil),
Labels: allLabels,
FailOnErr: true,
})
Expand Down
Loading

0 comments on commit 64db9a3

Please sign in to comment.