Skip to content

Commit cbb6859

Browse files
authored
Support configuration file for e2e tests (#3260)
1 parent b3f1b4d commit cbb6859

File tree

10 files changed

+307
-77
lines changed

10 files changed

+307
-77
lines changed

e2e/Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ cleanup-ibc-test-containers:
77
$(DOCKER) rm $$id ; \
88
done
99

10-
e2e-test: cleanup-ibc-test-containers
10+
init:
11+
./scripts/init.sh
12+
13+
e2e-test: init cleanup-ibc-test-containers
1114
./scripts/run-e2e.sh $(test) $(entrypoint)
1215

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

16-
.PHONY: cleanup-ibc-test-containers e2e-test compatibility-tests
19+
.PHONY: cleanup-ibc-test-containers e2e-test compatibility-tests init

e2e/README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ be quite common in most tests.
3737

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

40-
There are several envinronment variables that alter the behaviour of the make target.
40+
The tests can be configured using a configuration file or environment variables.
41+
42+
See [the example](./sample.config.yaml) to get started. The default location the tests look is `~/.ibc-go-e2e-config.yaml`
43+
But this can be specified directly using the `E2E_CONFIG_PATH` environment variable.
44+
45+
There are several environment variables that alter the behaviour of the make target which will override any
46+
options specified in your config file.
4147

4248
| Environment Variable | Description | Default Value |
4349
|----------------------|-------------------------------------------|---------------|

e2e/relayer/relayer.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ const (
2222
// Config holds configuration values for the relayer used in the tests.
2323
type Config struct {
2424
// Tag is the tag used for the relayer image.
25-
Tag string
25+
Tag string `yaml:"tag"`
2626
// Type specifies the type of relayer that this is.
27-
Type string
27+
Type string `yaml:"type"`
28+
// Image is the image that should be used for the relayer.
29+
Image string `yaml:"image"`
2830
}
2931

3032
// New returns an implementation of ibc.Relayer depending on the provided RelayerType.

e2e/sample.config.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This file contains configuration for running e2e tests.
2+
# Many of these fields can be overridden with environment variables.
3+
# All fields that support this have the corresponding environment variable name in a comment beside the field.
4+
5+
---
6+
chains:
7+
# the entry at index 0 corresponds to CHAIN_A
8+
- chainId: chain-a
9+
numValidators: 1
10+
numFullNodes: 0
11+
image: ghcr.io/cosmos/ibc-go-simd # override with CHAIN_IMAGE
12+
tag: main # override with CHAIN_A_TAG
13+
binary: simd # override with CHAIN_BINARY
14+
15+
# the entry at index 1 corresponds to CHAIN_B
16+
- chainId: chain-b
17+
numValidators: 1
18+
numFullNodes: 0
19+
image: ghcr.io/cosmos/ibc-go-simd # override with CHAIN_IMAGE
20+
tag: main # override with CHAIN_B_TAG
21+
binary: simd # override with CHAIN_BINARY
22+
23+
relayer:
24+
type: rly # override with RELAYER_TYPE
25+
image: damiannolan/rly
26+
tag: latest # override with RELAYER_TAG
27+
28+
cometbft:
29+
logLevel: info
30+
31+
debug:
32+
# setting this value to true will force log collection even if the test passes.
33+
dumpLogs: false
34+
35+
# Required only for upgrade tests.
36+
# Chain A will be upgraded the specified tag.
37+
# The plan name must be registered as an upgrade handler in the given tag.
38+
upgrade:
39+
planName: ""
40+
tag: ""

e2e/scripts/init.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
# ensure_config_file makes sure there is a config file for the e2e tests either by creating a new one using the sample,
6+
# it is copied to either the default location or the specified env location.
7+
function ensure_config_file(){
8+
local config_file_path="${HOME}/.ibc-go-e2e-config.yaml"
9+
if [[ ! -z "${E2E_CONFIG_PATH:-}" ]]; then
10+
config_file_path="${E2E_CONFIG_PATH}"
11+
fi
12+
if [[ ! -f "${config_file_path}" ]]; then
13+
echo "creating e2e config file from sample."
14+
echo "copying sample.config.yaml to ${config_file_path}"
15+
cp sample.config.yaml "${config_file_path}"
16+
fi
17+
echo "using config file at ${config_file_path} for e2e test"
18+
}
19+
20+
ensure_config_file

e2e/scripts/run-e2e.sh

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ set -eo pipefail
55
TEST="${1}"
66
ENTRY_POINT="${2:-}"
77

8-
export CHAIN_A_TAG="${CHAIN_A_TAG:-main}"
9-
export CHAIN_IMAGE="${CHAIN_IMAGE:-ghcr.io/cosmos/ibc-go-simd}"
10-
export CHAIN_BINARY="${CHAIN_BINARY:-simd}"
11-
128
# if jq is installed, we can automatically determine the test entrypoint.
139
if command -v jq > /dev/null; then
1410
cd ..

0 commit comments

Comments
 (0)