use of io.confluent.ksql.engine.KsqlEngine in project ksql by confluentinc.
the class KsqlResourceTest method shouldThrowOnHandleTerminateIfNotConfigured.
@Test
public void shouldThrowOnHandleTerminateIfNotConfigured() {
// Given:
ksqlResource = new KsqlResource(ksqlEngine, commandRunner, DISTRIBUTED_COMMAND_RESPONSE_TIMEOUT, activenessRegistrar, (ec, sc) -> InjectorChain.of(schemaInjectorFactory.apply(sc), topicInjectorFactory.apply(ec), new TopicDeleteInjector(ec, sc)), Optional.of(authorizationValidator), errorsHandler, connectErrorHandler, denyListPropertyValidator, commandRunnerWarning);
// When:
final KsqlRestException e = assertThrows(KsqlRestException.class, () -> ksqlResource.terminateCluster(securityContext, new ClusterTerminateRequest(ImmutableList.of(""))));
// Then:
assertThat(e, exceptionStatusCode(CoreMatchers.is(SERVICE_UNAVAILABLE.code())));
assertThat(e, exceptionErrorMessage(errorMessage(Matchers.is("Server initializing"))));
}
use of io.confluent.ksql.engine.KsqlEngine in project ksql by confluentinc.
the class TerminateQueryExecutorTest method shouldDefaultToDistributorForTerminateAll.
@Test
public void shouldDefaultToDistributorForTerminateAll() {
// Given:
final ConfiguredStatement<TerminateQuery> terminatePersistent = (ConfiguredStatement<TerminateQuery>) engine.configure("TERMINATE ALL;");
final KsqlEngine engine = mock(KsqlEngine.class);
// When:
final Optional<KsqlEntity> ksqlEntity = CUSTOM_EXECUTORS.terminateQuery().execute(terminatePersistent, mock(SessionProperties.class), engine, this.engine.getServiceContext()).getEntity();
// Then:
assertThat(ksqlEntity, is(Optional.empty()));
}
use of io.confluent.ksql.engine.KsqlEngine in project ksql by confluentinc.
the class TerminateQueryExecutorTest method shouldDefaultToDistributorForTerminateCluster.
@Test
public void shouldDefaultToDistributorForTerminateCluster() {
// Given:
final ConfiguredStatement<TerminateQuery> terminatePersistent = (ConfiguredStatement<TerminateQuery>) engine.configure("TERMINATE CLUSTER;");
final KsqlEngine engine = mock(KsqlEngine.class);
// When:
final Optional<KsqlEntity> ksqlEntity = CUSTOM_EXECUTORS.terminateQuery().execute(terminatePersistent, mock(SessionProperties.class), engine, this.engine.getServiceContext()).getEntity();
// Then:
assertThat(ksqlEntity, is(Optional.empty()));
}
use of io.confluent.ksql.engine.KsqlEngine in project ksql by confluentinc.
the class TerminateQueryExecutorTest method shouldTerminateTransientQuery.
@Test
public void shouldTerminateTransientQuery() {
// Given:
final ConfiguredStatement<TerminateQuery> terminateTransient = (ConfiguredStatement<TerminateQuery>) engine.configure("TERMINATE TRANSIENT_QUERY;");
final TransientQueryMetadata transientQueryMetadata = givenTransientQuery("TRANSIENT_QUERY", RUNNING_QUERY_STATE);
final QueryId transientQueryId = transientQueryMetadata.getQueryId();
final KsqlEngine engine = mock(KsqlEngine.class);
when(engine.getQuery(transientQueryId)).thenReturn(Optional.of(transientQueryMetadata));
// When:
final Optional<KsqlEntity> ksqlEntity = CUSTOM_EXECUTORS.terminateQuery().execute(terminateTransient, mock(SessionProperties.class), engine, this.engine.getServiceContext()).getEntity();
// Then:
assertThat(ksqlEntity, is(Optional.of(new TerminateQueryEntity(terminateTransient.getStatementText(), transientQueryId.toString(), true))));
}
use of io.confluent.ksql.engine.KsqlEngine in project ksql by confluentinc.
the class TerminateQueryExecutorTest method shouldDefaultToDistributorForPersistentQuery.
@Test
public void shouldDefaultToDistributorForPersistentQuery() {
// Given:
final ConfiguredStatement<TerminateQuery> terminatePersistent = (ConfiguredStatement<TerminateQuery>) engine.configure("TERMINATE PERSISTENT_QUERY;");
final PersistentQueryMetadata persistentQueryMetadata = givenPersistentQuery("PERSISTENT_QUERY", RUNNING_QUERY_STATE);
final QueryId persistentQueryId = persistentQueryMetadata.getQueryId();
final KsqlEngine engine = mock(KsqlEngine.class);
when(engine.getPersistentQuery(persistentQueryId)).thenReturn(Optional.of(persistentQueryMetadata));
// When:
final Optional<KsqlEntity> ksqlEntity = CUSTOM_EXECUTORS.terminateQuery().execute(terminatePersistent, mock(SessionProperties.class), engine, this.engine.getServiceContext()).getEntity();
// Then:
assertThat(ksqlEntity, is(Optional.empty()));
}
Aggregations