aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita Kozlovskiy <nikitka@gmail.com>2023-06-12 08:03:15 +0000
committernkozlovskiy <nmk@ydb.tech>2023-06-12 11:03:15 +0300
commit274eed8957285f3b12aad2bd2ec3cdbd501a9571 (patch)
treebc15885135d34777b13d75560a6f94c0d5ed0ccc
parentd4d1325a138f2bea1fbb4aa9ef8266382f7a09d1 (diff)
downloadydb-274eed8957285f3b12aad2bd2ec3cdbd501a9571.tar.gz
ci: write test shard name for testmo report
ci: write test shard name for testmo report Pull Request resolved: #249
-rwxr-xr-x.github/scripts/tests/extract-logs.py12
-rwxr-xr-x.github/scripts/tests/junit-postprocess.py19
-rw-r--r--.github/scripts/tests/junit_utils.py22
3 files changed, 39 insertions, 14 deletions
diff --git a/.github/scripts/tests/extract-logs.py b/.github/scripts/tests/extract-logs.py
index f6b49743aa..5493133f7e 100755
--- a/.github/scripts/tests/extract-logs.py
+++ b/.github/scripts/tests/extract-logs.py
@@ -8,6 +8,7 @@ from pathlib import Path
from typing import List
from log_parser import ctest_log_parser, parse_yunit_fails, parse_gtest_fails, log_reader
from mute_utils import MutedTestCheck, MutedShardCheck
+from junit_utils import add_junit_log_property
def make_filename(*parts):
@@ -84,13 +85,6 @@ def write_summary(summary, is_mute_shard, is_mute_test):
def patch_jsuite(log_urls, ctest_path, unit_paths):
- def add_link_property(tc, url):
- props = tc.find("properties")
- if props is None:
- props = ET.Element("properties")
- tc.append(props)
- props.append(ET.Element("property", dict(name="url:Log", value=url)))
-
suite_logs = {}
test_logs = {}
@@ -106,7 +100,7 @@ def patch_jsuite(log_urls, ctest_path, unit_paths):
for testcase in root.findall("testcase"):
log_url = suite_logs.get(testcase.attrib["classname"])
if log_url:
- add_link_property(testcase, log_url)
+ add_junit_log_property(testcase, log_url)
changed = True
if changed:
@@ -123,7 +117,7 @@ def patch_jsuite(log_urls, ctest_path, unit_paths):
cls, method = testcase.attrib["classname"], testcase.attrib["name"]
log_url = test_logs.get((cls, method))
if log_url:
- add_link_property(testcase, log_url)
+ add_junit_log_property(testcase, log_url)
changed = True
if changed:
print(f"patch {fn}")
diff --git a/.github/scripts/tests/junit-postprocess.py b/.github/scripts/tests/junit-postprocess.py
index b704eb02e2..3c4fdb05cc 100755
--- a/.github/scripts/tests/junit-postprocess.py
+++ b/.github/scripts/tests/junit-postprocess.py
@@ -4,6 +4,7 @@ import glob
import argparse
import xml.etree.ElementTree as ET
from mute_utils import mute_target, update_suite_info, MutedTestCheck
+from junit_utils import add_junit_property
def case_iterator(root):
@@ -12,14 +13,22 @@ def case_iterator(root):
yield case, cls, method
-def mute_junit(is_mute_test, folder, dry_run):
+def attach_filename(testcase, filename):
+ shardname = os.path.splitext(filename)[0]
+ add_junit_property(testcase, "shard", shardname)
+
+
+def postprocess_junit(is_mute_test, folder, dry_run):
for fn in glob.glob(os.path.join(folder, "*.xml")):
tree = ET.parse(fn)
root = tree.getroot()
total_muted = 0
for suite in root.findall("testsuite"):
muted_cnt = 0
+
for case, cls, method in case_iterator(suite):
+ attach_filename(case, os.path.basename(fn))
+
if is_mute_test(cls, method):
if mute_target(case):
print(f"mute {cls}::{method}")
@@ -32,10 +41,10 @@ def mute_junit(is_mute_test, folder, dry_run):
if total_muted:
update_suite_info(root, n_skipped=total_muted, n_remove_failures=total_muted)
- print(f"{'(dry-run) ' if dry_run else ''}patch {fn}")
+ print(f"{'(dry-run) ' if dry_run else ''}patch {fn}")
- if not dry_run:
- tree.write(fn, xml_declaration=True, encoding="UTF-8")
+ if not dry_run:
+ tree.write(fn, xml_declaration=True, encoding="UTF-8")
def main():
@@ -56,7 +65,7 @@ def main():
print("nothing to mute")
return
- mute_junit(is_mute_test, args.yunit_path, args.dry_run)
+ postprocess_junit(is_mute_test, args.yunit_path, args.dry_run)
if __name__ == "__main__":
diff --git a/.github/scripts/tests/junit_utils.py b/.github/scripts/tests/junit_utils.py
new file mode 100644
index 0000000000..c1aea12f80
--- /dev/null
+++ b/.github/scripts/tests/junit_utils.py
@@ -0,0 +1,22 @@
+from xml.etree import ElementTree as ET
+
+
+def get_or_create_properties(testcase):
+ props = testcase.find("properties")
+ if props is None:
+ props = ET.Element("properties")
+ testcase.append(props)
+ return props
+
+
+def add_junit_link_property(testcase, name, url):
+ add_junit_property(testcase, f"url:{name}", url)
+
+
+def add_junit_property(testcase, name, value):
+ props = get_or_create_properties(testcase)
+ props.append(ET.Element("property", dict(name=name, value=value)))
+
+
+def add_junit_log_property(testcase, url):
+ add_junit_link_property(testcase, "Log", url)