From 9d190be0a51170e02596c8541f2fd8cb59a9de04 Mon Sep 17 00:00:00 2001 From: AnieeG Date: Thu, 7 Sep 2023 17:48:11 -0700 Subject: [PATCH] specific network pairs --- .../ccip-tests/testsetups/ccip.go | 95 ++++++++++++------- 1 file changed, 61 insertions(+), 34 deletions(-) diff --git a/integration-tests/ccip-tests/testsetups/ccip.go b/integration-tests/ccip-tests/testsetups/ccip.go index 129b0d59dd..9bb94b3792 100644 --- a/integration-tests/ccip-tests/testsetups/ccip.go +++ b/integration-tests/ccip-tests/testsetups/ccip.go @@ -191,47 +191,35 @@ func (p *CCIPTestConfig) setLoadInputs() { } } -func (p *CCIPTestConfig) FormNetworkPairs() { - for i := 0; i < p.NoOfNetworks; i++ { - for j := i + 1; j < p.NoOfNetworks; j++ { +func (p *CCIPTestConfig) SetNetworkPairs(t *testing.T, lggr zerolog.Logger) error { + var allError error + // if network pairs are provided, then use them + // example usage - CCIP_NETWORK_PAIRS="networkA,networkB|networkC,networkD|networkA,networkC" + lanes, _ := utils.GetEnv("CCIP_NETWORK_PAIRS") + if lanes != "" { + p.NetworkPairs = []NetworkPair{} + networkPairs := strings.Split(lanes, "|") + for _, pair := range networkPairs { + networkNames := strings.Split(pair, ",") + if len(networkNames) != 2 { + allError = multierr.Append(allError, fmt.Errorf("invalid network pair")) + } + nets := networks.SetNetworks(networkNames) p.NetworkPairs = append(p.NetworkPairs, NetworkPair{ - NetworkA: p.AllNetworks[i], - NetworkB: p.AllNetworks[j], + NetworkA: nets[0], + NetworkB: nets[1], }) } + return allError } -} - -// NewCCIPTestConfig collects all test related CCIPTestConfig from environment variables -func NewCCIPTestConfig(t *testing.T, lggr zerolog.Logger, tType string) *CCIPTestConfig { - var allError error + // if network pairs are not provided with CCIP_NETWORK_PAIRS, then form all possible network pair combination from SELECTED_NETWORKS if len(networks.SelectedNetworks) < 3 { lggr.Fatal(). Interface("SELECTED_NETWORKS", networks.SelectedNetworks). Msg("Set source and destination network in index 1 & 2 of env variable SELECTED_NETWORKS") } - p := &CCIPTestConfig{ - Test: t, - MsgType: actions.TokenTransfer, - PhaseTimeout: DefaultPhaseTimeout, - TestDuration: DefaultTestDuration, - NodeFunding: DefaultNodeFunding, - NoOfNetworks: DefaultNoOfNetworks, - AllNetworks: networks.SelectedNetworks[1:], - GethResourceProfile: GethResourceProfile, - } - - if tType != Smoke { - p.CLNodeDBResourceProfile = DONDBResourceProfile - } - - if tType == Load { - p.EnvTTL = DefaultTTLForLongTests - p.CLNodeResourceProfile = DONResourceProfile - p.NodeFunding = NodeFundingForLoad - p.PhaseTimeout = DefaultPhaseTimeoutForLongTests - } - + p.AllNetworks = networks.SelectedNetworks[1:] + p.NoOfNetworks = DefaultNoOfNetworks inputNoOfNetworks, _ := utils.GetEnv("CCIP_NO_OF_NETWORKS") if inputNoOfNetworks != "" { n, err := strconv.Atoi(inputNoOfNetworks) @@ -260,7 +248,7 @@ func NewCCIPTestConfig(t *testing.T, lggr zerolog.Logger, tType string) *CCIPTes // and the provided networks are simulated network, create replicas of the provided networks with // different chain ids if len(p.AllNetworks) < p.NoOfNetworks { - if p.AllNetworks[0].Simulated { + if simulated { actualNoOfNetworks := len(p.AllNetworks) n := p.AllNetworks[0] for i := 0; i < p.NoOfNetworks-actualNoOfNetworks; i++ { @@ -281,7 +269,7 @@ func NewCCIPTestConfig(t *testing.T, lggr zerolog.Logger, tType string) *CCIPTes } lggr.Info().Interface("Networks", p.AllNetworks).Msg("Running tests with networks") if p.NoOfNetworks > 2 { - p.FormNetworkPairs() + p.FormNetworkPairCombinations() } else { p.NetworkPairs = []NetworkPair{ { @@ -295,6 +283,45 @@ func NewCCIPTestConfig(t *testing.T, lggr zerolog.Logger, tType string) *CCIPTes lggr.Info().Str("NetworkA", n.NetworkA.Name).Str("NetworkB", n.NetworkB.Name).Msg("Network Pairs") } + return allError +} + +func (p *CCIPTestConfig) FormNetworkPairCombinations() { + for i := 0; i < p.NoOfNetworks; i++ { + for j := i + 1; j < p.NoOfNetworks; j++ { + p.NetworkPairs = append(p.NetworkPairs, NetworkPair{ + NetworkA: p.AllNetworks[i], + NetworkB: p.AllNetworks[j], + }) + } + } +} + +// NewCCIPTestConfig collects all test related CCIPTestConfig from environment variables +func NewCCIPTestConfig(t *testing.T, lggr zerolog.Logger, tType string) *CCIPTestConfig { + var allError error + p := &CCIPTestConfig{ + Test: t, + MsgType: actions.TokenTransfer, + PhaseTimeout: DefaultPhaseTimeout, + TestDuration: DefaultTestDuration, + NodeFunding: DefaultNodeFunding, + GethResourceProfile: GethResourceProfile, + } + + if tType != Smoke { + p.CLNodeDBResourceProfile = DONDBResourceProfile + } + + if tType == Load { + p.EnvTTL = DefaultTTLForLongTests + p.CLNodeResourceProfile = DONResourceProfile + p.NodeFunding = NodeFundingForLoad + p.PhaseTimeout = DefaultPhaseTimeoutForLongTests + } + + allError = multierr.Append(allError, p.SetNetworkPairs(t, lggr)) + ttlDuration, _ := utils.GetEnv("CCIP_KEEP_ENV_TTL") if ttlDuration != "" { keepEnvFor, err := time.ParseDuration(ttlDuration)