Search in sources :

Example 1 with StreamedQueryResult

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));
}
Also used : StreamedQueryResult(io.confluent.ksql.api.client.StreamedQueryResult) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Example 2 with StreamedQueryResult

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));
}
Also used : Row(io.confluent.ksql.api.client.Row) GenericRow(io.confluent.ksql.GenericRow) StreamedQueryResult(io.confluent.ksql.api.client.StreamedQueryResult) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Example 3 with StreamedQueryResult

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));
    }
}
Also used : StreamedQueryResult(io.confluent.ksql.api.client.StreamedQueryResult) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Example 4 with StreamedQueryResult

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));
}
Also used : Row(io.confluent.ksql.api.client.Row) GenericRow(io.confluent.ksql.GenericRow) StreamedQueryResult(io.confluent.ksql.api.client.StreamedQueryResult) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Example 5 with StreamedQueryResult

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));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) StreamedQueryResult(io.confluent.ksql.api.client.StreamedQueryResult) Test(org.junit.Test) IntegrationTest(io.confluent.common.utils.IntegrationTest)

Aggregations

StreamedQueryResult (io.confluent.ksql.api.client.StreamedQueryResult)20 Test (org.junit.Test)20 IntegrationTest (io.confluent.common.utils.IntegrationTest)16 Row (io.confluent.ksql.api.client.Row)10 GenericRow (io.confluent.ksql.GenericRow)8 LinkedList (java.util.LinkedList)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 KsqlObject (io.confluent.ksql.api.client.KsqlObject)2 KsqlClientException (io.confluent.ksql.api.client.exception.KsqlClientException)2 ClientImpl (io.confluent.ksql.api.client.impl.ClientImpl)2 HashMap (java.util.HashMap)2 ExecutionException (java.util.concurrent.ExecutionException)2 ZooKeeperClientException (kafka.zookeeper.ZooKeeperClientException)2 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)2 KsqlArray (io.confluent.ksql.api.client.KsqlArray)1 BigDecimal (java.math.BigDecimal)1