Skip to content

Commit bd62797

Browse files
chore(ci): testing with Python3.10 and ZK 3.5.10, 3.6.3, 3.7.1 (#659)
Testing libs have been upgraded. The used java classpath now considers more .jar possible locations. test_connection.py tests is now done first, trying to make it less flaky. conftest.py has been added to give a way to display ZK cluster logs. Because of ZK 3.6 and 3.7 changes, configurations related to local session has been added. Disable GA fail-fast because of the flakiness
1 parent 5f7ae48 commit bd62797

File tree

9 files changed

+77
-13
lines changed

9 files changed

+77
-13
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
- name: Handle the code
1414
uses: actions/checkout@v2
1515

16-
- name: Set up Python 3.9
16+
- name: Set up Python 3.10
1717
uses: actions/setup-python@v2
1818
with:
19-
python-version: 3.9
19+
python-version: "3.10"
2020

2121
- name: Install pypa/build
2222
run: >-

.github/workflows/testing.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@ jobs:
1919
runs-on: ubuntu-latest
2020

2121
strategy:
22+
fail-fast: false
2223
matrix:
23-
python-version: [3.7, 3.8, 3.9, pypy-3.7]
24-
zk-version: [3.4.14, 3.5.8]
24+
python-version: [3.7, 3.8, 3.9, "3.10", pypy-3.7]
25+
zk-version: [3.4.14, 3.5.10, 3.6.3, 3.7.1]
2526
include:
2627
- python-version: 3.7
2728
tox-env: py37
2829
- python-version: 3.8
2930
tox-env: py38
3031
- python-version: 3.9
3132
tox-env: py39
33+
- python-version: "3.10"
34+
tox-env: py310
3235
- python-version: pypy-3.7
3336
tox-env: pypy3
3437
steps:

constraints.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Consistent testing environment.
22
coverage==6.3.2
3-
flake8==3.7.9
3+
flake8==3.9.2
44
mock==3.0.5
5-
objgraph==3.4.1
6-
pytest-cov~=2.12
7-
pytest~=4.6
5+
objgraph==3.5.0
6+
pytest==6.2.5
7+
pytest-cov==3.0.0
88

99
# Documentation building.
1010
Jinja2==2.7.3

kazoo/testing/common.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import logging
2828
import os
2929
import os.path
30+
import pathlib
3031
import shutil
3132
import signal
3233
import subprocess
@@ -207,6 +208,9 @@ def classpath(self):
207208
jars.extend(glob(os.path.join(
208209
self.install_path,
209210
"lib/*.jar")))
211+
jars.extend(glob(os.path.join(
212+
self.install_path,
213+
"*.jar")))
210214
# support for different file locations on Debian/Ubuntu
211215
jars.extend(glob(os.path.join(
212216
self.install_path,
@@ -268,6 +272,16 @@ def destroy(self):
268272

269273
shutil.rmtree(self.working_path, True)
270274

275+
def get_logs(self):
276+
log_path = pathlib.Path(
277+
self.working_path,
278+
'zookeeper.log'
279+
)
280+
if log_path.exists():
281+
log_file = log_path.open('r')
282+
lines = log_file.readlines()
283+
return lines[-100:]
284+
return []
271285

272286
class ZookeeperCluster(object):
273287

@@ -339,3 +353,9 @@ def terminate(self):
339353
def reset(self):
340354
for server in self:
341355
server.reset()
356+
357+
def get_logs(self):
358+
logs = []
359+
for server in self:
360+
logs += server.get_logs()
361+
return logs

kazoo/testing/harness.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"ZOOKEEPER_PORT_OFFSET": 20000,
2222
"ZOOKEEPER_CLUSTER_SIZE": 3,
2323
"ZOOKEEPER_OBSERVER_START_ID": -1,
24+
"ZOOKEEPER_LOCAL_SESSION_RO": "false"
2425
}
2526

2627

@@ -34,7 +35,8 @@ def get_global_cluster():
3435
"ZOOKEEPER_CLUSTER_SIZE",
3536
"ZOOKEEPER_VERSION",
3637
"ZOOKEEPER_OBSERVER_START_ID",
37-
"ZOOKEEPER_JAAS_AUTH"]
38+
"ZOOKEEPER_JAAS_AUTH",
39+
"ZOOKEEPER_LOCAL_SESSION_RO"]
3840
}
3941
if CLUSTER is not None:
4042
if CLUSTER_CONF == cluster_conf:
@@ -61,9 +63,16 @@ def get_global_cluster():
6163
"For deb package installations this is /usr/share/java")
6264

6365
if ZK_VERSION >= (3, 5):
66+
ZOOKEEPER_LOCAL_SESSION_RO = cluster_conf.get(
67+
"ZOOKEEPER_LOCAL_SESSION_RO"
68+
)
6469
additional_configuration_entries = [
6570
"4lw.commands.whitelist=*",
66-
"reconfigEnabled=true"
71+
"reconfigEnabled=true",
72+
# required to avoid session validation error
73+
# in read only test
74+
"localSessionsEnabled=" + ZOOKEEPER_LOCAL_SESSION_RO,
75+
"localSessionsUpgradingEnabled=" + ZOOKEEPER_LOCAL_SESSION_RO
6776
]
6877
# If defined, this sets the superuser password to "test"
6978
additional_java_system_properties = [

kazoo/tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import logging
2+
3+
log = logging.getLogger(__name__)
4+
5+
6+
def pytest_exception_interact(node, call, report):
7+
cluster = node._testcase.cluster
8+
log.error('Zookeeper cluster logs:')
9+
for logs in cluster.get_logs():
10+
log.error(logs)

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ def back(state):
257257

258258
class TestReadOnlyMode(KazooTestCase):
259259
def setUp(self):
260+
os.environ["ZOOKEEPER_LOCAL_SESSION_RO"] = "true"
260261
self.setup_zookeeper(read_only=True)
261262
skip = False
262263
if CI_ZK_VERSION and CI_ZK_VERSION < (3, 4):
@@ -272,6 +273,7 @@ def setUp(self):
272273

273274
def tearDown(self):
274275
self.client.stop()
276+
os.environ.pop('ZOOKEEPER_LOCAL_SESSION_RO', None)
275277

276278
def test_read_only(self):
277279
from kazoo.exceptions import NotReadOnlyCallError
@@ -288,9 +290,24 @@ def listen(state):
288290
ev.set()
289291

290292
try:
291-
self.cluster[1].stop()
292-
self.cluster[2].stop()
293-
ev.wait(6)
293+
# stopping both nodes at the same time
294+
# else the test seems flaky when on CI hosts
295+
zk_stop_threads = []
296+
zk_stop_threads.append(
297+
threading.Thread(
298+
target=self.cluster[1].stop, daemon=True
299+
)
300+
)
301+
zk_stop_threads.append(
302+
threading.Thread(
303+
target=self.cluster[2].stop, daemon=True
304+
)
305+
)
306+
for thread in zk_stop_threads:
307+
thread.start()
308+
for thread in zk_stop_threads:
309+
thread.join()
310+
ev.wait(15)
294311
assert ev.is_set()
295312
assert client.client_state == KeeperState.CONNECTED_RO
296313

kazoo/tests/test_sasl.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def setUp(self):
3131

3232
def tearDown(self):
3333
self.teardown_zookeeper()
34+
os.environ.pop('ZOOKEEPER_JAAS_AUTH', None)
3435

3536
def test_connect_sasl_auth(self):
3637
from kazoo.security import make_acl
@@ -80,6 +81,7 @@ def setUp(self):
8081

8182
def tearDown(self):
8283
self.teardown_zookeeper()
84+
os.environ.pop('ZOOKEEPER_JAAS_AUTH', None)
8385

8486
def test_connect_sasl_auth(self):
8587
from kazoo.security import make_acl
@@ -145,6 +147,7 @@ def setUp(self):
145147

146148
def tearDown(self):
147149
self.teardown_zookeeper()
150+
os.environ.pop('ZOOKEEPER_JAAS_AUTH', None)
148151

149152
def test_connect_gssapi_auth(self):
150153
from kazoo.security import make_acl

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ classifiers =
2020
Programming Language :: Python :: 3
2121
Programming Language :: Python :: 3.7
2222
Programming Language :: Python :: 3.8
23+
Programming Language :: Python :: 3.9
24+
Programming Language :: Python :: 3.10
2325
Programming Language :: Python :: Implementation :: CPython
2426
Programming Language :: Python :: Implementation :: PyPy
2527
Topic :: Communications

0 commit comments

Comments
 (0)