You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by dc...@apache.org on 2021/08/04 02:08:19 UTC
[cassandra-dtest] branch trunk updated: Fix flaky test
consistent_bootstrap_test.py::TestBootstrapConsistency::test_consistent_reads_after_move
This is an automated email from the ASF dual-hosted git repository.
dcapwell pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-dtest.git
The following commit(s) were added to refs/heads/trunk by this push:
new 230c66c Fix flaky test consistent_bootstrap_test.py::TestBootstrapConsistency::test_consistent_reads_after_move
230c66c is described below
commit 230c66c9395fb339d08744d832279281928d3b9b
Author: David Capwell <dc...@gmail.com>
AuthorDate: Tue Aug 3 19:07:56 2021 -0700
Fix flaky test consistent_bootstrap_test.py::TestBootstrapConsistency::test_consistent_reads_after_move
patch by David Capwell; reviewed by Abe Ratnofsky, Ekaterina Dimitrova for CASSANDRA-16826
---
consistent_bootstrap_test.py | 4 ++--
tools/data.py | 5 +++--
tools/flaky.py | 6 ++++--
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/consistent_bootstrap_test.py b/consistent_bootstrap_test.py
index 59a03d1..e995988 100644
--- a/consistent_bootstrap_test.py
+++ b/consistent_bootstrap_test.py
@@ -49,10 +49,10 @@ class TestBootstrapConsistency(Tester):
logger.debug("Checking that no data was lost")
for n in range(10, 20):
- query_c1c2(n2session, n, ConsistencyLevel.ALL)
+ query_c1c2(n2session, n, ConsistencyLevel.ALL, max_attempts=3)
for n in range(30, 1000):
- query_c1c2(n2session, n, ConsistencyLevel.ALL)
+ query_c1c2(n2session, n, ConsistencyLevel.ALL, max_attempts=3)
def test_consistent_reads_after_bootstrap(self):
logger.debug("Creating a ring")
diff --git a/tools/data.py b/tools/data.py
index d5607e0..7573af3 100644
--- a/tools/data.py
+++ b/tools/data.py
@@ -8,6 +8,7 @@ from cassandra.query import SimpleStatement
from . import assertions
from dtest import create_cf, DtestTimeoutError
from tools.funcutils import get_rate_limited_function
+from tools.flaky import retry
logger = logging.getLogger(__name__)
@@ -29,9 +30,9 @@ def insert_c1c2(session, keys=None, n=None, consistency=ConsistencyLevel.QUORUM)
execute_concurrent_with_args(session, statement, [['k{}'.format(k)] for k in keys])
-def query_c1c2(session, key, consistency=ConsistencyLevel.QUORUM, tolerate_missing=False, must_be_missing=False):
+def query_c1c2(session, key, consistency=ConsistencyLevel.QUORUM, tolerate_missing=False, must_be_missing=False, max_attempts=1):
query = SimpleStatement('SELECT c1, c2 FROM cf WHERE key=\'k%d\'' % key, consistency_level=consistency)
- rows = list(session.execute(query))
+ rows = list(retry(lambda: session.execute(query), max_attempts=max_attempts))
if not tolerate_missing:
assertions.assert_length_equal(rows, 1)
res = rows[0]
diff --git a/tools/flaky.py b/tools/flaky.py
index 7baedad..48237f5 100644
--- a/tools/flaky.py
+++ b/tools/flaky.py
@@ -36,9 +36,11 @@ def requires_rerun(err, *args):
# err[0] contains the type of the error that occurred
return err[0] == RerunTestException
-def retry(fn, num_retries=10, allowed_error=None, sleep_seconds=1):
+def retry(fn, max_attempts=10, allowed_error=None, sleep_seconds=1):
+ if max_attempts <= 0:
+ raise ValueError("max_attempts must be a positive value, but given {}".format(str(max_attempts)))
last_error = None
- for x in range(0, num_retries):
+ for _ in range(0, max_attempts):
try:
return fn()
except Exception as e:
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org