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

Make keep containers configurable #6795

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion e2e/sample.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ activeRelayer: hermes # override with RELAYER_ID
relayers:
- id: hermes
image: ghcr.io/informalsystems/hermes
tag: "v1.7.0"
tag: "1.10.0"
- id: rly
image: ghcr.io/cosmos/relayer
tag: "latest"
Expand All @@ -38,6 +38,8 @@ cometbft:
debug:
# setting this value to true will force log collection even if the test passes.
dumpLogs: false
# settings this value to true will keep the containers running after the test finishes.
keepContainers: true

# Required only for upgrade tests.
# Chain A will be upgraded the specified tag.
Expand Down
21 changes: 19 additions & 2 deletions e2e/testsuite/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const (
ChainUpgradePlanEnv = "CHAIN_UPGRADE_PLAN"
// E2EConfigFilePathEnv allows you to specify a custom path for the config file to be used.
E2EConfigFilePathEnv = "E2E_CONFIG_PATH"
// KeepContainersEnv instructs interchaintest to not delete the containers after a test has run.
// this ensures that chain containers are not deleted after a test suite is run if other tests
// depend on those chains.
KeepContainersEnv = "KEEP_CONTAINERS"

// defaultBinary is the default binary that will be used by the chains.
defaultBinary = "simd"
Expand Down Expand Up @@ -297,6 +301,11 @@ type DebugConfig struct {

// GenesisDebug contains debug information specific to Genesis.
GenesisDebug GenesisDebugConfig `yaml:"genesis"`

// KeepContainers specifies if the containers should be kept after the test suite is done.
// NOTE: when running a full test suite, this value should be set to true in order to preserve
// shared resources.
KeepContainers bool `yaml:"keepContainers"`
}

// LoadConfig attempts to load a atest configuration from the default file path.
Expand Down Expand Up @@ -372,6 +381,10 @@ func applyEnvironmentVariableOverrides(fromFile TestConfig) TestConfig {
fromFile.UpgradeConfig.Tag = envTc.UpgradeConfig.Tag
}

if isEnvTrue(KeepContainersEnv) {
fromFile.DebugConfig.KeepContainers = true
}

return fromFile
}

Expand Down Expand Up @@ -513,12 +526,16 @@ func GetChainBTag() string {
// if the tests are running locally.
// Note: github actions passes a CI env value of true by default to all runners.
func IsCI() bool {
return strings.ToLower(os.Getenv("CI")) == "true"
return isEnvTrue("CI")
}

// IsFork returns true if the tests are running in fork mode, false is returned otherwise.
func IsFork() bool {
return strings.ToLower(os.Getenv("FORK")) == "true"
return isEnvTrue("FORK")
}

func isEnvTrue(env string) bool {
return strings.ToLower(os.Getenv(env)) == "true"
}

// ChainOptions stores chain configurations for the chains that will be
Expand Down
4 changes: 3 additions & 1 deletion e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ func (s *E2ETestSuite) initalizeRelayerPool(n int) []ibc.Relayer {
func (s *E2ETestSuite) SetupChains(ctx context.Context, channelOptionsModifier ChainOptionModifier, chainSpecOpts ...ChainOptionConfiguration) {
s.T().Logf("Setting up chains: %s", s.T().Name())

s.Require().NoError(os.Setenv("KEEP_CONTAINERS", "true"))
if LoadConfig().DebugConfig.KeepContainers {
s.Require().NoError(os.Setenv(KeepContainersEnv, "true"))
}

s.initState()
s.configureGenesisDebugExport()
Expand Down
Loading