-
Notifications
You must be signed in to change notification settings - Fork 639
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
feat(test): adding support for backwards compatibility testing #1912
Changes from 26 commits
8f44301
f470bcf
2297280
4c30485
f7136fe
cebb54b
44372fa
4f32582
02a4650
a1242ec
97cc9e3
d100cc8
e40eb94
b4b6e0d
4f5dc37
7dbd60d
dc545df
3850159
c155674
e7856f2
53189f7
e8efc01
a2c1ae0
85452f5
107aeca
fc0dc1f
c4bca40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: Manual E2E | ||
on: | ||
# when https://github.com/community/community/discussions/11795 is resolved | ||
# we will be able to dynamically build up the list of valid inputs. | ||
# for now this needs to be manual. | ||
workflow_dispatch: | ||
inputs: | ||
test-entry-point: | ||
description: 'Test entry point' | ||
required: true | ||
type: choice | ||
options: | ||
- TestFeeMiddlewareTestSuite | ||
chain-a-image: | ||
description: 'The image to use for chain A' | ||
required: true | ||
type: string | ||
default: "ghcr.io/cosmos/ibc-go-simd-e2e" | ||
chain-a-tag: | ||
description: 'The tag to use for chain A' | ||
required: true | ||
type: choice | ||
default: main | ||
options: | ||
- main | ||
- v4.0.0-rc3 | ||
- v3.0.0-rc2 | ||
- v2.2.0 | ||
- v2.1.0 | ||
- v2.0.0 | ||
chain-b-image: | ||
description: 'The image to use for chain B' | ||
required: true | ||
type: string | ||
default: "ghcr.io/cosmos/ibc-go-simd" | ||
chain-b-tag: | ||
default: v4.0.0-rc3 | ||
description: 'The tag to use for chain B' | ||
required: true | ||
type: choice | ||
options: | ||
- v4.0.0-rc3 | ||
- v3.0.0-rc2 | ||
- v2.2.0 | ||
- v2.1.0 | ||
- v2.0.0 | ||
relayer-tag: | ||
description: 'The tag to use for the relayer' | ||
required: true | ||
default: "v2.0.0-rc2" | ||
type: string | ||
|
||
|
||
jobs: | ||
# dynamically build a matrix of test/test suite pairs to run | ||
build-test-matrix: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18 | ||
- id: set-matrix | ||
run: echo "::set-output name=matrix::$(go run cmd/build_test_matrix/main.go)" | ||
env: | ||
TEST_ENTRYPOINT: "${{ github.event.inputs.test-entry-point }}" | ||
|
||
|
||
|
||
e2e-manual: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build-test-matrix | ||
env: | ||
CHAIN_A_SIMD_TAG: "${{ github.event.inputs.chain-a-tag }}" | ||
CHAIN_A_SIMD_IMAGE: "${{ github.event.inputs.chain-a-image }}" | ||
CHAIN_B_SIMD_TAG: "${{ github.event.inputs.chain-b-tag }}" | ||
CHAIN_B_SIMD_IMAGE: "${{ github.event.inputs.chain-b-image }}" | ||
# see images here https://github.com/cosmos/relayer/pkgs/container/relayer/versions | ||
RLY_TAG: "${{ github.event.inputs.relayer-tag }}" | ||
strategy: | ||
fail-fast: false | ||
matrix: ${{ fromJSON(needs.build-test-matrix.outputs.matrix) }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.18 | ||
- name: Run e2e Test | ||
run: | | ||
cd e2e | ||
make e2e-test suite=${{ matrix.suite }} test=${{ matrix.test }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ const ( | |
testNamePrefix = "Test" | ||
testFileNameSuffix = "_test.go" | ||
e2eTestDirectory = "e2e" | ||
testEntryPointEnv = "TEST_ENTRYPOINT" | ||
) | ||
|
||
// GithubActionTestMatrix represents | ||
|
@@ -29,7 +30,7 @@ type TestSuitePair struct { | |
} | ||
|
||
func main() { | ||
githubActionMatrix, err := getGithubActionMatrixForTests(e2eTestDirectory) | ||
githubActionMatrix, err := getGithubActionMatrixForTests(e2eTestDirectory, getTestFunctionToRun()) | ||
if err != nil { | ||
fmt.Printf("error generating github action json: %s", err) | ||
os.Exit(1) | ||
|
@@ -43,10 +44,20 @@ func main() { | |
fmt.Println(string(ghBytes)) | ||
} | ||
|
||
// getTestFunctionToRun returns the specified test function to run if present, otherwise | ||
// it returns an empty string which will result in running all test suites. | ||
func getTestFunctionToRun() string { | ||
testSuite, ok := os.LookupEnv(testEntryPointEnv) | ||
if !ok { | ||
return "" | ||
} | ||
return testSuite | ||
} | ||
|
||
// getGithubActionMatrixForTests returns a json string representing the contents that should go in the matrix | ||
// field in a github action workflow. This string can be used with `fromJSON(str)` to dynamically build | ||
// the workflow matrix to include all E2E tests under the e2eRootDirectory directory. | ||
func getGithubActionMatrixForTests(e2eRootDirectory string) (GithubActionTestMatrix, error) { | ||
func getGithubActionMatrixForTests(e2eRootDirectory, suite string) (GithubActionTestMatrix, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add godoc to specify the usage of an empty string to indicate runAllTests? |
||
testSuiteMapping := map[string][]string{} | ||
fset := token.NewFileSet() | ||
err := filepath.Walk(e2eRootDirectory, func(path string, info fs.FileInfo, err error) error { | ||
|
@@ -69,7 +80,9 @@ func getGithubActionMatrixForTests(e2eRootDirectory string) (GithubActionTestMat | |
return fmt.Errorf("failed extracting test suite name and test cases: %s", err) | ||
} | ||
|
||
testSuiteMapping[suiteNameForFile] = testCases | ||
if suite == "" || suiteNameForFile == suite { | ||
testSuiteMapping[suiteNameForFile] = testCases | ||
} | ||
|
||
return nil | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,42 +8,71 @@ import ( | |
) | ||
|
||
const ( | ||
DefaultSimdImage = "ghcr.io/cosmos/ibc-go-simd-e2e" | ||
SimdImageEnv = "SIMD_IMAGE" | ||
SimdTagEnv = "SIMD_TAG" | ||
GoRelayerTag = "RLY_TAG" | ||
// ChainASimdImageEnv specifies the image that Chain A will use. | ||
ChainASimdImageEnv = "CHAIN_A_SIMD_IMAGE" | ||
// ChainASimdTagEnv specifies the tag that Chain A will use. | ||
ChainASimdTagEnv = "CHAIN_A_SIMD_TAG" | ||
// ChainBSimdImageEnv specifies the image that Chain B will use. If unspecified | ||
// the value will default to the same value as Chain A. | ||
ChainBSimdImageEnv = "CHAIN_B_SIMD_IMAGE" | ||
// ChainBSimdTagEnv specifies the tag that Chain B will use. If unspecified | ||
// the value will default to the same value as Chain A. | ||
ChainBSimdTagEnv = "CHAIN_B_SIMD_TAG" | ||
GoRelayerTagEnv = "RLY_TAG" | ||
|
||
defaultRlyTag = "main" | ||
defaultSimdImage = "ghcr.io/cosmos/ibc-go-simd-e2e" | ||
defaultRlyTag = "main" | ||
) | ||
|
||
// TestConfig holds various fields used in the E2E tests. | ||
type TestConfig struct { | ||
SimdImage string | ||
SimdTag string | ||
RlyTag string | ||
ChainAConfig ChainConfig | ||
ChainBConfig ChainConfig | ||
RlyTag string | ||
} | ||
|
||
type ChainConfig struct { | ||
Image string | ||
Tag string | ||
} | ||
|
||
// FromEnv returns a TestConfig constructed from environment variables. | ||
func FromEnv() TestConfig { | ||
simdImage, ok := os.LookupEnv(SimdImageEnv) | ||
chainASimdImage, ok := os.LookupEnv(ChainASimdImageEnv) | ||
if !ok { | ||
chainASimdImage = defaultSimdImage | ||
} | ||
|
||
chainASimdTag, ok := os.LookupEnv(ChainASimdTagEnv) | ||
if !ok { | ||
simdImage = DefaultSimdImage | ||
panic(fmt.Sprintf("must specify simd version for test with environment variable [%s]", ChainASimdTagEnv)) | ||
} | ||
|
||
simdTag, ok := os.LookupEnv(SimdTagEnv) | ||
chainBSimdImage, ok := os.LookupEnv(ChainBSimdImageEnv) | ||
if !ok { | ||
panic(fmt.Sprintf("must specify simd version for test with environment variable [%s]", SimdTagEnv)) | ||
chainBSimdImage = chainASimdImage | ||
} | ||
|
||
rlyTag, ok := os.LookupEnv(GoRelayerTag) | ||
chainBSimdTag, ok := os.LookupEnv(ChainBSimdTagEnv) | ||
if !ok { | ||
chainBSimdTag = chainASimdTag | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we document the default behaviour somewhere? That is when the chainB image/tag isn't specified. It might be a little odd if the image is specified but that tag isn't? or vice versa? |
||
} | ||
|
||
rlyTag, ok := os.LookupEnv(GoRelayerTagEnv) | ||
if !ok { | ||
rlyTag = defaultRlyTag | ||
} | ||
|
||
return TestConfig{ | ||
SimdImage: simdImage, | ||
SimdTag: simdTag, | ||
RlyTag: rlyTag, | ||
ChainAConfig: ChainConfig{ | ||
Image: chainASimdImage, | ||
Tag: chainASimdTag, | ||
}, | ||
ChainBConfig: ChainConfig{ | ||
Image: chainBSimdImage, | ||
Tag: chainBSimdTag, | ||
}, | ||
RlyTag: rlyTag, | ||
} | ||
} | ||
|
||
|
@@ -62,24 +91,24 @@ type ChainOptionConfiguration func(options *ChainOptions) | |
// These options can be configured by passing configuration functions to E2ETestSuite.GetChains. | ||
func DefaultChainOptions() ChainOptions { | ||
tc := FromEnv() | ||
chainACfg := newDefaultSimappConfig(tc, "simapp-a", "chain-a", "atoma") | ||
chainBCfg := newDefaultSimappConfig(tc, "simapp-b", "chain-b", "atomb") | ||
chainACfg := newDefaultSimappConfig(tc.ChainAConfig, "simapp-a", "chain-a", "atoma") | ||
chainBCfg := newDefaultSimappConfig(tc.ChainBConfig, "simapp-b", "chain-b", "atomb") | ||
return ChainOptions{ | ||
ChainAConfig: &chainACfg, | ||
ChainBConfig: &chainBCfg, | ||
} | ||
} | ||
|
||
// newDefaultSimappConfig creates an ibc configuration for simd. | ||
func newDefaultSimappConfig(tc TestConfig, name, chainID, denom string) ibc.ChainConfig { | ||
func newDefaultSimappConfig(cc ChainConfig, name, chainID, denom string) ibc.ChainConfig { | ||
return ibc.ChainConfig{ | ||
Type: "cosmos", | ||
Name: name, | ||
ChainID: chainID, | ||
Images: []ibc.DockerImage{ | ||
{ | ||
Repository: tc.SimdImage, | ||
Version: tc.SimdTag, | ||
Repository: cc.Image, | ||
Version: cc.Tag, | ||
}, | ||
}, | ||
Bin: "simd", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we get v3.1, v2.3 etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to start with I just added a few basic entries. This are just images that exist already. All this list is doing is giving us a drop down menu. We can edit it as we see fit! We just need to make sure the images exist.