Fixing timing issue with metrics test

This commit is contained in:
GregBestland
2016-08-30 11:26:31 -05:00
parent f5e15123d3
commit 365f1318cc

View File

@@ -320,6 +320,17 @@ class RequestAnalyzer(object):
class MetricsRequestSize(BasicExistingKeyspaceUnitTestCase): class MetricsRequestSize(BasicExistingKeyspaceUnitTestCase):
def wait_for_count(self, ra, expected_count, error=False):
for _ in range(10):
if not error:
if ra.successful is expected_count:
return True
else:
if ra.errors is expected_count:
return True
time.sleep(.01)
return False
def test_metrics_per_cluster(self): def test_metrics_per_cluster(self):
""" """
Test to validate that requests listeners. Test to validate that requests listeners.
@@ -343,8 +354,9 @@ class MetricsRequestSize(BasicExistingKeyspaceUnitTestCase):
except SyntaxException: except SyntaxException:
continue continue
self.assertEqual(ra.errors, 3) self.assertTrue(self.wait_for_count(ra, 10))
self.assertEqual(ra.successful, 10) self.assertTrue(self.wait_for_count(ra, 3, error=True))
# Make sure a poorly coded RA doesn't cause issues # Make sure a poorly coded RA doesn't cause issues
RequestAnalyzer(self.session, throw_on_success=False, throw_on_fail=True) RequestAnalyzer(self.session, throw_on_success=False, throw_on_fail=True)