diff --git a/monitoring/uss_qualifier/main.py b/monitoring/uss_qualifier/main.py index 57f5eed45c..fa53964541 100644 --- a/monitoring/uss_qualifier/main.py +++ b/monitoring/uss_qualifier/main.py @@ -67,6 +67,12 @@ def parseArgs() -> argparse.Namespace: help="Path to folder where artifacts should be written. If not specified, defaults to output/{CONFIG_NAME}", ) + parser.add_argument( + "--runtime-metadata", + default=None, + help="JSON string containing runtime metadata to record in the test run report (if specified).", + ) + return parser.parse_args() @@ -138,6 +144,7 @@ def run_config( skip_validation: bool, exit_before_execution: bool, output_path: Optional[str], + runtime_metadata: Optional[dict], ): config_src = load_dict_with_references(config_name) @@ -193,6 +200,9 @@ def run_config( logger.info("Executing test run") report = execute_test_run(whole_config, description) + if runtime_metadata is not None: + report.runtime_metadata = runtime_metadata + if config.artifacts: generate_artifacts(report, config.artifacts, output_path) @@ -210,6 +220,12 @@ def run_config( def main() -> int: args = parseArgs() + runtime_metadata = ( + json.loads(args.runtime_metadata) if args.runtime_metadata else None + ) + if runtime_metadata is not None and not isinstance(runtime_metadata, dict): + raise ValueError("--runtime-metadata must specify a JSON dictionary") + config_names = str(args.config).split(",") if args.config_output: @@ -235,6 +251,7 @@ def main() -> int: args.skip_validation, args.exit_before_execution, output_path, + runtime_metadata, ) if exit_code != os.EX_OK: return exit_code diff --git a/monitoring/uss_qualifier/reports/report.py b/monitoring/uss_qualifier/reports/report.py index 4f969508f6..748c2b6afe 100644 --- a/monitoring/uss_qualifier/reports/report.py +++ b/monitoring/uss_qualifier/reports/report.py @@ -738,6 +738,9 @@ class TestRunReport(ImplicitDict): report: TestSuiteActionReport """Report produced by configured test action""" + runtime_metadata: Optional[dict] + """Metadata for the test run specified at runtime.""" + def redact_access_tokens(report: Union[Dict[str, Any], list]) -> None: if isinstance(report, dict): diff --git a/monitoring/uss_qualifier/reports/templates/sequence_view/overview.html b/monitoring/uss_qualifier/reports/templates/sequence_view/overview.html index 86d22dccbd..46a7c0d1ae 100644 --- a/monitoring/uss_qualifier/reports/templates/sequence_view/overview.html +++ b/monitoring/uss_qualifier/reports/templates/sequence_view/overview.html @@ -72,6 +72,16 @@

Sequence view of uss_qualifier test run

+{% if "runtime_metadata" in report %} +
+

Runtime metadata

+
+ {{ explorer_content("runtime_metadata_tree", report.runtime_metadata) }} + {% set collapsible.queries = collapsible.queries + ["runtime_metadata_tree"] %} +
+
+{% endif %} +

Scenarios executed

@@ -147,6 +157,9 @@

Scenarios executed

diff --git a/schemas/monitoring/uss_qualifier/reports/report/TestRunReport.json b/schemas/monitoring/uss_qualifier/reports/report/TestRunReport.json index 2f078d65a8..60cbf7a25d 100644 --- a/schemas/monitoring/uss_qualifier/reports/report/TestRunReport.json +++ b/schemas/monitoring/uss_qualifier/reports/report/TestRunReport.json @@ -30,6 +30,13 @@ "report": { "$ref": "TestSuiteActionReport.json", "description": "Report produced by configured test action" + }, + "runtime_metadata": { + "description": "Metadata for the test run specified at runtime.", + "type": [ + "object", + "null" + ] } }, "required": [