Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support configuration file for e2e tests #3260

Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e8e5760
support configuration file for e2e tests
chatton Mar 8, 2023
0d6ad85
return chain a tag if b tag is not specified
chatton Mar 8, 2023
1506784
apply env var overrides correctly
chatton Mar 8, 2023
cb5453b
correctly specify chain IDs
chatton Mar 8, 2023
2da60ba
chore: change tendermint logging to debug for e2e
colin-axner Mar 9, 2023
f8d3fd5
fix: correctly set override
colin-axner Mar 9, 2023
ffd1bc6
Merge branch 'main' into colin/e2e-logging
chatton Mar 10, 2023
5d981e8
adding script to init the config file
chatton Mar 10, 2023
0430410
cleaning up test config merging and fixing init script
chatton Mar 10, 2023
b6d433d
added upgrade configs to sample config
chatton Mar 10, 2023
3d64b25
remove upgrade plans
chatton Mar 10, 2023
5854ee1
added explicit environmental variable name requirement
chatton Mar 10, 2023
58994aa
merge main
chatton Mar 13, 2023
b29c48c
chore: change log level to info
colin-axner Mar 13, 2023
504aa0c
Merge branch 'colin/e2e-logging' of github.com:cosmos/ibc-go into col…
colin-axner Mar 13, 2023
1ce1e55
Merge branch 'main' into colin/e2e-logging
colin-axner Mar 13, 2023
b37861d
Merge branch 'main' into cian/issue#3254-add-support-for-config-file-…
chatton Mar 13, 2023
62ebe60
merge main
chatton Mar 14, 2023
c5ff4ae
cleaned up loading config from env
chatton Mar 14, 2023
2d1a8c7
update to use damiannolan/rly image
chatton Mar 14, 2023
b879999
make init run before e2e test
chatton Mar 14, 2023
69035aa
Merge branch 'colin/e2e-logging' into cian/issue#3254-add-support-for…
chatton Mar 14, 2023
fb99afc
add support for cometbft logging
chatton Mar 14, 2023
163bafa
Merge branch 'main' into cian/issue#3254-add-support-for-config-file-…
chatton Mar 14, 2023
6164983
merge main
chatton Mar 14, 2023
d6c1bd2
Merge branch 'main' into cian/issue#3254-add-support-for-config-file-…
chatton Mar 14, 2023
36ea3c1
changed structure to yaml to enable comments in the config file
chatton Mar 14, 2023
b2fb47e
changed tags to yaml
chatton Mar 14, 2023
a022e9f
Merge branch 'main' into cian/issue#3254-add-support-for-config-file-…
chatton Mar 14, 2023
99ccccc
cleaned up comment in config file
chatton Mar 14, 2023
46caa85
Merge branch 'cian/issue#3254-add-support-for-config-file-for-running…
chatton Mar 14, 2023
f188d36
added option to force dump logs
chatton Mar 14, 2023
0bee55f
Merge branch 'main' into cian/issue#3254-add-support-for-config-file-…
chatton Mar 14, 2023
5c0b820
fixed e2e readme
chatton Mar 14, 2023
03b11dc
correctly handle dumpLogs value
chatton Mar 15, 2023
960b594
Merge branch 'main' into cian/issue#3254-add-support-for-config-file-…
chatton Mar 15, 2023
d6d13df
merge main
chatton Mar 20, 2023
f1d5a0f
Merge branch 'main' into cian/issue#3254-add-support-for-config-file-…
chatton Mar 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions e2e/Makefile
Original file line number Diff line number Diff line change
@@ -7,10 +7,13 @@ cleanup-ibc-test-containers:
$(DOCKER) rm $$id ; \
done

e2e-test: cleanup-ibc-test-containers
init:
./scripts/init.sh

e2e-test: init cleanup-ibc-test-containers
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addition of init here means we shouldn't need to do anything to get the default config created.

./scripts/run-e2e.sh $(test) $(entrypoint)

compatibility-tests:
./scripts/run-compatibility-tests.sh $(release_branch)

.PHONY: cleanup-ibc-test-containers e2e-test compatibility-tests
.PHONY: cleanup-ibc-test-containers e2e-test compatibility-tests init
8 changes: 7 additions & 1 deletion e2e/README.md
Original file line number Diff line number Diff line change
@@ -37,7 +37,13 @@ be quite common in most tests.

Tests can be run using a Makefile target under the e2e directory. `e2e/Makefile`

There are several envinronment variables that alter the behaviour of the make target.
The tests can be configured using a configuration file or environment variables.

See [the example](./sample.config.yaml) to get started. The default location the tests look is `~/.ibc-go-e2e-config.yaml`
But this can be specified directly using the `E2E_CONFIG_PATH` environment variable.

There are several environment variables that alter the behaviour of the make target which will override any
options specified in your config file.

| Environment Variable | Description | Default Value |
|----------------------|-------------------------------------------|---------------|
6 changes: 4 additions & 2 deletions e2e/relayer/relayer.go
Original file line number Diff line number Diff line change
@@ -22,9 +22,11 @@ const (
// Config holds configuration values for the relayer used in the tests.
type Config struct {
// Tag is the tag used for the relayer image.
Tag string
Tag string `yaml:"tag"`
// Type specifies the type of relayer that this is.
Type string
Type string `yaml:"type"`
// Image is the image that should be used for the relayer.
Image string `yaml:"image"`
}

// New returns an implementation of ibc.Relayer depending on the provided RelayerType.
40 changes: 40 additions & 0 deletions e2e/sample.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This file contains configuration for running e2e tests.
# Many of these fields can be overridden with environment variables.
# All fields that support this have the corresponding environment variable name in a comment beside the field.

---
chains:
# the entry at index 0 corresponds to CHAIN_A
- chainId: chain-a
numValidators: 1
numFullNodes: 0
image: ghcr.io/cosmos/ibc-go-simd # override with CHAIN_IMAGE
tag: main # override with CHAIN_A_TAG
binary: simd # override with CHAIN_BINARY

# the entry at index 1 corresponds to CHAIN_B
- chainId: chain-b
numValidators: 1
numFullNodes: 0
image: ghcr.io/cosmos/ibc-go-simd # override with CHAIN_IMAGE
tag: main # override with CHAIN_B_TAG
binary: simd # override with CHAIN_BINARY

relayer:
type: rly # override with RELAYER_TYPE
image: damiannolan/rly
tag: latest # override with RELAYER_TAG

cometbft:
logLevel: info

debug:
# setting this value to true will force log collection even if the test passes.
dumpLogs: false

# Required only for upgrade tests.
# Chain A will be upgraded the specified tag.
# The plan name must be registered as an upgrade handler in the given tag.
upgrade:
planName: ""
tag: ""
20 changes: 20 additions & 0 deletions e2e/scripts/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -euo pipefail

# ensure_config_file makes sure there is a config file for the e2e tests either by creating a new one using the sample,
# it is copied to either the default location or the specified env location.
function ensure_config_file(){
local config_file_path="${HOME}/.ibc-go-e2e-config.yaml"
if [[ ! -z "${E2E_CONFIG_PATH:-}" ]]; then
config_file_path="${E2E_CONFIG_PATH}"
fi
if [[ ! -f "${config_file_path}" ]]; then
echo "creating e2e config file from sample."
echo "copying sample.config.yaml to ${config_file_path}"
cp sample.config.yaml "${config_file_path}"
fi
echo "using config file at ${config_file_path} for e2e test"
}

ensure_config_file
4 changes: 0 additions & 4 deletions e2e/scripts/run-e2e.sh
Original file line number Diff line number Diff line change
@@ -5,10 +5,6 @@ set -eo pipefail
TEST="${1}"
ENTRY_POINT="${2:-}"

export CHAIN_A_TAG="${CHAIN_A_TAG:-main}"
export CHAIN_IMAGE="${CHAIN_IMAGE:-ghcr.io/cosmos/ibc-go-simd}"
export CHAIN_BINARY="${CHAIN_BINARY:-simd}"

# if jq is installed, we can automatically determine the test entrypoint.
if command -v jq > /dev/null; then
cd ..
242 changes: 199 additions & 43 deletions e2e/testconfig/testconfig.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"os"
"path"
"strings"

tmjson "github.com/cometbft/cometbft/libs/json"
@@ -17,6 +18,7 @@ import (
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
interchaintestutil "github.com/strangelove-ventures/interchaintest/v7/testutil"
"gopkg.in/yaml.v2"

"github.com/cosmos/ibc-go/e2e/relayer"
"github.com/cosmos/ibc-go/e2e/semverutil"
@@ -42,6 +44,8 @@ const (
ChainUpgradeTagEnv = "CHAIN_UPGRADE_TAG"
// ChainUpgradePlanEnv specifies the upgrade plan name
ChainUpgradePlanEnv = "CHAIN_UPGRADE_PLAN"
// E2EConfigFilePathEnv allows you to specify a custom path for the config file to be used.
E2EConfigFilePathEnv = "E2E_CONFIG_PATH"

// defaultBinary is the default binary that will be used by the chains.
defaultBinary = "simd"
@@ -52,6 +56,9 @@ const (
defaultChainTag = "main"
// defaultRelayerType is the default relayer that will be used if none is specified.
defaultRelayerType = relayer.Rly
// defaultConfigFileName is the default filename for the config file that can be used to configure
// e2e tests. See sample.config.yaml as an example for what this should look like.
defaultConfigFileName = ".ibc-go-e2e-config.yaml"
)

func getChainImage(binary string) string {
@@ -61,24 +68,160 @@ func getChainImage(binary string) string {
return fmt.Sprintf("ghcr.io/cosmos/ibc-go-%s", binary)
}

// TestConfig holds various fields used in the E2E tests.
// TestConfig holds configuration used throughout the different e2e tests.
type TestConfig struct {
ChainAConfig ChainConfig
ChainBConfig ChainConfig
RelayerConfig relayer.Config
UpgradeTag string
UpgradePlanName string
// ChainConfigs holds configuration values related to the chains used in the tests.
ChainConfigs []ChainConfig `yaml:"chains"`
// RelayerConfig holds configuration for the relayer to be used.
RelayerConfig relayer.Config `yaml:"relayer"`
// UpgradeConfig holds values used only for the upgrade tests.
UpgradeConfig UpgradeConfig `yaml:"upgrade"`
// CometBFTConfig holds values for configuring CometBFT.
CometBFTConfig CometBFTConfig `yaml:"cometbft"`
// DebugConfig holds configuration for miscellaneous options.
DebugConfig DebugConfig `yaml:"debug"`
}

// GetChainNumValidators returns the number of validators for the specific chain index.
// default 1
func (tc TestConfig) GetChainNumValidators(idx int) int {
if tc.ChainConfigs[idx].NumValidators > 0 {
return tc.ChainConfigs[idx].NumValidators
}
return 1
}

// GetChainNumFullNodes returns the number of full nodes for the specific chain index.
// default 0
func (tc TestConfig) GetChainNumFullNodes(idx int) int {
if tc.ChainConfigs[idx].NumFullNodes > 0 {
return tc.ChainConfigs[idx].NumFullNodes
}
return 0
}

// GetChainAID returns the chain-id for chain A.
func (tc TestConfig) GetChainAID() string {
if tc.ChainConfigs[0].ChainID != "" {
return tc.ChainConfigs[0].ChainID
}
return "chain-a"
}

// GetChainBID returns the chain-id for chain B.
func (tc TestConfig) GetChainBID() string {
if tc.ChainConfigs[1].ChainID != "" {
return tc.ChainConfigs[1].ChainID
}
return "chain-b"
}

// UpgradeConfig holds values relevant to upgrade tests.
type UpgradeConfig struct {
PlanName string `yaml:"planName"`
Tag string `yaml:"tag"`
}

// ChainConfig holds information about an individual chain used in the tests.
type ChainConfig struct {
Image string
Tag string
Binary string
ChainID string `yaml:"chainId"`
Image string `yaml:"image"`
Tag string `yaml:"tag"`
Binary string `yaml:"binary"`
NumValidators int `yaml:"numValidators"`
NumFullNodes int `yaml:"numFullNodes"`
}

type CometBFTConfig struct {
LogLevel string `yaml:"logLevel"`
}

type DebugConfig struct {
// DumpLogs forces the logs to be collected before removing test containers.
DumpLogs bool `yaml:"dumpLogs"`
}

// LoadConfig attempts to load a atest configuration from the default file path.
// if any environment variables are specified, they will take precedence over the individual configuration
// options.
func LoadConfig() TestConfig {
fileTc, foundFile := fromFile()
if !foundFile {
return fromEnv()
}
return applyEnvironmentVariableOverrides(fileTc)
}

// fromFile returns a TestConfig from a json file and a boolean indicating if the file was found.
func fromFile() (TestConfig, bool) {
var tc TestConfig
bz, err := os.ReadFile(getConfigFilePath())
if err != nil {
return TestConfig{}, false
}

if err := yaml.Unmarshal(bz, &tc); err != nil {
panic(err)
}

return tc, true
}

// applyEnvironmentVariableOverrides applies all environment variable changes to the config
// loaded from a file.
func applyEnvironmentVariableOverrides(fromFile TestConfig) TestConfig {
envTc := fromEnv()

if os.Getenv(ChainATagEnv) != "" {
fromFile.ChainConfigs[0].Tag = envTc.ChainConfigs[0].Tag
}

if os.Getenv(ChainBTagEnv) != "" {
fromFile.ChainConfigs[1].Tag = envTc.ChainConfigs[1].Tag
}

if os.Getenv(ChainBinaryEnv) != "" {
for i := range fromFile.ChainConfigs {
fromFile.ChainConfigs[i].Binary = envTc.ChainConfigs[i].Binary
}
}

if os.Getenv(ChainImageEnv) != "" {
for i := range fromFile.ChainConfigs {
fromFile.ChainConfigs[i].Image = envTc.ChainConfigs[i].Image
}
}

if os.Getenv(RelayerTagEnv) != "" {
fromFile.RelayerConfig.Tag = envTc.RelayerConfig.Tag
}

if os.Getenv(RelayerTypeEnv) != "" {
fromFile.RelayerConfig.Type = envTc.RelayerConfig.Type
}

if os.Getenv(ChainUpgradePlanEnv) != "" {
fromFile.UpgradeConfig.PlanName = envTc.UpgradeConfig.PlanName
}

if os.Getenv(ChainUpgradeTagEnv) != "" {
fromFile.UpgradeConfig.Tag = envTc.UpgradeConfig.Tag
}

return fromFile
}

// FromEnv returns a TestConfig constructed from environment variables.
func FromEnv() TestConfig {
// fromEnv returns a TestConfig constructed from environment variables.
func fromEnv() TestConfig {
return TestConfig{
ChainConfigs: getChainConfigsFromEnv(),
UpgradeConfig: getUpgradePlanConfigFromEnv(),
RelayerConfig: getRelayerConfigFromEnv(),
}
}

// getChainConfigsFromEnv returns the chain configs from environment variables.
func getChainConfigsFromEnv() []ChainConfig {
chainBinary, ok := os.LookupEnv(ChainBinaryEnv)
if !ok {
chainBinary = defaultBinary
@@ -99,37 +242,37 @@ func FromEnv() TestConfig {
if ok {
chainAImage = specifiedChainImage
}
chainBImage := chainAImage

upgradeTag, ok := os.LookupEnv(ChainUpgradeTagEnv)
if !ok {
upgradeTag = ""
}

upgradePlan, ok := os.LookupEnv(ChainUpgradePlanEnv)
if !ok {
upgradePlan = ""
}

return TestConfig{
ChainAConfig: ChainConfig{
chainBImage := chainAImage
return []ChainConfig{
{
Image: chainAImage,
Tag: chainATag,
Binary: chainBinary,
},
ChainBConfig: ChainConfig{
{
Image: chainBImage,
Tag: chainBTag,
Binary: chainBinary,
},
UpgradeTag: upgradeTag,
UpgradePlanName: upgradePlan,
RelayerConfig: GetRelayerConfigFromEnv(),
}
}

// GetRelayerConfigFromEnv returns the RelayerConfig from present environment variables.
func GetRelayerConfigFromEnv() relayer.Config {
// getConfigFilePath returns the absolute path where the e2e config file should be.
func getConfigFilePath() string {
if absoluteConfigPath := os.Getenv(E2EConfigFilePathEnv); absoluteConfigPath != "" {
return absoluteConfigPath
}

homeDir, err := os.UserHomeDir()
if err != nil {
panic(err)
}
return path.Join(homeDir, defaultConfigFileName)
}

// getRelayerConfigFromEnv returns the RelayerConfig from present environment variables.
func getRelayerConfigFromEnv() relayer.Config {
relayerType := strings.TrimSpace(os.Getenv(RelayerTypeEnv))
if relayerType == "" {
relayerType = defaultRelayerType
@@ -150,20 +293,32 @@ func GetRelayerConfigFromEnv() relayer.Config {
}
}

func GetChainATag() string {
chainATag, ok := os.LookupEnv(ChainATagEnv)
// getUpgradePlanConfigFromEnv returns the upgrade config from environment variables.
func getUpgradePlanConfigFromEnv() UpgradeConfig {
upgradeTag, ok := os.LookupEnv(ChainUpgradeTagEnv)
if !ok {
upgradeTag = ""
}

upgradePlan, ok := os.LookupEnv(ChainUpgradePlanEnv)
if !ok {
panic(fmt.Sprintf("no environment variable specified for %s", ChainATagEnv))
upgradePlan = ""
}
return UpgradeConfig{
PlanName: upgradePlan,
Tag: upgradeTag,
}
return chainATag
}

func GetChainATag() string {
return LoadConfig().ChainConfigs[0].Tag
}

func GetChainBTag() string {
chainBTag, ok := os.LookupEnv(ChainBTagEnv)
if !ok {
return GetChainATag()
if chainBTag := LoadConfig().ChainConfigs[1].Tag; chainBTag != "" {
return chainBTag
}
return chainBTag
return GetChainATag()
}

// IsCI returns true if the tests are running in CI, false is returned
@@ -187,21 +342,22 @@ type ChainOptionConfiguration func(options *ChainOptions)
// DefaultChainOptions returns the default configuration for the chains.
// These options can be configured by passing configuration functions to E2ETestSuite.GetChains.
func DefaultChainOptions() ChainOptions {
tc := FromEnv()
chainACfg := newDefaultSimappConfig(tc.ChainAConfig, "simapp-a", "chain-a", "atoma")
chainBCfg := newDefaultSimappConfig(tc.ChainBConfig, "simapp-b", "chain-b", "atomb")
tc := LoadConfig()

chainACfg := newDefaultSimappConfig(tc.ChainConfigs[0], "simapp-a", tc.GetChainAID(), "atoma", tc.CometBFTConfig)
chainBCfg := newDefaultSimappConfig(tc.ChainConfigs[1], "simapp-b", tc.GetChainBID(), "atomb", tc.CometBFTConfig)
return ChainOptions{
ChainAConfig: &chainACfg,
ChainBConfig: &chainBCfg,
}
}

// newDefaultSimappConfig creates an ibc configuration for simd.
func newDefaultSimappConfig(cc ChainConfig, name, chainID, denom string) ibc.ChainConfig {
func newDefaultSimappConfig(cc ChainConfig, name, chainID, denom string, cometCfg CometBFTConfig) ibc.ChainConfig {
configFileOverrides := make(map[string]any)
tmTomlOverrides := make(interchaintestutil.Toml)

tmTomlOverrides["log_level"] = "info" // change to debug to increase cometbft logging
tmTomlOverrides["log_level"] = cometCfg.LogLevel // change to debug in ~/.ibc-go-e2e-config.json to increase cometbft logging.
configFileOverrides["config/config.toml"] = tmTomlOverrides

return ibc.ChainConfig{
26 changes: 13 additions & 13 deletions e2e/tests/upgrades/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -37,9 +37,9 @@ const (
)

func TestUpgradeTestSuite(t *testing.T) {
testCfg := testconfig.FromEnv()
if testCfg.UpgradeTag == "" || testCfg.UpgradePlanName == "" {
t.Fatal("upgrade tag and upgrade plan name must be provided in test configuration")
testCfg := testconfig.LoadConfig()
if testCfg.UpgradeConfig.Tag == "" || testCfg.UpgradeConfig.PlanName == "" {
t.Fatalf("%s and %s must be set when running an upgrade test", testconfig.ChainUpgradeTagEnv, testconfig.ChainUpgradePlanEnv)
}

suite.Run(t, new(UpgradeTestSuite))
@@ -96,7 +96,7 @@ func (s *UpgradeTestSuite) UpgradeChain(ctx context.Context, chain *cosmos.Cosmo

func (s *UpgradeTestSuite) TestIBCChainUpgrade() {
t := s.T()
testCfg := testconfig.FromEnv()
testCfg := testconfig.LoadConfig()

ctx := context.Background()
relayer, channelA := s.SetupChainsRelayerAndChannel(ctx)
@@ -153,7 +153,7 @@ func (s *UpgradeTestSuite) TestIBCChainUpgrade() {
s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA, chainB), "failed to wait for blocks")

t.Run("upgrade chainA", func(t *testing.T) {
s.UpgradeChain(ctx, chainA, chainAUpgradeProposalWallet, testCfg.UpgradePlanName, testCfg.ChainAConfig.Tag, testCfg.UpgradeTag)
s.UpgradeChain(ctx, chainA, chainAUpgradeProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
})

t.Run("restart relayer", func(t *testing.T) {
@@ -229,10 +229,10 @@ func (s *UpgradeTestSuite) TestChainUpgrade() {
})

t.Run("upgrade chain", func(t *testing.T) {
testCfg := testconfig.FromEnv()
testCfg := testconfig.LoadConfig()
proposerWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)

s.UpgradeChain(ctx, chain, proposerWallet, testCfg.UpgradePlanName, testCfg.ChainAConfig.Tag, testCfg.UpgradeTag)
s.UpgradeChain(ctx, chain, proposerWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
})

t.Run("send funds to test wallet", func(t *testing.T) {
@@ -255,7 +255,7 @@ func (s *UpgradeTestSuite) TestChainUpgrade() {

func (s *UpgradeTestSuite) TestV5ToV6ChainUpgrade() {
t := s.T()
testCfg := testconfig.FromEnv()
testCfg := testconfig.LoadConfig()

ctx := context.Background()
relayer, _ := s.SetupChainsRelayerAndChannel(ctx)
@@ -353,7 +353,7 @@ func (s *UpgradeTestSuite) TestV5ToV6ChainUpgrade() {
s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA, chainB), "failed to wait for blocks")

t.Run("upgrade chainA", func(t *testing.T) {
s.UpgradeChain(ctx, chainA, chainAUpgradeProposalWallet, testCfg.UpgradePlanName, testCfg.ChainAConfig.Tag, testCfg.UpgradeTag)
s.UpgradeChain(ctx, chainA, chainAUpgradeProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
})

t.Run("restart relayer", func(t *testing.T) {
@@ -458,7 +458,7 @@ func (s *UpgradeTestSuite) TestV5ToV6ChainUpgrade() {
// can be sent before and after the upgrade without issue
func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() {
t := s.T()
testCfg := testconfig.FromEnv()
testCfg := testconfig.LoadConfig()

ctx := context.Background()
relayer, channelA := s.SetupChainsRelayerAndChannel(ctx)
@@ -569,7 +569,7 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() {
chainAUpgradeProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)

t.Run("upgrade chainA", func(t *testing.T) {
s.UpgradeChain(ctx, chainA, chainAUpgradeProposalWallet, testCfg.UpgradePlanName, testCfg.ChainAConfig.Tag, testCfg.UpgradeTag)
s.UpgradeChain(ctx, chainA, chainAUpgradeProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
})

t.Run("check that the tendermint clients are active again after upgrade", func(t *testing.T) {
@@ -607,7 +607,7 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() {

func (s *UpgradeTestSuite) TestV7ChainUpgradeAddLocalhost() {
t := s.T()
testCfg := testconfig.FromEnv()
testCfg := testconfig.LoadConfig()

ctx := context.Background()
_, _ = s.SetupChainsRelayerAndChannel(ctx)
@@ -617,7 +617,7 @@ func (s *UpgradeTestSuite) TestV7ChainUpgradeAddLocalhost() {

t.Run("upgrade chain", func(t *testing.T) {
govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
s.UpgradeChain(ctx, chain, govProposalWallet, testCfg.UpgradePlanName, testCfg.ChainAConfig.Tag, testCfg.UpgradeTag)
s.UpgradeChain(ctx, chain, govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
})

t.Run("ensure the localhost client is active and sentinel connection is stored in state", func(t *testing.T) {
17 changes: 11 additions & 6 deletions e2e/testsuite/diagnostics/diagnostics.go
Original file line number Diff line number Diff line change
@@ -18,18 +18,23 @@ import (
)

const (
e2eDir = "e2e"
defaultFilePerm = 0o750
dockerInspectFileName = "docker-inspect.json"
e2eDir = "e2e"
defaultFilePerm = 0o750
)

// Collect can be used in `t.Cleanup` and will copy all the of the container logs and relevant files
// into e2e/<test-suite>/<test-name>.log. These log files will be uploaded to GH upon test failure.
func Collect(t *testing.T, dc *dockerclient.Client, cfg testconfig.ChainOptions) {
t.Helper()

if !t.Failed() {
t.Logf("test passed, not uploading logs")
return
debugCfg := testconfig.LoadConfig().DebugConfig
if !debugCfg.DumpLogs {
// when we are not forcing log collection, we only upload upon test failing.
if !t.Failed() {
t.Logf("test passed, not uploading logs")
return
}
}

t.Logf("writing logs for test: %s", t.Name())
@@ -87,7 +92,7 @@ func Collect(t *testing.T, dc *dockerclient.Client, cfg testconfig.ChainOptions)
t.Logf("successfully wrote diagnostics file %s", absoluteFilePathInContainer)
}

localFilePath := ospath.Join(containerDir, "docker-inspect.json")
localFilePath := ospath.Join(containerDir, dockerInspectFileName)
if err := fetchAndWriteDockerInspectOutput(ctx, dc, container.ID, localFilePath); err != nil {
t.Logf("failed to fetch docker inspect output: %s", err)
continue
14 changes: 8 additions & 6 deletions e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ func (s *E2ETestSuite) GetRelayerUsers(ctx context.Context, chainOpts ...testcon
func (s *E2ETestSuite) SetupChainsRelayerAndChannel(ctx context.Context, channelOpts ...func(*ibc.CreateChannelOptions)) (ibc.Relayer, ibc.ChannelOutput) {
chainA, chainB := s.GetChains()

r := relayer.New(s.T(), testconfig.FromEnv().RelayerConfig, s.logger, s.DockerClient, s.network)
r := relayer.New(s.T(), testconfig.LoadConfig().RelayerConfig, s.logger, s.DockerClient, s.network)

pathName := s.generatePathName()

@@ -464,9 +464,9 @@ func (s *E2ETestSuite) createCosmosChains(chainOptions testconfig.ChainOptions)

logger := zaptest.NewLogger(t)

numValidators, numFullNodes := getValidatorsAndFullNodes()

numValidators, numFullNodes := getValidatorsAndFullNodes(0)
chainA := cosmos.NewCosmosChain(t.Name(), *chainOptions.ChainAConfig, numValidators, numFullNodes, logger)
numValidators, numFullNodes = getValidatorsAndFullNodes(1)
chainB := cosmos.NewCosmosChain(t.Name(), *chainOptions.ChainBConfig, numValidators, numFullNodes, logger)

// this is intentionally called after the interchaintest.DockerSetup function. The above function registers a
@@ -617,11 +617,13 @@ func GetIBCToken(fullTokenDenom string, portID, channelID string) transfertypes.
}

// getValidatorsAndFullNodes returns the number of validators and full nodes respectively that should be used for
// the test. If the test is running in CI, more nodes are used, when running locally a single node is used to
// the test. If the test is running in CI, more nodes are used, when running locally a single node is used by default to
// use less resources and allow the tests to run faster.
func getValidatorsAndFullNodes() (int, int) {
// both the number of validators and full nodes can be overwritten in a config file.
func getValidatorsAndFullNodes(chainIdx int) (int, int) {
if testconfig.IsCI() {
return 4, 1
}
return 1, 0
tc := testconfig.LoadConfig()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

return tc.GetChainNumValidators(chainIdx), tc.GetChainNumFullNodes(chainIdx)
}