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

Dynamically generate compatibility test files #7547

Merged
merged 56 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
838c29b
poc: create basic script to exract test names
chatton Oct 12, 2023
6819e7b
query tags from ibc go repo to determine versions
chatton Oct 12, 2023
20d3bb7
adding validate fn
chatton Oct 12, 2023
88d9017
pass in release branch
chatton Oct 12, 2023
5774ceb
wip: returning all versions within range
chatton Oct 14, 2023
b2b2ec2
chore: add parse fn
chatton Oct 14, 2023
3e65cc7
chore: fix workflow
chatton Oct 14, 2023
7d961aa
Merge branch 'main' into cian/dynamically-generate-compatibility-files
chatton Oct 20, 2023
6f8a7ba
Merge branch 'main' into cian/dynamically-generate-compatibility-files
chatton Oct 20, 2023
dc0a9f9
chore: extract metadata as map
chatton Oct 20, 2023
1b3dc05
chore: tweak compatibility workflow
chatton Oct 20, 2023
1cd41f3
chore: revert workflow change
chatton Oct 20, 2023
76c95a6
chore: skip building images
chatton Oct 20, 2023
6ed0b8f
chore: skip building images
chatton Oct 20, 2023
1ca21e6
chore: add from versions to e2e test files
chatton Oct 20, 2023
78cac4a
chore: add argument to specify file
chatton Oct 20, 2023
8e97684
chore: merge main
chatton Sep 24, 2024
ca94e62
chore: merge requirments file
chatton Sep 24, 2024
51a1466
docs: improving docstrings
chatton Sep 24, 2024
f753a89
Merge branch 'main' into cian/dynamically-generate-compatibility-files
chatton Nov 11, 2024
f6d4e37
chore: updating minimum supported version
chatton Nov 11, 2024
4a17e14
chore: refactoring to use include syntax
chatton Nov 11, 2024
07ed1db
chore: fixed logic error in validation
chatton Nov 11, 2024
828c81b
chore: added space in workflow
chatton Nov 11, 2024
35f44aa
chore: correct version for test
chatton Nov 11, 2024
13cd392
chore: run tests both ways without needing to specify it explicitly
chatton Nov 11, 2024
18ed201
chore: adding additional docstrings and removing stale functions
chatton Nov 12, 2024
0e67c14
chore: updating annotation
chatton Nov 12, 2024
a9320b2
chore: remove unrequired fields
chatton Nov 12, 2024
e62bdcd
chore: modifying workflow variable names
chatton Nov 12, 2024
b37f90f
chore: updated correct supported versions for transfer entire balance
chatton Nov 12, 2024
fdd4386
chore: adding additional annotations to test files
chatton Nov 12, 2024
a22b85e
chore: prevent duplicate entries being added, add annotations for cli…
chatton Nov 12, 2024
5c5673a
chore: updating annotations for ica base_test.go and adding connectio…
chatton Nov 12, 2024
f79f8ad
chore: added ica workflows to compatibility workflow and updated anno…
chatton Nov 12, 2024
844c543
chore: adding remaining tests
chatton Nov 12, 2024
ec81d1d
chore: corrected annotations
chatton Nov 12, 2024
16edbfb
chore: removed compatibility matricies
chatton Nov 12, 2024
0177b57
Merge branch 'main' into cian/dynamically-generate-compatibility-files
chatton Nov 12, 2024
9d7a30b
chore: re-add part of workflow that builds the images
chatton Nov 12, 2024
9930491
chore: adding image to _add_test_entries
chatton Nov 12, 2024
192144f
chore: use - instead of = in comment
chatton Nov 12, 2024
20d646b
chore: removing unnecessary script
chatton Nov 12, 2024
0664256
chore: update variable name
chatton Nov 12, 2024
d9827a7
chore: support ability to break up tests into smaller batches
chatton Nov 13, 2024
205a1cd
chore: add from version annotations to TestHostEnabledParam
chatton Nov 13, 2024
f672c76
chore: specifying versions for TestInterchainAccountsQuery
chatton Nov 13, 2024
bb771e6
chore: propagate chain value
chatton Nov 13, 2024
aedff03
chore: enabling specifing a from_version field on a per test level
chatton Nov 14, 2024
96b3374
chore: adding exhaustive list of versions for unordered channel transfer
chatton Nov 14, 2024
379c06c
chore: added field to skip tests
chatton Nov 14, 2024
765956d
chore: added version filtering on ica localhost test
chatton Nov 14, 2024
a44c581
chore: corrected annotation on ICA test
chatton Nov 14, 2024
0e03eaf
chore: adding readme for compatibility generation
chatton Nov 14, 2024
93ea04c
chore: fixed version parsing and added additional docstrings
chatton Nov 14, 2024
3852f39
chore: fixed markdown linter (╯°□°)╯︵ ┻━┻
chatton Nov 14, 2024
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
Prev Previous commit
Next Next commit
chore: refactoring to use include syntax
  • Loading branch information
chatton committed Nov 11, 2024
commit 4a17e1494d715606ec25b8f650715d525fd0f0e2
3 changes: 3 additions & 0 deletions e2e/tests/transfer/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() {

// TestMsgTransfer_Succeeds_Nonincentivized_MultiDenom will test sending successful IBC transfers from chainA to chainB.
// A multidenom transfer with native chainB tokens and IBC tokens from chainA is executed from chainB to chainA.
// compatibility:TestMsgTransfer_Succeeds_Nonincentivized_MultiDenom:from_version: v9.0.0
func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized_MultiDenom() {
t := s.T()
ctx := context.TODO()
Expand Down Expand Up @@ -272,6 +273,7 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized_MultiDenom(

// TestMsgTransfer_Fails_InvalidAddress_MultiDenom attempts to send a multidenom IBC transfer
// to an invalid address and ensures that the tokens on the sending chain are returned to the sender.
// compatibility:TestMsgTransfer_Fails_InvalidAddress_MultiDenom:from_version: v9.0.0
func (s *TransferTestSuite) TestMsgTransfer_Fails_InvalidAddress_MultiDenom() {
t := s.T()
ctx := context.TODO()
Expand Down Expand Up @@ -550,6 +552,7 @@ func (s *TransferTestSuite) TestMsgTransfer_WithMemo() {

// TestMsgTransfer_EntireBalance tests that it is possible to transfer the entire balance
// of a given denom by using types.UnboundedSpendLimit as the amount.
// compatibility:TestMsgTransfer_EntireBalance:from_version: v7.7.0
func (s *TransferTestSuite) TestMsgTransfer_EntireBalance() {
t := s.T()
ctx := context.TODO()
Expand Down
54 changes: 36 additions & 18 deletions scripts/generate-compatibility-json.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def _get_max_version(versions):
def _get_tags_to_test(min_version: semver.Version, max_version: semver.Version, all_versions: List[semver.Version]):
all_versions = [parse_version(v) for v in all_versions]
"""return all tags that are between the min and max versions"""
# TODO: fix this hack
return ["v" + str(v) for v in all_versions if min_version < v < max_version]


Expand All @@ -102,8 +101,7 @@ def main():
file_metadata = _build_file_metadata(file_lines)
tags = _get_ibc_go_releases(args.release_version)

# TODO: fix hack
# strip the v
# strip the v prefix from the version
min_version = file_metadata["fields"]["from_version"][1:]
max_version = _get_max_version(tags)

Expand All @@ -121,37 +119,57 @@ def main():
test_suite = file_metadata["test_suite"]
test_functions = file_metadata["tests"]

include_entries = []
for test in test_functions:
for version in other_versions:
if not _test_should_be_run(test, version, file_metadata["fields"]):
continue

include_entries.append({
"chain-a": release_versions[0],
"chain-b": version,
"entrypoint": test_suite,
"test": test,
"relayer-type": args.relayer,
"chain-image": args.image
})

# compatibility_json is the json object that will be used as the input to a github workflow
# which will expand out into a matrix of tests to run.
compatibility_json = {
"chain-a": sorted(release_versions),
"chain-b": sorted(other_versions),
"entrypoint": [test_suite],
"test": sorted(test_functions),
"relayer-type": [args.relayer],
"chain-image": [args.image]
"include": include_entries,
}

_validate(compatibility_json)

# output the json on a single line. This ensures the output is directly passable to a github workflow.
print(json.dumps(compatibility_json), end="")


def _validate(compatibility_json: Dict):
"""validates that the generated compatibility json fields will be valid for a github workflow."""
required_keys = frozenset({"chain-a", "chain-b", "entrypoint", "test", "relayer-type"})
if "include" not in compatibility_json:
raise ValueError("no include entries found")

required_keys = frozenset({"chain-a", "chain-b", "entrypoint", "test", "relayer-type", "chain-image"})
for k in required_keys:
if k not in compatibility_json:
if k not in compatibility_json["include"]:
raise ValueError(f"key {k} not found in {compatibility_json.keys()}")

if len(compatibility_json["entrypoint"]) != 1:
raise ValueError(f"found more than one entrypoint: {compatibility_json['entrypoint']}")

if len(compatibility_json["test"]) <= 0:
raise ValueError("no tests found")
def _test_should_be_run(test_name: str, version: str, file_fields: Dict) -> bool:
"""determines if the test should be run. Each test can have its own version defined, if it has been defined
we can check to see if this test should run, based on the other test parameters."""

min_version = file_fields.get(f"{test_name}:{FROM_VERSION}")

# no custom version defined for this test, run it as normal using the from_version specified on the test suite.
if min_version is None:
return True

min_semver_version = parse_version(min_version)
semver_version = parse_version(version)

if len(compatibility_json["relayer-type"]) <= 0:
raise ValueError("no relayer specified")
return min_semver_version <= semver_version


def _get_ibc_go_releases(from_version: str) -> List[str]:
Expand Down
Loading