Commit 3be2e93a authored by Sebastien Robin's avatar Sebastien Robin Committed by Cédric Le Ninivin

testnode: try much more agressively to kill remaining processes

Kill any process having in command line the path reserved for unit
test. This would really allows to kill any remaining process if any.

Do not look if processes are child of testnode, because processes
like mariadb and others are not running as child
parent 4040fdf4
......@@ -48,6 +48,7 @@ class NodeTestSuite(SlapOSInstance):
"""
def __init__(self, reference, working_directory):
self.test_node_working_directory = working_directory
d = os.path.join(working_directory, reference)
super(NodeTestSuite, self).__init__(d)
self.reference = reference
......
......@@ -187,7 +187,7 @@ class ProcessManager(object):
return re.findall(r'^ (--\w+)',
self.spawn(program_path, '--help')['stdout'], re.M)
def killall(self, name):
def killall(self, path):
"""
Kill processes of given name, only if they're orphan or subprocesses of
the testnode.
......@@ -196,20 +196,12 @@ class ProcessManager(object):
pid = os.getpid()
for process in psutil.process_iter():
try:
if process.name() != name:
continue
p = process.parent()
if p is not None:
while p is not None:
if p.pid == pid:
break
p = p.parent()
else:
if not(path in str(process.cmdline())):
continue
except (psutil.AccessDenied, psutil.NoSuchProcess):
continue
logger.debug('ProcesssManager, killall on %s having pid %s',
name, process.pid)
process.name, process.pid)
to_kill_list.append(process.pid)
for pid in to_kill_list:
killCommand(pid)
......
......@@ -207,7 +207,7 @@ class SlapOSControler(object):
createFolder(self.software_root, True)
def initializeSlapOSControler(self, slapproxy_log=None, process_manager=None,
reset_software=False, software_path_list=None):
reset_software=False, software_path_list=None, process_path_to_kill=None):
self.process_manager = process_manager
self.software_path_list = software_path_list
logger.debug('SlapOSControler, initialize, reset_software: %r', reset_software)
......@@ -230,7 +230,8 @@ class SlapOSControler(object):
kwargs['stdout'] = slapproxy_log_fp
kwargs['stderr'] = slapproxy_log_fp
# Make sure there is no slapos alive from previous run
process_manager.killall('slapos')
if process_path_to_kill is not None:
process_manager.killall(process_path_to_kill)
proxy = subprocess.Popen([config['slapos_binary'],
'proxy', 'start', '--cfg' , self.slapos_config], **kwargs)
process_manager.process_pid_set.add(proxy.pid)
......
......@@ -53,7 +53,8 @@ class UnitTestRunner(object):
self.testnode.config)
def _prepareSlapOS(self, working_directory, slapos_instance,
create_partition=1, software_path_list=None, **kw):
create_partition=1, software_path_list=None,
process_path_to_kill=None, **kw):
"""
Launch slapos to build software and partitions
"""
......@@ -72,7 +73,7 @@ class UnitTestRunner(object):
slapos_controler.initializeSlapOSControler(slapproxy_log=slapproxy_log,
process_manager=self.testnode.process_manager, reset_software=reset_software,
software_path_list=software_path_list)
software_path_list=software_path_list, process_path_to_kill=process_path_to_kill)
self.testnode.process_manager.supervisord_pid_file = os.path.join(\
slapos_controler.instance_root, 'var', 'run', 'supervisord.pid')
method_list= ["runSoftwareRelease"]
......@@ -118,7 +119,8 @@ class UnitTestRunner(object):
return self._prepareSlapOS(node_test_suite.working_directory,
node_test_suite,
software_path_list=[node_test_suite.custom_profile_path],
cluster_configuration={'_': json.dumps(node_test_suite.cluster_configuration)})
cluster_configuration={'_': json.dumps(node_test_suite.cluster_configuration)},
process_path_to_kill=node_test_suite.test_node_working_directory)
def getInstanceRoot(self, node_test_suite):
return self._getSlapOSControler(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment