From 5183a07bed27ef1911320043bc0995eecacfa836 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 8 Nov 2023 10:42:52 +0400 Subject: [PATCH] Fix CI (#2367) * Fix CI --- .github/workflows/ci.yml | 27 +++---------------- .readthedocs.yml | 2 +- dev-requirements.txt | 10 ++++--- setup.cfg | 2 +- .../test_async/test_server/test_helpers.py | 27 ++++++++++--------- 5 files changed, 26 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f38fdc108..c6820bd94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,45 +12,24 @@ jobs: - name: Set up Python 3.x uses: actions/setup-python@v4 with: - python-version: 3.x + python-version: "3.11" - name: Install dependencies run: | python3 -m pip install nox - name: Lint the code run: nox -s lint - docs: - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - name: Set up Python 3.x - uses: actions/setup-python@v4 - with: - python-version: 3.x - - name: Install dependencies - run: | - python3 -m pip install nox - - name: Build the docs - run: nox -s docs - test-linux: strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] - experimental: [false] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] nox-session: [""] runs-on: ["ubuntu-latest"] - include: - - python-version: 3.11-dev - experimental: true - nox-session: test-3.11 - runs-on: "ubuntu-latest" runs-on: ${{ matrix.runs-on }} name: test-${{ matrix.python-version }} - continue-on-error: ${{ matrix.experimental }} + continue-on-error: false steps: - name: Checkout Repository uses: actions/checkout@v3 diff --git a/.readthedocs.yml b/.readthedocs.yml index 1041df2a4..3cb2282d2 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -3,7 +3,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3" + python: "3.11" python: install: diff --git a/dev-requirements.txt b/dev-requirements.txt index 6cc2d1c33..7e3f4c9f4 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -15,12 +15,14 @@ twine build nox -# No wheels for Python 3.10 yet! -numpy; python_version<"3.10" -pandas; python_version<"3.10" +numpy +pandas # Testing the 'search_mvt' API response -mapbox-vector-tile; python_version<"3.10" +mapbox-vector-tile +# Python 3.7 gets an old version of mapbox-vector-tile, requiring an +# old version of protobuf +protobuf<4; python_version<="3.7" # Docs # Override Read the Docs default (sphinx<2 and sphinx-rtd-theme<0.5) diff --git a/setup.cfg b/setup.cfg index a527b5b93..d54c7cd19 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,7 @@ ignore = E203, E266, E501, W503 [tool:pytest] junit_family=legacy -addopts = -vvv -p no:logging --cov-report=term-missing --cov=elasticsearch --cov-config=.coveragerc +addopts = -vvv --cov-report=term-missing --cov=elasticsearch --cov-config=.coveragerc [tool:isort] profile=black diff --git a/test_elasticsearch/test_async/test_server/test_helpers.py b/test_elasticsearch/test_async/test_server/test_helpers.py index 037ab7166..5d5ce3d17 100644 --- a/test_elasticsearch/test_async/test_server/test_helpers.py +++ b/test_elasticsearch/test_async/test_server/test_helpers.py @@ -16,6 +16,7 @@ # under the License. import asyncio +import logging from datetime import datetime, timedelta, timezone from unittest.mock import MagicMock, call, patch @@ -619,8 +620,10 @@ async def test_no_scroll_id_fast_route(self, async_client, scan_teardown): scroll_mock.assert_not_called() clear_mock.assert_not_called() - @patch("elasticsearch._async.helpers.logger") - async def test_logger(self, logger_mock, async_client, scan_teardown): + async def test_logger( + self, caplog: pytest.LogCaptureFixture, async_client, scan_teardown + ): + caplog.set_level(logging.WARNING, logger="elasticsearch.helpers") bulk = [] for x in range(4): bulk.append({"index": {"_index": "test_index"}}) @@ -640,12 +643,16 @@ async def test_logger(self, logger_mock, async_client, scan_teardown): clear_scroll=False, ) ] - logger_mock.warning.assert_called() + assert caplog.messages == [ + "Scroll request has only succeeded on 4 (+0 skipped) shards out of 5." + ] + + caplog.clear() with patch.object( async_client, "options", return_value=async_client ), patch.object(async_client, "scroll", MockScroll()): - try: + with pytest.raises(ScanError): _ = [ x async for x in helpers.async_scan( @@ -656,14 +663,10 @@ async def test_logger(self, logger_mock, async_client, scan_teardown): clear_scroll=False, ) ] - except ScanError: - pass - logger_mock.warning.assert_called_with( - "Scroll request has only succeeded on %d (+%d skipped) shards out of %d.", - 4, - 0, - 5, - ) + + assert caplog.messages == [ + "Scroll request has only succeeded on 4 (+0 skipped) shards out of 5." + ] async def test_clear_scroll(self, async_client, scan_teardown): bulk = []