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"));
}
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);
}
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());
}
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());
}
}
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));
}
Aggregations