Skip to content

Commit

Permalink
system-probe: Add pkg/process/monitor to tests (#25463)
Browse files Browse the repository at this point in the history
* 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 <gjulianm@users.noreply.github.com>

---------

Co-authored-by: Guillermo Julián <gjulianm@users.noreply.github.com>
  • Loading branch information
vitkyrka and gjulianm authored May 16, 2024
1 parent 5a3dd5f commit 49c10b7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tasks/system_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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

Expand Down

0 comments on commit 49c10b7

Please sign in to comment.