From 49c10b77c2e30285a08585fd0f3e105d8d979de7 Mon Sep 17 00:00:00 2001 From: Vincent Whitchurch Date: Thu, 16 May 2024 18:56:05 +0200 Subject: [PATCH] system-probe: Add pkg/process/monitor to tests (#25463) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * system-probe: Add pkg/process/monitor to tests The process monitor used by USM lives under pkg/process/monitor and has a test suite; run it as part of the system-probe tests to prevent it from breaking. * system-probe: Fix formatting with ruff * system-probe: Ignore packages without dirs If the package does not contain any dirs for the current set of tags, ignore it instead of reporting empty paths which cause crashes later. This is needed now since pkg/process/monitor is not available for Windows. * Use explicit check Co-authored-by: Guillermo Julián --------- Co-authored-by: Guillermo Julián --- tasks/system_probe.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tasks/system_probe.py b/tasks/system_probe.py index 11fab314aadaa..d18835c2ba57d 100644 --- a/tasks/system_probe.py +++ b/tasks/system_probe.py @@ -42,7 +42,12 @@ KITCHEN_DIR = os.getenv('DD_AGENT_TESTING_DIR') or os.path.normpath(os.path.join(os.getcwd(), "test", "kitchen")) KITCHEN_ARTIFACT_DIR = os.path.join(KITCHEN_DIR, "site-cookbooks", "dd-system-probe-check", "files", "default", "tests") -TEST_PACKAGES_LIST = ["./pkg/ebpf/...", "./pkg/network/...", "./pkg/collector/corechecks/ebpf/..."] +TEST_PACKAGES_LIST = [ + "./pkg/ebpf/...", + "./pkg/network/...", + "./pkg/collector/corechecks/ebpf/...", + "./pkg/process/monitor/...", +] TEST_PACKAGES = " ".join(TEST_PACKAGES_LIST) TEST_TIMEOUTS = { "pkg/network/tracer$": "0", @@ -794,7 +799,7 @@ def go_package_dirs(packages, build_tags): target_packages = [] for pkg in packages: - target_packages += ( + dirs = ( check_output( f"go list -find -f \"{{{{ .Dir }}}}\" -mod=mod -tags \"{','.join(build_tags)}\" {pkg}", shell=True, @@ -803,6 +808,9 @@ def go_package_dirs(packages, build_tags): .strip() .split("\n") ) + # Some packages may not be available on all architectures, ignore them + # instead of reporting empty path names + target_packages += [dir for dir in dirs if len(dir) > 0] return target_packages