Skip to content

Commit

Permalink
Support Python 3.10 (#1355)
Browse files Browse the repository at this point in the history
Co-authored-by: Quentin Pradet <quentin.pradet@elastic.co>
  • Loading branch information
Rick Boyd and pquentin authored Oct 25, 2021
1 parent 6a16ec6 commit e90597e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 deletions.
1 change: 1 addition & 0 deletions .ci/variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"python_versions": {
"PY38": "3.8.10",
"PY39": "3.9.2",
"PY310": "3.10.0",
"MIN_PY_VER": "3.8.10"
}
}
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ PY_BIN = python3
PIP_WRAPPER = $(PY_BIN) -m pip
export PY38 = $(shell jq -r '.python_versions.PY38' .ci/variables.json)
export PY39 = $(shell jq -r '.python_versions.PY39' .ci/variables.json)
export PY310 = $(shell jq -r '.python_versions.PY310' .ci/variables.json)
export PIP_VERSION = $(shell jq -r '.prerequisite_versions.PIP' .ci/variables.json)
export SETUPTOOLS_VERSION = $(shell jq -r '.prerequisite_versions.SETUPTOOLS' .ci/variables.json)
export WHEEL_VERSION = $(shell jq -r '.prerequisite_versions.WHEEL' .ci/variables.json)
Expand All @@ -38,6 +39,7 @@ VE_MISSING_HELP = "\033[0;31mIMPORTANT\033[0m: Couldn't find $(PWD)/$(VIRTUAL_EN
prereq:
pyenv install --skip-existing $(PY38)
pyenv install --skip-existing $(PY39)
pyenv install --skip-existing $(PY310)
pyenv local $(PY38)
@# Ensure all Python versions are registered for this project
@ jq -r '.python_versions | [.[] | tostring] | join("\n")' .ci/variables.json > .python-version
Expand Down Expand Up @@ -108,15 +110,20 @@ test: check-venv

precommit: lint

# checks min and max python versions
it: check-venv python-caches-clean tox-env-clean
. $(VENV_ACTIVATE_FILE); tox
. $(VENV_ACTIVATE_FILE); tox -e py38
. $(VENV_ACTIVATE_FILE); tox -e py310

it38: check-venv python-caches-clean tox-env-clean
. $(VENV_ACTIVATE_FILE); tox -e py38

it39: check-venv python-caches-clean tox-env-clean
. $(VENV_ACTIVATE_FILE); tox -e py39

it310: check-venv python-caches-clean tox-env-clean
. $(VENV_ACTIVATE_FILE); tox -e py310

check-all: lint test it

benchmark: check-venv
Expand All @@ -129,4 +136,4 @@ release-checks: check-venv
release: check-venv release-checks clean docs it
. $(VENV_ACTIVATE_FILE); ./release.sh $(release_version) $(next_version)

.PHONY: install clean nondocs-clean docs-clean python-caches-clean tox-env-clean docs serve-docs test it it38 benchmark release release-checks prereq venv-create check-env
.PHONY: install clean nondocs-clean docs-clean python-caches-clean tox-env-clean docs serve-docs test it it38 it39 it310 benchmark release release-checks prereq venv-create check-env
2 changes: 1 addition & 1 deletion it/proxy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def http_proxy():
f"-v {config_dir}/squid.conf:/etc/squid/squid.conf "
f"-p 3128:3128 datadog/squid"
)
proxy_container_id = lines[0].strip()
proxy_container_id = lines[-1].strip()
proxy = HttpProxy(authenticated_url="http://testuser:testuser@127.0.0.1:3128", anonymous_url="http://127.0.0.1:3128")
yield proxy
process.run_subprocess(f"docker stop {proxy_container_id}")
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def str_from_file(name):
long_description = str_from_file("README.rst")

# tuples of (major, minor) of supported Python versions ordered from lowest to highest
supported_python_versions = [(3, 8), (3, 9)]
supported_python_versions = [(3, 8), (3, 9), (3, 10)]

################################################################################################
#
Expand All @@ -56,7 +56,7 @@ def str_from_file(name):
# License: MIT
"py-cpuinfo==7.0.0",
# License: MIT
"tabulate==0.8.7",
"tabulate==0.8.9",
# License: MIT
"jsonschema==3.1.1",
# License: BSD
Expand All @@ -69,8 +69,8 @@ def str_from_file(name):
# always use the latest version, these are certificate files...
# License: MPL 2.0
"certifi",
# License: Apache 2.0
"yappi==1.2.3",
# License: MIT
"yappi==1.3.3",
# License: BSD
"ijson==2.6.1",
# License: Apache 2.0
Expand All @@ -92,9 +92,9 @@ def str_from_file(name):

tests_require = [
"ujson",
"pytest==5.4.0",
"pytest==6.2.5",
"pytest-benchmark==3.2.2",
"pytest-asyncio==0.14.0"
"pytest-asyncio==0.16.0"
]

# These packages are only required when developing Rally
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def as_future(result=None, exception=None):
:param exception: Exceptional result.
:return: The corresponding future.
"""
f = asyncio.Future()
f = asyncio.get_running_loop().create_future()
if exception and result:
raise AssertionError("Specify a result or an exception but not both")
if exception:
Expand Down
10 changes: 5 additions & 5 deletions tests/driver/runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3312,7 +3312,7 @@ async def test_raw_with_timeout_and_opaqueid(self, es):
class SleepTests(TestCase):
@mock.patch("elasticsearch.Elasticsearch")
# To avoid real sleeps in unit tests
@mock.patch("asyncio.sleep", return_value=as_future())
@mock.patch("asyncio.sleep")
@run_async
async def test_missing_parameter(self, sleep, es):
r = runner.Sleep()
Expand All @@ -3330,7 +3330,7 @@ async def test_missing_parameter(self, sleep, es):

@mock.patch("elasticsearch.Elasticsearch")
# To avoid real sleeps in unit tests
@mock.patch("asyncio.sleep", return_value=as_future())
@mock.patch("asyncio.sleep")
@run_async
async def test_sleep(self, sleep, es):
r = runner.Sleep()
Expand Down Expand Up @@ -3850,7 +3850,7 @@ async def test_waits_for_ongoing_indices_recovery(self, es):
class ShrinkIndexTests(TestCase):
@mock.patch("elasticsearch.Elasticsearch")
# To avoid real sleeps in unit tests
@mock.patch("asyncio.sleep", return_value=as_future())
@mock.patch("asyncio.sleep")
@run_async
async def test_shrink_index_with_shrink_node(self, sleep, es):
es.indices.get.return_value = as_future({"src": {}})
Expand Down Expand Up @@ -3907,7 +3907,7 @@ async def test_shrink_index_with_shrink_node(self, sleep, es):

@mock.patch("elasticsearch.Elasticsearch")
# To avoid real sleeps in unit tests
@mock.patch("asyncio.sleep", return_value=as_future())
@mock.patch("asyncio.sleep")
@run_async
async def test_shrink_index_derives_shrink_node(self, sleep, es):
es.indices.get.return_value = as_future({"src": {}})
Expand Down Expand Up @@ -3970,7 +3970,7 @@ async def test_shrink_index_derives_shrink_node(self, sleep, es):

@mock.patch("elasticsearch.Elasticsearch")
# To avoid real sleeps in unit tests
@mock.patch("asyncio.sleep", return_value=as_future())
@mock.patch("asyncio.sleep")
@run_async
async def test_shrink_index_pattern_with_shrink_node(self, sleep, es):
es.indices.get.return_value = as_future({"src1": {}, "src2": {}, "src-2020": {}})
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
###############################################################################
[tox]
envlist =
py38, py39
py38, py39, py310
platform =
linux|darwin

[testenv]
deps = .[develop]
passenv =
HOME
JAVA8_HOME
Expand Down

0 comments on commit e90597e

Please sign in to comment.