Add kill method to PsProcess

Change-Id: Id9a10672086dac8bc23b54ed496161aa6989e4d2
This commit is contained in:
Federico Ressi 2021-08-12 16:47:12 +02:00
parent c16170f190
commit 1027cd96df
2 changed files with 10 additions and 2 deletions

View File

@ -67,6 +67,15 @@ class PsProcessBase:
LOG.error(str(ex))
return None
def kill(self, signal: int = None, **execute_params):
command_line = _command.shell_command("kill")
if signal is not None:
command_line += f"-s {signal}"
command_line += str(self.pid)
_execute.execute(command_line,
ssh_client=self.ssh_client,
**execute_params)
class PsProcessTuple(typing.NamedTuple):
"""Process listed by ps command

View File

@ -117,8 +117,7 @@ class OpenStackTopologyTest(testtools.TestCase):
self.assertIs(node.ssh_client, processes.unique.ssh_client)
# Process isn't listed after kill
sh.execute(f"kill -9 {processes.unique.pid}",
ssh_client=node.ssh_client)
processes.unique.kill()
for attempt in tobiko.retry(timeout=30., interval=5.):
processes = topology.list_nodes_processes(
command_line=command_line,