use of io.confluent.ksql.api.client.StreamedQueryResult in project ksql by confluentinc.
the class ClientIntegrationTest method shouldStreamPushQueryAsync.
@Test
public void shouldStreamPushQueryAsync() throws Exception {
// When
final StreamedQueryResult streamedQueryResult = client.streamQuery(PUSH_QUERY).get();
// Then
assertThat(streamedQueryResult.columnNames(), is(TEST_COLUMN_NAMES));
assertThat(streamedQueryResult.columnTypes(), is(TEST_COLUMN_TYPES));
assertThat(streamedQueryResult.queryID(), is(notNullValue()));
shouldReceiveStreamRows(streamedQueryResult, false);
assertThat(streamedQueryResult.isComplete(), is(false));
}
use of io.confluent.ksql.api.client.StreamedQueryResult in project ksql by confluentinc.
the class ClientIntegrationTest method shouldStreamPushQuerySync.
@Test
public void shouldStreamPushQuerySync() throws Exception {
// When
final StreamedQueryResult streamedQueryResult = client.streamQuery(PUSH_QUERY).get();
// Then
assertThat(streamedQueryResult.columnNames(), is(TEST_COLUMN_NAMES));
assertThat(streamedQueryResult.columnTypes(), is(TEST_COLUMN_TYPES));
assertThat(streamedQueryResult.queryID(), is(notNullValue()));
for (int i = 0; i < TEST_NUM_ROWS; i++) {
final Row row = streamedQueryResult.poll();
verifyStreamRowWithIndex(row, i);
}
assertThat(streamedQueryResult.isComplete(), is(false));
}
use of io.confluent.ksql.api.client.StreamedQueryResult in project ksql by confluentinc.
the class ClientIntegrationTest method shouldStreamMultiplePushQueries.
@Test
public void shouldStreamMultiplePushQueries() throws Exception {
// When
final StreamedQueryResult[] streamedQueryResults = new StreamedQueryResult[NUM_CONCURRENT_REQUESTS_TO_TEST];
for (int i = 0; i < streamedQueryResults.length; i++) {
streamedQueryResults[i] = client.streamQuery(PUSH_QUERY).get();
}
// Then
for (final StreamedQueryResult streamedQueryResult : streamedQueryResults) {
assertThat(streamedQueryResult.columnNames(), is(TEST_COLUMN_NAMES));
assertThat(streamedQueryResult.columnTypes(), is(TEST_COLUMN_TYPES));
assertThat(streamedQueryResult.queryID(), is(notNullValue()));
}
for (final StreamedQueryResult streamedQueryResult : streamedQueryResults) {
shouldReceiveStreamRows(streamedQueryResult, false);
}
for (final StreamedQueryResult streamedQueryResult : streamedQueryResults) {
assertThat(streamedQueryResult.isComplete(), is(false));
}
}
use of io.confluent.ksql.api.client.StreamedQueryResult in project ksql by confluentinc.
the class ClientIntegrationTest method shouldStreamPushQueryWithLimitSync.
@Test
public void shouldStreamPushQueryWithLimitSync() throws Exception {
// When
final StreamedQueryResult streamedQueryResult = client.streamQuery(PUSH_QUERY_WITH_LIMIT).get();
// Then
assertThat(streamedQueryResult.columnNames(), is(TEST_COLUMN_NAMES));
assertThat(streamedQueryResult.columnTypes(), is(TEST_COLUMN_TYPES));
assertThat(streamedQueryResult.queryID(), is(notNullValue()));
for (int i = 0; i < PUSH_QUERY_LIMIT_NUM_ROWS; i++) {
final Row row = streamedQueryResult.poll();
verifyStreamRowWithIndex(row, i);
}
assertThat(streamedQueryResult.poll(), is(nullValue()));
assertThat(streamedQueryResult.isComplete(), is(true));
}
use of io.confluent.ksql.api.client.StreamedQueryResult in project ksql by confluentinc.
the class ClientIntegrationTest method shouldTerminatePushQueryIssuedViaStreamQuery.
@Test
public void shouldTerminatePushQueryIssuedViaStreamQuery() throws Exception {
// Given: one persistent query for the agg table
verifyNumActiveQueries(1);
final StreamedQueryResult streamedQueryResult = client.streamQuery(PUSH_QUERY).get();
final String queryId = streamedQueryResult.queryID();
assertThat(queryId, is(notNullValue()));
// Query is running on server, and StreamedQueryResult is not complete
verifyNumActiveQueries(2);
assertThat(streamedQueryResult.isComplete(), is(false));
// When
client.terminatePushQuery(queryId).get();
// Then: query is no longer running on server, and StreamedQueryResult is complete
verifyNumActiveQueries(1);
assertThatEventually(streamedQueryResult::isComplete, is(true));
}
Aggregations