use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.
the class KsqlResourceTest method givenKsqlConfigWith.
private void givenKsqlConfigWith(final Map<String, Object> additionalConfig) {
final Map<String, Object> config = ksqlRestConfig.getKsqlConfigProperties();
config.putAll(additionalConfig);
ksqlConfig = new KsqlConfig(config);
final MetricCollectors metricCollectors = new MetricCollectors();
ksqlEngine = KsqlEngineTestUtil.createKsqlEngine(serviceContext, metaStore, (engine) -> new KsqlEngineMetrics("", engine, Collections.emptyMap(), Optional.empty(), metricCollectors), new SequentialQueryIdGenerator(), ksqlConfig, metricCollectors);
setUpKsqlResource();
}
use of io.confluent.ksql.metrics.MetricCollectors 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.metrics.MetricCollectors in project ksql by confluentinc.
the class ListSourceExecutorTest method shouldDescribeStreams.
@Test
public void shouldDescribeStreams() {
// Given:
final KsqlStream<?> stream1 = engine.givenSource(DataSourceType.KSTREAM, "stream1");
final KsqlStream<?> stream2 = engine.givenSource(DataSourceType.KSTREAM, "stream2", ImmutableSet.of(SourceName.of("stream1")));
engine.givenSource(DataSourceType.KTABLE, "table");
// When:
final SourceDescriptionList descriptionList = (SourceDescriptionList) CUSTOM_EXECUTORS.describeStreams().execute((ConfiguredStatement<DescribeStreams>) engine.configure("DESCRIBE STREAMS;"), SESSION_PROPERTIES, engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(descriptionList.getSourceDescriptions(), containsInAnyOrder(SourceDescriptionFactory.create(stream1, false, ImmutableList.of(), ImmutableList.of(), Optional.of(topicWith1PartitionAndRfOf1), ImmutableList.of(), ImmutableList.of("stream2"), new MetricCollectors()), SourceDescriptionFactory.create(stream2, false, ImmutableList.of(), ImmutableList.of(), Optional.of(topicWith1PartitionAndRfOf1), ImmutableList.of(), ImmutableList.of(), new MetricCollectors())));
}
use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.
the class ListSourceExecutorTest method shouldShowColumnsSource.
@Test
public void shouldShowColumnsSource() {
// Given:
engine.givenSource(DataSourceType.KSTREAM, "SOURCE");
final ExecuteResult result = engine.getEngine().execute(engine.getServiceContext(), engine.configure("CREATE STREAM SINK AS SELECT * FROM source;"));
final PersistentQueryMetadata metadata = (PersistentQueryMetadata) result.getQuery().orElseThrow(IllegalArgumentException::new);
final DataSource stream = engine.getEngine().getMetaStore().getSource(SourceName.of("SINK"));
// When:
final SourceDescriptionEntity sourceDescription = (SourceDescriptionEntity) CUSTOM_EXECUTORS.showColumns().execute(ConfiguredStatement.of(PreparedStatement.of("DESCRIBE SINK;", new ShowColumns(SourceName.of("SINK"), false)), SessionConfig.of(engine.getKsqlConfig(), ImmutableMap.of())), SESSION_PROPERTIES, engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
final QueryStatusCount queryStatusCount = QueryStatusCount.fromStreamsStateCounts(Collections.singletonMap(metadata.getState(), 1));
assertThat(sourceDescription.getSourceDescription(), equalTo(SourceDescriptionFactory.create(stream, false, ImmutableList.of(), ImmutableList.of(new RunningQuery(metadata.getStatementString(), ImmutableSet.of(metadata.getSinkName().get().toString(FormatOptions.noEscape())), ImmutableSet.of(metadata.getResultTopic().get().getKafkaTopicName()), metadata.getQueryId(), queryStatusCount, KsqlConstants.KsqlQueryType.PERSISTENT)), Optional.empty(), ImmutableList.of(), ImmutableList.of(), new MetricCollectors())));
}
use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.
the class ListSourceExecutorTest method shouldShowStreamsExtended.
@Test
public void shouldShowStreamsExtended() {
// Given:
final KsqlStream<?> stream1 = engine.givenSource(DataSourceType.KSTREAM, "stream1");
final KsqlStream<?> stream2 = engine.givenSource(DataSourceType.KSTREAM, "stream2", ImmutableSet.of(SourceName.of("stream1")));
engine.givenSource(DataSourceType.KTABLE, "table");
// When:
final SourceDescriptionList descriptionList = (SourceDescriptionList) CUSTOM_EXECUTORS.listStreams().execute((ConfiguredStatement<ListStreams>) engine.configure("SHOW STREAMS EXTENDED;"), SESSION_PROPERTIES, engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(descriptionList.getSourceDescriptions(), containsInAnyOrder(SourceDescriptionFactory.create(stream1, true, ImmutableList.of(), ImmutableList.of(), Optional.of(topicWith1PartitionAndRfOf1), ImmutableList.of(), ImmutableList.of("stream2"), new MetricCollectors()), SourceDescriptionFactory.create(stream2, true, ImmutableList.of(), ImmutableList.of(), Optional.of(topicWith1PartitionAndRfOf1), ImmutableList.of(), ImmutableList.of(), new MetricCollectors())));
}
Aggregations