Skip to content

Commit ae07056

Browse files
WIP: ci: add a job for Windows testing
1 parent 4b13135 commit ae07056

File tree

10 files changed

+158
-82
lines changed

10 files changed

+158
-82
lines changed

.github/workflows/testing.yml

Lines changed: 120 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,117 @@ on:
1111
- release/*
1212

1313
jobs:
14-
validate:
15-
name: Code Validation
16-
17-
runs-on: ubuntu-latest
18-
14+
# validate:
15+
# name: Code Validation
16+
17+
# runs-on: ubuntu-latest
18+
19+
# steps:
20+
# - name: Handle the code
21+
# uses: actions/checkout@v2
22+
23+
# - name: "Set up Python 3.10"
24+
# uses: actions/setup-python@v2
25+
# with:
26+
# python-version: "3.10"
27+
28+
# - name: Handle pip cache
29+
# uses: actions/cache@v2
30+
# with:
31+
# path: ~/.cache/pip
32+
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
33+
# restore-keys: |
34+
# ${{ runner.os }}-pip-
35+
36+
# - name: Install required dependencies
37+
# run: |
38+
# python3 -m pip install --upgrade pip
39+
# pip install tox tox-wheel
40+
41+
# - name: Code check
42+
# run: tox -e ${TOX_VENV}
43+
# env:
44+
# TOX_VENV: black,pep8
45+
46+
# test:
47+
# needs: [validate]
48+
49+
# strategy:
50+
# fail-fast: false
51+
# matrix:
52+
# python-version: ["3.7", "3.8", "3.9", "3.10", "pypy-3.7"]
53+
# zk-version: ["3.4.14", "3.5.10", "3.6.3", "3.7.1"]
54+
# include:
55+
# - python-version: "3.7"
56+
# tox-env: py37
57+
# - python-version: "3.8"
58+
# tox-env: py38
59+
# - python-version: "3.9"
60+
# tox-env: py39
61+
# - python-version: "3.10"
62+
# tox-env: py310
63+
# - python-version: "pypy-3.7"
64+
# tox-env: pypy3
65+
66+
# name: >
67+
# Linux - Test Python ${{ matrix.python-version }},
68+
# ZK ${{ matrix.zk-version }}
69+
70+
# runs-on: ubuntun-latest
71+
# steps:
72+
# - name: Handle the code
73+
# uses: actions/checkout@v2
74+
75+
# - name: Set up Python ${{ matrix.python-version }}
76+
# uses: actions/setup-python@v2
77+
# with:
78+
# python-version: ${{ matrix.python-version }}
79+
80+
# - name: Handle pip cache
81+
# uses: actions/cache@v2
82+
# with:
83+
# path: ~/.cache/pip
84+
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
85+
# restore-keys: |
86+
# ${{ runner.os }}-pip-
87+
88+
# - name: Handle ZK installation cache
89+
# uses: actions/cache@v2
90+
# with:
91+
# path: zookeeper
92+
# key: ${{ runner.os }}-zookeeper
93+
# restore-keys: |
94+
# ${{ runner.os }}-zookeeper
95+
96+
# - name: Install required dependencies
97+
# run: |
98+
# sudo apt-get -y install libevent-dev krb5-kdc krb5-admin-server libkrb5-dev
99+
# python3 -m pip install --upgrade pip
100+
# pip install tox
101+
102+
# - name: Test with tox
103+
# run: tox -e ${TOX_VENV}
104+
# env:
105+
# TOX_VENV: ${{ format('{0}-{1}', matrix.tox-env, 'gevent-eventlet-sasl,codecov') }}
106+
# ZOOKEEPER_VERSION: ${{ matrix.zk-version }}
107+
# # TODO: can be removed once tests for ZK 3.4 are removed
108+
# ZOOKEEPER_PREFIX: "${{ !contains(matrix.zk-version, '3.4') && 'apache-' || '' }}"
109+
# ZOOKEEPER_SUFFIX: "${{ !contains(matrix.zk-version, '3.4') && '-bin' || '' }}"
110+
# ZOOKEEPER_LIB: "${{ !contains(matrix.zk-version, '3.4') && 'lib' || '' }}"
111+
112+
# - name: Publish Codecov report
113+
# uses: codecov/codecov-action@v2
114+
115+
test_windows:
116+
# needs: [validate]
117+
name: Windows - Test Python 3.10, ZK 3.7.1
118+
119+
runs-on: windows-latest
19120
steps:
20121
- name: Handle the code
21122
uses: actions/checkout@v2
22123

23-
- name: "Set up Python 3.10"
124+
- name: Set up Python 3.10
24125
uses: actions/setup-python@v2
25126
with:
26127
python-version: "3.10"
@@ -33,58 +134,6 @@ jobs:
33134
restore-keys: |
34135
${{ runner.os }}-pip-
35136
36-
- name: Install required dependencies
37-
run: |
38-
python3 -m pip install --upgrade pip
39-
pip install tox tox-wheel
40-
41-
- name: Code check
42-
run: tox -e ${TOX_VENV}
43-
env:
44-
TOX_VENV: black,pep8
45-
46-
test:
47-
needs: [validate]
48-
49-
name: >
50-
Test Python ${{ matrix.python-version }},
51-
ZK ${{ matrix.zk-version }}
52-
53-
runs-on: ubuntu-latest
54-
55-
strategy:
56-
fail-fast: false
57-
matrix:
58-
python-version: ["3.7", "3.8", "3.9", "3.10", "pypy-3.7"]
59-
zk-version: ["3.4.14", "3.5.10", "3.6.3", "3.7.1"]
60-
include:
61-
- python-version: "3.7"
62-
tox-env: py37
63-
- python-version: "3.8"
64-
tox-env: py38
65-
- python-version: "3.9"
66-
tox-env: py39
67-
- python-version: "3.10"
68-
tox-env: py310
69-
- python-version: "pypy-3.7"
70-
tox-env: pypy3
71-
steps:
72-
- name: Handle the code
73-
uses: actions/checkout@v2
74-
75-
- name: Set up Python ${{ matrix.python-version }}
76-
uses: actions/setup-python@v2
77-
with:
78-
python-version: ${{ matrix.python-version }}
79-
80-
- name: Handle pip cache
81-
uses: actions/cache@v2
82-
with:
83-
path: ~/.cache/pip
84-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
85-
restore-keys: |
86-
${{ runner.os }}-pip-
87-
88137
- name: Handle ZK installation cache
89138
uses: actions/cache@v2
90139
with:
@@ -93,21 +142,24 @@ jobs:
93142
restore-keys: |
94143
${{ runner.os }}-zookeeper
95144
145+
# https://github.com/actions/setup-java
146+
- name: Setup Java
147+
uses: actions/setup-java@v3
148+
with:
149+
distribution: 'temurin'
150+
java-version: '17'
151+
96152
- name: Install required dependencies
97153
run: |
98-
sudo apt-get -y install libevent-dev krb5-kdc krb5-admin-server libkrb5-dev
99154
python3 -m pip install --upgrade pip
100155
pip install tox
101156
102157
- name: Test with tox
103-
run: tox -e ${TOX_VENV}
158+
run: tox -e py310
104159
env:
105-
TOX_VENV: ${{ format('{0}-{1}', matrix.tox-env, 'gevent-eventlet-sasl,codecov') }}
106-
ZOOKEEPER_VERSION: ${{ matrix.zk-version }}
160+
ZOOKEEPER_VERSION: 3.7.1
107161
# TODO: can be removed once tests for ZK 3.4 are removed
108-
ZOOKEEPER_PREFIX: "${{ !contains(matrix.zk-version, '3.4') && 'apache-' || '' }}"
109-
ZOOKEEPER_SUFFIX: "${{ !contains(matrix.zk-version, '3.4') && '-bin' || '' }}"
110-
ZOOKEEPER_LIB: "${{ !contains(matrix.zk-version, '3.4') && 'lib' || '' }}"
111-
112-
- name: Publish Codecov report
113-
uses: codecov/codecov-action@v2
162+
ZOOKEEPER_PREFIX: "apache-"
163+
ZOOKEEPER_SUFFIX: "-bin"
164+
ZOOKEEPER_LIB: "lib"
165+
shell: bash

kazoo/handlers/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,11 @@ def fileobj_to_fd(fileobj):
354354
raise TypeError("Invalid file object: " "{!r}".format(fileobj))
355355
if fd < 0:
356356
raise TypeError("Invalid file descriptor: {}".format(fd))
357-
os.fstat(fd)
357+
358+
# XXX: needed?
359+
# selectors_module.register handle fileobject, why doing
360+
# stuff getting fd here? why performing check?
361+
# os.fstat(fd)
358362
return fd
359363

360364

kazoo/protocol/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ def _connect_attempt(self, host, hostip, port, retry):
659659
return STOP_CONNECTING
660660
except (ConnectionDropped, KazooTimeoutError) as e:
661661
if isinstance(e, ConnectionDropped):
662-
self.logger.warning("Connection dropped: %s", e)
662+
self.logger.exception("Connection dropped: %s", e)
663663
else:
664664
self.logger.warning("Connection time-out: %s", e)
665665
if client._state != KeeperState.CONNECTING:

kazoo/testing/common.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def classpath(self):
239239
jars = glob((os.path.join(self.install_path, "zookeeper-*.jar")))
240240
if jars:
241241
# Release build (`ant package`)
242-
jars.extend(glob(os.path.join(self.install_path, "lib/*.jar")))
242+
jars.extend(glob(os.path.join(self.install_path, "lib", "*.jar")))
243243
jars.extend(glob(os.path.join(self.install_path, "*.jar")))
244244
# support for different file locations on Debian/Ubuntu
245245
jars.extend(glob(os.path.join(self.install_path, "log4j-*.jar")))
@@ -252,10 +252,10 @@ def classpath(self):
252252
else:
253253
# Development build (plain `ant`)
254254
jars = glob(
255-
(os.path.join(self.install_path, "build/zookeeper-*.jar"))
255+
(os.path.join(self.install_path, "build", "zookeeper-*.jar"))
256256
)
257257
jars.extend(
258-
glob(os.path.join(self.install_path, "build/lib/*.jar"))
258+
glob(os.path.join(self.install_path, "build", "lib", "*.jar"))
259259
)
260260

261261
return os.pathsep.join(jars)

kazoo/tests/conftest.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55

66
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)
7+
if hasattr(node, '_testcase') and hasattr(node._testcase, 'cluster'):
8+
cluster = node._testcase.cluster
9+
log.error("Zookeeper cluster logs:")
10+
for logs in cluster.get_logs():
11+
log.error(logs)

kazoo/tests/test_cache.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import gc
22
import importlib
3+
import sys
34
import uuid
45

56
from mock import patch, call, Mock
@@ -28,6 +29,11 @@ def tearDown(self):
2829

2930
def choose_an_installed_handler(self):
3031
for handler_module, handler_class in self.HANDLERS:
32+
if (
33+
handler_module == "kazoo.handlers.gevent"
34+
and sys.platform == "win32"
35+
):
36+
continue
3137
try:
3238
mod = importlib.import_module(handler_module)
3339
cls = getattr(mod, handler_class)

kazoo/tests/test_eventlet_handler.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,12 @@ def broken():
131131
r.get()
132132

133133
def test_huge_file_descriptor(self):
134-
import resource
134+
try:
135+
import resource
136+
except ImportError:
137+
self.skipTest(
138+
"resource module unavailable on this platform"
139+
)
135140
from eventlet.green import socket
136141
from kazoo.handlers.utils import create_tcp_socket
137142

kazoo/tests/test_gevent_handler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
import sys
23

34
import pytest
45

@@ -9,6 +10,7 @@
910
from kazoo.tests import test_client
1011

1112

13+
@pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
1214
class TestGeventHandler(unittest.TestCase):
1315
def setUp(self):
1416
try:
@@ -76,7 +78,7 @@ def func():
7678
h.dispatch_callback(call1)
7779
ev.wait()
7880

79-
81+
@pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
8082
class TestBasicGeventClient(KazooTestCase):
8183
def setUp(self):
8284
try:
@@ -164,7 +166,7 @@ def test_huge_file_descriptor(self):
164166
for sock in socks:
165167
sock.close()
166168

167-
169+
@pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
168170
class TestGeventClient(test_client.TestClient):
169171
def setUp(self):
170172
try:

kazoo/tests/test_threading_handler.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ def test_double_start_stop(self):
4545
assert h._running is False
4646

4747
def test_huge_file_descriptor(self):
48-
import resource
48+
try:
49+
import resource
50+
except ImportError:
51+
self.skipTest(
52+
"resource module unavailable on this platform"
53+
)
4954
import socket
5055
from kazoo.handlers.utils import create_tcp_socket
5156

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ deps =
3232
sasl: kerberos
3333
codecov: codecov
3434
commands =
35+
bash \
3536
sasl: {toxinidir}/init_krb5.sh {envtmpdir}/kerberos \
36-
/{toxinidir}/ensure-zookeeper-env.sh \
37+
{toxinidir}/ensure-zookeeper-env.sh \
3738
pytest {posargs: -ra -v --cov-report=xml --cov=kazoo kazoo/tests}
3839

3940

0 commit comments

Comments
 (0)