use of io.confluent.ksql.rest.entity.StreamsTaskMetadata in project ksql by confluentinc.
the class ConsoleTest method shouldPrintExplainQueryWithError.
@Test
public void shouldPrintExplainQueryWithError() {
final long timestamp = 1596644936314L;
// Given:
final QueryDescriptionEntity queryEntity = new QueryDescriptionEntity("statement", new QueryDescription(new QueryId("id"), "statement", Optional.empty(), ImmutableList.of(new FieldInfo("name", new SchemaInfo(SqlBaseType.STRING, ImmutableList.of(), null), Optional.empty())), ImmutableSet.of("source"), ImmutableSet.of("sink"), "topology", "executionPlan", ImmutableMap.of("overridden.prop", 42), ImmutableMap.of(new KsqlHostInfoEntity("foo", 123), KsqlQueryStatus.ERROR), KsqlQueryType.PERSISTENT, ImmutableList.of(new QueryError(timestamp, "error", Type.SYSTEM)), ImmutableSet.of(new StreamsTaskMetadata("test", Collections.emptySet(), Optional.empty())), "consumerGroupId"));
final KsqlEntityList entityList = new KsqlEntityList(ImmutableList.of(queryEntity));
// When:
console.printKsqlEntityList(entityList);
// Then:
final String output = terminal.getOutputString();
Approvals.verify(output, approvalOptions);
}
use of io.confluent.ksql.rest.entity.StreamsTaskMetadata in project ksql by confluentinc.
the class ListQueriesExecutorTest method shouldScatterGatherAndMergeShowQueriesExtended.
@Test
public void shouldScatterGatherAndMergeShowQueriesExtended() {
// Given
when(sessionProperties.getInternalRequest()).thenReturn(false);
final ConfiguredStatement<ListQueries> showQueries = (ConfiguredStatement<ListQueries>) engine.configure("SHOW QUERIES EXTENDED;");
final StreamsTaskMetadata localTaskMetadata = mock(StreamsTaskMetadata.class);
final StreamsTaskMetadata remoteTaskMetadata = mock(StreamsTaskMetadata.class);
final PersistentQueryMetadata localMetadata = givenPersistentQuery("id", RUNNING_QUERY_STATE, Collections.singleton(localTaskMetadata));
final PersistentQueryMetadata remoteMetadata = givenPersistentQuery("id", ERROR_QUERY_STATE, Collections.singleton(remoteTaskMetadata));
final KsqlEngine engine = mock(KsqlEngine.class);
when(engine.getAllLiveQueries()).thenReturn(ImmutableList.of(localMetadata));
when(engine.getPersistentQueries()).thenReturn(ImmutableList.of(localMetadata));
final List<QueryDescription> remoteQueryDescriptions = Collections.singletonList(QueryDescriptionFactory.forQueryMetadata(remoteMetadata, Collections.singletonMap(REMOTE_KSQL_HOST_INFO_ENTITY, KsqlQueryStatus.ERROR)));
when(remoteQueryDescriptionList.getQueryDescriptions()).thenReturn(remoteQueryDescriptions);
when(ksqlEntityList.get(anyInt())).thenReturn(remoteQueryDescriptionList);
when(response.getResponse()).thenReturn(ksqlEntityList);
final Map<KsqlHostInfoEntity, KsqlQueryStatus> mergedMap = new HashMap<>();
mergedMap.put(REMOTE_KSQL_HOST_INFO_ENTITY, KsqlQueryStatus.ERROR);
mergedMap.put(LOCAL_KSQL_HOST_INFO_ENTITY, KsqlQueryStatus.RUNNING);
// When
final QueryDescriptionList queries = (QueryDescriptionList) CUSTOM_EXECUTORS.listQueries().execute(showQueries, sessionProperties, engine, serviceContext).getEntity().orElseThrow(IllegalStateException::new);
// Then
final QueryDescription mergedQueryDescription = QueryDescriptionFactory.forQueryMetadata(localMetadata, mergedMap);
mergedQueryDescription.updateTaskMetadata(Collections.singleton(remoteTaskMetadata));
assertThat(queries.getQueryDescriptions(), containsInAnyOrder(mergedQueryDescription));
}
Aggregations