Search in sources :

Example 1 with HealthCheckResponse

use of io.confluent.ksql.rest.entity.HealthCheckResponse in project ksql by confluentinc.

the class HealthCheckAgentTest method shouldReturnHealthyIfKafkaCheckFailsWithAuthorizationException.

@Test
public void shouldReturnHealthyIfKafkaCheckFailsWithAuthorizationException() {
    // Given:
    givenDescribeTopicsThrows(KsqlTopicAuthorizationException.class);
    // When:
    final HealthCheckResponse response = healthCheckAgent.checkHealth();
    // Then:
    assertThat(response.getDetails().get(KAFKA_CHECK_NAME).getIsHealthy(), is(true));
    assertThat(response.getIsHealthy(), is(true));
}
Also used : HealthCheckResponse(io.confluent.ksql.rest.entity.HealthCheckResponse) Test(org.junit.Test)

Example 2 with HealthCheckResponse

use of io.confluent.ksql.rest.entity.HealthCheckResponse in project ksql by confluentinc.

the class HealthCheckAgentTest method shouldCheckHealth.

@Test
public void shouldCheckHealth() {
    // When:
    final HealthCheckResponse response = healthCheckAgent.checkHealth();
    // Then:
    verify(ksqlClient, atLeastOnce()).makeKsqlRequest(eq(SERVER_URI), any(), eq(REQUEST_PROPERTIES));
    assertThat(response.getDetails().get(METASTORE_CHECK_NAME).getIsHealthy(), is(true));
    assertThat(response.getDetails().get(KAFKA_CHECK_NAME).getIsHealthy(), is(true));
    assertThat(response.getDetails().get(COMMAND_RUNNER_CHECK_NAME).getIsHealthy(), is(true));
    assertThat(response.getIsHealthy(), is(true));
}
Also used : HealthCheckResponse(io.confluent.ksql.rest.entity.HealthCheckResponse) Test(org.junit.Test)

Example 3 with HealthCheckResponse

use of io.confluent.ksql.rest.entity.HealthCheckResponse in project ksql by confluentinc.

the class HealthCheckAgentTest method shouldReturnUnhealthyIfKafkaCheckFails.

@Test
public void shouldReturnUnhealthyIfKafkaCheckFails() {
    // Given:
    givenDescribeTopicsThrows(KafkaResponseGetFailedException.class);
    // When:
    final HealthCheckResponse response = healthCheckAgent.checkHealth();
    // Then:
    assertThat(response.getDetails().get(KAFKA_CHECK_NAME).getIsHealthy(), is(false));
    assertThat(response.getIsHealthy(), is(false));
}
Also used : HealthCheckResponse(io.confluent.ksql.rest.entity.HealthCheckResponse) Test(org.junit.Test)

Example 4 with HealthCheckResponse

use of io.confluent.ksql.rest.entity.HealthCheckResponse in project ksql by confluentinc.

the class BackupRollbackIntegrationTest method isDegradedState.

private boolean isDegradedState() {
    // If in degraded state, then the following command will return a warning
    final List<KsqlEntity> response = makeKsqlRequest("Show Streams;");
    final List<KsqlWarning> warnings = response.get(0).getWarnings();
    final HealthCheckResponse res = RestIntegrationTestUtil.checkServerHealth(REST_APP);
    return !res.getDetails().get(COMMAND_RUNNER_CHECK_NAME).getIsHealthy() && (warnings.size() > 0 && warnings.get(0).getMessage().contains(DefaultErrorMessages.COMMAND_RUNNER_DEGRADED_INCOMPATIBLE_COMMANDS_ERROR_MESSAGE));
}
Also used : HealthCheckResponse(io.confluent.ksql.rest.entity.HealthCheckResponse) KsqlWarning(io.confluent.ksql.rest.entity.KsqlWarning) KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity)

Example 5 with HealthCheckResponse

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));
}
Also used : HealthCheckResponse(io.confluent.ksql.rest.entity.HealthCheckResponse) Test(org.junit.Test)

Aggregations

HealthCheckResponse (io.confluent.ksql.rest.entity.HealthCheckResponse)11 Test (org.junit.Test)10 IntegrationTest (io.confluent.common.utils.IntegrationTest)2 KsqlEntity (io.confluent.ksql.rest.entity.KsqlEntity)2 KsqlWarning (io.confluent.ksql.rest.entity.KsqlWarning)2 UnknownTopicOrPartitionException (org.apache.kafka.common.errors.UnknownTopicOrPartitionException)2 HealthCheckResponseDetail (io.confluent.ksql.rest.entity.HealthCheckResponseDetail)1 KsqlConfig (io.confluent.ksql.util.KsqlConfig)1 HashMap (java.util.HashMap)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1