Skip to content

Commit

Permalink
WIP: ci: add a job for Windows testing
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenSorriaux committed Nov 11, 2022
1 parent 4b13135 commit 9e217a7
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 80 deletions.
188 changes: 120 additions & 68 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,117 @@ on:
- release/*

jobs:
validate:
name: Code Validation

runs-on: ubuntu-latest

# validate:
# name: Code Validation

# runs-on: ubuntu-latest

# steps:
# - name: Handle the code
# uses: actions/checkout@v2

# - name: "Set up Python 3.10"
# uses: actions/setup-python@v2
# with:
# python-version: "3.10"

# - name: Handle pip cache
# uses: actions/cache@v2
# with:
# path: ~/.cache/pip
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
# restore-keys: |
# ${{ runner.os }}-pip-

# - name: Install required dependencies
# run: |
# python3 -m pip install --upgrade pip
# pip install tox tox-wheel

# - name: Code check
# run: tox -e ${TOX_VENV}
# env:
# TOX_VENV: black,pep8

# test:
# needs: [validate]

# strategy:
# fail-fast: false
# matrix:
# python-version: ["3.7", "3.8", "3.9", "3.10", "pypy-3.7"]
# zk-version: ["3.4.14", "3.5.10", "3.6.3", "3.7.1"]
# include:
# - python-version: "3.7"
# tox-env: py37
# - python-version: "3.8"
# tox-env: py38
# - python-version: "3.9"
# tox-env: py39
# - python-version: "3.10"
# tox-env: py310
# - python-version: "pypy-3.7"
# tox-env: pypy3

# name: >
# Linux - Test Python ${{ matrix.python-version }},
# ZK ${{ matrix.zk-version }}

# runs-on: ubuntun-latest
# steps:
# - name: Handle the code
# uses: actions/checkout@v2

# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v2
# with:
# python-version: ${{ matrix.python-version }}

# - name: Handle pip cache
# uses: actions/cache@v2
# with:
# path: ~/.cache/pip
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
# restore-keys: |
# ${{ runner.os }}-pip-

# - name: Handle ZK installation cache
# uses: actions/cache@v2
# with:
# path: zookeeper
# key: ${{ runner.os }}-zookeeper
# restore-keys: |
# ${{ runner.os }}-zookeeper

# - name: Install required dependencies
# run: |
# sudo apt-get -y install libevent-dev krb5-kdc krb5-admin-server libkrb5-dev
# python3 -m pip install --upgrade pip
# pip install tox

# - name: Test with tox
# run: tox -e ${TOX_VENV}
# env:
# TOX_VENV: ${{ format('{0}-{1}', matrix.tox-env, 'gevent-eventlet-sasl,codecov') }}
# ZOOKEEPER_VERSION: ${{ matrix.zk-version }}
# # TODO: can be removed once tests for ZK 3.4 are removed
# ZOOKEEPER_PREFIX: "${{ !contains(matrix.zk-version, '3.4') && 'apache-' || '' }}"
# ZOOKEEPER_SUFFIX: "${{ !contains(matrix.zk-version, '3.4') && '-bin' || '' }}"
# ZOOKEEPER_LIB: "${{ !contains(matrix.zk-version, '3.4') && 'lib' || '' }}"

# - name: Publish Codecov report
# uses: codecov/codecov-action@v2

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@v2

- name: "Set up Python 3.10"
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
Expand All @@ -33,58 +134,6 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
- name: Install required dependencies
run: |
python3 -m pip install --upgrade pip
pip install tox tox-wheel
- name: Code check
run: tox -e ${TOX_VENV}
env:
TOX_VENV: black,pep8

test:
needs: [validate]

name: >
Test Python ${{ matrix.python-version }},
ZK ${{ matrix.zk-version }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "pypy-3.7"]
zk-version: ["3.4.14", "3.5.10", "3.6.3", "3.7.1"]
include:
- python-version: "3.7"
tox-env: py37
- python-version: "3.8"
tox-env: py38
- python-version: "3.9"
tox-env: py39
- python-version: "3.10"
tox-env: py310
- python-version: "pypy-3.7"
tox-env: pypy3
steps:
- name: Handle the code
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Handle pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Handle ZK installation cache
uses: actions/cache@v2
with:
Expand All @@ -93,21 +142,24 @@ jobs:
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: |
sudo apt-get -y install libevent-dev krb5-kdc krb5-admin-server libkrb5-dev
python3 -m pip install --upgrade pip
pip install tox
- name: Test with tox
run: tox -e ${TOX_VENV}
run: tox -e py310
env:
TOX_VENV: ${{ format('{0}-{1}', matrix.tox-env, 'gevent-eventlet-sasl,codecov') }}
ZOOKEEPER_VERSION: ${{ matrix.zk-version }}
ZOOKEEPER_VERSION: 3.7.1
# TODO: can be removed once tests for ZK 3.4 are removed
ZOOKEEPER_PREFIX: "${{ !contains(matrix.zk-version, '3.4') && 'apache-' || '' }}"
ZOOKEEPER_SUFFIX: "${{ !contains(matrix.zk-version, '3.4') && '-bin' || '' }}"
ZOOKEEPER_LIB: "${{ !contains(matrix.zk-version, '3.4') && 'lib' || '' }}"

- name: Publish Codecov report
uses: codecov/codecov-action@v2
ZOOKEEPER_PREFIX: "apache-"
ZOOKEEPER_SUFFIX: "-bin"
ZOOKEEPER_LIB: "lib"
shell: bash
6 changes: 5 additions & 1 deletion kazoo/handlers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,11 @@ def fileobj_to_fd(fileobj):
raise TypeError("Invalid file object: " "{!r}".format(fileobj))
if fd < 0:
raise TypeError("Invalid file descriptor: {}".format(fd))
os.fstat(fd)

# XXX: needed?
# selectors_module.register handle fileobject, why doing
# stuff getting fd here? why performing check?
# os.fstat(fd)
return fd


Expand Down
2 changes: 1 addition & 1 deletion kazoo/protocol/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ def _connect_attempt(self, host, hostip, port, retry):
return STOP_CONNECTING
except (ConnectionDropped, KazooTimeoutError) as e:
if isinstance(e, ConnectionDropped):
self.logger.warning("Connection dropped: %s", e)
self.logger.exception("Connection dropped: %s", e)
else:
self.logger.warning("Connection time-out: %s", e)
if client._state != KeeperState.CONNECTING:
Expand Down
6 changes: 3 additions & 3 deletions kazoo/testing/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def classpath(self):
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")))
Expand All @@ -252,10 +252,10 @@ def classpath(self):
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)
Expand Down
9 changes: 5 additions & 4 deletions kazoo/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@


def pytest_exception_interact(node, call, report):
cluster = node._testcase.cluster
log.error("Zookeeper cluster logs:")
for logs in cluster.get_logs():
log.error(logs)
if hasattr(node, '_testcase') and hasattr(node._testcase, 'cluster'):
cluster = node._testcase.cluster
log.error("Zookeeper cluster logs:")
for logs in cluster.get_logs():
log.error(logs)
6 changes: 6 additions & 0 deletions kazoo/tests/test_cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import gc
import importlib
import sys
import uuid

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

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)
Expand Down
6 changes: 4 additions & 2 deletions kazoo/tests/test_gevent_handler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
import sys

import pytest

Expand All @@ -9,6 +10,7 @@
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:
Expand Down Expand Up @@ -76,7 +78,7 @@ def func():
h.dispatch_callback(call1)
ev.wait()


@pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
class TestBasicGeventClient(KazooTestCase):
def setUp(self):
try:
Expand Down Expand Up @@ -164,7 +166,7 @@ def test_huge_file_descriptor(self):
for sock in socks:
sock.close()


@pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
class TestGeventClient(test_client.TestClient):
def setUp(self):
try:
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ deps =
sasl: kerberos
codecov: codecov
commands =
bash \
sasl: {toxinidir}/init_krb5.sh {envtmpdir}/kerberos \
/{toxinidir}/ensure-zookeeper-env.sh \
{toxinidir}/ensure-zookeeper-env.sh \
pytest {posargs: -ra -v --cov-report=xml --cov=kazoo kazoo/tests}


Expand Down

0 comments on commit 9e217a7

Please sign in to comment.