Permalink
Browse files

Removed some superfluous logging

Also, moved the stop test functionality into its own function
  • Loading branch information...
msmith-techempower committed Jun 6, 2017
1 parent f8ce439 commit c049f973870abb2d32ee3e0dd65a34dd81b0ca39
Showing with 27 additions and 41 deletions.
  1. +27 −41 toolset/benchmark/benchmarker.py
@@ -550,10 +550,6 @@ def exit_with_code(code):
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):
time.sleep(60)
@@ -579,11 +575,6 @@ def exit_with_code(code):
logging.info("Sleeping %s seconds to ensure framework is ready" % self.sleep)
time.sleep(self.sleep)
##########################
# Capturing PIDs started
##########################
startedPIDs = subprocess.check_output(['ps -aux'], shell=True)
##########################
# Verify URLs
##########################
@@ -610,36 +601,7 @@ def exit_with_code(code):
##########################
# Stop this test
##########################
out.write(header("Stopping %s" % test.name))
out.flush()
self.__process.terminate()
slept = 0
returnCode = None
while(slept < 30 and returnCode is None):
time.sleep(1)
slept += 1
returnCode = self.__process.poll()
if returnCode is None:
leftovers = ""
for line in subprocess.check_output(['ps -aux'], shell=True).splitlines():
if line not in startedPIDs:
leftovers += line + os.linesep
started = ""
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("Processes Started"))
out.write(started)
out.write(header("Processes Not Killed"))
out.write(leftovers)
out.flush()
return exit_with_code(1)
self.__stop_test(test, out)
out.write(header("Stopped %s" % test.name))
out.flush()
@@ -676,8 +638,7 @@ def exit_with_code(code):
print "Failed verify!"
return exit_with_code(1)
except KeyboardInterrupt:
if self.__process is not None:
self.__process.terminate()
self.__stop_test(test, out)
except (OSError, IOError, subprocess.CalledProcessError) as e:
self.__write_intermediate_results(test.name,"<setup.py> raised an exception")
out.write(header("Subprocess Error %s" % test.name))
@@ -693,6 +654,31 @@ def exit_with_code(code):
# End __run_tests
############################################################
def __stop_test(self, test, out):
if self.__process is not None:
out.write(header("Stopping %s" % test.name))
out.flush()
self.__process.terminate()
slept = 0
returnCode = None
while(slept < 30 and returnCode is None):
time.sleep(1)
slept += 1
returnCode = self.__process.poll()
if returnCode is None:
leftovers = ""
for line in subprocess.check_output(['ps -aux'], shell=True).splitlines():
leftovers += 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("Running Processes"))
out.write(leftovers)
out.flush()
return exit_with_code(1)
def is_port_bound(self, port):
return self.__is_port_bound(port)

0 comments on commit c049f97

Please sign in to comment.