Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions tests/integration/standard/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,13 @@ def test_no_connection_refused_on_timeout(self):
insert_statement = self.session.prepare("INSERT INTO test3rf.lwt (k, v) VALUES (0, 0) IF NOT EXISTS")
delete_statement = self.session.prepare("DELETE FROM test3rf.lwt WHERE k = 0 IF EXISTS")

iterations = int(os.getenv("LWT_ITERATIONS", 1000))
iterations = 100

# Use a short request timeout to reliably trigger client-side
# timeouts during the concurrent LWT barrage. Without this the
# test is flaky: on fast CI runners all LWT operations may
# succeed before the default timeout.
short_timeout_profile = ExecutionProfile(request_timeout=0.005)

# Prepare series of parallel statements
statements_and_params = []
Expand All @@ -934,24 +940,31 @@ def test_no_connection_refused_on_timeout(self):
statements_and_params.append((delete_statement, ()))

received_timeout = False
results = execute_concurrent(self.session, statements_and_params, raise_on_first_error=False)
results = execute_concurrent(self.session, statements_and_params,
raise_on_first_error=False,
execution_profile=short_timeout_profile)
for (success, result) in results:
if success:
continue
else:
# In this case result is an exception
exception_type = type(result).__name__
if exception_type == "NoHostAvailable":
pytest.fail("PYTHON-91: Disconnected from Cassandra: %s" % result.message)
if exception_type in ["WriteTimeout", "WriteFailure", "ReadTimeout", "ReadFailure", "ErrorMessageSub"]:
if type(result).__name__ in ["WriteTimeout", "WriteFailure"]:
received_timeout = True
received_timeout = True
continue
if exception_type in ["WriteTimeout", "WriteFailure", "ReadTimeout", "ReadFailure",
"OperationTimedOut", "ErrorMessageSub"]:
received_timeout = True
continue

pytest.fail("Unexpected exception %s: %s" % (exception_type, result.message))
pytest.fail("Unexpected exception %s: %s" % (exception_type, result))

# Make sure we actually saw timeouts
assert received_timeout, "Expected at least one timeout during concurrent LWT operations"

# Make sure test passed
assert received_timeout
# PYTHON-91: verify the session is still usable after timeouts —
# the connection must not have been permanently broken.
self.session.execute("SELECT * FROM test3rf.lwt LIMIT 1")

@xfail_scylla('Fails on Scylla with error `SERIAL/LOCAL_SERIAL consistency may only be requested for one partition at a time`')
def test_was_applied_batch_stmt(self):
Expand Down
Loading