Skip to content
Permalink
Browse files
Relax timeouts and less concurrency for test_contention_many_threads
authored by Adam Holmberg; reviewed by Ekaterina Dimitrova and Benjamin Lerer for CASSANDRA-13517
  • Loading branch information
aholmberg authored and ekaterinadimitrova2 committed Mar 26, 2021
1 parent f9c3d78 commit af190977b64176fdcbca296cb49089ce8cb57266
Showing 1 changed file with 7 additions and 5 deletions.
@@ -5,6 +5,7 @@
from threading import Thread

from cassandra import ConsistencyLevel, WriteTimeout
from cassandra.cluster import Cluster, ExecutionProfile, EXEC_PROFILE_DEFAULT
from cassandra.query import SimpleStatement

from tools.assertions import assert_unavailable
@@ -88,7 +89,7 @@ def test_contention_multi_iterations(self):
# Warning, this test will require you to raise the open
# file limit on OSX. Use 'ulimit -n 1000'
def test_contention_many_threads(self):
self._contention_test(300, 1)
self._contention_test(250, 1)

def _contention_test(self, threads, iterations):
"""
@@ -113,7 +114,6 @@ def __init__(self, wid, session, iterations, query):
self.retries = 0

def run(self):
global worker_done
i = 0
prev = 0
while i < self.iterations:
@@ -159,16 +159,18 @@ def run(self):
nodes = self.cluster.nodelist()
workers = []

c = self.patient_cql_connection(nodes[0], keyspace='ks')
q = c.prepare("""

session = Cluster([nodes[0].ip_addr], connect_timeout=15, idle_heartbeat_interval=0,
execution_profiles={EXEC_PROFILE_DEFAULT: ExecutionProfile(request_timeout=60)}).connect('ks')
q = session.prepare("""
BEGIN BATCH
UPDATE test SET v = ? WHERE k = 0 IF v = ?;
INSERT INTO test (k, id) VALUES (0, ?) IF NOT EXISTS;
APPLY BATCH
""")

for n in range(0, threads):
workers.append(Worker(n, c, iterations, q))
workers.append(Worker(n, session, iterations, q))

start = time.time()

0 comments on commit af19097

Please sign in to comment.