Skip to content

Commit

Permalink
Fix python test
Browse files Browse the repository at this point in the history
Fix the python test to ensure the cmdLine is found in at least one
process instead of them all because we cannot fetch the cmdLine from
privileged process.
  • Loading branch information
belimawr committed Nov 15, 2023
1 parent 1480659 commit eecad32
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions metricbeat/module/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,6 @@ def test_process(self):
for evt in output:
process = evt["system"]["process"]
found_cmdline |= "cmdline" in process
if not found_cmdline:
try:
print("ProcessName: ", evt['process']['pid'])
print("ProcessName: ", evt['process']['name'])
print("ProcessArgs: ", evt['process']['args'])
except Exception:
print(">>>>>>>>>>>>>>>>>>>> did not find pid, name or args for process")

# Remove 'env' prior to checking documented fields because its keys are dynamic.
process.pop("env", None)
Expand All @@ -441,9 +434,8 @@ def test_process(self):
process.pop("num_threads", None)

self.assertCountEqual(SYSTEM_PROCESS_FIELDS, process.keys())

self.assertTrue(
found_cmdline, "cmdline not found in any process events")
self.assertTrue(
found_cmdline, "cmdline not found in any process events")

@unittest.skipUnless(re.match("(?i)linux|darwin|freebsd", sys.platform), "os")
def test_process_unix(self):
Expand Down

0 comments on commit eecad32

Please sign in to comment.