Sync from SUSE:SLFO:Main python-elasticsearch revision 0227344cc6dd7ce383a2e7119f412b29

This commit is contained in:
Adrian Schröter 2025-02-07 18:17:09 +01:00
parent 8fd8979b71
commit a27c9a877e
7 changed files with 352 additions and 143 deletions

View File

@ -0,0 +1,193 @@
From 740005db4dcd732015606d86eff29eb15a0193b2 Mon Sep 17 00:00:00 2001
From: Daniel Garcia Moreno <daniel.garcia@suse.com>
Date: Wed, 8 Jan 2025 08:50:23 +0100
Subject: [PATCH] Make pyarrow dependency optional for tests
---
.../test_client/test_deprecated_options.py | 40 ++++++++-------
.../test_client/test_serializers.py | 49 ++++++++-----------
test_elasticsearch/test_serializer.py | 9 +++-
3 files changed, 48 insertions(+), 50 deletions(-)
diff --git a/test_elasticsearch/test_client/test_deprecated_options.py b/test_elasticsearch/test_client/test_deprecated_options.py
index 810e75cf..ea797ce8 100644
--- a/test_elasticsearch/test_client/test_deprecated_options.py
+++ b/test_elasticsearch/test_client/test_deprecated_options.py
@@ -22,6 +22,24 @@ import pytest
from elasticsearch import Elasticsearch, JsonSerializer
+EXPECTED_SERIALIZERS = {
+ "application/vnd.mapbox-vector-tile",
+ "application/x-ndjson",
+ "application/json",
+ "text/*",
+ "application/vnd.elasticsearch+json",
+ "application/vnd.elasticsearch+x-ndjson",
+}
+
+
+try:
+ import pyarrow as pa
+ EXPECTED_SERIALIZERS.add("application/vnd.apache.arrow.stream")
+except ImportError:
+ pa = None
+
+
+
def test_sniff_on_connection_fail():
with warnings.catch_warnings(record=True) as w:
client = Elasticsearch("http://localhost:9200", sniff_on_connection_fail=True)
@@ -129,15 +147,7 @@ def test_serializer_and_serializers():
client.transport.serializers.get_serializer("application/json"),
CustomSerializer,
)
- assert set(client.transport.serializers.serializers.keys()) == {
- "application/vnd.mapbox-vector-tile",
- "application/x-ndjson",
- "application/json",
- "text/*",
- "application/vnd.apache.arrow.stream",
- "application/vnd.elasticsearch+json",
- "application/vnd.elasticsearch+x-ndjson",
- }
+ assert set(client.transport.serializers.serializers.keys()) == EXPECTED_SERIALIZERS
client = Elasticsearch(
"http://localhost:9200",
@@ -150,13 +160,5 @@ def test_serializer_and_serializers():
client.transport.serializers.get_serializer("application/json"),
CustomSerializer,
)
- assert set(client.transport.serializers.serializers.keys()) == {
- "application/vnd.mapbox-vector-tile",
- "application/x-ndjson",
- "application/json",
- "text/*",
- "application/vnd.apache.arrow.stream",
- "application/vnd.elasticsearch+json",
- "application/vnd.elasticsearch+x-ndjson",
- "application/cbor",
- }
+ expected = EXPECTED_SERIALIZERS | {"application/cbor"}
+ assert set(client.transport.serializers.serializers.keys()) == expected
diff --git a/test_elasticsearch/test_client/test_serializers.py b/test_elasticsearch/test_client/test_serializers.py
index 9d13386e..4b18212d 100644
--- a/test_elasticsearch/test_client/test_serializers.py
+++ b/test_elasticsearch/test_client/test_serializers.py
@@ -21,6 +21,23 @@ from elasticsearch import Elasticsearch
from test_elasticsearch.test_cases import DummyTransportTestCase
+EXPECTED_SERIALIZERS = {
+ "application/json",
+ "text/*",
+ "application/x-ndjson",
+ "application/vnd.mapbox-vector-tile",
+ "application/vnd.elasticsearch+json",
+ "application/vnd.elasticsearch+x-ndjson",
+}
+
+
+try:
+ import pyarrow as pa
+ EXPECTED_SERIALIZERS.add("application/vnd.apache.arrow.stream")
+except ImportError:
+ pa = None
+
+
class TestSerializers(DummyTransportTestCase):
def test_compat_mode_on_by_default(self):
calls = self.client.transport.calls
@@ -90,16 +107,8 @@ class TestSerializers(DummyTransportTestCase):
"https://localhost:9200", serializers={f"application/{mime_subtype}": ser}
)
serializers = client.transport.serializers.serializers
- assert set(serializers.keys()) == {
- "application/json",
- "text/*",
- "application/x-ndjson",
- "application/vnd.apache.arrow.stream",
- "application/vnd.mapbox-vector-tile",
- "application/vnd.elasticsearch+json",
- "application/vnd.elasticsearch+x-ndjson",
- }
+ assert set(serializers.keys()) == EXPECTED_SERIALIZERS
assert serializers[f"application/{mime_subtype}"] is ser
assert serializers[f"application/vnd.elasticsearch+{mime_subtype}"] is ser
@@ -118,16 +127,7 @@ class TestSerializers(DummyTransportTestCase):
},
)
serializers = client.transport.serializers.serializers
- assert set(serializers.keys()) == {
- "application/json",
- "text/*",
- "application/x-ndjson",
- "application/vnd.apache.arrow.stream",
- "application/vnd.mapbox-vector-tile",
- "application/vnd.elasticsearch+json",
- "application/vnd.elasticsearch+x-ndjson",
- }
-
+ assert set(serializers.keys()) == EXPECTED_SERIALIZERS
assert serializers[f"application/{mime_subtype}"] is ser1
assert serializers[f"application/vnd.elasticsearch+{mime_subtype}"] is ser2
@@ -138,15 +138,6 @@ class TestSerializers(DummyTransportTestCase):
ser = CustomSerializer()
client = Elasticsearch("https://localhost:9200", serializer=ser)
serializers = client.transport.serializers.serializers
- assert set(serializers.keys()) == {
- "application/json",
- "text/*",
- "application/x-ndjson",
- "application/vnd.apache.arrow.stream",
- "application/vnd.mapbox-vector-tile",
- "application/vnd.elasticsearch+json",
- "application/vnd.elasticsearch+x-ndjson",
- }
-
+ assert set(serializers.keys()) == EXPECTED_SERIALIZERS
assert serializers["application/json"] is ser
assert serializers["application/vnd.elasticsearch+json"] is ser
diff --git a/test_elasticsearch/test_serializer.py b/test_elasticsearch/test_serializer.py
index 02723e8f..313029ba 100644
--- a/test_elasticsearch/test_serializer.py
+++ b/test_elasticsearch/test_serializer.py
@@ -19,9 +19,14 @@ import uuid
from datetime import datetime
from decimal import Decimal
-import pyarrow as pa
import pytest
+try:
+ import pyarrow as pa
+ from elasticsearch.serializer import PyArrowSerializer
+except ImportError:
+ pa = None
+
try:
import numpy as np
import pandas as pd
@@ -35,7 +40,6 @@ from elasticsearch.exceptions import SerializationError
from elasticsearch.serializer import (
JSONSerializer,
OrjsonSerializer,
- PyArrowSerializer,
TextSerializer,
)
@@ -163,6 +167,7 @@ def test_serializes_pandas_category(json_serializer):
assert b'{"d":[1,2,3]}' == json_serializer.dumps({"d": cat})
+@pytest.mark.skipif(pa is None, reason="Test requires pyarrow to be available")
def test_pyarrow_loads():
data = [
pa.array([1, 2, 3, 4]),
--
2.47.0

BIN
7.6.0.tar.gz (Stored with Git LFS)

Binary file not shown.

View File

@ -1,46 +0,0 @@
---
test_elasticsearch/test_connection.py | 2 +-
test_elasticsearch/test_helpers.py | 2 +-
test_elasticsearch/test_server/test_helpers.py | 2 +-
test_elasticsearch/test_transport.py | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
--- a/test_elasticsearch/test_connection.py
+++ b/test_elasticsearch/test_connection.py
@@ -2,7 +2,7 @@ import re
import ssl
import gzip
import io
-from mock import Mock, patch
+from unittest.mock import Mock, patch
import urllib3
import warnings
from requests.auth import AuthBase
--- a/test_elasticsearch/test_helpers.py
+++ b/test_elasticsearch/test_helpers.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-import mock
+from unittest import mock
import time
import threading
from unittest import SkipTest
--- a/test_elasticsearch/test_server/test_helpers.py
+++ b/test_elasticsearch/test_server/test_helpers.py
@@ -1,4 +1,4 @@
-from mock import patch
+from unittest.mock import patch
from elasticsearch import helpers, TransportError
from elasticsearch.helpers import ScanError
--- a/test_elasticsearch/test_transport.py
+++ b/test_elasticsearch/test_transport.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import time
-from mock import patch
+from unittest.mock import patch
from elasticsearch.transport import Transport, get_host_info
from elasticsearch.connection import Connection

View File

@ -1,77 +0,0 @@
---
dev-requirements.txt | 2 --
setup.py | 2 --
test_elasticsearch/run_tests.py | 13 ++-----------
test_elasticsearch/test_helpers.py | 2 +-
4 files changed, 3 insertions(+), 16 deletions(-)
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -1,8 +1,6 @@
requests>=2, <3
-nose
coverage
mock
-nosexcover
sphinx<1.7
sphinx_rtd_theme
jinja2
--- a/setup.py
+++ b/setup.py
@@ -13,11 +13,9 @@ with open(join(dirname(__file__), "READM
install_requires = ["urllib3>=1.21.1"]
tests_require = [
"requests>=2.0.0, <3.0.0",
- "nose",
"coverage",
"mock",
"pyyaml",
- "nosexcover",
]
docs_require = ["sphinx<1.7", "sphinx_rtd_theme"]
--- a/test_elasticsearch/run_tests.py
+++ b/test_elasticsearch/run_tests.py
@@ -6,7 +6,7 @@ from os import environ
from os.path import dirname, join, pardir, abspath, exists
import subprocess
-import nose
+import unittest
def fetch_es_repo():
@@ -64,21 +64,12 @@ def run_all(argv=None):
# fetch yaml tests
fetch_es_repo()
- # always insert coverage when running tests
if argv is None:
argv = [
- "nosetests",
- "--with-xunit",
- "--with-xcoverage",
- "--cover-package=elasticsearch",
- "--cover-erase",
- "--logging-filter=elasticsearch",
- "--logging-level=DEBUG",
"--verbose",
- "--with-id",
]
- nose.run_exit(argv=argv, defaultTest=abspath(dirname(__file__)))
+ unittest.main(argv=argv, defaultTest=abspath(dirname(__file__)))
if __name__ == "__main__":
--- a/test_elasticsearch/test_helpers.py
+++ b/test_elasticsearch/test_helpers.py
@@ -2,7 +2,7 @@
import mock
import time
import threading
-from nose.plugins.skip import SkipTest
+from unittest import SkipTest
from elasticsearch import helpers, Elasticsearch
from elasticsearch.serializer import JSONSerializer

View File

@ -1,7 +1,145 @@
-------------------------------------------------------------------
Wed Jan 8 08:59:00 UTC 2025 - Daniel Garcia <daniel.garcia@suse.com>
- Add patch to do not depend on pyarrow for tests: 0001-Make-pyarrow-dependency-optional-for-tests.patch
- Update to 8.17.0:
* Allow simsimd again on Python 3.13 (#2722)
* Update APIs:
- Mark all Inference APIs as stable.
- Add allow_partial_search_results to the Open Point in Time API
- Add keep_alive to the Get async search status API
- Remove the keep_alive, pre_filter_shard_size and scroll parameters from the Submit async search API. They were never supported.
- Add master_timeout and timeout to all autoscaling policy APIs
- Add master_timeout to the Alias exists and Get alias APIs
- Add list_executed_pipelines and require_data_stream to Bulk API
- Add include_model_definition to Get trained models API
- Add meta to Create data frame analytics API
- Add aggs to Create datafeeds API
- Add allow_no_indices, expand_wildcards, ignore_throttled and ignore_unavailable to Create anomaly detection jobs API
- 8.16.0:
* Support Python 3.13 (#2680)
* Emit Python warnings for beta and tech preview APIs (#2675).
* Vectorstore: use a retriever query for hybrid search (#2666)
* Allow retries for statuses other than 429 in streaming bulk (#2071, contributed by @ayayron)
* Make BulkIndexError and ScanError serializable (#2669, contributed by @seagrine)
* Fix import when trace is missing from opentelemetry package (#2694, contributed by @nicoloboschi)
* Update APIs:
- Fix nodes parameter in Task management API (contributed by @margaretpearce)
- Add Test query rule API
- Add Create Cross-Cluster API key and Update Cross-Cluster API key APIs
- Add experimental Verify snapshot repository API
- Add data_stream_name and settings to Delete auto-follow pattern API
- Add max_samples_per_key to Get async EQL status API
- Add lifecycle and remove unused data_retention and downsampling parameters from Put data stream lifecycle API
- Add include_remotes and remove flat_settings from Cluster stats API
- Add remote_indices to Create or update application privileges and Create or update roles APIs
- 8.15.1:
* Fix OTel context loss in parallel bulk helper (#2616)
* Use request converter to generate python examples (#2645)
* Add Geoip database configuration APIs: Create or update, Get and Delete
* Add q parameter to Update by Query API
* Add allow_no_indices and ignore_unavailable parameters to Resolve index API
- 8.15.0:
* Added the Connector API (#2623)
* Added support for semantic_text and semantic query.
* Added support for sequences of job id, model id and tags where applicable in ML APIs
* Added dry_run and force parameters to the Perform inference API
* Added optional Arrow deserialization support (#2632)
* Merged Query Ruleset API into new Query Rules API (#2607)
* Added mapping code examples (#2596)
* Fixed reference docs (#2629)
* Dropped Python 3.7 support (#2618)
- 8.14.0:
* Fixed node_pool_class override (#2581, contributed by @tallakh)
* Added retriever to the Search API
* Added deprecated and removed allow_auto_create from the Create or update component template API
* Added allow_auto_create, cause, deprecated, ignore_missing_component_templates and master_timeout to the Create or update index template API
* Added cause, removed flat_settings and timeout from the Create or update index template legacy API
* Removed various unsupported parameters from the Simulate index API
* Added various supported paramters to the Simulate index template API
* Added the completion and rerank task types to the Inference APIs
* Added the query and timeout parameters to the Perform inference API
* Added typed_keys to the Search Application Search API
* Added with_profile_uid to the Get API key information and Query API key information APIs
- 8.13.2:
* Added the ml.update_trained_model_deployment API
* Marked Requests 2.32.2 as incompatible with the Elasticsearch client
- 8.13.1:
* Added force_synthetic_source to the Get API
* Added wait_for_completion to the Create trained model API
* Added typed_keys to the Query API key information API
- 8.13.0:
* Added native OpenTelemetry support (#2435)
* Added optional orjson (a fast, correct JSON library) serialization support (#2493)
* Added the text_structure.test_grok_pattern API
* Added the indices.resolve_cluster API
* Renamed the model_id parameter to inference_id in the inference APIs
* Changed all synonyms APIs from experimental to stable.
* Fixed API key documentation (#2477, contributed by @iuliaferoli)
- 8.12.1:
* Fixed but deprecated parameter aliases in body parameter (#2427)
* Added mappings and bulk to quickstart page (#2417)
-------------------------------------------------------------------
Wed Jan 8 08:55:50 UTC 2025 - Daniel Garcia <daniel.garcia@suse.com>
- Skip some flaky tests that fails in OBS build
-------------------------------------------------------------------
Sat Jan 20 12:38:49 UTC 2024 - Dirk Müller <dmueller@suse.com>
- update to 8.12.0:
* Dropped support for Python 3.6
* Allowed unrestricted `body` parameter again (see #2383 for
details)
* Added the Inference APIs
* Added the ES|QL API
* Added `active_only` parameter to `security.get_api_key` API
* Added `expiration` parameter to `security.update_api_key` API
-------------------------------------------------------------------
Wed Dec 27 10:02:59 UTC 2023 - Dirk Müller <dmueller@suse.com>
- update to 8.11.1:
* Added missing `role_templates` to `security.put_role_mapping`
API
* Added interactive examples page to documentation
* Changed API reference to have one page per sub-client
-------------------------------------------------------------------
Mon Nov 27 18:55:59 UTC 2023 - Dirk Müller <dmueller@suse.com>
- update to 8.11.0:
* Added support for Python 3.12
* Added missing `scores` parameter to create trained model
vocabulary API
* Added missing `delete_dest_index` parameter to delete
transform API
* Removed deprecation warnings when using `body` parameter
* Fixed some type hints to use covariant Sequence instead of
invariant List (#2324, #2325)
-------------------------------------------------------------------
Mon Oct 2 10:27:22 UTC 2023 - Dirk Müller <dmueller@suse.com>
- update to 8.10.0:
* Add the Query rules APIs
* Add the Synonyms APIs
-------------------------------------------------------------------
Fri Sep 1 16:36:50 UTC 2023 - Matej Cepl <mcepl@suse.com>
- Update to 8.9.0:
Number of changes is so large, that I suggest looking at it at
https://www.elastic.co/guide/en/elasticsearch/client/python-api/master/release-notes.html.
- Remove upstreamed python-elasticsearch-no-nose.patch and
python-elasticsearch-no-mock.patch.
------------------------------------------------------------------- -------------------------------------------------------------------
Fri Apr 21 12:24:36 UTC 2023 - Dirk Müller <dmueller@suse.com> Fri Apr 21 12:24:36 UTC 2023 - Dirk Müller <dmueller@suse.com>
- add sle15_python_module_pythons (jsc#PED-68) - add sle15_python_module_pythons (jsc#PED-68)
- Remove upstreamed python-elasticsearch-no-mock.patch.
------------------------------------------------------------------- -------------------------------------------------------------------
Thu Apr 13 22:41:05 UTC 2023 - Matej Cepl <mcepl@suse.com> Thu Apr 13 22:41:05 UTC 2023 - Matej Cepl <mcepl@suse.com>
@ -293,7 +431,7 @@ Fri Jun 7 09:21:34 UTC 2019 - Marketa Calabkova <mcalabkova@suse.com>
* Blocking pool must fit thread_count * Blocking pool must fit thread_count
* Update client to support missing ES 7 API's and query params. * Update client to support missing ES 7 API's and query params.
* Removed deprecated option update_all_types * Removed deprecated option update_all_types
* Using insecure SSL configuration (verify_cert=False) raises a * Using insecure SSL configuration (verify_cert=False) raises a
warning, this can be not showed with ssl_show_warn=False warning, this can be not showed with ssl_show_warn=False
* Add support for 7.x api's in Elasticsearch * Add support for 7.x api's in Elasticsearch
@ -326,7 +464,7 @@ Tue Dec 4 12:47:36 UTC 2018 - Matej Cepl <mcepl@suse.com>
------------------------------------------------------------------- -------------------------------------------------------------------
Thu Nov 23 15:32:45 UTC 2017 - mimi.vx@gmail.com Thu Nov 23 15:32:45 UTC 2017 - mimi.vx@gmail.com
- fix Source url, use pypi package - fix Source url, use pypi package
------------------------------------------------------------------- -------------------------------------------------------------------
Thu Nov 23 13:27:11 UTC 2017 - kkaempf@suse.com Thu Nov 23 13:27:11 UTC 2017 - kkaempf@suse.com

View File

@ -1,7 +1,7 @@
# #
# spec file for package python-elasticsearch # spec file for package python-elasticsearch
# #
# Copyright (c) 2023 SUSE LLC # Copyright (c) 2025 SUSE LLC
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@ -16,26 +16,25 @@
# #
%define skip_python2 1
%{?sle15_python_module_pythons} %{?sle15_python_module_pythons}
Name: python-elasticsearch Name: python-elasticsearch
# DO NOT UPDATE until the compatible version of # DO NOT UPDATE until the compatible version of
# python-elasticsearch-dsl is available (i.e., the same major # python-elasticsearch-dsl is available
# version ... currently we are waiting on 8.* release). Version: 8.17.0
Version: 7.6.0
Release: 0 Release: 0
Summary: Python client for Elasticsearch Summary: Python client for Elasticsearch
License: Apache-2.0 License: Apache-2.0
Group: Development/Languages/Python Group: Development/Languages/Python
URL: https://github.com/elastic/elasticsearch-py URL: https://github.com/elastic/elasticsearch-py
Source: https://github.com/elastic/elasticsearch-py/archive/%{version}.tar.gz Source: https://github.com/elastic/elasticsearch-py/archive/refs/tags/v%{version}.tar.gz
Patch0: python-elasticsearch-no-nose.patch # PATCH-FIX-UPSTREAM 0001-Make-pyarrow-dependency-optional-for-tests.patch gh#elastic/elasticsearch-py#2733
# https://github.com/elastic/elasticsearch-py/issues/1983 Patch1: 0001-Make-pyarrow-dependency-optional-for-tests.patch
Patch1: python-elasticsearch-no-mock.patch
BuildRequires: %{python_module certifi} BuildRequires: %{python_module certifi}
BuildRequires: %{python_module elastic-transport} BuildRequires: %{python_module elastic-transport}
BuildRequires: %{python_module setuptools} BuildRequires: %{python_module hatchling}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module urllib3 >= 1.21.1} BuildRequires: %{python_module urllib3 >= 1.21.1}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes BuildRequires: fdupes
BuildRequires: python-rpm-macros BuildRequires: python-rpm-macros
Requires: python-elastic-transport Requires: python-elastic-transport
@ -43,6 +42,7 @@ BuildArch: noarch
# SECTION test # SECTION test
BuildRequires: %{python_module PyYAML >= 5.4} BuildRequires: %{python_module PyYAML >= 5.4}
BuildRequires: %{python_module aiohttp >= 3 with %python-aiohttp < 4} BuildRequires: %{python_module aiohttp >= 3 with %python-aiohttp < 4}
BuildRequires: %{python_module orjson}
BuildRequires: %{python_module pytest-asyncio} BuildRequires: %{python_module pytest-asyncio}
BuildRequires: %{python_module pytest} BuildRequires: %{python_module pytest}
BuildRequires: %{python_module python-dateutil} BuildRequires: %{python_module python-dateutil}
@ -58,21 +58,22 @@ to be opinion-free and very extendable.
%prep %prep
%autosetup -p1 -n elasticsearch-py-%{version} %autosetup -p1 -n elasticsearch-py-%{version}
sed -i '/addopts/d' setup.cfg sed -i '/addopts/d' setup.cfg
rm README.rst
%build %build
%python_build %pyproject_wheel
%install %install
%python_install %pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib} %python_expand %fdupes %{buildroot}%{$python_sitelib}
%check %check
%pytest # Skip some flaky tests that fails in OBS
donttest="test_sniff_uses_sniff_timeout or test_sniff_on_node_failure_triggers"
%pytest -k "not ($donttest)"
%files %{python_files} %files %{python_files}
%license LICENSE %license LICENSE
%doc AUTHORS Changelog.rst README %doc CODE_OF_CONDUCT.md CHANGELOG.md README.md
%{python_sitelib}/elasticsearch %{python_sitelib}/elasticsearch
%{python_sitelib}/elasticsearch-%{version}*-info %{python_sitelib}/elasticsearch-%{version}*-info

BIN
v8.17.0.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.