use of io.confluent.ksql.rest.entity.KsqlErrorMessage in project ksql by confluentinc.
the class ClusterTerminationTest method shouldReturn50303WhenTerminating.
private void shouldReturn50303WhenTerminating() {
// Given: TERMINATE CLUSTER has been issued
// When:
final KsqlErrorMessage error = RestIntegrationTestUtil.makeKsqlRequestWithError(REST_APP, "SHOW STREAMS;");
// Then:
assertThat(error.getErrorCode(), is(Errors.ERROR_CODE_SERVER_SHUTTING_DOWN));
}
use of io.confluent.ksql.rest.entity.KsqlErrorMessage in project ksql by confluentinc.
the class PreconditionFunctionalTest method shouldNotServeRequestsWhileWaitingForPrecondition.
@Test
public void shouldNotServeRequestsWhileWaitingForPrecondition() {
// When:
final KsqlErrorMessage error = RestIntegrationTestUtil.makeKsqlRequestWithError(REST_APP, "SHOW STREAMS;");
// Then:
assertThat(error.getErrorCode(), is(CUSTOM_ERROR_CODE));
}
use of io.confluent.ksql.rest.entity.KsqlErrorMessage in project ksql by confluentinc.
the class ListQueriesExecutorTest method shouldIncludeUnresponsiveIfShowQueriesErrorResponse.
@Test
public void shouldIncludeUnresponsiveIfShowQueriesErrorResponse() {
// Given
when(sessionProperties.getInternalRequest()).thenReturn(false);
final ConfiguredStatement<ListQueries> showQueries = (ConfiguredStatement<ListQueries>) engine.configure("SHOW QUERIES;");
final PersistentQueryMetadata metadata = givenPersistentQuery("id", RUNNING_QUERY_STATE);
final KsqlEngine engine = mock(KsqlEngine.class);
when(engine.getAllLiveQueries()).thenReturn(ImmutableList.of(metadata));
when(engine.getPersistentQueries()).thenReturn(ImmutableList.of(metadata));
when(response.isErroneous()).thenReturn(true);
when(response.getErrorMessage()).thenReturn(new KsqlErrorMessage(10000, "error"));
queryStatusCount.updateStatusCount(RUNNING_QUERY_STATE, 1);
queryStatusCount.updateStatusCount(KsqlQueryStatus.UNRESPONSIVE, 1);
// When
final Queries queries = (Queries) CUSTOM_EXECUTORS.listQueries().execute(showQueries, sessionProperties, engine, serviceContext).getEntity().orElseThrow(IllegalStateException::new);
// Then
assertThat(queries.getQueries(), containsInAnyOrder(persistentQueryMetadataToRunningQuery(metadata, queryStatusCount)));
}
use of io.confluent.ksql.rest.entity.KsqlErrorMessage in project ksql by confluentinc.
the class ListQueriesExecutorTest method shouldIncludeUnresponsiveIfShowQueriesExtendedErrorResponse.
@Test
public void shouldIncludeUnresponsiveIfShowQueriesExtendedErrorResponse() {
// Given
when(sessionProperties.getInternalRequest()).thenReturn(false);
final ConfiguredStatement<ListQueries> showQueries = (ConfiguredStatement<ListQueries>) engine.configure("SHOW QUERIES EXTENDED;");
final PersistentQueryMetadata metadata = givenPersistentQuery("id", RUNNING_QUERY_STATE);
final KsqlEngine engine = mock(KsqlEngine.class);
when(engine.getAllLiveQueries()).thenReturn(ImmutableList.of(metadata));
when(engine.getPersistentQueries()).thenReturn(ImmutableList.of(metadata));
when(response.isErroneous()).thenReturn(true);
when(response.getErrorMessage()).thenReturn(new KsqlErrorMessage(10000, "error"));
final Map<KsqlHostInfoEntity, KsqlQueryStatus> map = new HashMap<>();
map.put(LOCAL_KSQL_HOST_INFO_ENTITY, KsqlQueryStatus.RUNNING);
map.put(REMOTE_KSQL_HOST_INFO_ENTITY, KsqlQueryStatus.UNRESPONSIVE);
// When
final QueryDescriptionList queries = (QueryDescriptionList) CUSTOM_EXECUTORS.listQueries().execute(showQueries, sessionProperties, engine, serviceContext).getEntity().orElseThrow(IllegalStateException::new);
// Then
assertThat(queries.getQueryDescriptions(), containsInAnyOrder(QueryDescriptionFactory.forQueryMetadata(metadata, map)));
}
use of io.confluent.ksql.rest.entity.KsqlErrorMessage in project ksql by confluentinc.
the class StreamedQueryResourceTest method shouldReturnForbiddenKafkaAccessForPullQueryAuthorizationDenied.
@Test
public void shouldReturnForbiddenKafkaAccessForPullQueryAuthorizationDenied() {
// Given:
when(mockStatementParser.<Query>parseSingleStatement(PULL_QUERY_STRING)).thenReturn(query);
doThrow(new KsqlTopicAuthorizationException(AclOperation.READ, Collections.singleton(TOPIC_NAME))).when(authorizationValidator).checkAuthorization(any(), any(), any());
// When:
final EndpointResponse response = testResource.streamQuery(securityContext, new KsqlRequest(PULL_QUERY_STRING, Collections.emptyMap(), Collections.emptyMap(), null), new CompletableFuture<>(), Optional.empty(), new MetricsCallbackHolder(), context);
final KsqlErrorMessage responseEntity = (KsqlErrorMessage) response.getEntity();
final KsqlErrorMessage expectedEntity = (KsqlErrorMessage) AUTHORIZATION_ERROR_RESPONSE.getEntity();
assertEquals(response.getStatus(), AUTHORIZATION_ERROR_RESPONSE.getStatus());
assertEquals(responseEntity.getMessage(), expectedEntity.getMessage());
}
Aggregations