Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] CI: Enable testing on Windows #388

Draft
wants to merge 26 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1b7bbb6
Satisfy testing on macOS
amotl Oct 28, 2020
f2b5c7b
CI: Adjust CrateDB version in versions.cfg only on Linux
amotl Nov 3, 2020
edeb599
Attempt to mitigate "Failed to start Crate instance in time"
amotl Nov 3, 2020
18b332f
CI: Enable testing on Windows
amotl Nov 3, 2020
a9920f0
CI: Use "bash" when running on Windows
amotl Nov 3, 2020
ea3fee2
CI: Disable firewall on Windows before running tests
amotl Nov 3, 2020
769c627
CI: Attempt to mitigate CrateDB bootstrap errors on Windows
amotl Nov 3, 2020
9cba456
CI: Another attempt to mitigate "Unrecognized Windows Sockets error: …
amotl Nov 3, 2020
f589521
CI: Another attempt to mitigate "Unrecognized Windows Sockets error: …
amotl Nov 3, 2020
3e788da
CI: Disable IPv6 on Windows
amotl Nov 3, 2020
3a1c22f
CI: Attempt to fix Windows by setting SystemRoot env variable
amotl Nov 5, 2020
a2c86cf
CI: Fix Windows path handling
amotl Nov 5, 2020
c87dc71
CI: Improve logging to find out about any errors when starting CrateDB
amotl Nov 5, 2020
39fbad7
CI: Improve logging to find out about any errors when starting CrateDB
amotl Nov 5, 2020
8717536
CI: Fix path computation for Windows again
amotl Nov 5, 2020
0d0c4c4
CI: Give test layer some more time to tear down on Windows
amotl Nov 5, 2020
100aa9f
CI: Add comment
amotl Nov 5, 2020
18e60c3
CI: Give test layer some more time to tear down on Windows
amotl Nov 5, 2020
2a73fdd
CI: Ignore test layer timeout on tear down on Windows
amotl Nov 5, 2020
0e5533f
CI: Improve layer shutdown behaviour
amotl Nov 5, 2020
04ebe12
CI: Adjust GHA/Windows
amotl Nov 5, 2020
cb54ce8
CI: GHA/Windows again
amotl Nov 5, 2020
f5abad9
fixup! CI: Adjust CrateDB version in versions.cfg only on Linux
amotl May 25, 2022
7f8ca8b
Sandbox: Update zc.buildout to 2.13.7
amotl May 25, 2022
7d45ba0
CI: Don't fail fast when invoking the test matrix
amotl May 25, 2022
73b94ad
CI: Fix finding `bin/test` on Windows
amotl May 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-2019]
python-version: ['3.7', '3.8', '3.9', '3.10']
cratedb-version: ['4.8.0']
sqla-version: ['1.3.24']
fail-fast: true
fail-fast: false

steps:
- uses: actions/checkout@v3
Expand All @@ -36,13 +36,37 @@ jobs:
echo "/usr/local/opt/gnu-getopt/bin" >> $GITHUB_PATH

- name: Install dependencies
shell: bash
run: |
./devtools/setup_ci.sh --cratedb-version=${{ matrix.cratedb-version }} --sqlalchemy-version=${{ matrix.sqla-version }}

- name: Fix Windows environment
if: matrix.os == 'windows-2019'
shell: bash
run: |
# Disable firewall.
netsh advfirewall set allprofiles state off

# Reset IP stack.
netsh winsock reset

# Disable IPv6.
# https://superuser.com/questions/1545288/disable-ipv6-connectivity-on-windows-without-restarting-the-computer
netsh interface teredo set state disabled
netsh interface ipv6 6to4 set state state=disabled undoonstop=disabled
netsh interface ipv6 isatap set state state=disabled

- name: Invoke tests
shell: bash
run: |
bin/flake8
bin/coverage run bin/test -vv1

test_program=bin/test
if [ ${{ matrix.os }} = "windows-2019" ]; then
test_program=bin/test-script.py
fi
bin/coverage run $test_program -vv1

bin/coverage xml

# https://github.com/codecov/codecov-action
Expand Down
11 changes: 10 additions & 1 deletion DEVELOP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ To run against a single interpreter, you can also invoke::
are listening on the default CrateDB transport port to avoid side effects with
the test layer.

Preparing a release
In order to run the tests on other operating systems than Linux, invoke::

./bin/test-quick

This will skip some tests currently not working on macOS. It can also be used
to speed up the tests, because the tests for testing the test layer will also
be skipped.


Preparing a Release
===================

To create a new release, you must:
Expand Down
8 changes: 8 additions & 0 deletions base.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extends = versions.cfg
versions = versions
show-picked-versions = true
parts = test
test-quick
crate
scripts
coverage
Expand Down Expand Up @@ -40,6 +41,13 @@ recipe = zc.recipe.testrunner
defaults = ['--auto-color']
eggs = crate [test,sqlalchemy]

[test-quick]
relative-paths=true
working-directory = ${buildout:directory}
recipe = zc.recipe.testrunner
defaults = ['--auto-color', '--ignore_dir', 'testing', '--test', '!test_no_retry_on_read_timeout|test_client_threaded|test_client_keepalive|test_username|test_default_schema']
eggs = crate [test,sqlalchemy]

[linter]
recipe = zc.recipe.egg:script
eggs = flake8
Expand Down
14 changes: 8 additions & 6 deletions devtools/setup_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ function main() {
# Replace SQLAlchemy version.
sed -ir "s/SQLAlchemy.*/SQLAlchemy = ${sqlalchemy_version}/g" versions.cfg

# Replace CrateDB version.
if [ ${cratedb_version} = "nightly" ]; then
sed -ir "s/releases/releases\/nightly/g" base.cfg
sed -ir "s/crate_server.*/crate_server = latest/g" versions.cfg
else
sed -ir "s/crate_server.*/crate_server = ${cratedb_version}/g" versions.cfg
# Adjust CrateDB version, only on Linux.
if [ $(uname -s) = "Linux" ]; then
if [ ${cratedb_version} = "nightly" ]; then
sed -ir "s/releases/releases\/nightly/g" base.cfg
sed -ir "s/crate_server.*/crate_server = latest/g" versions.cfg
else
sed -ir "s/crate_server.*/crate_server = ${cratedb_version}/g" versions.cfg
fi
fi

buildout -n -c base.cfg
Expand Down
6 changes: 6 additions & 0 deletions src/crate/client/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import json
import os
import socket
import pathlib
import sys
import unittest
import doctest
from pprint import pprint
Expand Down Expand Up @@ -166,7 +168,11 @@ def setUpWithCrateLayer(test):
cursor.execute(stmt)
assert cursor.fetchall()[0][0] == 1

# Compute path to file for data loading.
data_path = docs_path('testing/testdata/data/test_a.json')
if sys.platform == 'win32':
data_path = pathlib.PureWindowsPath(data_path).as_uri()

# load testing data into crate
cursor.execute("copy locations from ?", (data_path,))
# refresh location table so imported data is visible immediately
Expand Down
18 changes: 16 additions & 2 deletions src/crate/testing/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ def __init__(self,
self.verbose = verbose
self.env = env or {}
self.env.setdefault('CRATE_USE_IPV4', 'true')
if sys.platform == 'win32':
self.env.setdefault('_JAVA_OPTIONS', '-Djava.awt.headless=true -Djava.net.preferIPv4Stack=true')
self.env.setdefault('SystemRoot', 'C:\\Windows')
self.env.setdefault('JAVA_HOME', os.environ.get('JAVA_HOME', ''))
self._stdout_consumers = []
self.conn_pool = urllib3.PoolManager(num_pools=1)
Expand Down Expand Up @@ -294,6 +297,7 @@ def _clean(self):

def start(self):
self._clean()
sys.stderr.write("Starting process '{}'\n".format(self.start_cmd))
self.process = subprocess.Popen(self.start_cmd,
env=self.env,
stdout=subprocess.PIPE)
Expand Down Expand Up @@ -323,7 +327,17 @@ def start(self):
def stop(self):
if self.process:
self.process.terminate()
self.process.communicate(timeout=10)
try:
self.process.communicate(timeout=10)
except subprocess.TimeoutExpired:
# On GHA/Windows, it always runs into a timeout, even after 45 seconds.
#
# The child process is not killed if the timeout expires, so in order
# to cleanup properly a well-behaved application should kill the child
# process and finish communication.
# https://docs.python.org/3/library/subprocess.html#subprocess.Popen.communicate
self.process.kill()
# self.process.communicate()
self.process.stdout.close()
self.process = None
self.conn_pool.clear()
Expand All @@ -348,7 +362,7 @@ def _wait_for(self, validator):
self.stop()
raise e

if wait_time > 30:
if wait_time > 45:
for line in line_buf.lines:
log.error(line)
self.stop()
Expand Down
3 changes: 2 additions & 1 deletion src/crate/testing/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@


def docs_path(*parts):
return os.path.abspath(
path = os.path.abspath(
os.path.join(
os.path.dirname(os.path.dirname(__file__)), *parts
)
)
return path


def project_root(*parts):
Expand Down
3 changes: 3 additions & 0 deletions versions.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ py = 1.10.0
tox = 3.23.0
twine = 3.4.0
pkginfo = 1.7.0
virtualenv = 15.1.0
wheel = 0.24.0
zc.buildout = 2.13.7
zc.customdoctests = 1.0.1
zc.recipe.egg = 2.0.7
zc.recipe.testrunner = 2.2
Expand Down