Skip to content

Commit d65305a

Browse files
committed
Reuse base class executeQuery() in AnalyticsSQLIT
Signed-off-by: Kai Huang <ahkcs@amazon.com>
1 parent f5d7d15 commit d65305a

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

integ-test/src/test/java/org/opensearch/sql/sql/AnalyticsSQLIT.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
package org.opensearch.sql.sql;
77

8-
import static org.opensearch.sql.legacy.TestUtils.getResponseBody;
98
import static org.opensearch.sql.legacy.TestUtils.isIndexExist;
109
import static org.opensearch.sql.util.MatcherUtils.rows;
1110
import static org.opensearch.sql.util.MatcherUtils.schema;
@@ -16,8 +15,6 @@
1615
import org.json.JSONObject;
1716
import org.junit.Test;
1817
import org.opensearch.client.Request;
19-
import org.opensearch.client.RequestOptions;
20-
import org.opensearch.client.Response;
2118
import org.opensearch.client.ResponseException;
2219
import org.opensearch.sql.legacy.SQLIntegTestCase;
2320

@@ -57,17 +54,9 @@ private void createParquetLogsIndex() throws IOException {
5754
client().performRequest(request);
5855
}
5956

60-
private JSONObject executeSqlQuery(String sql) throws IOException {
61-
Request request = new Request("POST", "/_plugins/_sql");
62-
request.setJsonEntity("{\"query\": \"" + sql + "\"}");
63-
request.setOptions(RequestOptions.DEFAULT);
64-
Response response = client().performRequest(request);
65-
return new JSONObject(getResponseBody(response));
66-
}
67-
6857
@Test
6958
public void testSelectStarSchemaAndData() throws IOException {
70-
JSONObject result = executeSqlQuery("SELECT * FROM parquet_logs");
59+
JSONObject result = executeQuery("SELECT * FROM parquet_logs");
7160
verifySchema(
7261
result,
7362
schema("ip_addr", "string"),
@@ -85,7 +74,7 @@ public void testSelectStarSchemaAndData() throws IOException {
8574

8675
@Test
8776
public void testSelectSpecificColumns() throws IOException {
88-
JSONObject result = executeSqlQuery("SELECT status, message FROM parquet_logs");
77+
JSONObject result = executeQuery("SELECT status, message FROM parquet_logs");
8978
verifySchema(result, schema("status", "integer"), schema("message", "string"));
9079
verifyDataRows(
9180
result,
@@ -96,6 +85,6 @@ public void testSelectSpecificColumns() throws IOException {
9685

9786
@Test(expected = ResponseException.class)
9887
public void testSyntaxError() throws IOException {
99-
executeSqlQuery("SELEC * FROM parquet_logs");
88+
executeQuery("SELEC * FROM parquet_logs");
10089
}
10190
}

0 commit comments

Comments
 (0)