cql-pytest: recognize when Scylla crashes
Before this patch, if Scylla crashes during some test in cql-pytest, all tests after it will fail because they can't connect to Scylla - and we can get a report on hundreds of failures without a clear sign of where the real problem was. This patch introduces an autouse fixture (i.e., a fixture automatically used by every test) which tries to run a do-nothing CQL command after each test. If this CQL command fails, we conclude that Scylla crashed and report the test in which this happened - and exist pytest instead of failing a hundred more tests. Fixes #8080 Signed-off-by: Nadav Har'El <nyh@scylladb.com> Message-Id: <20210304132804.1527977-1-nyh@scylladb.com>
This commit is contained in:
@@ -64,6 +64,19 @@ def cql(request):
|
||||
)
|
||||
return cluster.connect()
|
||||
|
||||
# A function-scoped autouse=True fixture allows us to test after every test
|
||||
# that the CQL connection is still alive - and if not report the test which
|
||||
# crashed Scylla and stop running any more tests.
|
||||
@pytest.fixture(scope="function", autouse=True)
|
||||
def cql_test_connection(cql, request):
|
||||
yield
|
||||
try:
|
||||
# We want to run a do-nothing CQL command. "use system" is the
|
||||
# closest to do-nothing I could find...
|
||||
cql.execute("use system")
|
||||
except:
|
||||
pytest.exit(f"Scylla appears to have crashed in test {request.node.parent.name}::{request.node.name}")
|
||||
|
||||
# "test_keyspace" fixture: Creates and returns a temporary keyspace to be
|
||||
# used in tests that need a keyspace. The keyspace is created with RF=1,
|
||||
# and automatically deleted at the end. We use scope="session" so that all
|
||||
|
||||
Reference in New Issue
Block a user