Skip to content

Commit 31fdca6

Browse files
feat(testing): add test for Windows platform
1 parent b06ffd7 commit 31fdca6

File tree

11 files changed

+77
-17
lines changed

11 files changed

+77
-17
lines changed

.github/workflows/testing.yml

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ jobs:
1717
runs-on: ubuntu-latest
1818

1919
steps:
20-
- name: Handle the code
21-
uses: actions/checkout@v4
20+
- uses: actions/checkout@v4
2221

23-
- name: "Set up Python 3.10"
24-
uses: actions/setup-python@v4
22+
- uses: actions/setup-python@v4
2523
with:
2624
python-version: "3.10"
2725

@@ -47,9 +45,8 @@ jobs:
4745
needs: [validate]
4846

4947
name: >
50-
Test Python ${{ matrix.python-version }},
48+
Linux - Test Python ${{ matrix.python-version }},
5149
ZK ${{ matrix.zk-version }}
52-
5350
runs-on: ubuntu-latest
5451

5552
strategy:
@@ -69,8 +66,7 @@ jobs:
6966
- python-version: "pypy-3.7"
7067
tox-env: pypy3
7168
steps:
72-
- name: Handle the code
73-
uses: actions/checkout@v4
69+
- uses: actions/checkout@v4
7470

7571
- name: Set up Python ${{ matrix.python-version }}
7672
uses: actions/setup-python@v4
@@ -111,3 +107,52 @@ jobs:
111107

112108
- name: Publish Codecov report
113109
uses: codecov/codecov-action@v3
110+
111+
test_windows:
112+
needs: [validate]
113+
name: Windows - Sanity test using a single version of Python and ZK
114+
115+
runs-on: windows-latest
116+
steps:
117+
- uses: actions/checkout@v4
118+
119+
- uses: actions/setup-python@v4
120+
with:
121+
python-version: "3.10"
122+
123+
- name: Handle pip cache
124+
uses: actions/cache@v3
125+
with:
126+
path: ~/.cache/pip
127+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
128+
restore-keys: |
129+
${{ runner.os }}-pip-
130+
131+
- name: Handle ZK installation cache
132+
uses: actions/cache@v3
133+
with:
134+
path: zookeeper
135+
key: ${{ runner.os }}-zookeeper
136+
restore-keys: |
137+
${{ runner.os }}-zookeeper
138+
139+
# https://github.com/actions/setup-java
140+
- name: Setup Java
141+
uses: actions/setup-java@v3
142+
with:
143+
distribution: 'temurin'
144+
java-version: '17'
145+
146+
- name: Install required dependencies
147+
run: |
148+
python3 -m pip install --upgrade pip
149+
pip install tox
150+
151+
- name: Test with tox
152+
run: tox -e py310
153+
env:
154+
ZOOKEEPER_VERSION: 3.7.1
155+
ZOOKEEPER_PREFIX: "apache-"
156+
ZOOKEEPER_SUFFIX: "-bin"
157+
ZOOKEEPER_LIB: "lib"
158+
shell: bash

kazoo/handlers/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def selector_select(
382382
selector.register(fd, events)
383383
except (ValueError, OSError) as e:
384384
# gevent can raise OSError
385-
raise ValueError('Invalid event mask or fd') from e
385+
raise ValueError("Invalid event mask or fd") from e
386386

387387
revents, wevents, xevents = [], [], []
388388
try:

kazoo/recipe/lock.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ def _watch_session(self, state):
209209
return True
210210

211211
def _inner_acquire(self, blocking, timeout, ephemeral=True):
212-
213212
# wait until it's our chance to get it..
214213
if self.is_acquired:
215214
if not blocking:

kazoo/testing/common.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def classpath(self):
240240
jars = glob((os.path.join(self.install_path, "zookeeper-*.jar")))
241241
if jars:
242242
# Release build (`ant package`)
243-
jars.extend(glob(os.path.join(self.install_path, "lib/*.jar")))
243+
jars.extend(glob(os.path.join(self.install_path, "lib", "*.jar")))
244244
jars.extend(glob(os.path.join(self.install_path, "*.jar")))
245245
# support for different file locations on Debian/Ubuntu
246246
jars.extend(glob(os.path.join(self.install_path, "log4j-*.jar")))
@@ -253,10 +253,10 @@ def classpath(self):
253253
else:
254254
# Development build (plain `ant`)
255255
jars = glob(
256-
(os.path.join(self.install_path, "build/zookeeper-*.jar"))
256+
(os.path.join(self.install_path, "build", "zookeeper-*.jar"))
257257
)
258258
jars.extend(
259-
glob(os.path.join(self.install_path, "build/lib/*.jar"))
259+
glob(os.path.join(self.install_path, "build", "lib", "*.jar"))
260260
)
261261

262262
return os.pathsep.join(jars)

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 unittest.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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ 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("resource module unavailable on this platform")
135138
from eventlet.green import socket
136139
from kazoo.handlers.utils import create_tcp_socket
137140

kazoo/tests/test_gevent_handler.py

Lines changed: 4 additions & 0 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:
@@ -77,6 +79,7 @@ def func():
7779
ev.wait()
7880

7981

82+
@pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
8083
class TestBasicGeventClient(KazooTestCase):
8184
def setUp(self):
8285
try:
@@ -165,6 +168,7 @@ def test_huge_file_descriptor(self):
165168
sock.close()
166169

167170

171+
@pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
168172
class TestGeventClient(test_client.TestClient):
169173
def setUp(self):
170174
try:

kazoo/tests/test_hosts.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def test_ipv6(self):
3636
assert chroot is None
3737

3838
def test_hosts_list(self):
39-
4039
hosts, chroot = collect_hosts("zk01:2181, zk02:2181, zk03:2181")
4140
expected1 = [("zk01", 2181), ("zk02", 2181), ("zk03", 2181)]
4241
assert hosts == expected1

kazoo/tests/test_threading_handler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ 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("resource module unavailable on this platform")
4952
import socket
5053
from kazoo.handlers.utils import create_tcp_socket
5154

kazoo/tests/util.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ def __init__(
9898
getnow=(lambda: time.time),
9999
getsleep=(lambda: time.sleep),
100100
):
101-
102101
if timeout is not None:
103102
self.timeout = timeout
104103

0 commit comments

Comments
 (0)