You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ju...@apache.org on 2022/01/13 17:20:15 UTC
[buildstream] branch juerg/tests-casd-server-shutdown created (now 81621f6)
This is an automated email from the ASF dual-hosted git repository.
juergbi pushed a change to branch juerg/tests-casd-server-shutdown
in repository https://gitbox.apache.org/repos/asf/buildstream.git.
at 81621f6 tests/testutils/artifactshare.py: Fix shutdown of test server
This branch includes the following new commits:
new 66358da casserver.py: Request shutdown before closing casd channel
new 81621f6 tests/testutils/artifactshare.py: Fix shutdown of test server
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[buildstream] 01/02: casserver.py: Request shutdown before closing casd channel
Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
juergbi pushed a commit to branch juerg/tests-casd-server-shutdown
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 66358da16b18ea1045de2e0299c72631be1220b8
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Thu Jan 13 07:24:46 2022 +0100
casserver.py: Request shutdown before closing casd channel
This is required to pass the assertion in `CASDChannel.close()`:
assert self._shutdown_requested, "Please request shutdown before closing"
---
src/buildstream/_cas/casserver.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/buildstream/_cas/casserver.py b/src/buildstream/_cas/casserver.py
index e9dd3c8..fb196c8 100644
--- a/src/buildstream/_cas/casserver.py
+++ b/src/buildstream/_cas/casserver.py
@@ -147,6 +147,7 @@ def create_server(repo, *, enable_push, quota, index_only, log_level=LogLevel.Le
yield server
finally:
+ casd_channel.request_shutdown()
casd_channel.close()
casd_manager.release_resources()
[buildstream] 02/02: tests/testutils/artifactshare.py: Fix shutdown of test server
Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
juergbi pushed a commit to branch juerg/tests-casd-server-shutdown
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 81621f6ade835499fa77f23116b5e647455f422e
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Thu Jan 13 17:42:12 2022 +0100
tests/testutils/artifactshare.py: Fix shutdown of test server
buildbox-casd processes used by test servers were not terminated and
kept running after the end of the tests (or crashed because the test
deleted the directories used by buildbox-casd).
---
tests/testutils/artifactshare.py | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/tests/testutils/artifactshare.py b/tests/testutils/artifactshare.py
index 8ce8a41..3a7a953 100644
--- a/tests/testutils/artifactshare.py
+++ b/tests/testutils/artifactshare.py
@@ -1,7 +1,6 @@
import os
import shutil
import signal
-import sys
from collections import namedtuple
from contextlib import ExitStack, contextmanager
from concurrent import futures
@@ -42,20 +41,11 @@ class BaseArtifactShare:
# Run the artifact server.
#
def run(self, q):
+ # Block SIGTERM and SIGINT to allow graceful shutdown and cleanup after initialization
+ signal.pthread_sigmask(signal.SIG_BLOCK, [signal.SIGTERM, signal.SIGINT])
+
with ExitStack() as stack:
try:
- # Handle SIGTERM by calling sys.exit(0), which will raise a SystemExit exception,
- # properly executing cleanup code in `finally` clauses and context managers.
- # This is required to terminate buildbox-casd on SIGTERM.
- signal.signal(signal.SIGTERM, lambda signalnum, frame: sys.exit(0))
-
- try:
- from pytest_cov.embed import cleanup_on_sigterm
- except ImportError:
- pass
- else:
- cleanup_on_sigterm()
-
server = stack.enter_context(self._create_server())
port = server.add_insecure_port("localhost:0")
server.start()
@@ -67,7 +57,17 @@ class BaseArtifactShare:
q.put(port)
# Sleep until termination by signal
- signal.pause()
+ signal.sigwait([signal.SIGTERM, signal.SIGINT])
+
+ server.stop(0)
+
+ # Save collected coverage data
+ try:
+ from pytest_cov.embed import cleanup
+ except ImportError:
+ pass
+ else:
+ cleanup()
# _create_server()
#
@@ -83,6 +83,7 @@ class BaseArtifactShare:
def close(self):
self.process.terminate()
self.process.join()
+ assert self.process.exitcode == 0
# DummyArtifactShare()