Skip to content

Commit bc213bc

Browse files
author
bjmb
committed
Fixed some tests to make sure there is a shuffle going on
1 parent 5c1e1a6 commit bc213bc

1 file changed

Lines changed: 42 additions & 12 deletions

File tree

tests/integration/long/test_loadbalancingpolicies.py

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -536,14 +536,28 @@ def test_token_aware_with_shuffle_rf2(self):
536536
self._wait_for_nodes_up(range(1, 4), cluster)
537537

538538
create_schema(cluster, session, keyspace, replication_factor=2)
539-
self._insert(session, keyspace)
540-
self._query(session, keyspace)
541539

542-
self.coordinator_stats.assert_query_count_equals(self, 1, 0)
543-
query_count_two = self.coordinator_stats.get_query_count(2)
544-
query_count_three = self.coordinator_stats.get_query_count(3)
545-
self.assertEqual(query_count_two + query_count_three, 12)
540+
LIMIT_TRIES = 20
541+
previous_query_count_two, previous_query_count_three = None, None
542+
for _ in range(LIMIT_TRIES):
543+
self._insert(session, keyspace)
544+
self._query(session, keyspace)
545+
546+
self.coordinator_stats.assert_query_count_equals(self, 1, 0)
547+
query_count_two = self.coordinator_stats.get_query_count(2)
548+
query_count_three = self.coordinator_stats.get_query_count(3)
549+
self.assertEqual(query_count_two + query_count_three, 12)
550+
self.coordinator_stats.reset_counts()
551+
552+
if previous_query_count_two is not None:
553+
if query_count_two != previous_query_count_two or query_count_three != previous_query_count_three:
554+
break
555+
previous_query_count_two, previous_query_count_three = query_count_two, query_count_three
556+
self.coordinator_stats.reset_counts()
557+
else:
558+
raise Exception("After {0} tries shuffle returned the same output".format(LIMIT_TRIES))
546559

560+
#check TokenAwarePolicy still return the remaining replicas when one goes down
547561
self.coordinator_stats.reset_counts()
548562
stop(2)
549563
self._wait_for_nodes_down([2], cluster)
@@ -572,14 +586,30 @@ def test_token_aware_with_shuffle_rf3(self):
572586
self._wait_for_nodes_up(range(1, 4), cluster)
573587

574588
create_schema(cluster, session, keyspace, replication_factor=3)
575-
self._insert(session, keyspace)
576-
self._query(session, keyspace)
577589

578-
query_count_one = self.coordinator_stats.get_query_count(1)
579-
query_count_two = self.coordinator_stats.get_query_count(2)
580-
query_count_three = self.coordinator_stats.get_query_count(3)
581-
self.assertEqual(query_count_one + query_count_two + query_count_three, 12)
590+
LIMIT_TRIES = 20
591+
previous_query_count_one, previous_query_count_two, previous_query_count_three = None, None, None
592+
for _ in range(LIMIT_TRIES):
593+
self._insert(session, keyspace)
594+
self._query(session, keyspace)
595+
596+
query_count_one = self.coordinator_stats.get_query_count(1)
597+
query_count_two = self.coordinator_stats.get_query_count(2)
598+
query_count_three = self.coordinator_stats.get_query_count(3)
599+
self.assertEqual(query_count_one + query_count_two + query_count_three, 12)
600+
601+
if previous_query_count_two is not None:
602+
if query_count_one != previous_query_count_one \
603+
or query_count_two != previous_query_count_two \
604+
or query_count_three != previous_query_count_three:
605+
break
606+
previous_query_count_one, previous_query_count_two, previous_query_count_three = \
607+
query_count_one, query_count_two, query_count_three
608+
self.coordinator_stats.reset_counts()
609+
else:
610+
raise Exception("After {0} tries shuffle returned the same output".format(LIMIT_TRIES))
582611

612+
# check TokenAwarePolicy still return the remaining replicas when one goes down
583613
self.coordinator_stats.reset_counts()
584614
stop(1)
585615
self._wait_for_nodes_down([1], cluster)

0 commit comments

Comments
 (0)