Search in sources :

Example 16 with QueryResponse

use of io.confluent.ksql.api.utils.QueryResponse in project ksql by confluentinc.

the class ApiTest method shouldExecuteInfoRquest.

@Test
@CoreApiTest
public void shouldExecuteInfoRquest() throws Exception {
    // When
    HttpResponse<Buffer> response = sendGetRequest("/info");
    // Then
    assertThat(response.statusCode(), is(200));
    assertThat(response.statusMessage(), is("OK"));
    QueryResponse queryResponse = new QueryResponse(response.bodyAsString());
    assertThat(queryResponse.responseObject.getJsonObject("KsqlServerInfo").getString("version"), is(AppInfo.getVersion()));
    assertThat(queryResponse.responseObject.getJsonObject("KsqlServerInfo").getString("kafkaClusterId"), is("kafka-cluster-id"));
    assertThat(queryResponse.responseObject.getJsonObject("KsqlServerInfo").getString("ksqlServiceId"), is("ksql-service-id"));
}
Also used : Buffer(io.vertx.core.buffer.Buffer) QueryResponse(io.confluent.ksql.api.utils.QueryResponse) Test(org.junit.Test)

Example 17 with QueryResponse

use of io.confluent.ksql.api.utils.QueryResponse in project ksql by confluentinc.

the class ApiTest method shouldHandleUnknownQueryIDInCloseQuery.

@Test
public void shouldHandleUnknownQueryIDInCloseQuery() throws Exception {
    // Given
    JsonObject closeQueryRequestBody = new JsonObject().put("queryId", "xyzfasgf");
    // When
    HttpResponse<Buffer> response = sendPostRequest("/close-query", closeQueryRequestBody.toBuffer());
    // Then
    assertThat(response.statusCode(), is(400));
    assertThat(response.statusMessage(), is("Bad Request"));
    QueryResponse queryResponse = new QueryResponse(response.bodyAsString());
    validateError(ERROR_CODE_BAD_REQUEST, "No query with id xyzfasgf", queryResponse.responseObject);
}
Also used : Buffer(io.vertx.core.buffer.Buffer) QueryResponse(io.confluent.ksql.api.utils.QueryResponse) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Example 18 with QueryResponse

use of io.confluent.ksql.api.utils.QueryResponse in project ksql by confluentinc.

the class PullBandwidthThrottleIntegrationTest method executeQueryWithVariables.

private QueryResponse executeQueryWithVariables(final String sql, final JsonObject variables) {
    JsonObject properties = new JsonObject();
    JsonObject requestBody = new JsonObject().put("sql", sql).put("properties", properties).put("sessionVariables", variables);
    HttpResponse<Buffer> response = sendRequest("/query-stream", requestBody.toBuffer());
    return new QueryResponse(response.bodyAsString());
}
Also used : Buffer(io.vertx.core.buffer.Buffer) QueryResponse(io.confluent.ksql.api.utils.QueryResponse) JsonObject(io.vertx.core.json.JsonObject)

Example 19 with QueryResponse

use of io.confluent.ksql.api.utils.QueryResponse in project ksql by confluentinc.

the class PullBandwidthThrottleIntegrationTest method pullTableBandwidthThrottleTest.

@Test
public void pullTableBandwidthThrottleTest() {
    String veryLong = createDataSize(100000);
    String sql = "SELECT CONCAT(\'" + veryLong + "\') as placeholder from " + AGG_TABLE + ";";
    // the pull query should go through 2 times
    for (int i = 0; i < 2; i += 1) {
        assertThatEventually(() -> {
            QueryResponse queryResponse1 = executeQuery(sql);
            return queryResponse1.rows;
        }, hasSize(5));
    }
    // the third try should fail
    try {
        executeQuery(sql);
    } catch (KsqlException e) {
        assertEquals(RATE_LIMIT_MESSAGE, e.getMessage());
    }
}
Also used : QueryResponse(io.confluent.ksql.api.utils.QueryResponse) KsqlException(io.confluent.ksql.util.KsqlException) IntegrationTest(io.confluent.common.utils.IntegrationTest) Test(org.junit.Test)

Example 20 with QueryResponse

use of io.confluent.ksql.api.utils.QueryResponse in project ksql by confluentinc.

the class ApiIntegrationTest method shouldRejectInsertRequest.

private void shouldRejectInsertRequest(final String target, final JsonObject row, final String message) {
    HttpResponse<Buffer> response = makeInsertsRequest(target, row);
    assertThat(response.statusCode(), is(400));
    assertThat(response.statusMessage(), is("Bad Request"));
    QueryResponse queryResponse = new QueryResponse(response.bodyAsString());
    assertThat(queryResponse.responseObject.getInteger("error_code"), is(ERROR_CODE_BAD_STATEMENT));
    assertThat(queryResponse.responseObject.getString("message"), containsString(message));
}
Also used : Buffer(io.vertx.core.buffer.Buffer) QueryResponse(io.confluent.ksql.api.utils.QueryResponse)

Aggregations

QueryResponse (io.confluent.ksql.api.utils.QueryResponse)43 Test (org.junit.Test)30 Buffer (io.vertx.core.buffer.Buffer)29 JsonObject (io.vertx.core.json.JsonObject)21 IntegrationTest (io.confluent.common.utils.IntegrationTest)10 PushQueryId (io.confluent.ksql.rest.entity.PushQueryId)8 VertxCompletableFuture (io.confluent.ksql.util.VertxCompletableFuture)7 HttpResponse (io.vertx.ext.web.client.HttpResponse)7 Matchers.containsString (org.hamcrest.Matchers.containsString)7 JsonArray (io.vertx.core.json.JsonArray)6 ReceiveStream (io.confluent.ksql.api.utils.ReceiveStream)4 ArrayList (java.util.ArrayList)4 WebClient (io.vertx.ext.web.client.WebClient)3 ImmutableList (com.google.common.collect.ImmutableList)2 KsqlEngine (io.confluent.ksql.engine.KsqlEngine)2 QueryStreamArgs (io.confluent.ksql.rest.entity.QueryStreamArgs)2 KsqlException (io.confluent.ksql.util.KsqlException)2 HttpVersion (io.vertx.core.http.HttpVersion)2 List (java.util.List)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2