summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Sorriaux <stephen.sorriaux@gmail.com>2023-04-24 14:40:20 -0400
committerStephen Sorriaux <stephen.sorriaux@gmail.com>2023-04-24 18:13:18 -0400
commit623bf836b9c23d9d28cf8cb6a60e04bc6c3fecca (patch)
tree093cc08a56fca14e68b38afd977f29b7d96b8bd1
parentb39ca3748e1f3ea1cd393b52b9466fbfc2b29670 (diff)
downloadkazoo-feat/windows-testing.tar.gz
feat(testing): add test for Windows platformfeat/windows-testing
-rw-r--r--.github/workflows/testing.yml54
-rw-r--r--kazoo/handlers/utils.py2
-rw-r--r--kazoo/recipe/lock.py1
-rw-r--r--kazoo/testing/common.py6
-rw-r--r--kazoo/tests/test_cache.py6
-rw-r--r--kazoo/tests/test_eventlet_handler.py5
-rw-r--r--kazoo/tests/test_gevent_handler.py4
-rw-r--r--kazoo/tests/test_hosts.py1
-rw-r--r--kazoo/tests/test_threading_handler.py5
-rw-r--r--kazoo/tests/util.py1
-rw-r--r--tox.ini2
11 files changed, 76 insertions, 11 deletions
diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml
index c715b09..952eae2 100644
--- a/.github/workflows/testing.yml
+++ b/.github/workflows/testing.yml
@@ -47,9 +47,8 @@ jobs:
needs: [validate]
name: >
- Test Python ${{ matrix.python-version }},
+ Linux - Test Python ${{ matrix.python-version }},
ZK ${{ matrix.zk-version }}
-
runs-on: ubuntu-latest
strategy:
@@ -111,3 +110,54 @@ jobs:
- name: Publish Codecov report
uses: codecov/codecov-action@v3
+
+ test_windows:
+ needs: [validate]
+ name: Windows - Test Python 3.10, ZK 3.7.1
+
+ runs-on: windows-latest
+ steps:
+ - name: Handle the code
+ uses: actions/checkout@v3
+
+ - name: "Set up Python 3.10"
+ uses: actions/setup-python@v4
+ with:
+ python-version: "3.10"
+
+ - name: Handle pip cache
+ uses: actions/cache@v3
+ with:
+ path: ~/.cache/pip
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
+ restore-keys: |
+ ${{ runner.os }}-pip-
+
+ - name: Handle ZK installation cache
+ uses: actions/cache@v3
+ with:
+ path: zookeeper
+ key: ${{ runner.os }}-zookeeper
+ restore-keys: |
+ ${{ runner.os }}-zookeeper
+
+ # https://github.com/actions/setup-java
+ - name: Setup Java
+ uses: actions/setup-java@v3
+ with:
+ distribution: 'temurin'
+ java-version: '17'
+
+ - name: Install required dependencies
+ run: |
+ python3 -m pip install --upgrade pip
+ pip install tox
+
+ - name: Test with tox
+ run: tox -e py310
+ env:
+ ZOOKEEPER_VERSION: 3.7.1
+ ZOOKEEPER_PREFIX: "apache-"
+ ZOOKEEPER_SUFFIX: "-bin"
+ ZOOKEEPER_LIB: "lib"
+ shell: bash
diff --git a/kazoo/handlers/utils.py b/kazoo/handlers/utils.py
index 9db26c4..858df38 100644
--- a/kazoo/handlers/utils.py
+++ b/kazoo/handlers/utils.py
@@ -382,7 +382,7 @@ def selector_select(
selector.register(fd, events)
except (ValueError, OSError) as e:
# gevent can raise OSError
- raise ValueError('Invalid event mask or fd') from e
+ raise ValueError("Invalid event mask or fd") from e
revents, wevents, xevents = [], [], []
try:
diff --git a/kazoo/recipe/lock.py b/kazoo/recipe/lock.py
index 59c6d8f..8a49039 100644
--- a/kazoo/recipe/lock.py
+++ b/kazoo/recipe/lock.py
@@ -209,7 +209,6 @@ class Lock(object):
return True
def _inner_acquire(self, blocking, timeout, ephemeral=True):
-
# wait until it's our chance to get it..
if self.is_acquired:
if not blocking:
diff --git a/kazoo/testing/common.py b/kazoo/testing/common.py
index a349199..3c635ef 100644
--- a/kazoo/testing/common.py
+++ b/kazoo/testing/common.py
@@ -240,7 +240,7 @@ log4j.appender.ROLLINGFILE.File="""
jars = glob((os.path.join(self.install_path, "zookeeper-*.jar")))
if jars:
# Release build (`ant package`)
- jars.extend(glob(os.path.join(self.install_path, "lib/*.jar")))
+ jars.extend(glob(os.path.join(self.install_path, "lib", "*.jar")))
jars.extend(glob(os.path.join(self.install_path, "*.jar")))
# support for different file locations on Debian/Ubuntu
jars.extend(glob(os.path.join(self.install_path, "log4j-*.jar")))
@@ -253,10 +253,10 @@ log4j.appender.ROLLINGFILE.File="""
else:
# Development build (plain `ant`)
jars = glob(
- (os.path.join(self.install_path, "build/zookeeper-*.jar"))
+ (os.path.join(self.install_path, "build", "zookeeper-*.jar"))
)
jars.extend(
- glob(os.path.join(self.install_path, "build/lib/*.jar"))
+ glob(os.path.join(self.install_path, "build", "lib", "*.jar"))
)
return os.pathsep.join(jars)
diff --git a/kazoo/tests/test_cache.py b/kazoo/tests/test_cache.py
index 31dabc7..7251db6 100644
--- a/kazoo/tests/test_cache.py
+++ b/kazoo/tests/test_cache.py
@@ -1,5 +1,6 @@
import gc
import importlib
+import sys
import uuid
from unittest.mock import patch, call, Mock
@@ -28,6 +29,11 @@ class KazooAdaptiveHandlerTestCase(KazooTestHarness):
def choose_an_installed_handler(self):
for handler_module, handler_class in self.HANDLERS:
+ if (
+ handler_module == "kazoo.handlers.gevent"
+ and sys.platform == "win32"
+ ):
+ continue
try:
mod = importlib.import_module(handler_module)
cls = getattr(mod, handler_class)
diff --git a/kazoo/tests/test_eventlet_handler.py b/kazoo/tests/test_eventlet_handler.py
index 5e89789..2a201a8 100644
--- a/kazoo/tests/test_eventlet_handler.py
+++ b/kazoo/tests/test_eventlet_handler.py
@@ -131,7 +131,10 @@ class TestEventletHandler(unittest.TestCase):
r.get()
def test_huge_file_descriptor(self):
- import resource
+ try:
+ import resource
+ except ImportError:
+ self.skipTest("resource module unavailable on this platform")
from eventlet.green import socket
from kazoo.handlers.utils import create_tcp_socket
diff --git a/kazoo/tests/test_gevent_handler.py b/kazoo/tests/test_gevent_handler.py
index 0745c06..fb37238 100644
--- a/kazoo/tests/test_gevent_handler.py
+++ b/kazoo/tests/test_gevent_handler.py
@@ -1,4 +1,5 @@
import unittest
+import sys
import pytest
@@ -9,6 +10,7 @@ from kazoo.testing import KazooTestCase
from kazoo.tests import test_client
+@pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
class TestGeventHandler(unittest.TestCase):
def setUp(self):
try:
@@ -77,6 +79,7 @@ class TestGeventHandler(unittest.TestCase):
ev.wait()
+@pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
class TestBasicGeventClient(KazooTestCase):
def setUp(self):
try:
@@ -165,6 +168,7 @@ class TestBasicGeventClient(KazooTestCase):
sock.close()
+@pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
class TestGeventClient(test_client.TestClient):
def setUp(self):
try:
diff --git a/kazoo/tests/test_hosts.py b/kazoo/tests/test_hosts.py
index 8f8a811..a2fae1a 100644
--- a/kazoo/tests/test_hosts.py
+++ b/kazoo/tests/test_hosts.py
@@ -36,7 +36,6 @@ class HostsTestCase(TestCase):
assert chroot is None
def test_hosts_list(self):
-
hosts, chroot = collect_hosts("zk01:2181, zk02:2181, zk03:2181")
expected1 = [("zk01", 2181), ("zk02", 2181), ("zk03", 2181)]
assert hosts == expected1
diff --git a/kazoo/tests/test_threading_handler.py b/kazoo/tests/test_threading_handler.py
index 664c444..7799787 100644
--- a/kazoo/tests/test_threading_handler.py
+++ b/kazoo/tests/test_threading_handler.py
@@ -45,7 +45,10 @@ class TestThreadingHandler(unittest.TestCase):
assert h._running is False
def test_huge_file_descriptor(self):
- import resource
+ try:
+ import resource
+ except ImportError:
+ self.skipTest("resource module unavailable on this platform")
import socket
from kazoo.handlers.utils import create_tcp_socket
diff --git a/kazoo/tests/util.py b/kazoo/tests/util.py
index 6351468..836775a 100644
--- a/kazoo/tests/util.py
+++ b/kazoo/tests/util.py
@@ -98,7 +98,6 @@ class Wait(object):
getnow=(lambda: time.time),
getsleep=(lambda: time.sleep),
):
-
if timeout is not None:
self.timeout = timeout
diff --git a/tox.ini b/tox.ini
index 7a6cfe0..567acd2 100644
--- a/tox.ini
+++ b/tox.ini
@@ -32,7 +32,9 @@ deps =
allowlist_externals =
{toxinidir}/ensure-zookeeper-env.sh
{toxinidir}/init_krb5.sh
+ bash
commands =
+ bash \
sasl: {toxinidir}/init_krb5.sh {envtmpdir}/kerberos \
{toxinidir}/ensure-zookeeper-env.sh \
pytest {posargs: -ra -v --cov-report=xml --cov=kazoo kazoo/tests}