Skip to content
Snippets Groups Projects
Commit d6c3027f authored by Yaroslav Dynnikov's avatar Yaroslav Dynnikov
Browse files

test: rename instance.killpg -> kill

The intention is to eliminate ambiguities in the `Instance` API. Make
it more like `subprocess` module (as regards `kill` and `terminate`
functions).
parent edce4535
No related branches found
No related tags found
1 merge request!114Enhance pytest
...@@ -197,8 +197,8 @@ class Instance: ...@@ -197,8 +197,8 @@ class Instance:
with self.connection(timeout) as conn: with self.connection(timeout) as conn:
return conn.eval(expr, *args) return conn.eval(expr, *args)
def killpg(self): def kill(self):
"""Kill entire process group""" """Kill the instance brutally with SIGKILL"""
if self.process is None: if self.process is None:
# Be idempotent # Be idempotent
return return
...@@ -225,7 +225,7 @@ class Instance: ...@@ -225,7 +225,7 @@ class Instance:
try: try:
return self.process.wait(timeout=kill_after_seconds) return self.process.wait(timeout=kill_after_seconds)
finally: finally:
self.killpg() self.kill()
def start(self): def start(self):
if self.process: if self.process:
...@@ -242,9 +242,9 @@ class Instance: ...@@ -242,9 +242,9 @@ class Instance:
# Assert a new process group is created # Assert a new process group is created
assert os.getpgid(self.process.pid) == self.process.pid assert os.getpgid(self.process.pid) == self.process.pid
def restart(self, killpg: bool = False, drop_db: bool = False): def restart(self, kill: bool = False, drop_db: bool = False):
if killpg: if kill:
self.killpg() self.kill()
else: else:
self.terminate() self.terminate()
......
...@@ -171,7 +171,7 @@ def test_process_management(instance: Instance): ...@@ -171,7 +171,7 @@ def test_process_management(instance: Instance):
print(f"{instance} is still alive") print(f"{instance} is still alive")
# Kill the remaining child in the process group # Kill the remaining child in the process group
instance.killpg() instance.kill()
# When the supervisor is killed, the orphaned child is reparented # When the supervisor is killed, the orphaned child is reparented
# to a subreaper. Pytest isn't the one, and therefore it can't do # to a subreaper. Pytest isn't the one, and therefore it can't do
...@@ -197,8 +197,8 @@ def test_process_management(instance: Instance): ...@@ -197,8 +197,8 @@ def test_process_management(instance: Instance):
assert pid1 == pid2 assert pid1 == pid2
instance.terminate() instance.terminate()
instance.terminate() instance.terminate()
instance.killpg() instance.kill()
instance.killpg() instance.kill()
def test_propose_eval(instance: Instance): def test_propose_eval(instance: Instance):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment