Search in sources :

Example 21 with MetricCollectors

use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.

the class ListSourceExecutorTest method shouldAddWarningOnClientExceptionForDescription.

@Test
public void shouldAddWarningOnClientExceptionForDescription() {
    // Given:
    final KsqlStream<?> stream1 = engine.givenSource(DataSourceType.KSTREAM, "STREAM1");
    final ServiceContext serviceContext = engine.getServiceContext();
    serviceContext.getTopicClient().deleteTopics(ImmutableList.of("STREAM1"));
    // When:
    final KsqlEntity entity = CUSTOM_EXECUTORS.showColumns().execute((ConfiguredStatement<ShowColumns>) engine.configure("DESCRIBE STREAM1 EXTENDED;"), SESSION_PROPERTIES, engine.getEngine(), serviceContext).getEntity().orElseThrow(IllegalStateException::new);
    // Then:
    assertThat(entity, instanceOf(SourceDescriptionEntity.class));
    final SourceDescriptionEntity description = (SourceDescriptionEntity) entity;
    assertThat(description.getSourceDescription(), equalTo(SourceDescriptionFactory.create(stream1, true, ImmutableList.of(), ImmutableList.of(), Optional.empty(), ImmutableList.of(), ImmutableList.of(), new MetricCollectors())));
    assertThat(description.getWarnings(), contains(new KsqlWarning("Error from Kafka: unknown topic: STREAM1")));
}
Also used : ServiceContext(io.confluent.ksql.services.ServiceContext) TestServiceContext(io.confluent.ksql.services.TestServiceContext) ShowColumns(io.confluent.ksql.parser.tree.ShowColumns) SourceDescriptionEntity(io.confluent.ksql.rest.entity.SourceDescriptionEntity) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) KsqlWarning(io.confluent.ksql.rest.entity.KsqlWarning) KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity) Test(org.junit.Test)

Example 22 with MetricCollectors

use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.

the class ListSourceExecutorTest method shouldShowTablesExtended.

@Test
public void shouldShowTablesExtended() {
    // Given:
    final KsqlTable<?> table1 = engine.givenSource(DataSourceType.KTABLE, "table1");
    final KsqlTable<?> table2 = engine.givenSource(DataSourceType.KTABLE, "table2", ImmutableSet.of(SourceName.of("table1")));
    engine.givenSource(DataSourceType.KSTREAM, "stream");
    // When:
    final SourceDescriptionList descriptionList = (SourceDescriptionList) CUSTOM_EXECUTORS.listTables().execute((ConfiguredStatement<ListTables>) engine.configure("LIST TABLES EXTENDED;"), SESSION_PROPERTIES, engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
    // Then:
    final KafkaTopicClient client = engine.getServiceContext().getTopicClient();
    assertThat(descriptionList.getSourceDescriptions(), containsInAnyOrder(SourceDescriptionFactory.create(table1, true, ImmutableList.of(), ImmutableList.of(), Optional.of(client.describeTopic(table1.getKafkaTopicName())), ImmutableList.of(), ImmutableList.of("table2"), new MetricCollectors()), SourceDescriptionFactory.create(table2, true, ImmutableList.of(), ImmutableList.of(), Optional.of(client.describeTopic(table1.getKafkaTopicName())), ImmutableList.of(), ImmutableList.of(), new MetricCollectors())));
}
Also used : ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) KafkaTopicClient(io.confluent.ksql.services.KafkaTopicClient) SourceDescriptionList(io.confluent.ksql.rest.entity.SourceDescriptionList) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) Test(org.junit.Test)

Example 23 with MetricCollectors

use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.

the class KsqlRestApplicationTest method shouldAddConfigurableMetricsReportersIfPresentInKsqlConfig.

@Test
public void shouldAddConfigurableMetricsReportersIfPresentInKsqlConfig() {
    // When:
    final MetricsReporter mockReporter = mock(MetricsReporter.class);
    when(ksqlConfig.getConfiguredInstances(anyString(), any(), any())).thenReturn(Collections.singletonList(mockReporter));
    final MetricCollectors metricCollectors = new MetricCollectors();
    givenAppWithRestConfig(Collections.emptyMap(), metricCollectors);
    // Then:
    final List<MetricsReporter> reporters = metricCollectors.getMetrics().reporters();
    assertThat(reporters, hasItem(mockReporter));
}
Also used : MetricsReporter(org.apache.kafka.common.metrics.MetricsReporter) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) Test(org.junit.Test)

Example 24 with MetricCollectors

use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.

the class KsqlRestApplicationTest method shouldConfigureIQWithInterNodeListenerIfSet.

@Test
public void shouldConfigureIQWithInterNodeListenerIfSet() {
    // Given:
    givenAppWithRestConfig(ImmutableMap.of(KsqlRestConfig.LISTENERS_CONFIG, "http://localhost:0", KsqlRestConfig.ADVERTISED_LISTENER_CONFIG, "https://some.host:12345"), new MetricCollectors());
    // When:
    final KsqlConfig ksqlConfig = app.buildConfigWithPort();
    // Then:
    assertThat(ksqlConfig.getKsqlStreamConfigProps().get(StreamsConfig.APPLICATION_SERVER_CONFIG), is("https://some.host:12345"));
}
Also used : MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) KsqlConfig(io.confluent.ksql.util.KsqlConfig) Test(org.junit.Test)

Example 25 with MetricCollectors

use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.

the class SourceDescriptionFactoryTest method shouldReturnEmptyTimestampColumn.

@Test
public void shouldReturnEmptyTimestampColumn() {
    // Given:
    final String kafkaTopicName = "kafka";
    final DataSource dataSource = buildDataSource(kafkaTopicName, Optional.empty());
    // When
    final SourceDescription sourceDescription = SourceDescriptionFactory.create(dataSource, true, Collections.emptyList(), Collections.emptyList(), Optional.empty(), Collections.emptyList(), Collections.emptyList(), new MetricCollectors());
    // Then:
    assertThat(sourceDescription.getTimestamp(), is(""));
}
Also used : MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DataSource(io.confluent.ksql.metastore.model.DataSource) Test(org.junit.Test)

Aggregations

MetricCollectors (io.confluent.ksql.metrics.MetricCollectors)46 Test (org.junit.Test)29 KsqlConfig (io.confluent.ksql.util.KsqlConfig)15 SourceDescriptionList (io.confluent.ksql.rest.entity.SourceDescriptionList)13 Before (org.junit.Before)13 InternalFunctionRegistry (io.confluent.ksql.function.InternalFunctionRegistry)12 MetaStoreImpl (io.confluent.ksql.metastore.MetaStoreImpl)10 DataSource (io.confluent.ksql.metastore.model.DataSource)10 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)10 KsqlEngine (io.confluent.ksql.engine.KsqlEngine)9 ServiceContext (io.confluent.ksql.services.ServiceContext)9 SequentialQueryIdGenerator (io.confluent.ksql.query.id.SequentialQueryIdGenerator)8 ConfiguredStatement (io.confluent.ksql.statement.ConfiguredStatement)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 SourceDescriptionEntity (io.confluent.ksql.rest.entity.SourceDescriptionEntity)7 TestServiceContext (io.confluent.ksql.services.TestServiceContext)7 Collections (java.util.Collections)7 Map (java.util.Map)7 Optional (java.util.Optional)7