From 613c3329fe17b98f7bd74c49c31bac3901ca3551 Mon Sep 17 00:00:00 2001 From: Charles de Beauchesne Date: Fri, 20 Nov 2026 18:15:57 +0100 Subject: [PATCH 1/2] Remove the JSON report pytest-json-report produced report.json. Its last consumer, the easy-win activation, reads reportJunit.xml since #8612. - remove pytest-json-report and its conftest hooks - collect the item metadata (codeowners, feature ids, declarations) for the JUnit report from pytest_runtest_makereport, as the JSON metadata hook did - remove the unused utils/scripts/markdown_logs.py - update docs Co-Authored-By: Claude Opus 5.5 --- .gitignore | 1 - LICENSE-3rdparty.csv | 1 - conftest.py | 28 +++----------- docs/execute/logs.md | 2 +- .../understand/scenarios/k8s_lib_injection.md | 2 +- docs/understand/scenarios/onboarding.md | 1 - pyproject.toml | 2 +- requirements.txt | 1 - utils/scripts/gitlab_print_logs.sh | 2 +- utils/scripts/markdown_logs.py | 38 ------------------- 10 files changed, 9 insertions(+), 69 deletions(-) delete mode 100644 utils/scripts/markdown_logs.py diff --git a/.gitignore b/.gitignore index aaf85a73781..49eacc3a468 100644 --- a/.gitignore +++ b/.gitignore @@ -33,7 +33,6 @@ bld/ [Oo]bj/ [Ll]og/ dist/ -.report.json !lib-injection/build/docker/ruby/lib_injection_rails_app/bin !utils/build/docker/ruby/rails52/bin diff --git a/LICENSE-3rdparty.csv b/LICENSE-3rdparty.csv index 28167464a4e..6eb5f9541df 100644 --- a/LICENSE-3rdparty.csv +++ b/LICENSE-3rdparty.csv @@ -4,7 +4,6 @@ click,PyPI,BSD-3-Clause,Armin Ronacher requests,PyPI,Apache-2.0,Kenneth Reitz Werkzeug,PyPI,BSD-3-Clause,Armin Ronacher pytest,PyPI,MIT,"Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others" -pytest-json-report,PyPI,MIT,numirias black,PyPI,MIT,Łukasz Langa python-dateutil,PyPI,Apache-2.0,Gustavo Niemeyer packaging,PyPI,Apache-2.0,Donald Stufft and individual contributors diff --git a/conftest.py b/conftest.py index d7ee65ec5bc..ae19e70a968 100644 --- a/conftest.py +++ b/conftest.py @@ -16,7 +16,6 @@ import pytest from _pytest.junitxml import xml_key from pluggy._result import _Result as Result -from pytest_jsonreport.plugin import JSONReport from utils import context from utils._context.junit_parameters import fingerprint_parameters @@ -30,9 +29,6 @@ from utils.manifest import Manifest from utils.properties_serialization import SetupProperties -# Monkey patch JSON-report plugin to avoid noise in report -JSONReport.pytest_terminal_summary = lambda *args, **kwargs: None # noqa: ARG005 - # pytest does not keep a trace of deselected items, so we keep it in a global variable _deselected_items: list[pytest.Item] = [] setup_properties = SetupProperties() @@ -221,7 +217,6 @@ def pytest_configure(config: pytest.Config) -> None: pytest.exit(f"Scenario {config.option.scenario} does not exist", 1) if not config.option.replay and not config.option.collectonly: - config.option.json_report_file = f"{context.scenario.host_log_folder}/report.json" config.option.xmlpath = f"{context.scenario.host_log_folder}/reportJunit.xml" configure_decorators(config) @@ -525,15 +520,17 @@ def pytest_fixture_setup( @pytest.hookimpl(hookwrapper=True) -def pytest_runtest_makereport(item: pytest.Item, call: pytest.CallInfo) -> Generator[None, Result, None]: # noqa: ARG001 +def pytest_runtest_makereport(item: pytest.Item, call: pytest.CallInfo) -> Generator[None, Result, None]: + if call.when == "setup": + _collect_item_metadata(item) + # Run all other hooks to get the report object outcome = yield rep: pytest.TestReport = outcome.get_result() if rep.when == "call": # only attach outcome after test call # rep.outcome is one of: passed, failed, skipped - # but json_report also distinguishes xfailed/xpassed - # via rep.wasxfail and outcome + # xfailed/xpassed are distinguished via rep.wasxfail and outcome value = rep.outcome if getattr(rep, "wasxfail", None): if rep.outcome == "skipped": @@ -558,21 +555,6 @@ def _set_outcome_properties(outcome: PytestOutcome, user_properties: list[tuple] user_properties.append(("dd_tags[test.final_status]", final_status)) -@pytest.hookimpl(optionalhook=True) -def pytest_json_runtest_metadata(item: pytest.Item, call: pytest.CallInfo) -> dict | None: - if call.when != "setup": - return {} - - return _collect_item_metadata(item) - - -def pytest_json_modifyreport(json_report: dict) -> None: - # add usefull data for reporting - json_report["context"] = context.serialize() - - logger.debug("Modifying JSON report finished") - - def pytest_sessionfinish(session: pytest.Session, exitstatus: int) -> None: logger.info("Executing pytest_sessionfinish") diff --git a/docs/execute/logs.md b/docs/execute/logs.md index ce4c741f1b9..7d697799ffa 100644 --- a/docs/execute/logs.md +++ b/docs/execute/logs.md @@ -8,5 +8,5 @@ System tests export a lot of data in `logs/` folder, and this folder is usually * `logs/interfaces/agent`: **agent -> bakcend communication, key folder if you own an agent** * `logs/interfaces.log`: Debug log of what's happening on interfaces * `logs/pytest.log`: **Entire debug, including `logs/interfaces.log`, lot of infos here** -* `logs/report.json`: Technical data about the test run, will be exported to dashboard +* `logs/reportJunit.xml`: Test results in JUnit format, exported to Test Optimization * `logs/weblog_image.json`: Result of `docker inspect` on [weblog](../edit/weblog.md) images diff --git a/docs/understand/scenarios/k8s_lib_injection.md b/docs/understand/scenarios/k8s_lib_injection.md index e15bc40f0f5..e2c649d8556 100644 --- a/docs/understand/scenarios/k8s_lib_injection.md +++ b/docs/understand/scenarios/k8s_lib_injection.md @@ -479,7 +479,7 @@ In the following image you can see the log folder content: These are the main important log/data files: * **test.log:** General log generated by system-tests. -* **report.json:** Pytest results report. +* **reportJunit.xml:** Pytest results report in JUnit XML format. * **lib-injection-testing-xyz-config.yaml:** The kind cluster configuration. In this file you can check the open ports for each cluster and test case. * **lib-injection-testing-xyz_help_values:** Helm chart operator values for each test case. * **daemon.set.describe.log:** Datadog Cluster daemon set logs. diff --git a/docs/understand/scenarios/onboarding.md b/docs/understand/scenarios/onboarding.md index 2eb49b15c1d..08d3f7d698a 100644 --- a/docs/understand/scenarios/onboarding.md +++ b/docs/understand/scenarios/onboarding.md @@ -796,7 +796,6 @@ These are the main important log/data files: ## Root Level Files * **tests.log:** General log generated by system-tests. Here you will see the Pulumi outputs of the remote provisions. -* **report.json:** Pytest results report in JSON format. * **reportJunit.xml:** Pytest results report in JUnit XML format. * **known_versions.json:** Contains information about the known versions of components used in the test. * **setup_properties.json:** Contains the setup properties and configuration used for the test execution. diff --git a/pyproject.toml b/pyproject.toml index 572208e8658..81cf95c2b28 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ packages = ["tests", "utils", "manifests"] dependencies = {file = ["requirements.txt"]} [tool.pytest.ini_options] -addopts = "--json-report --json-report-indent=2 --color=yes --no-header -r Xf" +addopts = "--color=yes --no-header -r Xf" testpaths = [ "tests", ] diff --git a/requirements.txt b/requirements.txt index 9e6148e40c8..845a2b8d575 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,7 +26,6 @@ pulumi-aws==6.38.0 #On Boarding requirements pulumi-command==0.11.1 #On Boarding requirements pulumi-tls==5.0.3 #On Boarding requirements pulumi==3.116.0 #On Boarding requirements -pytest-json-report==1.5.0 pytest-split==0.9.0 pytest-xdist==3.2.1 pytest==7.1.3 diff --git a/utils/scripts/gitlab_print_logs.sh b/utils/scripts/gitlab_print_logs.sh index e297c8b622c..26a2f668ce3 100755 --- a/utils/scripts/gitlab_print_logs.sh +++ b/utils/scripts/gitlab_print_logs.sh @@ -25,7 +25,7 @@ if [ -f "${COLLAPSIBLE_LOGS_SCRIPT}" ]; then while IFS= read -r -d '' file; do section_id=$(printf '%s' "$file" | tr -c '[:alnum:]' '_') bash "${COLLAPSIBLE_LOGS_SCRIPT}" "$file" "logs_${LABEL}_${section_id}" "Logs for ${LABEL} - ${file}" - done < <(find reports -type f \! -name report.json \! -name tests.log -print0) + done < <(find reports -type f \! -name tests.log -print0) else echo "Skipping collapsible log dump: ${COLLAPSIBLE_LOGS_SCRIPT} not found" fi diff --git a/utils/scripts/markdown_logs.py b/utils/scripts/markdown_logs.py deleted file mode 100644 index 66619c26993..00000000000 --- a/utils/scripts/markdown_logs.py +++ /dev/null @@ -1,38 +0,0 @@ -import collections -import json -import os -from pathlib import Path - - -def table_row(*args: str) -> None: - print(f"| {' | '.join(args)} |") - - -def main() -> None: - result: dict[str, dict[str, int]] = {} - all_outcomes = {"passed": "✅", "xpassed": "🍇", "skipped": "⏸️", "failed": "❌"} - - for x in os.listdir("."): - if x.startswith("logs") and Path(f"{x}/report.json").is_file(): - result[x] = collections.defaultdict(int) - with open(f"{x}/report.json") as f: - data = json.load(f) - for test in data["tests"]: - outcome = "skipped" if test["metadata"]["details"] is not None else test["outcome"] - result[x][outcome] += 1 - - table_row("Scenario", *[f"{outcome} {icon}" for outcome, icon in all_outcomes.items()]) - table_row(*(["-"] * (len(all_outcomes) + 1))) - - for folder_name, outcomes in result.items(): - if folder_name == "logs": - scenario_name = "Main scenario" - else: - # "ab_cd_ef" => "Ab Cd Ef" - scenario_name = " ".join([s.capitalize() for s in folder_name[5:].split("_")]) - - table_row(scenario_name, *[str(outcomes.get(outcome, "")) for outcome in all_outcomes]) - - -if __name__ == "__main__": - main() From cf7ad54c35c04ee9e1af48bf4c9ef459029f132d Mon Sep 17 00:00:00 2001 From: Charles de Beauchesne Date: Mon, 23 Nov 2026 11:47:04 +0100 Subject: [PATCH 2/2] Update CI_IMAGE for the new requirements.txt Co-Authored-By: Claude Opus 5.5 --- utils/ci/gitlab/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/ci/gitlab/main.yml b/utils/ci/gitlab/main.yml index a0ecdf34ae7..bf55409118b 100644 --- a/utils/ci/gitlab/main.yml +++ b/utils/ci/gitlab/main.yml @@ -110,7 +110,7 @@ variables: # + utils/ci/gitlab/validate_param_env.py, which is copied into the image) # Update this when any of these files changes: # cat utils/ci/gitlab/docker/system-tests.Dockerfile requirements.txt utils/ci/gitlab/validate_param_env.py | sha256sum | cut -c1-12 - CI_IMAGE: "registry.ddbuild.io/system-tests/ci-runner:9eb0426b57c3" + CI_IMAGE: "registry.ddbuild.io/system-tests/ci-runner:ebfc794bf64e" SYSTEM_TESTS_SPLIT_PIPELINE: "$[[ inputs.split_pipeline ]]" .system_tests_param_base: