Skip to content

Commit 092eabd

Browse files
fix(tests): making test_read_only test less flaky
1 parent 33c348b commit 092eabd

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

kazoo/tests/test__connection.py renamed to kazoo/tests/test_connection.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def back(state):
258258
class TestReadOnlyMode(KazooTestCase):
259259
def setUp(self):
260260
os.environ["ZOOKEEPER_LOCAL_SESSION_RO"] = "true"
261-
self.setup_zookeeper(read_only=True)
261+
self.setup_zookeeper()
262262
skip = False
263263
if CI_ZK_VERSION and CI_ZK_VERSION < (3, 4):
264264
skip = True
@@ -278,8 +278,10 @@ def tearDown(self):
278278
def test_read_only(self):
279279
from kazoo.exceptions import NotReadOnlyCallError
280280
from kazoo.protocol.states import KeeperState
281+
from kazoo.retry import KazooRetry
281282

282-
client = self.client
283+
conn_retry = KazooRetry(max_tries=50, delay=0.5, max_delay=180)
284+
client = self._get_client(connection_retry=conn_retry, read_only=True)
283285
states = []
284286
ev = threading.Event()
285287

@@ -289,6 +291,7 @@ def listen(state):
289291
if client.client_state == KeeperState.CONNECTED_RO:
290292
ev.set()
291293

294+
client.start()
292295
try:
293296
# stopping both nodes at the same time
294297
# else the test seems flaky when on CI hosts

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ module = [
114114
'kazoo.testing.common',
115115
'kazoo.testing.harness',
116116
'kazoo.tests.conftest',
117-
'kazoo.tests.test__connection',
118117
'kazoo.tests.test_barrier',
119118
'kazoo.tests.test_build',
120119
'kazoo.tests.test_cache',
121120
'kazoo.tests.test_client',
121+
'kazoo.tests.test_connection',
122122
'kazoo.tests.test_counter',
123123
'kazoo.tests.test_election',
124124
'kazoo.tests.test_eventlet_handler',

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ allowlist_externals =
3636
commands =
3737
sasl: {toxinidir}/init_krb5.sh {envtmpdir}/kerberos \
3838
{toxinidir}/ensure-zookeeper-env.sh \
39-
pytest {posargs: -ra -v --cov-report=xml --cov=kazoo kazoo/tests}
39+
pytest {posargs: -ra -v --cov-report=xml --cov=kazoo kazoo/tests/test_connection.py}
4040

4141
[testenv:build]
4242

0 commit comments

Comments
 (0)