Skip to content

Commit

Permalink
Fix python test, remove debug
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 bab5bb4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ def withBeatsEnv(Map args = [:], Closure body) {
error("Error '${err.toString()}'")
} finally {
if (archive) {
archiveArtifacts(allowEmptyArchive: true, artifacts: "${directory}/build/system-tests/docker-logs/TEST-docker-compose-*.log, ${directory}/build/integration-tests/**/**, ${directory}/build/system-tests/last_run/**/**")
archiveArtifacts(allowEmptyArchive: true, artifacts: "${directory}/build/system-tests/docker-logs/TEST-docker-compose-*.log, ${directory}/build/integration-tests/**/**")
archiveTestOutput(directory: directory, testResults: testResults, artifacts: artifacts, id: args.id, upload: upload)
}
tearDown()
Expand Down
17 changes: 7 additions & 10 deletions metricbeat/module/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,10 @@ def test_process(self):
found_cmdline = False
for evt in output:
process = evt["system"]["process"]
# Not all process will have 'cmdline' due to permission issues,
# especially on Windows. Therefore we ensure at least some of
# them will have it.
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 +437,10 @@ 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")
# After iterating over all process, make sure at least one of them had
# the 'cmdline' set.
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 bab5bb4

Please sign in to comment.