use of io.confluent.ksql.version.metrics.ActivenessRegistrar 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.version.metrics.ActivenessRegistrar in project ksql by confluentinc.
the class KsqlResourceTest method shouldThrowOnDenyListValidatorWhenHandleKsqlStatement.
@Test
public void shouldThrowOnDenyListValidatorWhenHandleKsqlStatement() {
// 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);
final Map<String, Object> props = new HashMap<>(ksqlRestConfig.getKsqlConfigProperties());
props.put(KsqlConfig.KSQL_PROPERTIES_OVERRIDES_DENYLIST, StreamsConfig.NUM_STREAM_THREADS_CONFIG);
ksqlResource.configure(new KsqlConfig(props));
final Map<String, Object> overrides = ImmutableMap.of(StreamsConfig.NUM_STREAM_THREADS_CONFIG, 1);
doThrow(new KsqlException("deny override")).when(denyListPropertyValidator).validateAll(overrides);
// When:
final EndpointResponse response = ksqlResource.handleKsqlStatements(securityContext, new KsqlRequest("query", // stream properties
overrides, emptyMap(), null));
// Then:
verify(denyListPropertyValidator).validateAll(overrides);
assertThat(response.getStatus(), CoreMatchers.is(BAD_REQUEST.code()));
assertThat(((KsqlErrorMessage) response.getEntity()).getMessage(), is("deny override"));
}
use of io.confluent.ksql.version.metrics.ActivenessRegistrar in project ksql by confluentinc.
the class KsqlResourceTest method shouldThrowOnHandleStatementIfNotConfigured.
@Test
public void shouldThrowOnHandleStatementIfNotConfigured() {
// 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.handleKsqlStatements(securityContext, new KsqlRequest("query", emptyMap(), emptyMap(), null)));
// Then:
assertThat(e, exceptionStatusCode(CoreMatchers.is(SERVICE_UNAVAILABLE.code())));
assertThat(e, exceptionErrorMessage(errorMessage(Matchers.is("Server initializing"))));
}
use of io.confluent.ksql.version.metrics.ActivenessRegistrar in project ksql by confluentinc.
the class KsqlResourceTest method setUpKsqlResource.
private void setUpKsqlResource() {
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);
ksqlResource.configure(ksqlConfig);
}
Aggregations