mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-27 10:00:38 +00:00
python tests: NeonEnv: extract shutting down of child processes into a NeonEnv.stop() method
Also shuts down `Broker`, which, before this PR, we did start in `start()` but relied on the fixture to stop. Do it a bit earlier so that, after `NeonEnv.stop()` returns, there are no child processes using `repo_dir`. I need this property in the next commit which adds support for creating a repo_dir snapshot using overlayfs (Dockerfile `FROM scratch` style).
This commit is contained in:
@@ -746,20 +746,12 @@ class NeonEnvBuilder:
|
||||
# Stop all the nodes.
|
||||
if self.env:
|
||||
log.info("Cleaning up all storage and compute nodes")
|
||||
self.env.endpoints.stop_all()
|
||||
for sk in self.env.safekeepers:
|
||||
sk.stop(immediate=True)
|
||||
|
||||
for pageserver in self.env.pageservers:
|
||||
self.env.stop(
|
||||
immediate=True,
|
||||
# if the test threw an exception, don't check for errors
|
||||
# as a failing assertion would cause the cleanup below to fail
|
||||
if exc_type is not None:
|
||||
pageserver.assert_no_metric_errors()
|
||||
|
||||
pageserver.stop(immediate=True)
|
||||
|
||||
self.env.attachment_service.stop(immediate=True)
|
||||
|
||||
ps_assert_metric_no_errors=(exc_type is not None),
|
||||
)
|
||||
cleanup_error = None
|
||||
|
||||
if self.scrub_on_exit:
|
||||
@@ -942,6 +934,17 @@ class NeonEnv:
|
||||
for safekeeper in self.safekeepers:
|
||||
safekeeper.start()
|
||||
|
||||
def stop(self, immediate=False, ps_assert_metric_no_errors=False):
|
||||
self.endpoints.stop_all()
|
||||
for sk in self.safekeepers:
|
||||
sk.stop(immediate=immediate)
|
||||
for pageserver in self.pageservers:
|
||||
if ps_assert_metric_no_errors:
|
||||
pageserver.assert_no_metric_errors()
|
||||
pageserver.stop(immediate=immediate)
|
||||
self.attachment_service.stop(immediate=immediate)
|
||||
self.broker.stop()
|
||||
|
||||
@property
|
||||
def pageserver(self) -> NeonPageserver:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user