Upgrade to Elasticsearch Client 8.17.0
See gh-44100 Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
This commit is contained in:
parent
0e686ba452
commit
ed5100ecee
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -69,6 +69,7 @@ public class ElasticsearchReactiveHealthIndicator extends AbstractReactiveHealth
|
||||
builder.withDetail("task_max_waiting_in_queue_millis", response.taskMaxWaitingInQueueMillis());
|
||||
builder.withDetail("active_shards_percent_as_number",
|
||||
Double.parseDouble(response.activeShardsPercentAsNumber()));
|
||||
builder.withDetail("unassigned_primary_shards", response.unassignedPrimaryShards());
|
||||
return builder.build();
|
||||
}
|
||||
return builder.down().build();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -72,7 +72,7 @@ class ElasticsearchReactiveHealthIndicatorTests {
|
||||
|
||||
@Test
|
||||
void elasticsearchIsUp() {
|
||||
setupMockResponse(200, "green");
|
||||
setupMockResponse("green");
|
||||
Health health = this.healthIndicator.health().block(TIMEOUT);
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertHealthDetailsWithStatus(health.getDetails(), "green");
|
||||
@ -80,7 +80,7 @@ class ElasticsearchReactiveHealthIndicatorTests {
|
||||
|
||||
@Test
|
||||
void elasticsearchWithYellowStatusIsUp() {
|
||||
setupMockResponse(200, "yellow");
|
||||
setupMockResponse("yellow");
|
||||
Health health = this.healthIndicator.health().block(TIMEOUT);
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertHealthDetailsWithStatus(health.getDetails(), "yellow");
|
||||
@ -104,7 +104,7 @@ class ElasticsearchReactiveHealthIndicatorTests {
|
||||
|
||||
@Test
|
||||
void elasticsearchIsOutOfServiceByStatus() {
|
||||
setupMockResponse(200, "red");
|
||||
setupMockResponse("red");
|
||||
Health health = this.healthIndicator.health().block(TIMEOUT);
|
||||
assertThat(health.getStatus()).isEqualTo(Status.OUT_OF_SERVICE);
|
||||
assertHealthDetailsWithStatus(health.getDetails(), "red");
|
||||
@ -116,10 +116,11 @@ class ElasticsearchReactiveHealthIndicatorTests {
|
||||
entry("active_primary_shards", 0), entry("active_shards", 0), entry("relocating_shards", 0),
|
||||
entry("initializing_shards", 0), entry("unassigned_shards", 0), entry("delayed_unassigned_shards", 0),
|
||||
entry("number_of_pending_tasks", 0), entry("number_of_in_flight_fetch", 0),
|
||||
entry("task_max_waiting_in_queue_millis", 0L), entry("active_shards_percent_as_number", 100.0));
|
||||
entry("task_max_waiting_in_queue_millis", 0L), entry("active_shards_percent_as_number", 100.0),
|
||||
entry("unassigned_primary_shards", 10));
|
||||
}
|
||||
|
||||
private void setupMockResponse(int responseCode, String status) {
|
||||
private void setupMockResponse(String status) {
|
||||
MockResponse mockResponse = new MockResponse().setBody(createJsonResult(status))
|
||||
.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
||||
.setHeader("X-Elastic-Product", "Elasticsearch");
|
||||
@ -133,7 +134,8 @@ class ElasticsearchReactiveHealthIndicatorTests {
|
||||
+ "\"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}",
|
||||
+ "\"task_max_waiting_in_queue_millis\":0,\"active_shards_percent_as_number\":100.0,"
|
||||
+ "\"unassigned_primary_shards\": 10 }",
|
||||
status);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -122,20 +122,20 @@ class ElasticsearchRestClientHealthIndicatorTests {
|
||||
entry("active_primary_shards", 0), entry("active_shards", 0), entry("relocating_shards", 0),
|
||||
entry("initializing_shards", 0), entry("unassigned_shards", 0), entry("delayed_unassigned_shards", 0),
|
||||
entry("number_of_pending_tasks", 0), entry("number_of_in_flight_fetch", 0),
|
||||
entry("task_max_waiting_in_queue_millis", 0), entry("active_shards_percent_as_number", 100.0));
|
||||
entry("task_max_waiting_in_queue_millis", 0), entry("active_shards_percent_as_number", 100.0),
|
||||
entry("unassigned_primary_shards", 10));
|
||||
}
|
||||
|
||||
private String createJsonResult(int responseCode, String status) {
|
||||
if (responseCode == 200) {
|
||||
return String.format(
|
||||
"{\"cluster_name\":\"elasticsearch\","
|
||||
+ "\"status\":\"%s\",\"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}",
|
||||
status);
|
||||
return String.format("{\"cluster_name\":\"elasticsearch\","
|
||||
+ "\"status\":\"%s\",\"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,"
|
||||
+ "\"unassigned_primary_shards\": 10 }", status);
|
||||
}
|
||||
return "{\n \"error\": \"Server Error\",\n \"status\": " + responseCode + "\n}";
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ bom {
|
||||
releaseNotes("https://github.com/ehcache/ehcache3/releases/tag/v{version}")
|
||||
}
|
||||
}
|
||||
library("Elasticsearch Client", "8.15.5") {
|
||||
library("Elasticsearch Client", "8.17.1") {
|
||||
alignWith {
|
||||
version {
|
||||
from "org.springframework.data:spring-data-elasticsearch"
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -17,6 +17,7 @@
|
||||
package org.springframework.boot.testcontainers.service.connection.elasticsearch;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
|
||||
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -30,7 +31,7 @@ import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchClientA
|
||||
import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchConnectionDetails;
|
||||
import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.container.TestImage;
|
||||
import org.springframework.boot.testsupport.container.ElasticsearchContainer8;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@ -47,7 +48,8 @@ class ElasticsearchContainerConnectionDetailsFactoryTests {
|
||||
|
||||
@Container
|
||||
@ServiceConnection
|
||||
static final ElasticsearchContainer elasticsearch = TestImage.container(ElasticsearchContainer.class);
|
||||
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer8().withStartupAttempts(5)
|
||||
.withStartupTimeout(Duration.ofMinutes(10));
|
||||
|
||||
@Autowired(required = false)
|
||||
private ElasticsearchConnectionDetails connectionDetails;
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.testsupport.container;
|
||||
|
||||
import org.testcontainers.elasticsearch.ElasticsearchContainer;
|
||||
|
||||
/**
|
||||
* A container suitable for testing Elasticsearch 8.
|
||||
*
|
||||
* @author Dmytro Nosan
|
||||
*/
|
||||
public class ElasticsearchContainer8 extends ElasticsearchContainer {
|
||||
|
||||
public ElasticsearchContainer8() {
|
||||
super(TestImage.ELASTICSEARCH_8.toString());
|
||||
addEnv("ES_JAVA_OPTS", "-Xms32m -Xmx512m");
|
||||
addEnv("xpack.security.enabled", "false");
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -117,7 +117,7 @@ public enum TestImage {
|
||||
/**
|
||||
* A container image suitable for testing Elasticsearch 8.
|
||||
*/
|
||||
ELASTICSEARCH_8("elasticsearch", "8.6.1"),
|
||||
ELASTICSEARCH_8("elasticsearch", "8.17.1"),
|
||||
|
||||
/**
|
||||
* A container image suitable for testing Grafana OTel LGTM.
|
||||
|
Loading…
x
Reference in New Issue
Block a user