Skip to content

Commit

Permalink
run.py: Introduce metadata files for results
Browse files Browse the repository at this point in the history
This commit adds metadata files to java matrix reports, allowing argus
to correctly collect each version separately.

Task: scylladb/argus#289
  • Loading branch information
k0machi committed Sep 13, 2024
1 parent 547bb24 commit d47b95e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
13 changes: 7 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@ def main(java_driver_git, scylla_install_dir, tests, versions, driver_type,scyll

for version in versions:
logging.info("=== JAVA DRIVER VERSION %s ===", version)

try:
report = run.Run(
runner = run.Run(
java_driver_git=java_driver_git,
scylla_install_dir=scylla_install_dir,
tag=version,
tests=tests,
driver_type=driver_type,
scylla_version=scylla_version).run()

scylla_version=scylla_version)
try:
report = runner.run()
logging.info("=== JAVA DRIVER MATRIX RESULTS FOR %s ===", version)
logging.info(", ".join(f"{key}: {value}" for key, value in report.summary.items()))
if report.is_failed:
Expand All @@ -42,7 +41,9 @@ def main(java_driver_git, scylla_install_dir, tests, versions, driver_type,scyll
logging.exception(f"{version} failed")
status = 1
exc_type, exc_value, exc_traceback = sys.exc_info()
results[version] = dict(exception=traceback.format_exception(exc_type, exc_value, exc_traceback))
failure_reason = traceback.format_exception(exc_type, exc_value, exc_traceback)
results[version] = dict(exception=failure_reason)
runner.create_metadata_for_failure(reason="\n".join(failure_reason))

if recipients:
email_report = create_report(results=results)
Expand Down
22 changes: 21 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import logging
import os
import re
Expand Down Expand Up @@ -37,6 +38,10 @@ def _setup_out_dir(self):
os.makedirs(xunit_dir)
return xunit_dir

@property
def metadata_file_name(self) -> str:
return f'metadata_{self._tag}.json'

@cached_property
def version(self) -> str:
version = self._tag
Expand Down Expand Up @@ -116,6 +121,15 @@ def _apply_patch_files(self) -> bool:
if is_dir_empty:
logging.warning("The '%s' directory does not contain any files", self.version_folder)

def create_metadata_for_failure(self, reason: str) -> None:
metadata_file = Path(os.path.dirname(__file__)) / "reports" / self.metadata_file_name
metadata = {
"driver_name": f"TEST-{self._tag}",
"driver_type": "java",
"failure_reason": reason,
}
metadata_file.write_text(json.dumps(metadata))

def run(self) -> ProcessJUnit:
self._run_command_in_shell("git checkout .")
self._run_command_in_shell(f"git checkout {self._tag}")
Expand Down Expand Up @@ -153,9 +167,15 @@ def run(self) -> ProcessJUnit:
except AssertionError:
# Some tests are failed
pass

metadata_file = Path(os.path.dirname(__file__)) / "reports" / self.metadata_file_name
metadata = {
"driver_name": f"TEST-{self._tag}",
"driver_type": "python",
"junit_result": f"./TEST-{self._tag}.xml",
}
report = ProcessJUnit(
new_report_xml_path=Path(os.path.dirname(__file__)) / "reports" / f"TEST-{self._tag}.xml",
tests_result_path=self._report_path,
tag=self._tag)
metadata_file.write_text(json.dumps(metadata))
return report

0 comments on commit d47b95e

Please sign in to comment.