Make LWT timeout test require timeouts to succeed.
This commit is contained in:
@@ -21,7 +21,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
import unittest # noqa
|
import unittest # noqa
|
||||||
|
|
||||||
from cassandra import ConsistencyLevel, WriteTimeout
|
from cassandra import ConsistencyLevel
|
||||||
from cassandra.query import (PreparedStatement, BoundStatement, SimpleStatement,
|
from cassandra.query import (PreparedStatement, BoundStatement, SimpleStatement,
|
||||||
BatchStatement, BatchType, dict_factory)
|
BatchStatement, BatchType, dict_factory)
|
||||||
from cassandra.cluster import Cluster
|
from cassandra.cluster import Cluster
|
||||||
@@ -379,7 +379,6 @@ class LightweightTransactionsTests(unittest.TestCase):
|
|||||||
v int )'''
|
v int )'''
|
||||||
self.session.execute(ddl)
|
self.session.execute(ddl)
|
||||||
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""
|
"""
|
||||||
Shutdown cluster
|
Shutdown cluster
|
||||||
@@ -387,7 +386,6 @@ class LightweightTransactionsTests(unittest.TestCase):
|
|||||||
self.session.execute("DROP TABLE test3rf.lwt")
|
self.session.execute("DROP TABLE test3rf.lwt")
|
||||||
self.cluster.shutdown()
|
self.cluster.shutdown()
|
||||||
|
|
||||||
|
|
||||||
def test_no_connection_refused_on_timeout(self):
|
def test_no_connection_refused_on_timeout(self):
|
||||||
"""
|
"""
|
||||||
Test for PYTHON-91 "Connection closed after LWT timeout"
|
Test for PYTHON-91 "Connection closed after LWT timeout"
|
||||||
@@ -395,7 +393,6 @@ class LightweightTransactionsTests(unittest.TestCase):
|
|||||||
Number of iterations can be specified with LWT_ITERATIONS environment variable.
|
Number of iterations can be specified with LWT_ITERATIONS environment variable.
|
||||||
Default value is 1000
|
Default value is 1000
|
||||||
"""
|
"""
|
||||||
ok = True
|
|
||||||
insert_statement = self.session.prepare("INSERT INTO test3rf.lwt (k, v) VALUES (0, 0) IF NOT EXISTS")
|
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")
|
delete_statement = self.session.prepare("DELETE FROM test3rf.lwt WHERE k = 0 IF EXISTS")
|
||||||
|
|
||||||
@@ -408,21 +405,21 @@ class LightweightTransactionsTests(unittest.TestCase):
|
|||||||
statements_and_params.append((insert_statement, ()))
|
statements_and_params.append((insert_statement, ()))
|
||||||
statements_and_params.append((delete_statement, ()))
|
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)
|
||||||
for (success, result) in results:
|
for (success, result) in results:
|
||||||
if success:
|
if success:
|
||||||
continue
|
continue
|
||||||
# In this case result is an exception
|
# In this case result is an exception
|
||||||
if type(result).__name__ == "NoHostAvailable":
|
if type(result).__name__ == "NoHostAvailable":
|
||||||
print("PYTHON-91: Disconnected from Cassandra: %s" % result.message)
|
self.fail("PYTHON-91: Disconnected from Cassandra: %s" % result.message)
|
||||||
ok = False
|
|
||||||
break
|
break
|
||||||
if type(result).__name__ == "WriteTimeout":
|
if type(result).__name__ == "WriteTimeout":
|
||||||
print("Timeout: %s" % result.message)
|
print("Timeout: %s" % result.message)
|
||||||
|
received_timeout = True
|
||||||
continue
|
continue
|
||||||
ok = False
|
self.fail("Unexpected exception %s: %s" % (type(result).__name__, result.message))
|
||||||
print("Unexpected exception %s: %s" % (type(result).__name__, result.message))
|
|
||||||
break
|
break
|
||||||
|
|
||||||
# Make sure test passed
|
# Make sure test passed
|
||||||
self.assertTrue(ok)
|
self.assertTrue(received_timeout)
|
||||||
|
|||||||
Reference in New Issue
Block a user