Skip to content
Merged
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 @@ -68,7 +68,6 @@ public InfoContributor externalApiInfoContributor(
public HealthIndicator ogcApiHealth(
@Value("${elasticsearch.vocabs_index.name}") String vocabIndexName,
@Value("${elasticsearch.index.name}") String indexName,
@Value("${elasticsearch.cloud_optimized_index.name}") String coIndexName,
ElasticsearchClient client) {
return () -> {
try {
Expand All @@ -91,13 +90,6 @@ public HealthIndicator ogcApiHealth(
.build();
}

if(!client.indices().exists(ExistsRequest.of(b -> b.index(coIndexName))).value()) {
return Health.status(ErrorCode.MISSING_CO_CORE_INDEX.getStatus())
.withDetail("reason", ErrorCode.MISSING_CO_CORE_INDEX.getMessage())
.withDetail("code", ErrorCode.MISSING_CO_CORE_INDEX.getCode())
.build();
}

if(!client.indices().exists(ExistsRequest.of(b -> b.index(vocabIndexName))).value()) {
return Health.status(ErrorCode.MISSING_VOCAB_INDEX.getStatus())
.withDetail("reason", ErrorCode.MISSING_VOCAB_INDEX.getMessage())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public class ActuatorConfigTest {
private ActuatorConfig config;

private static final String INDEX = "test-core";
private static final String CO_INDEX = "test-co-core";
private static final String VOCAB_INDEX = "test-vocabs";

@BeforeEach
Expand All @@ -74,7 +73,7 @@ void greenCluster_allIndicesExist_returnsUp() throws Exception {
when(clusterHealth.status()).thenReturn(HealthStatus.Green);
when(client.indices().exists(any(ExistsRequest.class))).thenReturn(booleanHealthTrue);

Health health = config.ogcApiHealth(VOCAB_INDEX, INDEX, CO_INDEX, client).health();
Health health = config.ogcApiHealth(VOCAB_INDEX, INDEX, client).health();
assertEquals(Status.UP, health.getStatus());
}

Expand All @@ -84,7 +83,7 @@ void redCluster_returnsUnavailable() throws Exception {
when(client.cluster().health(any(Function.class))).thenReturn(clusterHealth);
when(clusterHealth.status()).thenReturn(HealthStatus.Red);

Health health = config.ogcApiHealth(VOCAB_INDEX, INDEX, CO_INDEX, client).health();
Health health = config.ogcApiHealth(VOCAB_INDEX, INDEX, client).health();

assertEquals(ErrorCode.ELASTICSEARCH_UNAVAILABLE.getStatus(), health.getStatus().toString());
assertTrue(health.getDetails().containsValue(ErrorCode.ELASTICSEARCH_UNAVAILABLE.getMessage()));
Expand All @@ -96,7 +95,7 @@ void yellowCluster_returnsUnavailable() throws Exception {
when(client.cluster().health(any(Function.class))).thenReturn(clusterHealth);
when(clusterHealth.status()).thenReturn(HealthStatus.Yellow);

Health health = config.ogcApiHealth(VOCAB_INDEX, INDEX, CO_INDEX, client).health();
Health health = config.ogcApiHealth(VOCAB_INDEX, INDEX, client).health();
assertEquals(ErrorCode.ELASTICSEARCH_UNAVAILABLE.getStatus(), health.getStatus().toString());
}

Expand All @@ -105,7 +104,7 @@ void yellowCluster_returnsUnavailable() throws Exception {
void exceptionThrown_returnsUnavailableWithException() throws Exception {
when(client.cluster().health(any(Function.class))).thenThrow(new RuntimeException("connection failed"));

Health health = config.ogcApiHealth(VOCAB_INDEX, INDEX, CO_INDEX, client).health();
Health health = config.ogcApiHealth(VOCAB_INDEX, INDEX, client).health();

assertEquals(ErrorCode.ELASTICSEARCH_UNAVAILABLE.getStatus(), health.getStatus().toString());
// Exception details in error section
Expand All @@ -128,7 +127,7 @@ void missingCoreIndex_returnsMissingCoreIndex() throws Exception {
return req.index().contains(INDEX) ? booleanHealthFalse : booleanHealthTrue;
});

Health health = config.ogcApiHealth(VOCAB_INDEX, INDEX, CO_INDEX, client).health();
Health health = config.ogcApiHealth(VOCAB_INDEX, INDEX, client).health();
assertEquals(ErrorCode.MISSING_CORE_INDEX.getCode(), health.getDetails().get("code").toString());
}

Expand All @@ -141,7 +140,7 @@ void missingVocabIndex_returnsMissingVocabIndex() throws Exception {
return req.index().contains(VOCAB_INDEX) ? booleanHealthFalse : booleanHealthTrue;
});

Health health = config.ogcApiHealth(VOCAB_INDEX, INDEX, CO_INDEX, client).health();
Health health = config.ogcApiHealth(VOCAB_INDEX, INDEX, client).health();
assertEquals(ErrorCode.MISSING_VOCAB_INDEX.getCode(), health.getDetails().get("code").toString());
}
}
Loading