Skip to content

Commit

Permalink
Make sure it works against elasticsearch 7.* library - closes #512
Browse files Browse the repository at this point in the history
  • Loading branch information
fizyk committed Aug 3, 2023
1 parent e3e9174 commit 2e8b559
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
42 changes: 42 additions & 0 deletions .github/actions/elastic_7/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: 'Pytest run'
description: 'Greet someone'
inputs:
python-version: # id of input
description: 'Python version to use'
required: true
elasticsearch:
description: 'Elasticsearch version'
required: true
runs:
using: "composite"
steps:
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ inputs.python-version }}
- uses: actions/cache@v3
with:
path: ~/elasticsearch
key: elasticsearch-${{ inputs.elasticsearch }}
- name: Setup elasticsearch
uses: ankane/setup-elasticsearch@v1
with:
elasticsearch-version: ${{ inputs.elasticsearch }}
- name: Prep environment
shell: bash
run: pip install pipenv && pipenv install --dev --skip-lock
- name: Downgrade elasticsearch
shell: bash
run: pipenv run pip install "elasticsearch<8"
- name: Run test
shell: bash
run: pipenv run pytest --elasticsearch-executable=$ES_HOME/bin/elasticsearch -n 0 --cov-report=xml
- name: Run xdist test
shell: bash
run: pipenv run pytest --elasticsearch-executable=$ES_HOME/bin/elasticsearch -n 1 --cov-report=xml:coverage-xdist.xml
- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
flags: linux,elastic-${{ inputs.elasticsearch }}
env_vars: OS, PYTHON
fail_ci_if_error: false
16 changes: 16 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,19 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
elasticsearch: "7.17"
tests_7_17_lib_7:
needs: [tests_7_17]
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.11"]
env:
OS: ubuntu-latest
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/elastic_7
with:
python-version: ${{ matrix.python-version }}
elasticsearch: "7.17"
1 change: 1 addition & 0 deletions newsfragments/512.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed compatibility with elasticsearch client 7.x
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies = [
"pytest >= 6.2",
"port-for >= 0.7.1",
"mirakuru",
"elasticsearch",
"elasticsearch >= 7",
]
requires-python = ">= 3.8"

Expand Down
5 changes: 3 additions & 2 deletions pytest_elasticsearch/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import pytest
from elasticsearch import Elasticsearch
from elasticsearch import __version__ as elastic_version
from mirakuru import ProcessExitedWithError
from port_for import get_port
from port_for.api import PortType
Expand Down Expand Up @@ -101,7 +102,6 @@ def elasticsearch_proc_fixture(
elasticsearch_index_store_type,
timeout=60,
)
print(elasticsearch_executor.command)

elasticsearch_executor.start()
yield elasticsearch_executor
Expand Down Expand Up @@ -161,7 +161,8 @@ def elasticsearch_fixture(request: FixtureRequest) -> Iterator[Elasticsearch]:
request_timeout=30,
verify_certs=False,
)
client.options(ignore_status=400)
if elastic_version >= (8, 0, 0):
client.options(ignore_status=400)

yield client
for index in client.indices.get_alias():
Expand Down

0 comments on commit 2e8b559

Please sign in to comment.