Search in sources :

Example 21 with KsqlEngine

use of io.confluent.ksql.engine.KsqlEngine 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)));
}
Also used : ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) KsqlEngine(io.confluent.ksql.engine.KsqlEngine) HashMap(java.util.HashMap) ListQueries(io.confluent.ksql.parser.tree.ListQueries) QueryDescriptionList(io.confluent.ksql.rest.entity.QueryDescriptionList) KsqlHostInfoEntity(io.confluent.ksql.rest.entity.KsqlHostInfoEntity) PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata) KsqlErrorMessage(io.confluent.ksql.rest.entity.KsqlErrorMessage) KsqlQueryStatus(io.confluent.ksql.util.KsqlConstants.KsqlQueryStatus) Test(org.junit.Test)

Example 22 with KsqlEngine

use of io.confluent.ksql.engine.KsqlEngine in project ksql by confluentinc.

the class ApiIntegrationTest method shouldExecutePushQueryFromLatestOffset.

@Test
public void shouldExecutePushQueryFromLatestOffset() {
    KsqlEngine engine = (KsqlEngine) REST_APP.getEngine();
    // One persistent query for the agg table
    assertThatEventually(engine::numberOfLiveQueries, is(1));
    // Given:
    String sql = "SELECT * from " + TEST_STREAM + " EMIT CHANGES LIMIT 1;";
    // Create a write stream to capture the incomplete response
    ReceiveStream writeStream = new ReceiveStream(vertx);
    // Make the request to stream a query
    JsonObject queryProperties = new JsonObject().put("auto.offset.reset", "latest");
    JsonObject queryRequestBody = new JsonObject().put("sql", sql).put("properties", queryProperties);
    VertxCompletableFuture<HttpResponse<Void>> responseFuture = new VertxCompletableFuture<>();
    client.post("/query-stream").as(BodyCodec.pipe(writeStream)).sendJsonObject(queryRequestBody, responseFuture);
    assertThatEventually(engine::numberOfLiveQueries, is(2));
    // New row to insert
    JsonObject row = new JsonObject().put("K", new JsonObject().put("F1", new JsonArray().add("my_key_shouldExecutePushQueryFromLatestOffset"))).put("STR", "Value_shouldExecutePushQueryFromLatestOffset").put("LONG", 2000L).put("DEC", // JsonObject does not accept BigDecimal
    12.34).put("BYTES_", new byte[] { 0, 1, 2 }).put("ARRAY", new JsonArray().add("a_shouldExecutePushQueryFromLatestOffset")).put("MAP", new JsonObject().put("k1", "v1_shouldExecutePushQueryFromLatestOffset")).put("STRUCT", new JsonObject().put("F1", 3)).put("COMPLEX", COMPLEX_FIELD_VALUE);
    // Insert a new row and wait for it to arrive
    assertThatEventually(() -> {
        try {
            // Attempt the insert multiple times, in case the query hasn't started yet
            shouldInsert(row);
            Buffer buff = writeStream.getBody();
            QueryResponse queryResponse = new QueryResponse(buff.toString());
            return queryResponse.rows.size();
        } catch (Throwable t) {
            return Integer.MAX_VALUE;
        }
    }, is(1));
    // Verify that the received row is the expected one
    Buffer buff = writeStream.getBody();
    QueryResponse queryResponse = new QueryResponse(buff.toString());
    assertThat(queryResponse.rows.get(0).getJsonObject(0), is(new JsonObject().put("F1", new JsonArray().add("my_key_shouldExecutePushQueryFromLatestOffset"))));
    assertThat(queryResponse.rows.get(0).getString(1), is("Value_shouldExecutePushQueryFromLatestOffset"));
    assertThat(queryResponse.rows.get(0).getLong(2), is(2000L));
    assertThat(queryResponse.rows.get(0).getDouble(3), is(12.34));
    assertThat(queryResponse.rows.get(0).getBinary(4), is(new byte[] { 0, 1, 2 }));
    assertThat(queryResponse.rows.get(0).getJsonArray(5), is(new JsonArray().add("a_shouldExecutePushQueryFromLatestOffset")));
    assertThat(queryResponse.rows.get(0).getJsonObject(6), is(new JsonObject().put("k1", "v1_shouldExecutePushQueryFromLatestOffset")));
    assertThat(queryResponse.rows.get(0).getJsonObject(7), is(new JsonObject().put("F1", 3)));
    assertThat(queryResponse.rows.get(0).getJsonObject(8), is(COMPLEX_FIELD_VALUE));
    // Check that query is cleaned up on the server
    assertThatEventually(engine::numberOfLiveQueries, is(1));
}
Also used : JsonArray(io.vertx.core.json.JsonArray) Buffer(io.vertx.core.buffer.Buffer) KsqlEngine(io.confluent.ksql.engine.KsqlEngine) ReceiveStream(io.confluent.ksql.api.utils.ReceiveStream) QueryResponse(io.confluent.ksql.api.utils.QueryResponse) JsonObject(io.vertx.core.json.JsonObject) HttpResponse(io.vertx.ext.web.client.HttpResponse) Matchers.containsString(org.hamcrest.Matchers.containsString) VertxCompletableFuture(io.confluent.ksql.util.VertxCompletableFuture) IntegrationTest(io.confluent.common.utils.IntegrationTest) Test(org.junit.Test)

Example 23 with KsqlEngine

use of io.confluent.ksql.engine.KsqlEngine in project ksql by confluentinc.

the class TestExecutor method buildAndExecuteQuery.

public void buildAndExecuteQuery(final TestCase testCase, final TestExecutionListener listener) {
    topicInfoCache.clear();
    final KsqlConfig ksqlConfig = testCase.applyPersistedProperties(new KsqlConfig(config));
    try {
        System.setProperty(RuntimeBuildContext.KSQL_TEST_TRACK_SERDE_TOPICS, "true");
        final List<TopologyTestDriverContainer> topologyTestDrivers = topologyBuilder.buildStreamsTopologyTestDrivers(testCase, serviceContext, ksqlEngine, ksqlConfig, kafka, listener);
        writeInputIntoTopics(testCase.getInputRecords(), kafka);
        final Set<String> inputTopics = testCase.getInputRecords().stream().map(Record::getTopicName).collect(Collectors.toSet());
        for (final TopologyTestDriverContainer topologyTestDriverContainer : topologyTestDrivers) {
            if (validateResults) {
                verifyTopology(testCase);
            }
            final Set<String> topicsFromInput = topologyTestDriverContainer.getSourceTopicNames().stream().filter(inputTopics::contains).collect(Collectors.toSet());
            final Set<String> topicsFromKafka = topologyTestDriverContainer.getSourceTopicNames().stream().filter(topicName -> !inputTopics.contains(topicName)).collect(Collectors.toSet());
            if (!topicsFromInput.isEmpty()) {
                pipeRecordsFromProvidedInput(testCase, topologyTestDriverContainer);
            }
            for (final String kafkaTopic : topicsFromKafka) {
                pipeRecordsFromKafka(kafkaTopic, topologyTestDriverContainer);
            }
            topologyTestDriverContainer.getTopologyTestDriver().producedTopicNames().forEach(topicInfoCache::get);
        }
        verifyOutput(testCase);
        testCase.expectedException().map(ee -> {
            throw new AssertionError("Expected test to throw" + StringDescription.toString(ee));
        });
        kafka.getAllTopics().stream().map(Topic::getName).forEach(topicInfoCache::get);
        final List<PostTopicNode> knownTopics = topicInfoCache.all().stream().map(ti -> {
            final Topic topic = kafka.getTopic(ti.getTopicName());
            final OptionalInt partitions = topic == null ? OptionalInt.empty() : OptionalInt.of(topic.getNumPartitions());
            final Optional<SchemaMetadata> keyMetadata = SchemaRegistryUtil.getLatestSchema(serviceContext.getSchemaRegistryClient(), ti.getTopicName(), true);
            final Optional<SchemaMetadata> valueMetadata = SchemaRegistryUtil.getLatestSchema(serviceContext.getSchemaRegistryClient(), ti.getTopicName(), false);
            return new PostTopicNode(ti.getTopicName(), ti.getKeyFormat(), ti.getValueFormat(), partitions, fromSchemaMetadata(keyMetadata), fromSchemaMetadata(valueMetadata));
        }).collect(Collectors.toList());
        final List<SourceNode> knownSources = ksqlEngine.getMetaStore().getAllDataSources().values().stream().map(SourceNode::fromDataSource).collect(Collectors.toList());
        if (validateResults) {
            testCase.getPostConditions().verify(ksqlEngine.getMetaStore(), knownTopics);
        }
        listener.runComplete(knownTopics, knownSources);
    } catch (final RuntimeException e) {
        final Optional<Matcher<Throwable>> expectedExceptionMatcher = testCase.expectedException();
        if (!expectedExceptionMatcher.isPresent()) {
            throw e;
        }
        assertThat(e, isThrowable(expectedExceptionMatcher.get()));
    } finally {
        System.clearProperty(RuntimeBuildContext.KSQL_TEST_TRACK_SERDE_TOPICS);
    }
}
Also used : InternalFunctionRegistry(io.confluent.ksql.function.InternalFunctionRegistry) SchemaNode(io.confluent.ksql.test.model.SchemaNode) SequentialQueryIdGenerator(io.confluent.ksql.query.id.SequentialQueryIdGenerator) SourceNode(io.confluent.ksql.test.model.SourceNode) StringDescription(org.hamcrest.StringDescription) SchemaRegistryClient(io.confluent.kafka.schemaregistry.client.SchemaRegistryClient) ServiceContext(io.confluent.ksql.services.ServiceContext) ProcessingLogContext(io.confluent.ksql.logging.processing.ProcessingLogContext) MutableMetaStore(io.confluent.ksql.metastore.MutableMetaStore) ByteBuffer(java.nio.ByteBuffer) DefaultConnectClient(io.confluent.ksql.services.DefaultConnectClient) NullNode(com.fasterxml.jackson.databind.node.NullNode) TestUtils(io.confluent.ksql.test.utils.TestUtils) Map(java.util.Map) JsonNode(com.fasterxml.jackson.databind.JsonNode) TestRecord(org.apache.kafka.streams.test.TestRecord) CONNECT_REQUEST_TIMEOUT_DEFAULT(io.confluent.ksql.util.KsqlConfig.CONNECT_REQUEST_TIMEOUT_DEFAULT) MockSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient) TestHeader(io.confluent.ksql.test.model.TestHeader) DefaultServiceContext(io.confluent.ksql.services.DefaultServiceContext) ImmutableSet(com.google.common.collect.ImmutableSet) RuntimeBuildContext(io.confluent.ksql.execution.runtime.RuntimeBuildContext) ImmutableMap(com.google.common.collect.ImmutableMap) FunctionRegistry(io.confluent.ksql.function.FunctionRegistry) Collection(java.util.Collection) TopicInfo(io.confluent.ksql.test.tools.TopicInfoCache.TopicInfo) Set(java.util.Set) ConsumerConfig(org.apache.kafka.clients.consumer.ConsumerConfig) KsqlConfig(io.confluent.ksql.util.KsqlConfig) Streams(com.google.common.collect.Streams) Collectors(java.util.stream.Collectors) MetaStoreImpl(io.confluent.ksql.metastore.MetaStoreImpl) DisabledKsqlClient(io.confluent.ksql.services.DisabledKsqlClient) List(java.util.List) Header(org.apache.kafka.common.header.Header) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) Entry(java.util.Map.Entry) KsqlEngineMetrics(io.confluent.ksql.internal.KsqlEngineMetrics) KsqlException(io.confluent.ksql.util.KsqlException) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) StreamsConfig(org.apache.kafka.streams.StreamsConfig) StubKafkaTopicClient(io.confluent.ksql.test.tools.stubs.StubKafkaTopicClient) ProducerRecord(org.apache.kafka.clients.producer.ProducerRecord) WindowData(io.confluent.ksql.test.model.WindowData) PostTopicNode(io.confluent.ksql.test.model.PostConditionsNode.PostTopicNode) Headers(org.apache.kafka.common.header.Headers) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) OptionalInt(java.util.OptionalInt) Function(java.util.function.Function) StubKafkaClientSupplier(io.confluent.ksql.test.tools.stubs.StubKafkaClientSupplier) SchemaRegistryUtil(io.confluent.ksql.schema.registry.SchemaRegistryUtil) ImmutableList(com.google.common.collect.ImmutableList) Windowed(org.apache.kafka.streams.kstream.Windowed) Objects.requireNonNull(java.util.Objects.requireNonNull) StubKafkaService(io.confluent.ksql.test.tools.stubs.StubKafkaService) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Matchers.hasEntry(org.hamcrest.Matchers.hasEntry) ProtobufFormat(io.confluent.ksql.serde.protobuf.ProtobufFormat) TestOutputTopic(org.apache.kafka.streams.TestOutputTopic) Iterator(java.util.Iterator) KsqlEngine(io.confluent.ksql.engine.KsqlEngine) MutableFunctionRegistry(io.confluent.ksql.function.MutableFunctionRegistry) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) StubKafkaConsumerGroupClient(io.confluent.ksql.test.tools.stubs.StubKafkaConsumerGroupClient) BytesUtils(io.confluent.ksql.util.BytesUtils) JUnitMatchers.isThrowable(org.junit.matchers.JUnitMatchers.isThrowable) KsqlServerException(io.confluent.ksql.util.KsqlServerException) Closeable(java.io.Closeable) Matcher(org.hamcrest.Matcher) VisibleForTesting(com.google.common.annotations.VisibleForTesting) SchemaMetadata(io.confluent.kafka.schemaregistry.client.SchemaMetadata) Collections(java.util.Collections) UdfLoaderUtil(io.confluent.ksql.function.UdfLoaderUtil) PostTopicNode(io.confluent.ksql.test.model.PostConditionsNode.PostTopicNode) Optional(java.util.Optional) KsqlConfig(io.confluent.ksql.util.KsqlConfig) OptionalInt(java.util.OptionalInt) SourceNode(io.confluent.ksql.test.model.SourceNode) JUnitMatchers.isThrowable(org.junit.matchers.JUnitMatchers.isThrowable) TestOutputTopic(org.apache.kafka.streams.TestOutputTopic)

Example 24 with KsqlEngine

use of io.confluent.ksql.engine.KsqlEngine in project ksql by confluentinc.

the class InteractiveStatementExecutorTest method setUp.

@Before
public void setUp() {
    ksqlConfig = KsqlConfigTestUtil.create(CLUSTER, ImmutableMap.of(StreamsConfig.APPLICATION_SERVER_CONFIG, "http://host:1234"));
    final FakeKafkaTopicClient fakeKafkaTopicClient = new FakeKafkaTopicClient();
    fakeKafkaTopicClient.createTopic("pageview_topic", 1, (short) 1, emptyMap());
    fakeKafkaTopicClient.createTopic("foo", 1, (short) 1, emptyMap());
    fakeKafkaTopicClient.createTopic("pageview_topic_json", 1, (short) 1, emptyMap());
    serviceContext = TestServiceContext.create(fakeKafkaTopicClient);
    final SpecificQueryIdGenerator hybridQueryIdGenerator = new SpecificQueryIdGenerator();
    final MetricCollectors metricCollectors = new MetricCollectors();
    ksqlEngine = KsqlEngineTestUtil.createKsqlEngine(serviceContext, new MetaStoreImpl(new InternalFunctionRegistry()), (engine) -> new KsqlEngineMetrics("", engine, Collections.emptyMap(), Optional.empty(), metricCollectors), hybridQueryIdGenerator, ksqlConfig, metricCollectors);
    statementParser = new StatementParser(ksqlEngine);
    statementExecutor = new InteractiveStatementExecutor(serviceContext, ksqlEngine, statementParser, hybridQueryIdGenerator, InternalTopicSerdes.deserializer(Command.class));
    statementExecutorWithMocks = new InteractiveStatementExecutor(serviceContext, mockEngine, mockParser, mockQueryIdGenerator, commandDeserializer);
    statementExecutor.configure(ksqlConfig);
    statementExecutorWithMocks.configure(ksqlConfig);
    plannedCommand = new Command(CREATE_STREAM_FOO_STATEMENT, emptyMap(), ksqlConfig.getAllConfigPropsWithSecretsObfuscated(), Optional.of(plan));
}
Also used : CoreMatchers(org.hamcrest.CoreMatchers) KsqlPlan(io.confluent.ksql.engine.KsqlPlan) InternalFunctionRegistry(io.confluent.ksql.function.InternalFunctionRegistry) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) Matchers.not(org.hamcrest.Matchers.not) KsqlEngineTestUtil(io.confluent.ksql.engine.KsqlEngineTestUtil) ServiceContext(io.confluent.ksql.services.ServiceContext) CommandId(io.confluent.ksql.rest.entity.CommandId) ArgumentMatcher(org.mockito.ArgumentMatcher) Pair(io.confluent.ksql.util.Pair) ExecuteResult(io.confluent.ksql.KsqlExecutionContext.ExecuteResult) Map(java.util.Map) After(org.junit.After) QueryId(io.confluent.ksql.query.QueryId) FakeKafkaTopicClient(io.confluent.ksql.services.FakeKafkaTopicClient) ClassRule(org.junit.ClassRule) PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata) ZooKeeperClientException(kafka.zookeeper.ZooKeeperClientException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) CommandStatus(io.confluent.ksql.rest.entity.CommandStatus) ImmutableMap(com.google.common.collect.ImmutableMap) DropStream(io.confluent.ksql.parser.tree.DropStream) StatementParser(io.confluent.ksql.rest.server.StatementParser) ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) KsqlConfig(io.confluent.ksql.util.KsqlConfig) TestServiceContext(io.confluent.ksql.services.TestServiceContext) MetaStoreImpl(io.confluent.ksql.metastore.MetaStoreImpl) List(java.util.List) TerminateQuery(io.confluent.ksql.parser.tree.TerminateQuery) Status(io.confluent.ksql.rest.entity.CommandStatus.Status) KsqlEngineMetrics(io.confluent.ksql.internal.KsqlEngineMetrics) KsqlException(io.confluent.ksql.util.KsqlException) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) Statement(io.confluent.ksql.parser.tree.Statement) Retry(io.confluent.ksql.integration.Retry) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) Mockito.eq(org.mockito.Mockito.eq) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) StreamsConfig(org.apache.kafka.streams.StreamsConfig) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) Action(io.confluent.ksql.rest.entity.CommandId.Action) EmbeddedSingleNodeKafkaCluster(io.confluent.ksql.test.util.EmbeddedSingleNodeKafkaCluster) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) Mock(org.mockito.Mock) Assert.assertThrows(org.junit.Assert.assertThrows) RunWith(org.junit.runner.RunWith) SpecificQueryIdGenerator(io.confluent.ksql.query.id.SpecificQueryIdGenerator) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) CreateStreamAsSelect(io.confluent.ksql.parser.tree.CreateStreamAsSelect) ArrayList(java.util.ArrayList) SessionConfig(io.confluent.ksql.config.SessionConfig) CreateStream(io.confluent.ksql.parser.tree.CreateStream) ArgumentCaptor(org.mockito.ArgumentCaptor) ImmutableList(com.google.common.collect.ImmutableList) ConfiguredKsqlPlan(io.confluent.ksql.planner.plan.ConfiguredKsqlPlan) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Deserializer(org.apache.kafka.common.serialization.Deserializer) Before(org.junit.Before) Collections.emptyMap(java.util.Collections.emptyMap) InOrder(org.mockito.InOrder) KsqlEngine(io.confluent.ksql.engine.KsqlEngine) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) Type(io.confluent.ksql.rest.entity.CommandId.Type) KsqlStatementException(io.confluent.ksql.util.KsqlStatementException) TimeUnit(java.util.concurrent.TimeUnit) RuleChain(org.junit.rules.RuleChain) KsqlConfigTestUtil(io.confluent.ksql.KsqlConfigTestUtil) Mockito(org.mockito.Mockito) Assert(org.junit.Assert) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) PreparedStatement(io.confluent.ksql.parser.KsqlParser.PreparedStatement) KsqlEngineMetrics(io.confluent.ksql.internal.KsqlEngineMetrics) StatementParser(io.confluent.ksql.rest.server.StatementParser) MetaStoreImpl(io.confluent.ksql.metastore.MetaStoreImpl) FakeKafkaTopicClient(io.confluent.ksql.services.FakeKafkaTopicClient) MetricCollectors(io.confluent.ksql.metrics.MetricCollectors) SpecificQueryIdGenerator(io.confluent.ksql.query.id.SpecificQueryIdGenerator) InternalFunctionRegistry(io.confluent.ksql.function.InternalFunctionRegistry) Before(org.junit.Before)

Example 25 with KsqlEngine

use of io.confluent.ksql.engine.KsqlEngine in project ksql by confluentinc.

the class ExplainExecutorTest method shouldExplainQueryId.

@Test
public void shouldExplainQueryId() {
    // Given:
    final ConfiguredStatement<Explain> explain = (ConfiguredStatement<Explain>) engine.configure("EXPLAIN id;");
    final PersistentQueryMetadata metadata = givenPersistentQuery("id");
    final KsqlEngine engine = mock(KsqlEngine.class);
    when(engine.getPersistentQuery(metadata.getQueryId())).thenReturn(Optional.of(metadata));
    // When:
    final QueryDescriptionEntity query = (QueryDescriptionEntity) customExecutors.explain().execute(explain, sessionProperties, engine, this.engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
    // Then:
    assertThat(query.getQueryDescription(), equalTo(QueryDescriptionFactory.forQueryMetadata(metadata, Collections.singletonMap(new KsqlHostInfoEntity(LOCAL_HOST), STATE))));
}
Also used : ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) KsqlEngine(io.confluent.ksql.engine.KsqlEngine) QueryDescriptionEntity(io.confluent.ksql.rest.entity.QueryDescriptionEntity) Explain(io.confluent.ksql.parser.tree.Explain) KsqlHostInfoEntity(io.confluent.ksql.rest.entity.KsqlHostInfoEntity) PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata) Test(org.junit.Test)

Aggregations

KsqlEngine (io.confluent.ksql.engine.KsqlEngine)38 Test (org.junit.Test)25 ConfiguredStatement (io.confluent.ksql.statement.ConfiguredStatement)24 PersistentQueryMetadata (io.confluent.ksql.util.PersistentQueryMetadata)22 InternalFunctionRegistry (io.confluent.ksql.function.InternalFunctionRegistry)14 SequentialQueryIdGenerator (io.confluent.ksql.query.id.SequentialQueryIdGenerator)14 KsqlConfig (io.confluent.ksql.util.KsqlConfig)14 MetricCollectors (io.confluent.ksql.metrics.MetricCollectors)13 ServiceContext (io.confluent.ksql.services.ServiceContext)13 MutableFunctionRegistry (io.confluent.ksql.function.MutableFunctionRegistry)11 KsqlEntity (io.confluent.ksql.rest.entity.KsqlEntity)11 KsqlHostInfoEntity (io.confluent.ksql.rest.entity.KsqlHostInfoEntity)11 Queries (io.confluent.ksql.rest.entity.Queries)11 List (java.util.List)11 MetaStoreImpl (io.confluent.ksql.metastore.MetaStoreImpl)10 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)10 Matchers.is (org.hamcrest.Matchers.is)10 ImmutableList (com.google.common.collect.ImmutableList)9 SessionConfig (io.confluent.ksql.config.SessionConfig)9 KsqlEngineMetrics (io.confluent.ksql.internal.KsqlEngineMetrics)9