From 39d1cc5533e8d22724231eeede154f3a6fcb69cc Mon Sep 17 00:00:00 2001 From: bjmb Date: Mon, 26 Jun 2017 16:37:21 -0400 Subject: [PATCH] Added potential fix for test_trace_unavailable --- tests/integration/standard/test_cluster.py | 31 +++++++++++++++++----- tests/integration/standard/test_metrics.py | 2 ++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/tests/integration/standard/test_cluster.py b/tests/integration/standard/test_cluster.py index e47c3953..03ed4769 100644 --- a/tests/integration/standard/test_cluster.py +++ b/tests/integration/standard/test_cluster.py @@ -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): """ diff --git a/tests/integration/standard/test_metrics.py b/tests/integration/standard/test_metrics.py index 00642aef..38113255 100644 --- a/tests/integration/standard/test_metrics.py +++ b/tests/integration/standard/test_metrics.py @@ -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)