Added potential fix for test_trace_unavailable

This commit is contained in:
bjmb 2017-06-26 16:37:21 -04:00
parent 54c5e982eb
commit 39d1cc5533
2 changed files with 26 additions and 7 deletions

View File

@ -605,19 +605,36 @@ class ClusterTests(unittest.TestCase):
@test_category query
"""
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
self.addCleanup(cluster.shutdown)
session = cluster.connect()
query = "SELECT * FROM system.local"
statement = SimpleStatement(query)
future = session.execute_async(statement, trace=True)
future.result()
self.assertRaises(TraceUnavailable, future.get_query_trace, -1.0)
query = SimpleStatement("SELECT * FROM system.local")
future = session.execute_async(query, trace=True)
self.assertRaises(TraceUnavailable, future.get_query_trace, max_wait=120)
max_retry_count = 10
for i in range(max_retry_count):
future = session.execute_async(statement, trace=True)
future.result()
try:
result = future.get_query_trace(-1.0)
# In case the result has time to come back before this timeout due to a race condition
check_trace(result)
except TraceUnavailable:
break
else:
raise Exception("get_query_trace didn't raise TraceUnavailable after {} tries".format(max_retry_count))
cluster.shutdown()
for i in range(max_retry_count):
future = session.execute_async(statement, trace=True)
try:
result = future.get_query_trace(max_wait=120)
# In case the result has been set check the trace
check_trace(result)
except TraceUnavailable:
break
else:
raise Exception("get_query_trace didn't raise TraceUnavailable after {} tries".format(max_retry_count))
def test_string_coverage(self):
"""

View File

@ -195,6 +195,8 @@ class MetricsNamespaceTest(BasicSharedKeyspaceUnitTestCaseRF3WM):
default_retry_policy=FallthroughRetryPolicy())
cluster2.connect(self.ks_name, wait_for_all_pools=True)
self.assertEqual(len(cluster2.metadata.all_hosts()), 3)
query = SimpleStatement("SELECT * FROM {0}.{0}".format(self.ks_name), consistency_level=ConsistencyLevel.ALL)
self.session.execute(query)