Skip to content
Permalink
Browse files
Fix flaky test: repair_tests/repair_test.py::TestRepair::test_local_d… (
#161)

Patch by Alex Petrov; reviewed by Caleb Rackliffe for CASSANDRA-16963
  • Loading branch information
ifesdjeen committed Jan 11, 2022
1 parent 0a6fbe4 commit 27c6d022c2d7c197be03c7d6ebe22861ca66a04d
Showing 2 changed files with 11 additions and 8 deletions.
@@ -109,12 +109,12 @@ def _populate_cluster(self, start=True):

# Insert 1000 keys, kill node 3, insert 1 key, restart node 3, insert 1000 more keys
logger.debug("Inserting data...")
insert_c1c2(session, n=1000, consistency=ConsistencyLevel.ALL)
insert_c1c2(session, n=1000, consistency=ConsistencyLevel.ALL, ks='ks')
node3.flush()
node3.stop(wait_other_notice=True)
insert_c1c2(session, keys=(1000, ), consistency=ConsistencyLevel.TWO)
insert_c1c2(session, keys=(1000, ), consistency=ConsistencyLevel.TWO, ks='ks')
node3.start(wait_for_binary_proto=True)
insert_c1c2(session, keys=list(range(1001, 2001)), consistency=ConsistencyLevel.ALL)
insert_c1c2(session, keys=list(range(1001, 2001)), consistency=ConsistencyLevel.ALL, ks='ks')

cluster.flush()

@@ -734,13 +734,13 @@ def _setup_multi_dc(self):

# Insert 1000 keys, kill node 2, insert 1 key, restart node 2, insert 1000 more keys
logger.debug("Inserting data...")
insert_c1c2(session, n=1000, consistency=ConsistencyLevel.ALL)
insert_c1c2(session, n=1000, consistency=ConsistencyLevel.ALL, ks='ks')
node2.flush()
node2.stop(wait_other_notice=True)
insert_c1c2(session, keys=(1000, ), consistency=ConsistencyLevel.THREE)
insert_c1c2(session, keys=(1000, ), consistency=ConsistencyLevel.THREE, ks='ks')
node2.start(wait_for_binary_proto=True)
node1.watch_log_for_alive(node2)
insert_c1c2(session, keys=list(range(1001, 2001)), consistency=ConsistencyLevel.ALL)
insert_c1c2(session, keys=list(range(1001, 2001)), consistency=ConsistencyLevel.ALL, ks='ks')

cluster.flush()

@@ -17,7 +17,7 @@ def create_c1c2_table(tester, session, read_repair=None):
create_cf(session, 'cf', columns={'c1': 'text', 'c2': 'text'}, read_repair=read_repair)


def insert_c1c2(session, keys=None, n=None, consistency=ConsistencyLevel.QUORUM):
def insert_c1c2(session, ks=None, keys=None, n=None, consistency=ConsistencyLevel.QUORUM):
if (keys is None and n is None) or (keys is not None and n is not None):
raise ValueError("Expected exactly one of 'keys' or 'n' arguments to not be None; "
"got keys={keys}, n={n}".format(keys=keys, n=n))
@@ -27,7 +27,10 @@ def insert_c1c2(session, keys=None, n=None, consistency=ConsistencyLevel.QUORUM)
else:
keys = range(n)

statement = session.prepare("INSERT INTO cf (key, c1, c2) VALUES (?, 'value1', 'value2')")
fully_qualified_cf = "cf"
if ((ks is not None) and (not (not ks))):
fully_qualified_cf = "{ks}.cf".format(ks=ks)
statement = session.prepare("INSERT INTO {fully_qualified_cf} (key, c1, c2) VALUES (?, 'value1', 'value2')".format(fully_qualified_cf=fully_qualified_cf))
statement.consistency_level = consistency

execute_concurrent_with_args(session, statement, [['k{}'.format(k)] for k in keys])

0 comments on commit 27c6d02

Please sign in to comment.