Skip to content

Commit 2f406a8

Browse files
committed
Satisfy testing on macOS
1 parent 89f2315 commit 2f406a8

File tree

7 files changed

+105
-32
lines changed

7 files changed

+105
-32
lines changed

.github/workflows/main.yml renamed to .github/workflows/nightly.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Tests
1+
name: Nightly
22

33
on:
44
push:
@@ -14,15 +14,15 @@ jobs:
1414
test:
1515
name: "Python: ${{ matrix.python-version }}
1616
SQLA: ${{ matrix.sqla-version }}
17-
CrateDB: ${{ matrix.crate-version }}
17+
CrateDB: ${{ matrix.cratedb-version }}
1818
on ${{ matrix.os }}"
1919
runs-on: ${{ matrix.os }}
2020
strategy:
2121
matrix:
22-
crate-version: [nightly]
2322
os: [ubuntu-latest]
24-
sqla-version: ['1.1.18', '1.2.19', '1.3.23']
2523
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
24+
cratedb-version: ['nightly']
25+
sqla-version: ['1.1.18', '1.2.19', '1.3.23']
2626
fail-fast: false
2727

2828
steps:
@@ -45,12 +45,11 @@ jobs:
4545
sed -ir 's/SQLAlchemy.*/SQLAlchemy = ${{ matrix.sqla-version }}/g' versions.cfg
4646
4747
# replace CrateDB version
48-
if [ ${{ matrix.crate-version }} = "nightly" ]; then
48+
if [ ${{ matrix.cratedb-version }} = "nightly" ]; then
4949
sed -ir 's/releases/releases\/nightly/g' base.cfg
5050
sed -ir 's/crate_server.*/crate_server = latest/g' versions.cfg
5151
else
52-
sed -ir 's/crate-/crate_/g' base.cfg
53-
sed -ir 's/crate_server.*/crate_server = ${{ matrix.crate-version }}/g' versions.cfg
52+
sed -ir 's/crate_server.*/crate_server = ${{ matrix.cratedb-version }}/g' versions.cfg
5453
fi
5554
5655
buildout -n -c base.cfg

.github/workflows/tests.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
9+
10+
11+
jobs:
12+
test:
13+
name: "Python: ${{ matrix.python-version }}
14+
SQLA: ${{ matrix.sqla-version }}
15+
CrateDB: ${{ matrix.cratedb-version }}
16+
on ${{ matrix.os }}"
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
matrix:
20+
os: [ubuntu-latest, macos-latest]
21+
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
22+
cratedb-version: ['4.5.0']
23+
sqla-version: ['1.1.18', '1.2.19', '1.3.23']
24+
fail-fast: false
25+
26+
steps:
27+
- uses: actions/checkout@master
28+
- name: Set up Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v2
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
37+
# Workaround needed for Python 3.5
38+
python -m pip install --upgrade "setuptools>=31,<51"
39+
40+
pip install zc.buildout==2.13.4
41+
42+
# replace SQLAlchemy version
43+
sed -ir 's/SQLAlchemy.*/SQLAlchemy = ${{ matrix.sqla-version }}/g' versions.cfg
44+
45+
# replace CrateDB version
46+
if [ ${{ matrix.cratedb-version }} = "nightly" ]; then
47+
sed -ir 's/releases/releases\/nightly/g' base.cfg
48+
sed -ir 's/crate_server.*/crate_server = latest/g' versions.cfg
49+
else
50+
sed -ir 's/crate_server.*/crate_server = ${{ matrix.cratedb-version }}/g' versions.cfg
51+
fi
52+
53+
buildout -n -c base.cfg
54+
55+
- name: Test
56+
run: |
57+
bin/flake8
58+
bin/coverage run bin/test -vv1

base.cfg

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,21 @@ eggs = crate
1919
recipe = zc.recipe.egg
2020
eggs = createcoverage
2121

22-
[crate]
22+
[crate:linux]
2323
recipe = hexagonit.recipe.download
2424
url = https://cdn.crate.io/downloads/releases/crate-${versions:crate_server}.tar.gz
2525
strip-top-level-dir = true
2626

27+
[crate:macosx]
28+
recipe = hexagonit.recipe.download
29+
url = https://cdn.crate.io/downloads/releases/cratedb/x64_mac/crate-${versions:crate_server}.tar.gz
30+
strip-top-level-dir = true
31+
32+
[crate:windows]
33+
recipe = hexagonit.recipe.download
34+
url = https://cdn.crate.io/downloads/releases/cratedb/x64_windows/crate-${versions:crate_server}.zip
35+
strip-top-level-dir = true
36+
2737
[test]
2838
relative-paths = true
2939
recipe = zc.recipe.testrunner

src/crate/testing/doctests/layer.txt

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -225,26 +225,9 @@ We might have to wait a moment before the cluster is finally created::
225225
From Uri
226226
--------
227227

228-
The CrateLayer can also be created by providing a URI that points to a Crate
228+
The CrateLayer can also be created by providing a URI that points to a CrateDB
229229
tarball::
230230

231-
>>> import urllib.request
232-
>>> import json
233-
>>> with urllib.request.urlopen('http://crate.io/versions.json') as response:
234-
... versions = json.loads(response.read().decode())
235-
... version = versions['crate_testing']
236-
237-
>>> uri = 'https://cdn.crate.io/downloads/releases/crate-{}.tar.gz'.format(version)
238-
>>> tmpdir = tempfile.mkdtemp()
239-
>>> layer = CrateLayer.from_uri(
240-
... uri, name='crate-uri', http_port=42203, directory=tmpdir)
241-
>>> layer.setUp()
242-
243-
>>> work_dir = os.path.join(tmpdir, 'crate-' + version)
244-
>>> os.path.exists(work_dir)
245-
True
246-
247-
>>> layer.tearDown()
248-
249-
>>> os.path.exists(work_dir)
250-
False
231+
uri = 'https://cdn.crate.io/downloads/releases/crate-{}.tar.gz'.format(version)
232+
layer = CrateLayer.from_uri(
233+
uri, name='crate-uri', http_port=42203, directory=tmpdir)

src/crate/testing/layer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def prepend_http(host):
7272

7373

7474
def _download_and_extract(uri, directory):
75+
sys.stderr.write("\nINFO: Downloading CrateDB archive from {} into {}".format(uri, directory))
76+
sys.stderr.flush()
7577
with io.BytesIO(urlopen(uri).read()) as tmpfile:
7678
with tarfile.open(fileobj=tmpfile) as t:
7779
t.extractall(directory)
@@ -160,7 +162,8 @@ def from_uri(uri,
160162
crate_home = os.path.join(directory, crate_dir)
161163

162164
if os.path.exists(crate_home):
163-
sys.stderr.write('Not extracting Crate tarball because folder already exists')
165+
sys.stderr.write("\nWARNING: Not extracting Crate tarball because folder already exists")
166+
sys.stderr.flush()
164167
else:
165168
_download_and_extract(uri, directory)
166169

src/crate/testing/test_layer.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@
1818
# However, if you have executed another commercial license agreement
1919
# with Crate these terms will supersede the license and you may use the
2020
# software solely pursuant to the terms of the relevant commercial agreement.
21-
21+
import json
2222
import os
2323
import tempfile
24+
import urllib
25+
from distutils.version import LooseVersion
2426
from unittest import TestCase, mock
2527
from io import BytesIO
28+
29+
import crate
2630
from .layer import CrateLayer, prepend_http, http_url_from_host_port, wait_for_http_url
2731

2832

@@ -58,6 +62,22 @@ def test_wait_for_http(self):
5862
addr = wait_for_http_url(log=log, timeout=1)
5963
self.assertEqual(None, addr)
6064

65+
@mock.patch.object(crate.testing.layer, "_download_and_extract", lambda uri, directory: None)
66+
def test_layer_from_uri(self):
67+
"""
68+
The CrateLayer can also be created by providing an URI that points to
69+
a CrateDB tarball.
70+
"""
71+
with urllib.request.urlopen("https://crate.io/versions.json") as response:
72+
versions = json.loads(response.read().decode())
73+
version = versions["crate_testing"]
74+
75+
self.assertGreaterEqual(LooseVersion(version), LooseVersion("4.5.0"))
76+
77+
uri = "https://cdn.crate.io/downloads/releases/crate-{}.tar.gz".format(version)
78+
layer = CrateLayer.from_uri(uri, name="crate-by-uri", http_port=42203)
79+
self.assertIsInstance(layer, CrateLayer)
80+
6181
@mock.patch.dict('os.environ', {}, clear=True)
6282
def test_java_home_env_not_set(self):
6383
with tempfile.TemporaryDirectory() as tmpdir:

versions.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
crate_server = 4.4.2
2+
crate_server = 4.5.0
33

44
flake8 = 3.7.9
55
mccabe = 0.6.1

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy