Repository navigation
ci(integration): split the slow tier and the gateway tests across runners #362
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1034e3c
ci(integration): split the slow tier and the gateway tests across run…
earakely-scale c597a58
ci(integration): keep tests a dependency links on one shard, and give…
earakely-scale 0a7976e
test: close the grant servers after each module, so one module's CA c…
earakely-scale 79880f9
Merge branch 'main' into ci/shard-slow-integration
earakely-scale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| """Rewrite tst/integration/slow_durations.json from the slow tier's JUnit reports, so the CI shards stay balanced. | ||
|
|
||
| python .github/scripts/slow_test_durations.py junit-integration-slow-*.xml | ||
|
|
||
| Download the reports from a green ``main`` run (the ``junit-integration-local-*`` artifacts of every | ||
| ``integration-local-slow`` and ``integration-local-gateway`` shard). Each test's time counts toward its file, | ||
| or toward the test itself for a file the table names in ``split_by_test``; that list is kept as it is. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import argparse | ||
| import json | ||
| import sys | ||
| import xml.etree.ElementTree as ET | ||
| from collections import defaultdict | ||
| from pathlib import Path | ||
|
|
||
| ROOT = Path(__file__).resolve().parents[2] | ||
| TABLE = ROOT / "tst" / "integration" / "slow_durations.json" | ||
|
|
||
|
|
||
| def main() -> int: | ||
| parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) | ||
| parser.add_argument("reports", nargs="+", help="JUnit XML reports written by pytest --junitxml") | ||
| parser.add_argument("--table", type=Path, default=TABLE, help="the durations table to rewrite") | ||
| parser.add_argument("--root", type=Path, default=ROOT, help="the checkout the reports' test files are in") | ||
| args = parser.parse_args() | ||
|
|
||
| table = json.loads(args.table.read_text()) | ||
| split = set(table.get("split_by_test", [])) | ||
| seconds: dict[str, float] = defaultdict(float) | ||
| for report in args.reports: | ||
| for case in ET.parse(report).getroot().iter("testcase"): | ||
| nodeid = _nodeid(case.get("classname", ""), case.get("name", ""), args.root) | ||
| if nodeid is None: | ||
| print(f"slow test durations: no test file for {case.get('classname')!r}; left out") | ||
| continue | ||
| path = nodeid.split("::", 1)[0] | ||
| seconds[nodeid if path in split else path] += float(case.get("time") or 0) | ||
| if not seconds: | ||
| print("slow test durations: the reports have no test cases; the table is unchanged") | ||
| return 1 | ||
| table["seconds"] = {unit: round(value, 1) for unit, value in sorted(seconds.items())} | ||
| args.table.write_text(json.dumps(table, indent=1) + "\n") | ||
| print(f"slow test durations: {len(seconds)} units, {sum(seconds.values()) / 60:.1f} min, written to {args.table}") | ||
| return 0 | ||
|
|
||
|
|
||
| def _nodeid(classname: str, name: str, root: Path) -> str | None: | ||
| """The pytest node id of a JUnit test case: the longest dotted prefix of its classname that is a test | ||
| file, then any classes, then the test's name.""" | ||
| parts = classname.split(".") | ||
| for cut in range(len(parts), 0, -1): | ||
| path = "/".join(parts[:cut]) + ".py" | ||
| if (root / path).is_file(): | ||
| return "::".join([path, *parts[cut:], name]) | ||
| return None | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.