Skip to content

Commit

Permalink
Merge branch 'opensearch-project:main' into osci_issue_258
Browse files Browse the repository at this point in the history
  • Loading branch information
dosa-chammandi authored Nov 6, 2023
2 parents 2c44efd + a0adc90 commit 2dce99e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions osbenchmark/utils/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@ def run_subprocess_with_logging(command_line, header=None, level=logging.INFO, s

def is_benchmark_process(p):
cmdline = p.cmdline()
# On Linux, /proc/PID/status truncates the command name to 15 characters.
return p.name() == "opensearch-benchmark" or \
(p.name().lower().startswith("python") and
(len(cmdline) > 1 and
(cmdline[1] == "opensearch-benchmark" or
cmdline[1].endswith(os.path.sep + "opensearch-benchmark"))))
p.name() == "opensearch-benc" or \
(len(cmdline) > 1 and
os.path.basename(cmdline[0].lower()).startswith("python") and
os.path.basename(cmdline[1]) == "opensearch-benchmark")


def find_all_other_benchmark_processes():
Expand Down
4 changes: 4 additions & 0 deletions tests/utils/process_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def test_kills_only_benchmark_processes(self, process_iter):
random_python = ProcessTests.Process(103, "python3", ["/some/django/app"])
other_process = ProcessTests.Process(104, "init", ["/usr/sbin/init"])
benchmark_process_p = ProcessTests.Process(105, "python3", ["/usr/bin/python3", "~/.local/bin/opensearch-benchmark"])
# On Linux, the process name is truncated to 15 characters.
benchmark_process_l = ProcessTests.Process(106, "opensearch-benc", ["/usr/bin/python3", "~/.local/bin/osbenchmark"])
benchmark_process_e = ProcessTests.Process(107, "opensearch-benchmark", ["/usr/bin/python3", "~/.local/bin/opensearch-benchmark"])
benchmark_process_mac = ProcessTests.Process(108, "Python", ["/Python.app/Contents/MacOS/Python",
"~/.local/bin/opensearch-benchmark"])
Expand All @@ -139,6 +141,7 @@ def test_kills_only_benchmark_processes(self, process_iter):
random_python,
other_process,
benchmark_process_p,
benchmark_process_l,
benchmark_process_e,
benchmark_process_mac,
own_benchmark_process,
Expand All @@ -153,6 +156,7 @@ def test_kills_only_benchmark_processes(self, process_iter):
self.assertFalse(random_python.killed)
self.assertFalse(other_process.killed)
self.assertTrue(benchmark_process_p.killed)
self.assertTrue(benchmark_process_l.killed)
self.assertTrue(benchmark_process_e.killed)
self.assertTrue(benchmark_process_mac.killed)
self.assertFalse(own_benchmark_process.killed)
Expand Down

0 comments on commit 2dce99e

Please sign in to comment.