use of io.confluent.ksql.rest.entity.KsqlWarning 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());
}
use of io.confluent.ksql.rest.entity.KsqlWarning in project ksql by confluentinc.
the class ListConnectorsExecutorTest method shouldListInvalidConnectorWithNoInfo.
@Test
public void shouldListInvalidConnectorWithNoInfo() {
// Given:
when(connectClient.connectors()).thenReturn(ConnectResponse.success(ImmutableList.of("connector2"), HttpStatus.SC_OK));
final ConfiguredStatement<ListConnectors> statement = ConfiguredStatement.of(PreparedStatement.of("", new ListConnectors(Optional.empty(), Scope.ALL)), SessionConfig.of(new KsqlConfig(ImmutableMap.of()), ImmutableMap.of()));
// When:
final Optional<KsqlEntity> entity = EXECUTOR.execute(statement, mock(SessionProperties.class), engine, serviceContext).getEntity();
// Then:
assertThat("expected response!", entity.isPresent());
final ConnectorList connectorList = (ConnectorList) entity.get();
assertThat(connectorList, is(new ConnectorList("", ImmutableList.of(new KsqlWarning("Could not describe connector connector2: DANGER WILL ROBINSON.")), ImmutableList.of(new SimpleConnectorInfo("connector2", ConnectorType.UNKNOWN, null, null)))));
}
use of io.confluent.ksql.rest.entity.KsqlWarning in project ksql by confluentinc.
the class ListSourceExecutorTest method assertSourceListWithWarning.
private static void assertSourceListWithWarning(final KsqlEntity entity, final DataSource... sources) {
assertThat(entity, instanceOf(SourceDescriptionList.class));
final SourceDescriptionList listing = (SourceDescriptionList) entity;
assertThat(listing.getSourceDescriptions(), containsInAnyOrder(Arrays.stream(sources).map(s -> equalTo(SourceDescriptionFactory.create(s, true, ImmutableList.of(), ImmutableList.of(), Optional.empty(), ImmutableList.of(), ImmutableList.of(), new MetricCollectors()))).collect(Collectors.toList())));
assertThat(listing.getWarnings(), containsInAnyOrder(Arrays.stream(sources).map(s -> equalTo(new KsqlWarning("Error from Kafka: unknown topic: " + s.getKafkaTopicName()))).collect(Collectors.toList())));
}
use of io.confluent.ksql.rest.entity.KsqlWarning in project ksql by confluentinc.
the class ConsoleTest method shouldPrintWarnings.
@Test
public void shouldPrintWarnings() {
// Given:
final KsqlEntity entity = new SourceDescriptionEntity("e", sourceDescription, ImmutableList.of(new KsqlWarning("oops"), new KsqlWarning("doh!")));
// When:
console.printKsqlEntityList(ImmutableList.of(entity));
// Then:
final String output = terminal.getOutputString();
Approvals.verify(output, approvalOptions);
}
use of io.confluent.ksql.rest.entity.KsqlWarning in project ksql by confluentinc.
the class StreamStreamJoinsDeprecationNoticesIntegrationTest method shouldReturnDeprecationWarningMessageOnDeprecatedStatements.
@Test
public void shouldReturnDeprecationWarningMessageOnDeprecatedStatements() {
// When
final KsqlEntity ksqlEntity = makeKsqlRequest(String.format("CREATE STREAM DEPRECATED_QUERY AS " + "SELECT * FROM %s AS l " + "LEFT JOIN %s AS r WITHIN 1 SECOND ON l.K->F1 = r.K->F1;", STREAM_DATA_PROVIDER_1.sourceName(), STREAM_DATA_PROVIDER_2.sourceName())).get(0);
// Then
final CommandStatusEntity commandStatusEntity = (CommandStatusEntity) ksqlEntity;
final CommandStatus commandStatus = commandStatusEntity.getCommandStatus();
assertThat(commandStatus.getStatus(), is(CommandStatus.Status.SUCCESS));
assertThat(commandStatus.getMessage(), containsString("Created query with ID CSAS_DEPRECATED_QUERY_"));
assertThat(commandStatusEntity.getWarnings(), contains(new KsqlWarning("DEPRECATION NOTICE: Stream-stream joins statements without a GRACE PERIOD " + "will not be accepted in a future ksqlDB version.\n" + "Please use the GRACE PERIOD clause as specified in " + "https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-reference/" + "select-push-query/")));
}
Aggregations