Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private DataRedisHealth() {
}

static Health.Builder up(Health.Builder builder, Properties info) {
builder.withDetail("version", info.getProperty("redis_version"));
builder.withDetail("version", info.getProperty("redis_version", "unknown"));
return builder.up();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ void redisIsUp() {
then(redisConnection).should().closeLater();
}

@Test
void redisIsUpWithMissingVersion() {
Properties info = new Properties();
ReactiveRedisConnection redisConnection = mock(ReactiveRedisConnection.class);
given(redisConnection.closeLater()).willReturn(Mono.empty());
ReactiveServerCommands commands = mock(ReactiveServerCommands.class);
given(commands.info("server")).willReturn(Mono.just(info));
DataRedisReactiveHealthIndicator healthIndicator = createHealthIndicator(redisConnection, commands);
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).containsOnlyKeys("version");
assertThat(h.getDetails()).containsEntry("version", "unknown");
}).expectComplete().verify(Duration.ofSeconds(30));
then(redisConnection).should().closeLater();
}

@Test
void healthWhenClusterStateIsAbsentShouldBeUp() {
ReactiveRedisConnectionFactory redisConnectionFactory = createClusterConnectionFactory(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ void redisIsUp() {
assertThat(health.getDetails()).containsEntry("version", "2.8.9");
}

@Test
void redisIsUpWithMissingVersion() {
Properties info = new Properties();
RedisConnection redisConnection = mock(RedisConnection.class);
RedisServerCommands serverCommands = mock(RedisServerCommands.class);
given(redisConnection.serverCommands()).willReturn(serverCommands);
given(serverCommands.info()).willReturn(info);
DataRedisHealthIndicator healthIndicator = createHealthIndicator(redisConnection);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails()).containsEntry("version", "unknown");
}

@Test
void redisIsDown() {
RedisConnection redisConnection = mock(RedisConnection.class);
Expand Down