use of io.confluent.ksql.rest.entity.HealthCheckResponse in project ksql by confluentinc.
the class HealthCheckAgentTest method shouldReturnUnhealthyIfMetastoreCheckFails.
@Test
public void shouldReturnUnhealthyIfMetastoreCheckFails() {
// Given:
when(ksqlClient.makeKsqlRequest(SERVER_URI, "list streams; list tables; list queries;", REQUEST_PROPERTIES)).thenReturn(unSuccessfulResponse);
// When:
final HealthCheckResponse response = healthCheckAgent.checkHealth();
// Then:
assertThat(response.getDetails().get(METASTORE_CHECK_NAME).getIsHealthy(), is(false));
assertThat(response.getIsHealthy(), is(false));
}
use of io.confluent.ksql.rest.entity.HealthCheckResponse in project ksql by confluentinc.
the class HealthCheckAgentTest method shouldReturnUnhealthyIfCommandRunnerCheckFails.
@Test
public void shouldReturnUnhealthyIfCommandRunnerCheckFails() {
// Given:
when(commandRunner.checkCommandRunnerStatus()).thenReturn(CommandRunner.CommandRunnerStatus.DEGRADED);
// When:
final HealthCheckResponse response = healthCheckAgent.checkHealth();
// Then:
assertThat(response.getDetails().get(COMMAND_RUNNER_CHECK_NAME).getIsHealthy(), is(false));
assertThat(response.getIsHealthy(), is(false));
}
use of io.confluent.ksql.rest.entity.HealthCheckResponse in project ksql by confluentinc.
the class HealthCheckAgentTest method shouldReturnHealthyIfKafkaCheckFailsWithUnknownTopicOrPartitionException.
@Test
public void shouldReturnHealthyIfKafkaCheckFailsWithUnknownTopicOrPartitionException() {
// Given:
givenDescribeTopicsThrows(new UnknownTopicOrPartitionException());
// When:
final HealthCheckResponse response = healthCheckAgent.checkHealth();
// Then:
assertThat(response.getDetails().get(KAFKA_CHECK_NAME).getIsHealthy(), is(true));
assertThat(response.getIsHealthy(), is(true));
}
use of io.confluent.ksql.rest.entity.HealthCheckResponse in project ksql by confluentinc.
the class HealthCheckAgentTest method shouldReturnHealthyIfKafkaCheckFailsWithUnknownTopicOrPartitionExceptionAsRootCause.
@Test
public void shouldReturnHealthyIfKafkaCheckFailsWithUnknownTopicOrPartitionExceptionAsRootCause() {
// Given:
givenDescribeTopicsThrows(new RuntimeException(new UnknownTopicOrPartitionException()));
// When:
final HealthCheckResponse response = healthCheckAgent.checkHealth();
// Then:
assertThat(response.getDetails().get(KAFKA_CHECK_NAME).getIsHealthy(), is(true));
assertThat(response.getIsHealthy(), is(true));
}
use of io.confluent.ksql.rest.entity.HealthCheckResponse in project ksql by confluentinc.
the class CommandTopicFunctionalTest method shouldReturnWarningsInRestResponseWhenDegradedCommandRunner.
@Test
public void shouldReturnWarningsInRestResponseWhenDegradedCommandRunner() {
// When:
REST_APP_1.start();
RestIntegrationTestUtil.createStream(REST_APP_1, PAGE_VIEWS_PROVIDER);
makeKsqlRequest(REST_APP_1, "CREATE STREAM S AS SELECT * FROM " + PAGE_VIEW_STREAM + ";" + "CREATE STREAM S2 AS SELECT * FROM S;");
final List<KsqlEntity> results1 = makeKsqlRequest(REST_APP_1, "show streams; show topics; show tables;");
results1.forEach(ksqlEntity -> {
assertThat("Warning shouldn't be present in response", ksqlEntity.getWarnings().size() == 0);
});
HealthCheckResponse healthCheckResponse = RestIntegrationTestUtil.checkServerHealth(REST_APP_1);
assertThat("CommandRunner healthcheck is healthy for server 1", healthCheckResponse.getDetails().get(COMMAND_RUNNER_CHECK_NAME).getIsHealthy());
// Delete command topic while server 1 still running
TEST_HARNESS.deleteTopics(Collections.singletonList(ReservedInternalTopics.commandTopic(new KsqlConfig(Collections.emptyMap()))));
// Slight delay in warnings appearing since a consumer poll has to complete before CommandRunner becomes DEGRADED
assertThatEventually("Corrupted warning should be present in response", () -> {
final List<KsqlEntity> results2 = makeKsqlRequest(REST_APP_1, "show streams; show topics; show tables;");
return results2.stream().allMatch(ksqlEntity -> {
final List<KsqlWarning> warnings = ksqlEntity.getWarnings();
return warnings.size() == 1 && warnings.get(0).getMessage().equals(DefaultErrorMessages.COMMAND_RUNNER_DEGRADED_CORRUPTED_ERROR_MESSAGE);
});
}, is(true));
// need healthcheck cache to expire
assertThatEventually("CommandRunner healthcheck is unhealthy for server 1", () -> {
final HealthCheckResponse newHealthCheckResponse = RestIntegrationTestUtil.checkServerHealth(REST_APP_1);
return newHealthCheckResponse.getDetails().get(COMMAND_RUNNER_CHECK_NAME).getIsHealthy();
}, is(false));
// Corrupted backup test
REST_APP_2.start();
// new DDL that diverges from backup triggers the corruption detection
final List<KsqlEntity> results3 = makeKsqlRequest(REST_APP_2, "CREATE STREAM pageviews_divergent" + "(" + PAGE_VIEWS_PROVIDER.ksqlSchemaString(false) + ") " + "WITH (kafka_topic='" + PAGE_VIEWS_PROVIDER.topicName() + "', value_format='json');");
results3.forEach(ksqlEntity -> {
assertThat("Warning should be present in response", ksqlEntity.getWarnings().size() == 1);
assertThat("Warning is corrupted warning", ksqlEntity.getWarnings().get(0).getMessage().equals(DefaultErrorMessages.COMMAND_RUNNER_DEGRADED_CORRUPTED_ERROR_MESSAGE));
});
assertThatEventually("CommandRunner healthcheck is unhealthy for server 2", () -> {
final HealthCheckResponse newHealthCheckResponse = RestIntegrationTestUtil.checkServerHealth(REST_APP_2);
return newHealthCheckResponse.getDetails().get(COMMAND_RUNNER_CHECK_NAME).getIsHealthy();
}, is(false));
// First server should still be in DEGRADED state even though second server created command topic on start up
final List<KsqlEntity> results4 = makeKsqlRequest(REST_APP_1, "show streams;");
results4.forEach(ksqlEntity -> {
assertThat("Warning should be present in response", ksqlEntity.getWarnings().size() == 1);
assertThat("Warning isn't corrupted warning", ksqlEntity.getWarnings().get(0).getMessage().equals(DefaultErrorMessages.COMMAND_RUNNER_DEGRADED_CORRUPTED_ERROR_MESSAGE));
});
healthCheckResponse = RestIntegrationTestUtil.checkServerHealth(REST_APP_1);
assertThat("CommandRunner healthcheck is unhealthy for server 1", !healthCheckResponse.getDetails().get(COMMAND_RUNNER_CHECK_NAME).getIsHealthy());
}
Aggregations