From 1f26317de805ef18c6997cd3a07de19e07807241 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Tue, 3 Dec 2024 11:04:08 +0000 Subject: [PATCH] Simplify E2E Configuration (#7568) * chore: replacing some environment variables with path to config file * chore: removed fields from workflow call * chore: remove e2e prefix directory * chore: read relative files correctly * chore: update path in workflows * chore: fix e2e-linting * chore: simplifying upgrade configuration * chore: fix unmarshalling error, default to ci config file * chore: adding back chain-image * chore: use GetUpgradeConfig function * chore: correctly specify upgrade plan env * chore: fix issue with directory function, bump timeout * chore: fix linter * chore: addressing PR feedback * chore: specify v9 as chain B in upgrade test --------- Co-authored-by: Gjermund Garaba --- .../e2e-compatibility-workflow-call.yaml | 2 - .github/workflows/e2e-fork.yml | 1 - .github/workflows/e2e-test-workflow-call.yml | 53 ++----- .github/workflows/e2e-upgrade.yaml | 129 ++-------------- .github/workflows/e2e-wasm.yaml | 2 - .github/workflows/e2e.yaml | 2 - e2e/ci-e2e-config.yaml | 70 +++++++++ e2e/internal/directories/directories.go | 7 +- e2e/sample.config.extended.yaml | 21 ++- e2e/tests/upgrades/upgrade_test.go | 28 ++-- e2e/tests/wasm/upgrade_test.go | 7 +- e2e/testsuite/diagnostics/diagnostics.go | 2 +- e2e/testsuite/testconfig.go | 143 +++++++++++------- e2e/testsuite/testsuite.go | 5 +- 14 files changed, 215 insertions(+), 257 deletions(-) create mode 100644 e2e/ci-e2e-config.yaml diff --git a/.github/workflows/e2e-compatibility-workflow-call.yaml b/.github/workflows/e2e-compatibility-workflow-call.yaml index 2ae3acdc724..3d794bed9fc 100644 --- a/.github/workflows/e2e-compatibility-workflow-call.yaml +++ b/.github/workflows/e2e-compatibility-workflow-call.yaml @@ -60,10 +60,8 @@ jobs: # Note: this is significant as the standard behaviour when running e2es on PRs # is that there is a set of env vars that are the same for each run. e.g. the same docker image is used # for every test. With compatibility tests, each test may be running different combinations of images. - CHAIN_IMAGE: 'ghcr.io/cosmos/ibc-go-simd' CHAIN_A_TAG: '${{ matrix.chain-a }}' CHAIN_B_TAG: '${{ matrix.chain-b }}' - CHAIN_BINARY: 'simd' RELAYER_ID: '${{ matrix.relayer-type }}' - name: Upload Diagnostics uses: actions/upload-artifact@v4 diff --git a/.github/workflows/e2e-fork.yml b/.github/workflows/e2e-fork.yml index afa3ed79dc6..1347ec5d91a 100644 --- a/.github/workflows/e2e-fork.yml +++ b/.github/workflows/e2e-fork.yml @@ -59,7 +59,6 @@ jobs: CHAIN_A_TAG: latest CHAIN_B_TAG: latest CHAIN_IMAGE: ibc-go-simd - RELAYER_ID: "hermes" # by default use hermes for fork e2es. FORK: "true" # run this job on forks and copies of ibc-go, for example: a public fork or a private copy of ibc-go. if: ${{ github.repository != 'cosmos/ibc-go' || github.event.pull_request.head.repo.fork || github.actor == 'dependabot[bot]' || github.event_name == 'workflow_dispatch' }} diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index ba59316f191..937218f4f34 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -23,7 +23,7 @@ on: default: '' # empty string means don't skip any test. chain-image: description: 'The image to use for chains' - required: true + required: false type: string default: 'ghcr.io/cosmos/ibc-go-simd' chain-a-tag: @@ -36,37 +36,12 @@ on: description: 'The tag to use for chain B' required: true type: string - chain-binary: - default: 'simd' - description: 'The chain binary' - required: false - type: string - chain-upgrade-tag: - default: '' - description: 'The image tag that the chain will be upgraded to' - required: false - type: string # upgrade-plan-name is only required during upgrade tests, and is otherwise ignored. upgrade-plan-name: default: '' description: 'The upgrade plan name' required: false type: string - relayer-image: - description: 'The image to use for the relayer' - required: false - default: '' # the tests themselves will choose a sensible default when unset. - type: string - relayer-type: - description: 'The type of relayer to use' - required: false - default: 'hermes' - type: string - relayer-tag: - description: 'The tag to use for the relayer' - required: false - default: '' # the tests themselves will choose a sensible default when unset. - type: string build-and-push-docker-image: description: 'Flag to specify if the docker image should be built and pushed beforehand' required: false @@ -82,6 +57,11 @@ on: required: false type: boolean default: false + e2e-config-path: + description: 'Specify relative or absolute path of config file for test' + required: false + type: string + default: 'ci-e2e-config.yaml' env: REGISTRY: ghcr.io @@ -98,11 +78,7 @@ jobs: echo "Chain Image: ${{ inputs.chain-image }}" echo "Chain A Tag: ${{ inputs.chain-a-tag }}" echo "Chain B Tag: ${{ inputs.chain-b-tag }}" - echo "Chain Upgrade Tag: ${{ inputs.chain-upgrade-tag }}" echo "Upgrade Plan Name: ${{ inputs.upgrade-plan-name }}" - echo "Relayer Image:" ${{ inputs.relayer-image }} - echo "Relayer Type: ${{ inputs.relayer-type }}" - echo "Relayer Tag: ${{ inputs.relayer-tag }}" echo "Test Entry Point: ${{ inputs.test-entry-point }}" echo "Test: ${{ inputs.test }}" echo "Github Ref Name: ${{ github.ref_name }}" @@ -226,14 +202,10 @@ jobs: - docker-build-wasm env: CHAIN_IMAGE: '${{ inputs.chain-image }}' + CHAIN_UPGRADE_PLAN: '${{ inputs.upgrade-plan-name }}' CHAIN_A_TAG: '${{ inputs.chain-a-tag }}' CHAIN_B_TAG: '${{ inputs.chain-b-tag }}' - RELAYER_IMAGE: '${{ inputs.relayer-image }}' - RELAYER_TAG: '${{ inputs.relayer-tag }}' - RELAYER_ID: '${{ inputs.relayer-type }}' - CHAIN_BINARY: '${{ inputs.chain-binary }}' - CHAIN_UPGRADE_TAG: '${{ inputs.chain-upgrade-tag }}' - CHAIN_UPGRADE_PLAN: '${{ inputs.upgrade-plan-name }}' + E2E_CONFIG_PATH: '${{ inputs.e2e-config-path }}' strategy: fail-fast: false matrix: ${{ fromJSON(needs.build-test-matrix.outputs.matrix) }} @@ -271,14 +243,7 @@ jobs: CHAIN_IMAGE: '${{ inputs.chain-image }}' CHAIN_A_TAG: '${{ inputs.chain-a-tag }}' CHAIN_B_TAG: '${{ inputs.chain-b-tag }}' - RELAYER_IMAGE: '${{ inputs.relayer-image }}' - RELAYER_TAG: '${{ inputs.relayer-tag }}' - RELAYER_ID: '${{ inputs.relayer-type }}' - CHAIN_BINARY: '${{ inputs.chain-binary }}' - CHAIN_UPGRADE_TAG: '${{ inputs.chain-upgrade-tag }}' - CHAIN_UPGRADE_PLAN: '${{ inputs.upgrade-plan-name }}' - # explicitly set to true so that if a test fails, it doesn't delete the chain and cause other tests to fail. - KEEP_CONTAINERS: "true" + E2E_CONFIG_PATH: '${{ inputs.e2e-config-path }}' strategy: fail-fast: false matrix: diff --git a/.github/workflows/e2e-upgrade.yaml b/.github/workflows/e2e-upgrade.yaml index 25a906c966b..adca6a3d2e9 100644 --- a/.github/workflows/e2e-upgrade.yaml +++ b/.github/workflows/e2e-upgrade.yaml @@ -5,215 +5,110 @@ on: branches: - main paths: - # upgrade tests will run on any changes to the upgrade_test.go file. + # upgrade tests will run on any changes to the upgrade_test.go file, + # and changes to the workflow itself. - 'e2e/tests/upgrades/upgrade_test.go' + - '.github/workflows/e2e-upgrade.yaml' schedule: - cron: '0 0 * * *' jobs: - upgrade-v7-hermes: + upgrade-v7: uses: ./.github/workflows/e2e-test-workflow-call.yml with: chain-image: ghcr.io/cosmos/ibc-go-simd - chain-binary: simd chain-a-tag: v6.1.0 chain-b-tag: v6.1.0 - chain-upgrade-tag: v7.0.0 upgrade-plan-name: "v7" test-entry-point: "TestUpgradeTestSuite" test: "TestV6ToV7ChainUpgrade" upload-logs: true - relayer-type: hermes - upgrade-v7_1-hermes: + upgrade-v7_1: uses: ./.github/workflows/e2e-test-workflow-call.yml with: chain-image: ghcr.io/cosmos/ibc-go-simd - chain-binary: simd chain-a-tag: v7.0.0 chain-b-tag: v7.0.0 - chain-upgrade-tag: v7.1.0 upgrade-plan-name: "v7.1" test-entry-point: "TestUpgradeTestSuite" test: "TestV7ToV7_1ChainUpgrade" upload-logs: true - relayer-type: hermes - upgrade-v8-hermes: + upgrade-v8: uses: ./.github/workflows/e2e-test-workflow-call.yml with: chain-image: ghcr.io/cosmos/ibc-go-simd - chain-binary: simd chain-a-tag: v7.0.0 chain-b-tag: v7.0.0 - chain-upgrade-tag: v8.0.0 upgrade-plan-name: "v8" test-entry-point: "TestUpgradeTestSuite" test: "TestV7ToV8ChainUpgrade" upload-logs: true - relayer-type: hermes - upgrade-v8_1-hermes: + upgrade-v8_1: uses: ./.github/workflows/e2e-test-workflow-call.yml with: chain-image: ghcr.io/cosmos/ibc-go-simd - chain-binary: simd chain-a-tag: v8.0.0 chain-b-tag: v8.0.0 - chain-upgrade-tag: v8.1.0 upgrade-plan-name: "v8.1" test-entry-point: "TestUpgradeTestSuite" test: "TestV8ToV8_1ChainUpgrade" upload-logs: true - relayer-type: hermes - upgrade-v8_1-channel-upgrades-hermes: + upgrade-v8_1-channel-upgrades: uses: ./.github/workflows/e2e-test-workflow-call.yml with: chain-image: ghcr.io/cosmos/ibc-go-simd - chain-binary: simd chain-a-tag: v8.0.0 chain-b-tag: v8.0.0 - chain-upgrade-tag: v8.1.0 upgrade-plan-name: "v8.1" test-entry-point: "TestUpgradeTestSuite" test: "TestV8ToV8_1ChainUpgrade_FeeMiddlewareChannelUpgrade" upload-logs: true - relayer-type: hermes - upgrade-v7-rly: - uses: ./.github/workflows/e2e-test-workflow-call.yml - with: - chain-image: ghcr.io/cosmos/ibc-go-simd - chain-binary: simd - chain-a-tag: v6.1.0 - chain-b-tag: v6.1.0 - chain-upgrade-tag: v7.0.0 - upgrade-plan-name: "v7" - test-entry-point: "TestUpgradeTestSuite" - test: "TestV6ToV7ChainUpgrade" - upload-logs: true - relayer-type: rly - relayer-image: ghcr.io/cosmos/relayer - relayer-tag: latest - - upgrade-v7_1-rly: - uses: ./.github/workflows/e2e-test-workflow-call.yml - with: - chain-image: ghcr.io/cosmos/ibc-go-simd - chain-binary: simd - chain-a-tag: v7.0.0 - chain-b-tag: v7.0.0 - chain-upgrade-tag: v7.1.0 - upgrade-plan-name: "v7.1" - test-entry-point: "TestUpgradeTestSuite" - test: "TestV7ToV7_1ChainUpgrade" - upload-logs: true - relayer-type: rly - relayer-image: ghcr.io/cosmos/relayer - relayer-tag: latest - - upgrade-v8-rly: - uses: ./.github/workflows/e2e-test-workflow-call.yml - with: - chain-image: ghcr.io/cosmos/ibc-go-simd - chain-binary: simd - chain-a-tag: v7.0.0 - chain-b-tag: v7.0.0 - chain-upgrade-tag: v8.0.0 - upgrade-plan-name: "v8" - test-entry-point: "TestUpgradeTestSuite" - test: "TestV7ToV8ChainUpgrade" - upload-logs: true - relayer-type: rly - relayer-image: ghcr.io/cosmos/relayer - relayer-tag: latest - - upgrade-v8_1-rly: - uses: ./.github/workflows/e2e-test-workflow-call.yml - with: - chain-image: ghcr.io/cosmos/ibc-go-simd - chain-binary: simd - chain-a-tag: v8.0.0 - chain-b-tag: v8.0.0 - chain-upgrade-tag: v8.1.0 - upgrade-plan-name: "v8.1" - test-entry-point: "TestUpgradeTestSuite" - test: "TestV8ToV8_1ChainUpgrade" - upload-logs: true - relayer-type: rly - relayer-image: ghcr.io/cosmos/relayer - relayer-tag: latest - - upgrade-ibcwasm-v8-hermes: + upgrade-ibcwasm-v8: uses: ./.github/workflows/e2e-test-workflow-call.yml with: chain-image: ghcr.io/cosmos/ibc-go-wasm-simd - chain-binary: simd chain-a-tag: v7.3.0-e2e-upgrade chain-b-tag: v7.3.0-e2e-upgrade - chain-upgrade-tag: v8.0.0-e2e-upgrade upgrade-plan-name: "ibcwasm-v8" test-entry-point: "TestIBCWasmUpgradeTestSuite" test: "TestIBCWasmChainUpgrade" upload-logs: true - relayer-type: hermes - - upgrade-v9-hermes: - uses: ./.github/workflows/e2e-test-workflow-call.yml - with: - chain-image: ghcr.io/cosmos/ibc-go-simd - chain-binary: simd - chain-a-tag: v8.4.0 - chain-b-tag: v8.4.0 - chain-upgrade-tag: main # TODO: Update tag to v9.0.0 once it is (pre)released - upgrade-plan-name: "v9" - test-entry-point: "TestUpgradeTestSuite" - test: "TestV8ToV9ChainUpgrade" - upload-logs: true - relayer-type: hermes - upgrade-v9-rly: + upgrade-v9: uses: ./.github/workflows/e2e-test-workflow-call.yml with: chain-image: ghcr.io/cosmos/ibc-go-simd - chain-binary: simd chain-a-tag: v8.4.0 chain-b-tag: v8.4.0 - chain-upgrade-tag: main # TODO: Update tag to v9.0.0 once it is (pre)released upgrade-plan-name: "v9" test-entry-point: "TestUpgradeTestSuite" test: "TestV8ToV9ChainUpgrade" upload-logs: true - relayer-type: rly - relayer-image: ghcr.io/cosmos/relayer - relayer-tag: latest upgrade-v9-localhost: uses: ./.github/workflows/e2e-test-workflow-call.yml with: chain-image: ghcr.io/cosmos/ibc-go-simd - chain-binary: simd chain-a-tag: v8.4.0 chain-b-tag: v8.4.0 - chain-upgrade-tag: main # TODO: Update tag to v9.0.0 once it is (pre)released upgrade-plan-name: "v9" test-entry-point: "TestUpgradeTestSuite" test: "TestV8ToV9ChainUpgrade_Localhost" upload-logs: true - relayer-type: hermes - upgrade-v9-channel-upgrades-hermes: + upgrade-v9-channel-upgrades: uses: ./.github/workflows/e2e-test-workflow-call.yml with: chain-image: ghcr.io/cosmos/ibc-go-simd - chain-binary: simd chain-a-tag: v8.4.0 - chain-b-tag: main # TODO: Update tag to v9.0.0 once it is (pre)released - chain-upgrade-tag: main # TODO: Update tag to v9.0.0 once it is (pre)released + chain-b-tag: v9.0.0 upgrade-plan-name: "v9" test-entry-point: "TestUpgradeTestSuite" test: "TestV8ToV9ChainUpgrade_ICS20v2ChannelUpgrade" upload-logs: true - relayer-type: hermes diff --git a/.github/workflows/e2e-wasm.yaml b/.github/workflows/e2e-wasm.yaml index ae3ec51725a..91252bf3da5 100644 --- a/.github/workflows/e2e-wasm.yaml +++ b/.github/workflows/e2e-wasm.yaml @@ -62,11 +62,9 @@ jobs: build-and-push-docker-image-wasm: true # if the test fails, we upload logs so that we can download them from the UI. upload-logs: true - chain-image: ghcr.io/cosmos/ibc-go-wasm-simd # with regular tests, both images are the same. chain-a-tag: '${{ needs.determine-image-tag.outputs.simd-tag }}' chain-b-tag: '${{ needs.determine-image-tag.outputs.simd-tag }}' - chain-binary: 'simd' # only run the grandpa test suite for wasm tests. test-entry-point: 'TestGrandpaTestSuite' # exclude transfer tests which rely on removed packet event attributes: # https://github.com/cosmos/ibc-go/issues/6243 diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 26fac5536ab..8b8a0300a8f 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -61,11 +61,9 @@ jobs: build-and-push-docker-image: true # if the test fails, we upload logs so that we can download them from the UI. upload-logs: true - chain-image: ghcr.io/cosmos/ibc-go-simd # with regular tests, both images are the same. chain-a-tag: '${{ needs.determine-image-tag.outputs.simd-tag }}' chain-b-tag: '${{ needs.determine-image-tag.outputs.simd-tag }}' - chain-binary: 'simd' # on regular PRs we won't run upgrade tests. # NOTE: we are exluding TestTransferTestSuite as we run this full suite instead of each individual test. test-exclusions: 'TestUpgradeTestSuite,TestGrandpaTestSuite,TestIBCWasmUpgradeTestSuite,TestTransferTestSuite,TestAuthzTransferTestSuite,TestTransferTestSuiteSendReceive,TestTransferTestSuiteSendEnabled,TestTransferLocalhostTestSuite,TestConnectionTestSuite,TestInterchainAccountsGovTestSuite,TestIncentivizedTransferTestSuite,TestTransferForwardingTestSuite' diff --git a/e2e/ci-e2e-config.yaml b/e2e/ci-e2e-config.yaml new file mode 100644 index 00000000000..3077cd5ef96 --- /dev/null +++ b/e2e/ci-e2e-config.yaml @@ -0,0 +1,70 @@ +# 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. + + +# | Environment Variable | Description | Default Value | +# |----------------------|-------------------------------------------|------------------------------| +# | CHAIN_IMAGE | The image that will be used for the chain | ghcr.io/cosmos/ibc-go-simd | +# | CHAIN_A_TAG | The tag used for chain A | N/A (must be set) | +# | CHAIN_B_TAG | The tag used for chain B | N/A (must be set) | +# | CHAIN_BINARY | The binary used in the container | simd | +# | RELAYER_TAG | The tag used for the relayer | 1.10.0 | +# | RELAYER_ID | The type of relayer to use (rly/hermes) | hermes | + + +# see sample.config.yaml for a bare minimum configuration example. +# set env E2E_CONFIG_PATH to point to this file to use it. +--- +chains: + # the entry at index 0 corresponds to CHAIN_A + - chainId: chainA-1 + numValidators: 4 + numFullNodes: 1 + image: ghcr.io/cosmos/ibc-go-simd # override with CHAIN_IMAGE + binary: simd # override with CHAIN_BINARY + + # the entry at index 1 corresponds to CHAIN_B + - chainId: chainB-1 + numValidators: 4 + numFullNodes: 1 + image: ghcr.io/cosmos/ibc-go-simd # override with CHAIN_IMAGE + binary: simd # override with CHAIN_BINARY + +# activeRelayer must match the id of a relayer specified in the relayers list below. +activeRelayer: hermes # override with RELAYER_ID + +relayers: + - id: hermes + image: ghcr.io/informalsystems/hermes + tag: "1.10.0" + - id: rly + image: ghcr.io/cosmos/relayer + tag: "latest" + - id: hyperspace + image: ghcr.io/misko9/hyperspace + tag: "20231122v39" + +cometbft: + logLevel: info + +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 + +upgradePlanName: "" +upgrades: + - planName: "v7" + tag: "v7.0.0" + - planName: "v7.1" + tag: "v7.1.0" + - planName: "v8" + tag: "v8.0.0" + - planName: "v8.1" + tag: "v8.1.0" + - planName: "v9" + tag: "v9.0.0" + - planName: "ibcwasm-v8" + tag: "v8.0.0-e2e-upgrade" diff --git a/e2e/internal/directories/directories.go b/e2e/internal/directories/directories.go index d4724ec280e..339adab1bcf 100644 --- a/e2e/internal/directories/directories.go +++ b/e2e/internal/directories/directories.go @@ -5,7 +5,6 @@ import ( "os" "path" "strings" - "testing" ) const ( @@ -16,9 +15,7 @@ const ( ) // E2E finds the e2e directory above the test. -func E2E(t *testing.T) (string, error) { - t.Helper() - +func E2E() (string, error) { wd, err := os.Getwd() if err != nil { return "", err @@ -32,7 +29,7 @@ func E2E(t *testing.T) (string, error) { // arbitrary value to avoid getting stuck in an infinite loop if this is called // in a context where the e2e directory does not exist. - if count > maxAttempts { + if count == maxAttempts { return "", fmt.Errorf("unable to find e2e directory after %d tries", maxAttempts) } diff --git a/e2e/sample.config.extended.yaml b/e2e/sample.config.extended.yaml index f14db4912dd..1cda5d3dd88 100644 --- a/e2e/sample.config.extended.yaml +++ b/e2e/sample.config.extended.yaml @@ -33,6 +33,7 @@ chains: tag: main # override with CHAIN_B_TAG binary: simd # override with CHAIN_BINARY +# activeRelayer must match the id of a relayer specified in the relayers list below. activeRelayer: hermes # override with RELAYER_ID # relayers provides a list all possible relayers that will be usable within a test @@ -58,9 +59,17 @@ debug: # 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. -# The plan name must be registered as an upgrade handler in the given tag. -upgrade: - planName: "" # override with CHAIN_UPGRADE_PLAN - tag: "" # override with CHAIN_UPGRADE_TAG +upgradePlanName: "" # specify a value that matches a planName in the upgrades list below. +upgrades: + - planName: "v7" + tag: "v7.0.0" + - planName: "v7.1" + tag: "v7.1.0" + - planName: "v8" + tag: "v8.0.0" + - planName: "v8.1" + tag: "v8.1.0" + - planName: "v9" + tag: "v9.0.0" + - planName: "ibcwasm-v8" + tag: "v8.0.0-e2e-upgrade" diff --git a/e2e/tests/upgrades/upgrade_test.go b/e2e/tests/upgrades/upgrade_test.go index b2fc69cff28..da73a1e5897 100644 --- a/e2e/tests/upgrades/upgrade_test.go +++ b/e2e/tests/upgrades/upgrade_test.go @@ -46,8 +46,8 @@ const ( func TestUpgradeTestSuite(t *testing.T) { testCfg := testsuite.LoadConfig() - if testCfg.UpgradeConfig.Tag == "" || testCfg.UpgradeConfig.PlanName == "" { - t.Fatalf("%s and %s must be set when running an upgrade test", testsuite.ChainUpgradeTagEnv, testsuite.ChainUpgradePlanEnv) + if testCfg.UpgradePlanName == "" { + t.Fatalf("%s must be set when running an upgrade test", testsuite.ChainUpgradePlanEnv) } testifysuite.Run(t, new(UpgradeTestSuite)) @@ -185,7 +185,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.(*cosmos.CosmosChain), chainAUpgradeProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag) + s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), chainAUpgradeProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag) }) t.Run("restart relayer", func(t *testing.T) { @@ -268,7 +268,7 @@ func (s *UpgradeTestSuite) TestChainUpgrade() { testCfg := testsuite.LoadConfig() proposerWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) - s.UpgradeChain(ctx, chain.(*cosmos.CosmosChain), proposerWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag) + s.UpgradeChain(ctx, chain.(*cosmos.CosmosChain), proposerWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag) }) t.Run("send funds to test wallet", func(t *testing.T) { @@ -408,7 +408,7 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() { chainAUpgradeProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) t.Run("upgrade chainA", func(t *testing.T) { - s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), chainAUpgradeProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag) + s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), chainAUpgradeProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag) }) // see this issue https://github.com/informalsystems/hermes/issues/3579 @@ -505,7 +505,7 @@ func (s *UpgradeTestSuite) TestV7ToV7_1ChainUpgrade() { t.Run("upgrade chain", func(t *testing.T) { govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) - s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag) + s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag) }) t.Run("ensure the localhost client is active and sentinel connection is stored in state", func(t *testing.T) { @@ -599,7 +599,7 @@ func (s *UpgradeTestSuite) TestV7ToV8ChainUpgrade() { t.Run("upgrade chain", func(t *testing.T) { govProposalWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) - s.UpgradeChain(ctx, chainB.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag) + s.UpgradeChain(ctx, chainB.(*cosmos.CosmosChain), govProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag) }) t.Run("update params", func(t *testing.T) { @@ -706,7 +706,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade() { t.Run("upgrade chain", func(t *testing.T) { testCfg := testsuite.LoadConfig() proposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) - s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), proposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag) + s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), proposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag) }) t.Run("29-fee migration partially refunds escrowed tokens", func(t *testing.T) { @@ -837,7 +837,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_FeeMiddlewareChannelUpgrade( t.Run("chain A", func(t *testing.T) { govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) - s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag) + s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag) }) }() @@ -847,7 +847,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_FeeMiddlewareChannelUpgrade( t.Run("chain B", func(t *testing.T) { govProposalWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) - s.UpgradeChain(ctx, chainB.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[1].Tag, testCfg.UpgradeConfig.Tag) + s.UpgradeChain(ctx, chainB.(*cosmos.CosmosChain), govProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[1].Tag, testCfg.GetUpgradeConfig().Tag) }) }() @@ -1099,7 +1099,7 @@ func (s *UpgradeTestSuite) TestV8ToV9ChainUpgrade() { t.Run("upgrade chain", func(t *testing.T) { govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) - s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag) + s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag) }) t.Run("start relayer", func(t *testing.T) { @@ -1229,7 +1229,7 @@ func (s *UpgradeTestSuite) TestV8ToV9ChainUpgrade_Localhost() { t.Run("upgrade chain", func(t *testing.T) { govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) - s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag) + s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag) }) t.Run("localhost does not exist in state after upgrade", func(t *testing.T) { @@ -1335,7 +1335,7 @@ func (s *UpgradeTestSuite) TestV8ToV9ChainUpgrade_ICS20v2ChannelUpgrade() { t.Run("upgrade chain", func(t *testing.T) { govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) - s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag) + s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag) }) t.Run("upgrade channel to ics20-2", func(t *testing.T) { @@ -1347,7 +1347,7 @@ func (s *UpgradeTestSuite) TestV8ToV9ChainUpgrade_ICS20v2ChannelUpgrade() { }) t.Run("verify channel A upgraded and transfer version is ics20-2", func(t *testing.T) { - err := test.WaitForCondition(time.Minute*2, time.Second*2, func() (bool, error) { + err := test.WaitForCondition(time.Minute*3, time.Second*2, func() (bool, error) { channel, err := query.Channel(ctx, chainA, channelA.PortID, channelA.ChannelID) if err != nil { return false, err diff --git a/e2e/tests/wasm/upgrade_test.go b/e2e/tests/wasm/upgrade_test.go index 3b683158d63..5d5533432f6 100644 --- a/e2e/tests/wasm/upgrade_test.go +++ b/e2e/tests/wasm/upgrade_test.go @@ -9,6 +9,7 @@ import ( "fmt" "io" "os" + "strings" "testing" "time" @@ -35,8 +36,8 @@ const ( func TestIBCWasmUpgradeTestSuite(t *testing.T) { testCfg := testsuite.LoadConfig() - if testCfg.UpgradeConfig.Tag == "" || testCfg.UpgradeConfig.PlanName == "" { - t.Fatalf("%s and %s must be set when running an upgrade test", testsuite.ChainUpgradeTagEnv, testsuite.ChainUpgradePlanEnv) + if strings.TrimSpace(testCfg.UpgradePlanName) == "" { + t.Fatalf("%s must be set when running an upgrade test", testsuite.ChainUpgradePlanEnv) } // wasm tests require a longer voting period to account for the time it takes to upload a contract. @@ -70,7 +71,7 @@ func (s *IBCWasmUpgradeTestSuite) TestIBCWasmChainUpgrade() { t.Run("upgrade chain", func(t *testing.T) { testCfg := testsuite.LoadConfig() - s.UpgradeChain(ctx, chain.(*cosmos.CosmosChain), userWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag) + s.UpgradeChain(ctx, chain.(*cosmos.CosmosChain), userWallet, testCfg.GetUpgradeConfig().PlanName, testCfg.ChainConfigs[0].Tag, testCfg.GetUpgradeConfig().Tag) }) t.Run("query wasm checksums", func(t *testing.T) { diff --git a/e2e/testsuite/diagnostics/diagnostics.go b/e2e/testsuite/diagnostics/diagnostics.go index 6619b844979..e00d670e14d 100644 --- a/e2e/testsuite/diagnostics/diagnostics.go +++ b/e2e/testsuite/diagnostics/diagnostics.go @@ -37,7 +37,7 @@ func Collect(t *testing.T, dc *dockerclient.Client, debugModeEnabled bool, suite t.Logf("writing logs for test: %s", t.Name()) ctx := context.TODO() - e2eDir, err := directories.E2E(t) + e2eDir, err := directories.E2E() if err != nil { t.Logf("failed finding log directory: %s", err) return diff --git a/e2e/testsuite/testconfig.go b/e2e/testsuite/testconfig.go index d9eec215109..e9fbddfaa4a 100644 --- a/e2e/testsuite/testconfig.go +++ b/e2e/testsuite/testconfig.go @@ -25,6 +25,7 @@ import ( cmtjson "github.com/cometbft/cometbft/libs/json" + "github.com/cosmos/ibc-go/e2e/internal/directories" "github.com/cosmos/ibc-go/e2e/relayer" "github.com/cosmos/ibc-go/e2e/semverutil" "github.com/cosmos/ibc-go/e2e/testvalues" @@ -47,11 +48,10 @@ const ( RelayerIDEnv = "RELAYER_ID" // ChainBinaryEnv binary is the binary that will be used for both chains. ChainBinaryEnv = "CHAIN_BINARY" - // ChainUpgradeTagEnv specifies the upgrade version tag - 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 allows you to specify a custom path for the config file to be used. It can be relative + // or absolute. 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 @@ -73,6 +73,8 @@ const ( // defaultConfigFileName is the default filename for the config file that can be used to configure // e2e tests. See sample.config.yaml or sample.config.extended.yaml as an example for what this should look like. defaultConfigFileName = ".ibc-go-e2e-config.yaml" + // defaultCIConfigFileName is the default filename for the config file that should be used for CI. + defaultCIConfigFileName = "ci-e2e-config.yaml" ) // defaultChainNames contains the default name for chainA and chainB. @@ -93,12 +95,15 @@ type TestConfig struct { RelayerConfigs []relayer.Config `yaml:"relayers"` // ActiveRelayer specifies the relayer that will be used. It must match the ID of one of the entries in RelayerConfigs. ActiveRelayer string `yaml:"activeRelayer"` - // 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"` + // UpgradePlanName specifies which upgrade plan to use. It must match a plan name for an entry in the + // list of UpgradeConfigs. + UpgradePlanName string `yaml:"upgradePlanName"` + // UpgradeConfigs provides a list of all possible upgrades. + UpgradeConfigs []UpgradeConfig `yaml:"upgrades"` } // Validate validates the test configuration is valid for use within the tests. @@ -115,6 +120,11 @@ func (tc TestConfig) Validate() error { if err := tc.validateGenesisDebugConfig(); err != nil { return fmt.Errorf("invalid Genesis debug configuration: %w", err) } + + if err := tc.validateUpgradeConfig(); err != nil { + return fmt.Errorf("invalid upgrade configuration: %w", err) + } + return nil } @@ -131,20 +141,8 @@ func (tc TestConfig) validateChains() error { return fmt.Errorf("chain config missing tag: %+v", cfg) } - // TODO: validate chainID in https://github.com/cosmos/ibc-go/issues/4697 - // these are not passed in the CI at the moment. Defaults are used. - if !IsCI() { - if cfg.ChainID == "" { - return fmt.Errorf("chain config missing chainID: %+v", cfg) - } - } - - // TODO: validate number of nodes in https://github.com/cosmos/ibc-go/issues/4697 - // these are not passed in the CI at the moment. - if !IsCI() { - if cfg.NumValidators == 0 && cfg.NumFullNodes == 0 { - return fmt.Errorf("chain config missing number of validators or full nodes: %+v", cfg) - } + if cfg.NumValidators == 0 && cfg.NumFullNodes == 0 { + return fmt.Errorf("chain config missing number of validators or full nodes: %+v", cfg) } } @@ -182,6 +180,16 @@ func (tc TestConfig) validateRelayers() error { return nil } +// GetUpgradeConfig returns the upgrade configuration for the current test configuration. +func (tc TestConfig) GetUpgradeConfig() UpgradeConfig { + for _, upgrade := range tc.UpgradeConfigs { + if upgrade.PlanName == tc.UpgradePlanName { + return upgrade + } + } + panic("upgrade plan not found in upgrade configs, this test config should not have passed validation") +} + // GetChainIndex returns the index of the chain with the given name, if it // exists. func (tc TestConfig) GetChainIndex(name string) (int, error) { @@ -207,6 +215,35 @@ func (tc TestConfig) validateGenesisDebugConfig() error { return err } +// validateUpgradeConfig ensures the upgrade configuration is valid. +func (tc TestConfig) validateUpgradeConfig() error { + if strings.TrimSpace(tc.UpgradePlanName) == "" { + return nil + } + + // the upgrade plan name specified must match one of the upgrade plans in the upgrade configs. + foundPlan := false + for _, upgrade := range tc.UpgradeConfigs { + if strings.TrimSpace(upgrade.Tag) == "" { + return fmt.Errorf("upgrade config missing tag: %+v", upgrade) + } + + if strings.TrimSpace(upgrade.PlanName) == "" { + return fmt.Errorf("upgrade config missing plan name: %+v", upgrade) + } + + if upgrade.PlanName == tc.UpgradePlanName { + foundPlan = true + } + } + + if foundPlan { + return nil + } + + return fmt.Errorf("upgrade plan %s not found in upgrade configs: %+v", tc.UpgradePlanName, tc.UpgradeConfigs) +} + // GetActiveRelayerConfig returns the currently specified relayer config. func (tc TestConfig) GetActiveRelayerConfig() *relayer.Config { for _, r := range tc.RelayerConfigs { @@ -357,9 +394,15 @@ func fromFile() (TestConfig, bool) { // populateDefaults populates default values for the test config if // certain required fields are not specified. func populateDefaults(tc TestConfig) TestConfig { + chainIDs := []string{ + "chainA-1", + "chainB-1", + "chainC-1", + } + for i := range tc.ChainConfigs { if tc.ChainConfigs[i].ChainID == "" { - tc.ChainConfigs[i].ChainID = fmt.Sprintf("chain-%d", i+1) + tc.ChainConfigs[i].ChainID = chainIDs[i] } if tc.ChainConfigs[i].Binary == "" { tc.ChainConfigs[i].Binary = defaultBinary @@ -421,11 +464,7 @@ func applyEnvironmentVariableOverrides(fromFile TestConfig) TestConfig { } if os.Getenv(ChainUpgradePlanEnv) != "" { - fromFile.UpgradeConfig.PlanName = envTc.UpgradeConfig.PlanName - } - - if os.Getenv(ChainUpgradeTagEnv) != "" { - fromFile.UpgradeConfig.Tag = envTc.UpgradeConfig.Tag + fromFile.UpgradePlanName = envTc.UpgradePlanName } if isEnvTrue(KeepContainersEnv) { @@ -438,18 +477,10 @@ func applyEnvironmentVariableOverrides(fromFile TestConfig) TestConfig { // fromEnv returns a TestConfig constructed from environment variables. func fromEnv() TestConfig { return TestConfig{ - ChainConfigs: getChainConfigsFromEnv(), - UpgradeConfig: getUpgradePlanConfigFromEnv(), - ActiveRelayer: os.Getenv(RelayerIDEnv), - - // TODO: we can remove this, and specify these values in a config file for the CI - // in https://github.com/cosmos/ibc-go/issues/4697 - RelayerConfigs: []relayer.Config{ - getDefaultRlyRelayerConfig(), - getDefaultHermesRelayerConfig(), - getDefaultHyperspaceRelayerConfig(), - }, - CometBFTConfig: CometBFTConfig{LogLevel: "info"}, + ChainConfigs: getChainConfigsFromEnv(), + UpgradePlanName: os.Getenv(ChainUpgradePlanEnv), + ActiveRelayer: os.Getenv(RelayerIDEnv), + CometBFTConfig: CometBFTConfig{LogLevel: "info"}, } } @@ -500,10 +531,27 @@ func getChainConfigsFromEnv() []ChainConfig { // getConfigFilePath returns the absolute path where the e2e config file should be. func getConfigFilePath() string { - if absoluteConfigPath := os.Getenv(E2EConfigFilePathEnv); absoluteConfigPath != "" { - return absoluteConfigPath + if specifiedConfigPath := os.Getenv(E2EConfigFilePathEnv); specifiedConfigPath != "" { + if path.IsAbs(specifiedConfigPath) { + return specifiedConfigPath + } + + e2eDir, err := directories.E2E() + if err != nil { + panic(err) + } + + return path.Join(e2eDir, specifiedConfigPath) + } + + if IsCI() { + if err := os.Setenv(E2EConfigFilePathEnv, defaultCIConfigFileName); err != nil { + panic(err) + } + return getConfigFilePath() } + // running locally. homeDir, err := os.UserHomeDir() if err != nil { panic(err) @@ -541,23 +589,6 @@ func getDefaultHyperspaceRelayerConfig() relayer.Config { } } -// 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 { - upgradePlan = "" - } - return UpgradeConfig{ - PlanName: upgradePlan, - Tag: upgradeTag, - } -} - func GetChainATag() string { return LoadConfig().ChainConfigs[0].Tag } diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index cb8ab6ed9c1..2326879adaf 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -125,7 +125,7 @@ func (s *E2ETestSuite) configureGenesisDebugExport() { // If no path is provided, use the default (e2e/diagnostics/genesis.json). if exportPath == "" { - e2eDir, err := directories.E2E(t) + e2eDir, err := directories.E2E() s.Require().NoError(err, "can't get e2edir") exportPath = path.Join(e2eDir, directories.DefaultGenesisExportPath) } @@ -735,9 +735,6 @@ func GetIBCToken(fullTokenDenom string, portID, channelID string) transfertypes. // use less resources and allow the tests to run faster. // both the number of validators and full nodes can be overwritten in a config file. func getValidatorsAndFullNodes(chainIdx int) (int, int) { - if IsCI() { - return 4, 1 - } tc := LoadConfig() return tc.GetChainNumValidators(chainIdx), tc.GetChainNumFullNodes(chainIdx) }