Browse Source

Added logging for terminator procs (#2820)

* Added logging for terminator procs

* os.linesep
Mike Smith 8 years ago
parent
commit
ec6ad3c75e
1 changed files with 24 additions and 1 deletions
  1. 24 1
      toolset/benchmark/benchmarker.py

+ 24 - 1
toolset/benchmark/benchmarker.py

@@ -550,6 +550,10 @@ class Benchmarker:
             out.flush()
             try:
                 self.__cleanup_leftover_processes_before_test()
+                ##########################
+                # Capturing PIDs before
+                ##########################
+                normalPIDs = subprocess.check_output(['ps -o pid,ppid,comm -u $(whoami)'], shell=True)
 
                 if self.__is_port_bound(test.port):
                     # We gave it our all
@@ -571,6 +575,11 @@ class Benchmarker:
                 logging.info("Sleeping %s seconds to ensure framework is ready" % self.sleep)
                 time.sleep(self.sleep)
 
+                ##########################
+                # Capturing PIDs started
+                ##########################
+                startedPIDs = subprocess.check_output(['ps -o pid,ppid,comm -u $(whoami)'], shell=True)
+
                 ##########################
                 # Verify URLs
                 ##########################
@@ -609,9 +618,23 @@ class Benchmarker:
                     out.flush()
                     time.sleep(5)
                     if self.__is_port_bound(test.port):
+                        leftovers = "  PID  PPID COMMAND" + os.linesep
+                        for line in subprocess.check_output(['ps -o pid,ppid,comm -u $(whoami)'], shell=True).splitlines():
+                            if line not in startedPIDs:
+                                leftovers += line + os.linesep
+
+                        started = "  PID  PPID COMMAND" + os.linesep
+                        for line in startedPIDs.splitlines():
+                            if line not in normalPIDs:
+                                started += line + os.linesep
+
                         # We gave it our all
                         self.__write_intermediate_results(test.name, "port " + str(test.port) + " was not released by stop")
-                        out.write(header("Error: Port %s was not released by stop %s" % (test.port, test.name)))
+                        out.write(header("Error: Port %s was not released by stop - %s" % (test.port, test.name)))
+                        out.write(header("Processes Started"))
+                        out.write(started)
+                        out.write(header("Processes Not Killed"))
+                        out.write(leftovers)
                         out.flush()
                         return exit_with_code(1)