Skip to content

Commit

Permalink
Fix CI (#2367)
Browse files Browse the repository at this point in the history
* Fix CI
  • Loading branch information
pquentin authored Nov 8, 2023
1 parent 3183aa3 commit 5183a07
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 42 deletions.
27 changes: 3 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3"
python: "3.11"

python:
install:
Expand Down
10 changes: 6 additions & 4 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 15 additions & 12 deletions test_elasticsearch/test_async/test_server/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.

import asyncio
import logging
from datetime import datetime, timedelta, timezone
from unittest.mock import MagicMock, call, patch

Expand Down Expand Up @@ -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"}})
Expand All @@ -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(
Expand All @@ -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 = []
Expand Down

0 comments on commit 5183a07

Please sign in to comment.