Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 0 additions & 144 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -739,150 +739,6 @@ jobs:
python_arch: 'x64'
tox_env: 'py312-pytest74-xdist-nocov'
os: 'macos-latest'
- name: 'pypy37-pytest73-nodist-cover (ubuntu)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest73-nodist-cover'
os: 'ubuntu-latest'
- name: 'pypy37-pytest73-nodist-cover (windows)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest73-nodist-cover'
os: 'windows-latest'
- name: 'pypy37-pytest73-nodist-cover (macos)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest73-nodist-cover'
os: 'macos-latest'
- name: 'pypy37-pytest73-nodist-nocov (ubuntu)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest73-nodist-nocov'
os: 'ubuntu-latest'
- name: 'pypy37-pytest73-nodist-nocov (windows)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest73-nodist-nocov'
os: 'windows-latest'
- name: 'pypy37-pytest73-nodist-nocov (macos)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest73-nodist-nocov'
os: 'macos-latest'
- name: 'pypy37-pytest73-xdist-cover (ubuntu)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest73-xdist-cover'
os: 'ubuntu-latest'
- name: 'pypy37-pytest73-xdist-cover (windows)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest73-xdist-cover'
os: 'windows-latest'
- name: 'pypy37-pytest73-xdist-cover (macos)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest73-xdist-cover'
os: 'macos-latest'
- name: 'pypy37-pytest73-xdist-nocov (ubuntu)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest73-xdist-nocov'
os: 'ubuntu-latest'
- name: 'pypy37-pytest73-xdist-nocov (windows)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest73-xdist-nocov'
os: 'windows-latest'
- name: 'pypy37-pytest73-xdist-nocov (macos)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest73-xdist-nocov'
os: 'macos-latest'
- name: 'pypy37-pytest74-nodist-cover (ubuntu)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest74-nodist-cover'
os: 'ubuntu-latest'
- name: 'pypy37-pytest74-nodist-cover (windows)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest74-nodist-cover'
os: 'windows-latest'
- name: 'pypy37-pytest74-nodist-cover (macos)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest74-nodist-cover'
os: 'macos-latest'
- name: 'pypy37-pytest74-nodist-nocov (ubuntu)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest74-nodist-nocov'
os: 'ubuntu-latest'
- name: 'pypy37-pytest74-nodist-nocov (windows)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest74-nodist-nocov'
os: 'windows-latest'
- name: 'pypy37-pytest74-nodist-nocov (macos)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest74-nodist-nocov'
os: 'macos-latest'
- name: 'pypy37-pytest74-xdist-cover (ubuntu)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest74-xdist-cover'
os: 'ubuntu-latest'
- name: 'pypy37-pytest74-xdist-cover (windows)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest74-xdist-cover'
os: 'windows-latest'
- name: 'pypy37-pytest74-xdist-cover (macos)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest74-xdist-cover'
os: 'macos-latest'
- name: 'pypy37-pytest74-xdist-nocov (ubuntu)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest74-xdist-nocov'
os: 'ubuntu-latest'
- name: 'pypy37-pytest74-xdist-nocov (windows)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest74-xdist-nocov'
os: 'windows-latest'
- name: 'pypy37-pytest74-xdist-nocov (macos)'
python: 'pypy-3.7'
toxpython: 'pypy3.7'
python_arch: 'x64'
tox_env: 'pypy37-pytest74-xdist-nocov'
os: 'macos-latest'
- name: 'pypy38-pytest73-nodist-cover (ubuntu)'
python: 'pypy-3.8'
toxpython: 'pypy3.8'
Expand Down
3 changes: 2 additions & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Authors
=======

* Ionel Cristian Mărieș - https://blog.ionelmc.ro
* Marc Abramowitz - http://marc-abramowitz.com
* Marc Abramowitz - https://github.com/msabramo
* Dave Collins - https://github.com/thedavecollins
* Stefan Krastanov - http://blog.krastanov.org
* Thomas Waldmann - https://github.com/ThomasWaldmann
Expand Down Expand Up @@ -33,3 +33,4 @@ Authors
* Friedrich Delgado - https://github.com/TauPan
* Sam James - https://github.com/thesamesam
* Florian Bruhin - https://github.com/The-Compiler
* Çağlar Kutlu - https://github.com/ckutlu
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Changelog
=========

4.0.1 (2023-12-17)
------------------
* Added support for ElasticSearch python support for 8.x and dropped <7.15.

4.0.0 (2022-10-26)
------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def read(*names, **kwargs):
'aspect': ['aspectlib'],
'histogram': ['pygal', 'pygaljs', 'setuptools'],
':python_version < "3.4"': ['statistics', 'pathlib2'],
'elasticsearch': ['elasticsearch'],
'elasticsearch': ['elasticsearch>=7.15.0'], # See https://github.com/elastic/elasticsearch-py/issues/1698
},
entry_points={
'pytest11': ['benchmark = pytest_benchmark.plugin'],
Expand Down
36 changes: 21 additions & 15 deletions src/pytest_benchmark/storage/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
try:
import elasticsearch
from elasticsearch.serializer import JSONSerializer
except ImportError as exc:
raise ImportError('Please install elasticsearch or pytest-benchmark[elasticsearch]') from exc

ES_VERSION_7 = elasticsearch.__version__[0] == 7
except ImportError as err:
raise ImportError('Please install elasticsearch or pytest-benchmark[elasticsearch]') from err


class BenchmarkJSONSerializer(JSONSerializer):
Expand Down Expand Up @@ -56,8 +58,7 @@ def query(self):
"""
Returns sorted records names (ids) that corresponds with project.
"""
body = {'size': 0, 'aggs': {'benchmark_ids': {'terms': {'field': 'benchmark_id'}}}}
result = self._es.search(index=self._es_index, doc_type=self._es_doctype, body=body)
result = self._es.search(index=self._es_index, aggs={'benchmark_ids': {'terms': {'field': 'benchmark_id'}}})
return sorted([record['key'] for record in result['aggregations']['benchmark_ids']['buckets']])

def load(self, id_prefix=None):
Expand All @@ -74,15 +75,18 @@ def load(self, id_prefix=None):
yield key, data

def _search(self, project, id_prefix=None):
body = {
'size': 1000,
'sort': [{'datetime': {'order': 'desc'}}],
'query': {'bool': {'filter': {'term': {'commit_info.project': project}}}},
}
if id_prefix:
body['query']['bool']['must'] = {'prefix': {'_id': id_prefix}}
query = {'bool': {'filter': {'term': {'commit_info.project': project}}}}
if id_prefix is not None:
query['bool']['must'] = {'prefix': {'_id': id_prefix}}

return self._es.search(index=self._es_index, doc_type=self._es_doctype, body=body)
result = self._es.search(
index=self._es_index,
size=1000,
sort=[{'datetime': {'order': 'desc'}}],
query=query,
)

return result

@staticmethod
def _benchmark_from_es_record(source_es_record):
Expand Down Expand Up @@ -137,8 +141,7 @@ def save(self, output_json, save):
bench['benchmark_id'] = benchmark_id
self._es.index(
index=self._es_index,
doc_type=self._es_doctype,
body=bench,
document=bench,
id=doc_id,
)
# hide user's credentials before logging
Expand Down Expand Up @@ -213,4 +216,7 @@ def _create_index(self):
}
}
}
self._es.indices.create(index=self._es_index, ignore=400, body=mapping)
if ES_VERSION_7:
self._es.indices.create(index=self._es_index, ignore=400, mappings=mapping)
else:
self._es.options(ignore_status=400).indices.create(index=self._es_index, mappings=mapping)
4 changes: 2 additions & 2 deletions tests/test_elasticsearch_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ def test_handle_saving(sess, logger_output, monkeypatch):
sess.json = None
sess.save_data = False
sess.handle_saving()

sess.storage._es.index.assert_called_with(
index='mocked',
doc_type='mocked',
body=ES_DATA,
document=ES_DATA,
id='FoobarOS_commitId_tests/test_normal.py::test_xfast_parametrized[0]',
)

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ envlist =
clean,
check,
docs,
{py38,py39,py310,py311,py312,pypy37,pypy38,pypy39,pypy310}-{pytest73,pytest74}-{nodist,xdist}-{cover,nocov},
{py38,py39,py310,py311,py312,pypy38,pypy39,pypy310}-{pytest73,pytest74}-{nodist,xdist}-{cover,nocov},
report
ignore_basepython_conflict = true

Expand Down