Skip to content

Commit

Permalink
[2.0] Bump dependencies and finish removing ES7 dependency (#418)
Browse files Browse the repository at this point in the history
* Bump dependencies, remove remaining ES7 dependencies, switch HA reference from beta to release

* Remove additional 7.x references
  • Loading branch information
strawgate authored Jan 6, 2025
1 parent 379ae1b commit 194311b
Show file tree
Hide file tree
Showing 9 changed files with 1,203 additions and 1,224 deletions.
8 changes: 4 additions & 4 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ Task | Description
-- | --
Run Home Assistant on port 8123 | Launch Home Assistant with your custom component code and the configuration defined in `.devcontainer/configuration.yaml`.
Run Unsupported Elasticsearch 7.0.0 (HTTP Port 9200) and Kibana 7.0.0 (HTTP Port 5601) | Launch Unsupported Elasticsearch 7.0.0 and Kibana 7.0.0.
Run Elasticsearch 7.10.0 (HTTP Port 9200) and Kibana 7.10.0 (HTTP Port 5601) | Launch Elasticsearch 7.10.0 and Kibana 7.10.0.
Run Elasticsearch 7.17.0 (HTTP Port 9200) and Kibana 7.17.0 (HTTP Port 5601) | Launch Elasticsearch 7.17.0 and Kibana 7.17.0.
Run Elasticsearch 8.0.0 (HTTPS Port 9200) and Kibana 8.0.0 (HTTP Port 5601) | Launch Elasticsearch 8.0.0 and Kibana 8.0.0.
Run Elasticsearch 8.7.0 (HTTPS Port 9200) and Kibana 8.7.0 (HTTP Port 5601) | Launch Elasticsearch 8.7.0 and Kibana 8.7.0.
Run Unsupported Elasticsearch 7.10.0 (HTTP Port 9200) and Kibana 7.10.0 (HTTP Port 5601) | Launch Elasticsearch 7.10.0 and Kibana 7.10.0.
Run Unsupported Elasticsearch 7.17.0 (HTTP Port 9200) and Kibana 7.17.0 (HTTP Port 5601) | Launch Elasticsearch 7.17.0 and Kibana 7.17.0.
Run Unsupported Elasticsearch 8.0.0 (HTTPS Port 9200) and Kibana 8.0.0 (HTTP Port 5601) | Launch Elasticsearch 8.0.0 and Kibana 8.0.0.
Run Unsupported Elasticsearch 8.7.0 (HTTPS Port 9200) and Kibana 8.7.0 (HTTP Port 5601) | Launch Elasticsearch 8.7.0 and Kibana 8.7.0.
Run Elasticsearch 8.11.0 (HTTPS Port 9200) and Kibana 8.11.0 (HTTP Port 5601) | Launch Elasticsearch 8.11.0 and Kibana 8.11.0.
Run Elasticsearch 8.13.0 (HTTPS Port 9200) and Kibana 8.13.0 (HTTP Port 5601) | Launch Elasticsearch 8.13.0 and Kibana 8.13.0.

Expand Down
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ updates:
interval: "weekly"
ignore:
- dependency-name: "homeassistant"
- dependency-name: "elasticsearch7"
- dependency-name: "elasticsearch8"

- package-ecosystem: "devcontainers"
directory: "/.devcontainer"
schedule:
interval: "weekly"
interval: "weekly"
9 changes: 2 additions & 7 deletions custom_components/elasticsearch/es_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from logging import Logger
from typing import Any

from elasticsearch7._async.client import AsyncElasticsearch as AsyncElasticsearch7
from elasticsearch8._async.client import AsyncElasticsearch as AsyncElasticsearch8


Expand All @@ -37,7 +36,7 @@ class GatewaySettings(ABC):
minimum_privileges: MappingProxyType[str, Any] | None = None

@abstractmethod
def to_client(self) -> AsyncElasticsearch7 | AsyncElasticsearch8:
def to_client(self) -> AsyncElasticsearch8:
"""Return an Elasticsearch client."""


Expand Down Expand Up @@ -76,7 +75,7 @@ async def async_init(self) -> None:

@property
@abstractmethod
def client(self) -> AsyncElasticsearch7 | AsyncElasticsearch8:
def client(self) -> AsyncElasticsearch8:
"""Return the underlying ES Client."""

@property
Expand Down Expand Up @@ -192,10 +191,6 @@ async def _is_supported_version(self) -> bool:
def _is_serverless(self, cluster_info: dict) -> bool:
"""Check if the Elasticsearch instance is serverless."""

# Build flavor is missing in 7.x versions
if "build_flavor" not in cluster_info["version"]:
return False

return cluster_info["version"]["build_flavor"] == "serverless"

def _meets_minimum_version(self, cluster_info: dict, minimum_version: tuple[int, int]) -> bool:
Expand Down
3 changes: 1 addition & 2 deletions custom_components/elasticsearch/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
],
"quality_scale": "platinum",
"requirements": [
"elasticsearch8==8.14.0",
"elasticsearch7==7.11.0"
"elasticsearch8==8.14.0"
],
"version": "2.0.0"
}
4 changes: 2 additions & 2 deletions hacs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Elasticsearch",
"render_readme": true,
"homeassistant": "2024.1.2"
}
"homeassistant": "2024.6.0"
}
2,260 changes: 1,190 additions & 1,070 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ packages = [{ include = "elasticsearch", from = "custom_components" }]
[tool.poetry.dependencies]
python = ">=3.12,<3.13"
elasticsearch8 = "~=8.14.0"
elasticsearch7 = "~=7.11.0"

[tool.poetry.group.dev.dependencies]
colorlog = "==6.9.0"
homeassistant = "==2024.6.0b8"
homeassistant = "==2024.6.0"
ruff = ">=0.0.291"
pip = ">=21.0,<24.4"
pydantic = ">=1.10.0"
Expand All @@ -28,7 +27,7 @@ syrupy = ">=4.6.0"
pytest = ">=7.3.1"
pytest-asyncio = ">=0.20.3"
pytest-cov = ">=4.0.0"
pytest-homeassistant-custom-component = "==0.13.131"
pytest-homeassistant-custom-component = "==0.13.132"
mock = ">4.0.0"
jsondiff = "*"

Expand Down
4 changes: 0 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ def create_tcpconnector(*args, **kwargs):
return TCPConnector(force_close=True, enable_cleanup_closed=False)

with (
mock.patch(
"elasticsearch7._async.http_aiohttp.aiohttp.ClientSession",
side_effect=create_session,
),
mock.patch(
"elastic_transport._node._http_aiohttp.aiohttp.ClientSession",
side_effect=create_session,
Expand Down
130 changes: 0 additions & 130 deletions tests/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,30 +218,6 @@
}
]

# "dict": {
# "string": "abc123",
# "int": 123,
# "float": 123.456,
# },
# "string": "abc123",
# "int": 123,
# "float": 123.456,
# "list": [1, 2, 3, 4],
# "set": {5, 5},
# "none": None,
# "Collision Test": "first value",
# "collision_test": "second value",
# "*_Non ECS-Compliant Attribute.ñame! 😀": True,
# # Keyless entry should be excluded from output
# "": "Key is empty, and should be excluded",
# # Custom classes should be excluded from output
# "naughty": object(),
# # Entries with non-string keys should be excluded from output
# datetime(year=2024,month=4,day=12): "Key is a datetime, and should be excluded",
# "Key is a datetime, and should be excluded": datetime(year=2024,month=4,day=12),
# 123: "Key is a number, and should be excluded",
# True: "Key is a bool, and should be excluded",

MOCK_NOON_APRIL_12TH_2023 = "2023-04-12T12:00:00+00:00"

MOCK_LOCATION_SERVER = {
Expand Down Expand Up @@ -300,43 +276,6 @@
"tagline": "You Know, for Search",
}


CLUSTER_INFO_7DOT11_RESPONSE_BODY = {
"name": "a6680a08c202",
"cluster_name": "docker-cluster",
"cluster_uuid": "AlICUdW5Tl2ZxNAA1Mk3fg",
"version": {
"number": "7.11.0",
"build_flavor": "default",
"build_type": "docker",
"build_hash": "8ced7813d6f16d2ef30792e2fcde3e755795ee04",
"build_date": "2021-02-08T22:44:01.320463Z",
"build_snapshot": False,
"lucene_version": "8.7.0",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1",
},
"tagline": "You Know, for Search",
}

CLUSTER_INFO_7DOT17_RESPONSE_BODY = {
"name": "a8bbdc6f0067",
"cluster_name": "docker-cluster",
"cluster_uuid": "H2qsoRzORwWNxSlhoUpbig",
"version": {
"number": "7.17.0",
"build_flavor": "default",
"build_type": "docker",
"build_hash": "bee86328705acaa9a6daede7140defd4d9ec56bd",
"build_date": "2022-01-28T08:36:04.875279988Z",
"build_snapshot": False,
"lucene_version": "8.11.1",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1",
},
"tagline": "You Know, for Search",
}

CLUSTER_INFO_SERVERLESS_RESPONSE_BODY = {
"name": "serverless",
"cluster_name": "home-assistant-cluster",
Expand Down Expand Up @@ -389,72 +328,3 @@
"minimum_index_compatibility_version": "7.0.0",
},
}

CLUSTER_INFO_8DOT8_RESPONSE_BODY = {
"name": "775d9437a77088",
"cluster_name": "home-assistant-cluster",
"cluster_uuid": "xtsjNokTQGClXbRibWjxyg",
"version": {
"number": "8.8.0",
"build_type": "docker",
"build_hash": "00000000",
"build_date": "2023-10-31",
"build_snapshot": False,
"lucene_version": "9.7.0",
"minimum_wire_compatibility_version": "8.11.0",
"minimum_index_compatibility_version": "8.11.0",
},
"tagline": "You Know, for Search",
}

CLUSTER_INFO_UNSUPPORTED_RESPONSE_BODY = {
"name": "775d9437a770",
"cluster_name": "home-assistant-cluster",
"cluster_uuid": "hz1_5bImTh-45ERkrHS7vg",
"version": {
"number": "7.10.0",
"build_type": "deb",
"build_hash": "1c34507e66d7db1211f66f3513706fdf548736aa",
"build_date": "2020-12-05T01:00:33.671820Z",
"build_snapshot": False,
"lucene_version": "8.7.0",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1",
},
"tagline": "You Know, for Search",
}

CLUSTER_INFO_RESPONSE_BODY = {
"name": "775d9437a770",
"cluster_name": "home-assistant-cluster",
"cluster_uuid": "hz1_5bImTh-45ERkrHS7vg",
"version": {
"number": "7.11.0",
"build_type": "deb",
"build_hash": "1c34507e66d7db1211f66f3513706fdf548736aa",
"build_date": "2020-12-05T01:00:33.671820Z",
"build_snapshot": False,
"lucene_version": "8.7.0",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1",
},
"tagline": "You Know, for Search",
}

CLUSTER_HEALTH_RESPONSE_BODY = {
"cluster_name": "home-assistant-cluster",
"status": "green",
"timed_out": False,
"number_of_nodes": 1,
"number_of_data_nodes": 1,
"active_primary_shards": 0,
"active_shards": 0,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks": 0,
"number_of_in_flight_fetch": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 100.0,
}

0 comments on commit 194311b

Please sign in to comment.