Reduce redis health indicator info command result size
See gh-24208
This commit is contained in:
parent
12f2529be5
commit
99cc3f4bfc
|
|
@ -65,7 +65,7 @@ public class RedisHealthIndicator extends AbstractHealthIndicator {
|
||||||
.withDetail("slots_fail", clusterInfo.getSlotsFail());
|
.withDetail("slots_fail", clusterInfo.getSlotsFail());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String version = connection.info().getProperty(REDIS_VERSION_PROPERTY);
|
String version = connection.info("server").getProperty(REDIS_VERSION_PROPERTY);
|
||||||
builder.up().withDetail("version", version);
|
builder.up().withDetail("version", version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class RedisReactiveHealthIndicator extends AbstractReactiveHealthIndicato
|
||||||
|
|
||||||
private Mono<Health> doHealthCheck(Health.Builder builder, ReactiveRedisConnection connection) {
|
private Mono<Health> doHealthCheck(Health.Builder builder, ReactiveRedisConnection connection) {
|
||||||
boolean isClusterConnection = connection instanceof ReactiveRedisClusterConnection;
|
boolean isClusterConnection = connection instanceof ReactiveRedisClusterConnection;
|
||||||
return connection.serverCommands().info().map((info) -> up(builder, info, isClusterConnection))
|
return connection.serverCommands().info("server").map((info) -> up(builder, info, isClusterConnection))
|
||||||
.onErrorResume((ex) -> Mono.just(down(builder, ex)))
|
.onErrorResume((ex) -> Mono.just(down(builder, ex)))
|
||||||
.flatMap((health) -> connection.closeLater().thenReturn(health));
|
.flatMap((health) -> connection.closeLater().thenReturn(health));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import org.springframework.data.redis.connection.RedisConnection;
|
||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.atLeastOnce;
|
import static org.mockito.Mockito.atLeastOnce;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
@ -51,7 +52,7 @@ class RedisHealthIndicatorTests {
|
||||||
Properties info = new Properties();
|
Properties info = new Properties();
|
||||||
info.put("redis_version", "2.8.9");
|
info.put("redis_version", "2.8.9");
|
||||||
RedisConnection redisConnection = mock(RedisConnection.class);
|
RedisConnection redisConnection = mock(RedisConnection.class);
|
||||||
given(redisConnection.info()).willReturn(info);
|
given(redisConnection.info("server")).willReturn(info);
|
||||||
RedisHealthIndicator healthIndicator = createHealthIndicator(redisConnection);
|
RedisHealthIndicator healthIndicator = createHealthIndicator(redisConnection);
|
||||||
Health health = healthIndicator.health();
|
Health health = healthIndicator.health();
|
||||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||||
|
|
@ -61,7 +62,7 @@ class RedisHealthIndicatorTests {
|
||||||
@Test
|
@Test
|
||||||
void redisIsDown() {
|
void redisIsDown() {
|
||||||
RedisConnection redisConnection = mock(RedisConnection.class);
|
RedisConnection redisConnection = mock(RedisConnection.class);
|
||||||
given(redisConnection.info()).willThrow(new RedisConnectionFailureException("Connection failed"));
|
given(redisConnection.info(anyString())).willThrow(new RedisConnectionFailureException("Connection failed"));
|
||||||
RedisHealthIndicator healthIndicator = createHealthIndicator(redisConnection);
|
RedisHealthIndicator healthIndicator = createHealthIndicator(redisConnection);
|
||||||
Health health = healthIndicator.health();
|
Health health = healthIndicator.health();
|
||||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
|
||||||
import org.springframework.data.redis.connection.ReactiveServerCommands;
|
import org.springframework.data.redis.connection.ReactiveServerCommands;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
@ -55,7 +56,7 @@ class RedisReactiveHealthIndicatorTests {
|
||||||
ReactiveRedisConnection redisConnection = mock(ReactiveRedisConnection.class);
|
ReactiveRedisConnection redisConnection = mock(ReactiveRedisConnection.class);
|
||||||
given(redisConnection.closeLater()).willReturn(Mono.empty());
|
given(redisConnection.closeLater()).willReturn(Mono.empty());
|
||||||
ReactiveServerCommands commands = mock(ReactiveServerCommands.class);
|
ReactiveServerCommands commands = mock(ReactiveServerCommands.class);
|
||||||
given(commands.info()).willReturn(Mono.just(info));
|
given(commands.info("server")).willReturn(Mono.just(info));
|
||||||
RedisReactiveHealthIndicator healthIndicator = createHealthIndicator(redisConnection, commands);
|
RedisReactiveHealthIndicator healthIndicator = createHealthIndicator(redisConnection, commands);
|
||||||
Mono<Health> health = healthIndicator.health();
|
Mono<Health> health = healthIndicator.health();
|
||||||
StepVerifier.create(health).consumeNextWith((h) -> {
|
StepVerifier.create(health).consumeNextWith((h) -> {
|
||||||
|
|
@ -87,7 +88,7 @@ class RedisReactiveHealthIndicatorTests {
|
||||||
@Test
|
@Test
|
||||||
void redisCommandIsDown() {
|
void redisCommandIsDown() {
|
||||||
ReactiveServerCommands commands = mock(ReactiveServerCommands.class);
|
ReactiveServerCommands commands = mock(ReactiveServerCommands.class);
|
||||||
given(commands.info()).willReturn(Mono.error(new RedisConnectionFailureException("Connection failed")));
|
given(commands.info(anyString())).willReturn(Mono.error(new RedisConnectionFailureException("Connection failed")));
|
||||||
ReactiveRedisConnection redisConnection = mock(ReactiveRedisConnection.class);
|
ReactiveRedisConnection redisConnection = mock(ReactiveRedisConnection.class);
|
||||||
given(redisConnection.closeLater()).willReturn(Mono.empty());
|
given(redisConnection.closeLater()).willReturn(Mono.empty());
|
||||||
RedisReactiveHealthIndicator healthIndicator = createHealthIndicator(redisConnection, commands);
|
RedisReactiveHealthIndicator healthIndicator = createHealthIndicator(redisConnection, commands);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue