You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/08/17 08:14:41 UTC
[GitHub] [flink] WencongLiu opened a new pull request, #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
WencongLiu opened a new pull request, #20609:
URL: https://github.com/apache/flink/pull/20609
<!--
*Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
## What is the purpose of the change
*Introduce the rest E2E tests for SQL Gateway*
## Brief change log
- *Add the rest part of E2E test for Sql Gateway*
## Verifying this change
This change added tests and can be verified as follows:
- *None*
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (yes)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
- The serializers: (no)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
- The S3 file system connector: (no)
## Documentation
- Does this pull request introduce a new feature? (no)
- If yes, how is the feature documented? (not documented)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] WencongLiu commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
WencongLiu commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r951259285
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -182,6 +189,7 @@ public void startFlinkCluster() throws IOException {
}
}
} catch (IOException ioe) {
+ LOG.info(Arrays.toString(ioe.getStackTrace()));
Review Comment:
Removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] WencongLiu commented on pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
WencongLiu commented on PR #20609:
URL: https://github.com/apache/flink/pull/20609#issuecomment-1218008292
@flinkbot run azure
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] WencongLiu commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
WencongLiu commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r953375107
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -301,7 +309,105 @@ public void submitSQLJob(SQLJobSubmission job, Duration timeout) throws Exceptio
});
new Thread(future).start();
future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
+ } else if (job.getClientMode() == SQLJobSubmission.ClientMode.REST) {
+ FutureTaskWithException<Void> future =
+ new FutureTaskWithException<>(
+ () -> {
+ Map<String, String> configMap =
+ GlobalConfiguration.loadConfiguration(
+ conf.toAbsolutePath().toString())
+ .toMap();
+ String host =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.address",
+ InetAddress.getByName("localhost")
+ .getHostAddress());
+ String port =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.port", "8083");
+ // Open a session
+ String sessionHandle = openSession(host, port);
+ List<String> sqlLines = job.getSqlLines();
+ for (String sql : sqlLines) {
+ // Execute statement
+ String operationHandle =
+ executeStatement(sessionHandle, sql, host, port);
+ int count = 5;
+ while (count > 0) {
+ TimeUnit.SECONDS.sleep(2);
+ // Fetch results
+ String results =
+ fetchResults(
+ sessionHandle, operationHandle, host, port);
+ if (results.contains("PAYLOAD")) {
+ break;
+ }
+ --count;
+ }
+ }
+ });
+ new Thread(future).start();
+ future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] WencongLiu commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
WencongLiu commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r951272970
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -301,7 +309,105 @@ public void submitSQLJob(SQLJobSubmission job, Duration timeout) throws Exceptio
});
new Thread(future).start();
future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
+ } else if (job.getClientMode() == SQLJobSubmission.ClientMode.REST) {
+ FutureTaskWithException<Void> future =
+ new FutureTaskWithException<>(
+ () -> {
+ Map<String, String> configMap =
+ GlobalConfiguration.loadConfiguration(
+ conf.toAbsolutePath().toString())
+ .toMap();
+ String host =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.address",
+ InetAddress.getByName("localhost")
+ .getHostAddress());
+ String port =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.port", "8083");
+ // Open a session
+ String sessionHandle = openSession(host, port);
+ List<String> sqlLines = job.getSqlLines();
+ for (String sql : sqlLines) {
+ // Execute statement
+ String operationHandle =
+ executeStatement(sessionHandle, sql, host, port);
+ int count = 5;
+ while (count > 0) {
+ TimeUnit.SECONDS.sleep(2);
Review Comment:
Has been modified to `EOF`. I think adding`fetch results` will increase the integrity of the e2e test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] WencongLiu commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
WencongLiu commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r953374044
##########
flink-end-to-end-tests/flink-sql-gateway-test/src/test/java/org/apache/flink/table/gateway/SqlGatewayE2ECase.java:
##########
@@ -82,6 +83,7 @@ public class SqlGatewayE2ECase extends TestLogger {
@Rule public final FlinkResource flinkResource = buildFlinkResource();
private static NetUtils.Port port;
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] fsk119 commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
fsk119 commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r954471863
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -537,4 +455,85 @@ public void copyLogsTo(Path targetDirectory) throws IOException {
Files.createDirectories(targetDirectory);
TestUtils.copyDirectory(log, targetDirectory);
}
+
+ /** This rest client is used to submit SQL strings to Rest Endpoint of Sql Gateway. */
+ private static class TestSqlGatewayRestClient {
+
+ private final String host;
+ private final String port;
+ private final String sessionHandle;
+
+ public TestSqlGatewayRestClient(Configuration configuration) throws Exception {
+ Map<String, String> configMap = configuration.toMap();
+ host =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.address",
+ InetAddress.getByName("localhost").getHostAddress());
+ port = configMap.getOrDefault("sql-gateway.endpoint.rest.port", "8083");
+ sessionHandle = openSession();
+ }
+
+ private String openSession() throws Exception {
+ FormBody.Builder builder = new FormBody.Builder();
+ FormBody requestBody = builder.build();
+ final Request request =
+ new Request.Builder()
+ .post(requestBody)
+ .url(String.format("http://%s:%s/v1/sessions/", host, port))
+ .build();
+ final JsonNode jsonNode = OBJECT_MAPPER.readTree(sendRequest(request));
+ return jsonNode.get("sessionHandle").asText();
+ }
+
+ public String executeStatement(String sql) throws Exception {
+ ObjectNode objectNode = OBJECT_MAPPER.createObjectNode();
+ objectNode.put("statement", sql);
+ RequestBody requestBody =
+ RequestBody.create(
+ MediaType.parse("application/json; charset=utf-8"),
+ OBJECT_MAPPER.writeValueAsString(objectNode));
+ final Request request =
+ new Request.Builder()
+ .post(requestBody)
+ .url(
+ String.format(
+ "http://%s:%s/v1/sessions/%s/statements",
+ host, port, sessionHandle))
+ .build();
+ final JsonNode jsonNode = OBJECT_MAPPER.readTree(sendRequest(request));
+ return jsonNode.get("operationHandle").asText();
+ }
+
+ public void waitUntilOperationTerminate(String operationHandle) throws Exception {
+ String status;
+ do {
+ final Request request =
+ new Request.Builder()
+ .get()
+ .url(
+ String.format(
+ "http://%s:%s/v1/sessions/%s/operations/%s/status",
+ host, port, sessionHandle, operationHandle))
+ .build();
+ final JsonNode jsonNode = OBJECT_MAPPER.readTree(sendRequest(request));
+ status = jsonNode.get("status").asText();
+ } while (!Objects.equals(status, "FINISHED") && !Objects.equals(status, "ERROR"));
+ }
+
+ private String sendRequest(Request request) throws Exception {
+ final OkHttpClient client = new OkHttpClient();
Review Comment:
nit: Can we reuse this client?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] fsk119 merged pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
fsk119 merged PR #20609:
URL: https://github.com/apache/flink/pull/20609
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] fsk119 commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
fsk119 commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r948612670
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -182,6 +189,7 @@ public void startFlinkCluster() throws IOException {
}
}
} catch (IOException ioe) {
+ LOG.info(Arrays.toString(ioe.getStackTrace()));
Review Comment:
Do we need to modify this?
##########
flink-end-to-end-tests/flink-sql-gateway-test/src/test/java/org/apache/flink/table/gateway/SqlGatewayE2ECase.java:
##########
@@ -82,6 +83,7 @@ public class SqlGatewayE2ECase extends TestLogger {
@Rule public final FlinkResource flinkResource = buildFlinkResource();
private static NetUtils.Port port;
Review Comment:
rename to hiveserver2Port?
##########
flink-end-to-end-tests/flink-sql-gateway-test/src/test/java/org/apache/flink/table/gateway/SqlGatewayE2ECase.java:
##########
@@ -117,8 +119,13 @@ public void testExecuteStatement() throws Exception {
.setClientMode(SQLJobSubmission.ClientMode.HIVE_JDBC)
.build(),
Duration.ofSeconds(60));
+ gateway.submitSQLJob(
+ new SQLJobSubmission.SQLJobSubmissionBuilder(lines)
+ .setClientMode(SQLJobSubmission.ClientMode.REST)
+ .build(),
+ Duration.ofSeconds(60));
}
Review Comment:
I think we should add a new test rather than reuse the same test case.
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -301,7 +309,105 @@ public void submitSQLJob(SQLJobSubmission job, Duration timeout) throws Exceptio
});
new Thread(future).start();
future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
+ } else if (job.getClientMode() == SQLJobSubmission.ClientMode.REST) {
+ FutureTaskWithException<Void> future =
+ new FutureTaskWithException<>(
+ () -> {
+ Map<String, String> configMap =
+ GlobalConfiguration.loadConfiguration(
+ conf.toAbsolutePath().toString())
+ .toMap();
+ String host =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.address",
+ InetAddress.getByName("localhost")
+ .getHostAddress());
+ String port =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.port", "8083");
+ // Open a session
+ String sessionHandle = openSession(host, port);
+ List<String> sqlLines = job.getSqlLines();
+ for (String sql : sqlLines) {
+ // Execute statement
+ String operationHandle =
+ executeStatement(sessionHandle, sql, host, port);
+ int count = 5;
+ while (count > 0) {
+ TimeUnit.SECONDS.sleep(2);
+ // Fetch results
+ String results =
+ fetchResults(
+ sessionHandle, operationHandle, host, port);
+ if (results.contains("PAYLOAD")) {
+ break;
+ }
+ --count;
+ }
+ }
+ });
+ new Thread(future).start();
+ future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
Review Comment:
Can we add such method to reuse the logic in the HIVE_JDBC and REST?
```
private void submitSQL(RunnableWithException command, Duration timeout) {
FutureTaskWithException<Void> future = new FutureTaskWithException<>(command);
new Thread(future).start();
future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
}
```
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/pom.xml:
##########
@@ -127,6 +127,11 @@ under the License.
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20201115</version>
+ </dependency>
Review Comment:
Why not using json format dependency?
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -301,7 +309,105 @@ public void submitSQLJob(SQLJobSubmission job, Duration timeout) throws Exceptio
});
new Thread(future).start();
future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
+ } else if (job.getClientMode() == SQLJobSubmission.ClientMode.REST) {
+ FutureTaskWithException<Void> future =
+ new FutureTaskWithException<>(
+ () -> {
+ Map<String, String> configMap =
+ GlobalConfiguration.loadConfiguration(
+ conf.toAbsolutePath().toString())
+ .toMap();
+ String host =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.address",
+ InetAddress.getByName("localhost")
+ .getHostAddress());
+ String port =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.port", "8083");
+ // Open a session
+ String sessionHandle = openSession(host, port);
Review Comment:
Here missing the logic about the ADD JAR. Please cc the logic in the Hive_JDBC
##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/rest/SqlGatewayRestEndpointFactory.java:
##########
@@ -94,6 +92,10 @@ public Set<ConfigOption<?>> requiredOptions() {
@Override
public Set<ConfigOption<?>> optionalOptions() {
- return Collections.emptySet();
+ Set<ConfigOption<?>> options = new HashSet<>();
+ options.add(BIND_ADDRESS);
+ options.add(PORT);
+ options.add(BIND_PORT);
+ return options;
Review Comment:
Why add this? If ADDRESS and PORT are used by the client, we should not add into the Server Options.
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -301,7 +309,105 @@ public void submitSQLJob(SQLJobSubmission job, Duration timeout) throws Exceptio
});
new Thread(future).start();
future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
+ } else if (job.getClientMode() == SQLJobSubmission.ClientMode.REST) {
+ FutureTaskWithException<Void> future =
+ new FutureTaskWithException<>(
+ () -> {
+ Map<String, String> configMap =
+ GlobalConfiguration.loadConfiguration(
+ conf.toAbsolutePath().toString())
+ .toMap();
+ String host =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.address",
+ InetAddress.getByName("localhost")
+ .getHostAddress());
+ String port =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.port", "8083");
+ // Open a session
+ String sessionHandle = openSession(host, port);
+ List<String> sqlLines = job.getSqlLines();
+ for (String sql : sqlLines) {
+ // Execute statement
+ String operationHandle =
+ executeStatement(sessionHandle, sql, host, port);
+ int count = 5;
+ while (count > 0) {
+ TimeUnit.SECONDS.sleep(2);
Review Comment:
Why we need `count`? We should fetch results until `EOF`.
BTW, here we only submit the SQL. Why do we fetch results? Why not fetching the OperationStatus until finished or error?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #20609:
URL: https://github.com/apache/flink/pull/20609#issuecomment-1217677657
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "adfaf2a2dbc116ae236d9754a9d964e5dc23be12",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "adfaf2a2dbc116ae236d9754a9d964e5dc23be12",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* adfaf2a2dbc116ae236d9754a9d964e5dc23be12 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] reswqa commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r951092456
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -301,7 +309,105 @@ public void submitSQLJob(SQLJobSubmission job, Duration timeout) throws Exceptio
});
new Thread(future).start();
future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
+ } else if (job.getClientMode() == SQLJobSubmission.ClientMode.REST) {
+ FutureTaskWithException<Void> future =
+ new FutureTaskWithException<>(
+ () -> {
+ Map<String, String> configMap =
+ GlobalConfiguration.loadConfiguration(
+ conf.toAbsolutePath().toString())
+ .toMap();
+ String host =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.address",
+ InetAddress.getByName("localhost")
+ .getHostAddress());
+ String port =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.port", "8083");
+ // Open a session
+ String sessionHandle = openSession(host, port);
+ List<String> sqlLines = job.getSqlLines();
+ for (String sql : sqlLines) {
+ // Execute statement
+ String operationHandle =
+ executeStatement(sessionHandle, sql, host, port);
+ int count = 5;
Review Comment:
I recommend naming it to `retryNumber`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] WencongLiu commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
WencongLiu commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r953373052
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -301,7 +309,105 @@ public void submitSQLJob(SQLJobSubmission job, Duration timeout) throws Exceptio
});
new Thread(future).start();
future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
+ } else if (job.getClientMode() == SQLJobSubmission.ClientMode.REST) {
+ FutureTaskWithException<Void> future =
+ new FutureTaskWithException<>(
+ () -> {
+ Map<String, String> configMap =
+ GlobalConfiguration.loadConfiguration(
+ conf.toAbsolutePath().toString())
+ .toMap();
+ String host =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.address",
+ InetAddress.getByName("localhost")
+ .getHostAddress());
+ String port =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.port", "8083");
+ // Open a session
+ String sessionHandle = openSession(host, port);
+ List<String> sqlLines = job.getSqlLines();
+ for (String sql : sqlLines) {
+ // Execute statement
+ String operationHandle =
+ executeStatement(sessionHandle, sql, host, port);
+ int count = 5;
+ while (count > 0) {
+ TimeUnit.SECONDS.sleep(2);
Review Comment:
Has been modified to keep fetching data until no data is generated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] reswqa commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
reswqa commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r951057263
##########
flink-end-to-end-tests/flink-sql-gateway-test/pom.xml:
##########
@@ -84,6 +90,12 @@ under the License.
<artifactId>flink-test-utils-junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.flink</groupId>
Review Comment:
Why do we need to introduce flink-sql-gateway dependency twice?
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -301,7 +309,105 @@ public void submitSQLJob(SQLJobSubmission job, Duration timeout) throws Exceptio
});
new Thread(future).start();
future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
+ } else if (job.getClientMode() == SQLJobSubmission.ClientMode.REST) {
+ FutureTaskWithException<Void> future =
+ new FutureTaskWithException<>(
+ () -> {
+ Map<String, String> configMap =
+ GlobalConfiguration.loadConfiguration(
+ conf.toAbsolutePath().toString())
+ .toMap();
+ String host =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.address",
+ InetAddress.getByName("localhost")
+ .getHostAddress());
+ String port =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.port", "8083");
+ // Open a session
+ String sessionHandle = openSession(host, port);
+ List<String> sqlLines = job.getSqlLines();
+ for (String sql : sqlLines) {
+ // Execute statement
+ String operationHandle =
+ executeStatement(sessionHandle, sql, host, port);
+ int count = 5;
+ while (count > 0) {
+ TimeUnit.SECONDS.sleep(2);
Review Comment:
It may not be a good idea to directly sleep for 2 seconds at the beginning. I am worried that this will affect the running time of E2E CI. If we can't think of a good way to deal with this problem, at least we can move the sleep statement after getting the results and reduce the sleep time appropriately.
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -301,7 +309,105 @@ public void submitSQLJob(SQLJobSubmission job, Duration timeout) throws Exceptio
});
new Thread(future).start();
future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
+ } else if (job.getClientMode() == SQLJobSubmission.ClientMode.REST) {
+ FutureTaskWithException<Void> future =
+ new FutureTaskWithException<>(
+ () -> {
+ Map<String, String> configMap =
+ GlobalConfiguration.loadConfiguration(
+ conf.toAbsolutePath().toString())
+ .toMap();
+ String host =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.address",
+ InetAddress.getByName("localhost")
+ .getHostAddress());
+ String port =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.port", "8083");
+ // Open a session
+ String sessionHandle = openSession(host, port);
+ List<String> sqlLines = job.getSqlLines();
+ for (String sql : sqlLines) {
+ // Execute statement
+ String operationHandle =
+ executeStatement(sessionHandle, sql, host, port);
+ int count = 5;
Review Comment:
I recommend naming it `retryNumber`
##########
flink-table/flink-sql-gateway/src/main/resources/META-INF/services/org.apache.flink.table.factories.Factory:
##########
@@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-org.apache.flink.table.gateway.rest.SqlGatewayRestEndpointFactory
\ No newline at end of file
+org.apache.flink.table.gateway.rest.SqlGatewayRestEndpointFactory
Review Comment:
What's changed here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] WencongLiu commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
WencongLiu commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r951257776
##########
flink-table/flink-sql-gateway/src/main/resources/META-INF/services/org.apache.flink.table.factories.Factory:
##########
@@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-org.apache.flink.table.gateway.rest.SqlGatewayRestEndpointFactory
\ No newline at end of file
+org.apache.flink.table.gateway.rest.SqlGatewayRestEndpointFactory
Review Comment:
Its directory has been changed from `META-INF.services` to `META-INF/services`
##########
flink-table/flink-sql-gateway/src/main/resources/META-INF/services/org.apache.flink.table.factories.Factory:
##########
@@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-org.apache.flink.table.gateway.rest.SqlGatewayRestEndpointFactory
\ No newline at end of file
+org.apache.flink.table.gateway.rest.SqlGatewayRestEndpointFactory
Review Comment:
Its directory has been changed from `META-INF.services` to `META-INF/services`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] WencongLiu commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
WencongLiu commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r951259006
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/pom.xml:
##########
@@ -127,6 +127,11 @@ under the License.
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20201115</version>
+ </dependency>
Review Comment:
This has been fixed already.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] WencongLiu commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
WencongLiu commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r951258498
##########
flink-end-to-end-tests/flink-sql-gateway-test/pom.xml:
##########
@@ -84,6 +90,12 @@ under the License.
<artifactId>flink-test-utils-junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.flink</groupId>
Review Comment:
Removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] WencongLiu commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
WencongLiu commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r953373052
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -301,7 +309,105 @@ public void submitSQLJob(SQLJobSubmission job, Duration timeout) throws Exceptio
});
new Thread(future).start();
future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
+ } else if (job.getClientMode() == SQLJobSubmission.ClientMode.REST) {
+ FutureTaskWithException<Void> future =
+ new FutureTaskWithException<>(
+ () -> {
+ Map<String, String> configMap =
+ GlobalConfiguration.loadConfiguration(
+ conf.toAbsolutePath().toString())
+ .toMap();
+ String host =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.address",
+ InetAddress.getByName("localhost")
+ .getHostAddress());
+ String port =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.port", "8083");
+ // Open a session
+ String sessionHandle = openSession(host, port);
+ List<String> sqlLines = job.getSqlLines();
+ for (String sql : sqlLines) {
+ // Execute statement
+ String operationHandle =
+ executeStatement(sessionHandle, sql, host, port);
+ int count = 5;
+ while (count > 0) {
+ TimeUnit.SECONDS.sleep(2);
Review Comment:
This has been modified to keep fetching data until no data is generated.
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -301,7 +309,105 @@ public void submitSQLJob(SQLJobSubmission job, Duration timeout) throws Exceptio
});
new Thread(future).start();
future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
+ } else if (job.getClientMode() == SQLJobSubmission.ClientMode.REST) {
+ FutureTaskWithException<Void> future =
+ new FutureTaskWithException<>(
+ () -> {
+ Map<String, String> configMap =
+ GlobalConfiguration.loadConfiguration(
+ conf.toAbsolutePath().toString())
+ .toMap();
+ String host =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.address",
+ InetAddress.getByName("localhost")
+ .getHostAddress());
+ String port =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.port", "8083");
+ // Open a session
+ String sessionHandle = openSession(host, port);
+ List<String> sqlLines = job.getSqlLines();
+ for (String sql : sqlLines) {
+ // Execute statement
+ String operationHandle =
+ executeStatement(sessionHandle, sql, host, port);
+ int count = 5;
Review Comment:
This has been modified to keep fetching data until no data is generated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] WencongLiu commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
WencongLiu commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r953374948
##########
flink-end-to-end-tests/flink-sql-gateway-test/src/test/java/org/apache/flink/table/gateway/SqlGatewayE2ECase.java:
##########
@@ -117,8 +119,13 @@ public void testExecuteStatement() throws Exception {
.setClientMode(SQLJobSubmission.ClientMode.HIVE_JDBC)
.build(),
Duration.ofSeconds(60));
+ gateway.submitSQLJob(
+ new SQLJobSubmission.SQLJobSubmissionBuilder(lines)
+ .setClientMode(SQLJobSubmission.ClientMode.REST)
+ .build(),
+ Duration.ofSeconds(60));
}
Review Comment:
Done. There are both `testHiveserver2ExecuteStatement` and `testRestExecuteStatement` currently.
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -301,7 +309,105 @@ public void submitSQLJob(SQLJobSubmission job, Duration timeout) throws Exceptio
});
new Thread(future).start();
future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
+ } else if (job.getClientMode() == SQLJobSubmission.ClientMode.REST) {
+ FutureTaskWithException<Void> future =
+ new FutureTaskWithException<>(
+ () -> {
+ Map<String, String> configMap =
+ GlobalConfiguration.loadConfiguration(
+ conf.toAbsolutePath().toString())
+ .toMap();
+ String host =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.address",
+ InetAddress.getByName("localhost")
+ .getHostAddress());
+ String port =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.port", "8083");
+ // Open a session
+ String sessionHandle = openSession(host, port);
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] WencongLiu commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
WencongLiu commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r953412031
##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/rest/SqlGatewayRestEndpointFactory.java:
##########
@@ -94,6 +92,10 @@ public Set<ConfigOption<?>> requiredOptions() {
@Override
public Set<ConfigOption<?>> optionalOptions() {
- return Collections.emptySet();
+ Set<ConfigOption<?>> options = new HashSet<>();
+ options.add(BIND_ADDRESS);
+ options.add(PORT);
+ options.add(BIND_PORT);
+ return options;
Review Comment:
Adding code here is for the options check.
These options are defined to match the logic of RestServerEndpoint reading configuration.
By default, the user only need to select a local address to set ADDRESS, then the server will bind the address to all the local IPV4 address (0.0.0.0) and bind the port to BIND_PORT(fallback to the default value of PORT). In the log, the server will suggest client to connect to ADDRESS with the default value of PORT.
1. If user specifies BIND_ADDRESS, then the server will bind to BIND_ADDRESS and suggest the user that the current client should connect to this BIND_ADDRESS in the log rather than ADDRESS.
2. If user specifies PORT, then the server will bind the port to BIND_PORT(fallback to the value of PORT).
3. If user specifies BIND_PORT, then the server will ignore PORT and directly bind the port to the value of BIND_PORT.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] fsk119 commented on a diff in pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
fsk119 commented on code in PR #20609:
URL: https://github.com/apache/flink/pull/20609#discussion_r953549271
##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/rest/SqlGatewayRestEndpointFactory.java:
##########
@@ -94,6 +92,10 @@ public Set<ConfigOption<?>> requiredOptions() {
@Override
public Set<ConfigOption<?>> optionalOptions() {
- return Collections.emptySet();
+ Set<ConfigOption<?>> options = new HashSet<>();
+ options.add(BIND_ADDRESS);
+ options.add(PORT);
+ options.add(BIND_PORT);
+ return options;
Review Comment:
Thanks for your illustration. +1 for the change. Could you describe the behaviour in the config options.
##########
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/FlinkDistribution.java:
##########
@@ -267,41 +275,144 @@ public void submitSQLJob(SQLJobSubmission job, Duration timeout) throws Exceptio
.setEnv(job.getEnvProcessor())
.runBlocking(timeout);
} else if (job.getClientMode() == SQLJobSubmission.ClientMode.HIVE_JDBC) {
- FutureTaskWithException<Void> future =
- new FutureTaskWithException<>(
- () -> {
- // register HiveDriver to the DriverManager
- Class.forName(HIVE_DRIVER);
- Map<String, String> configMap =
- GlobalConfiguration.loadConfiguration(
- conf.toAbsolutePath().toString())
- .toMap();
- String host =
- configMap.getOrDefault(
- "sql-gateway.endpoint.hiveserver2.host",
- InetAddress.getByName("localhost")
- .getHostAddress());
- String port =
- configMap.getOrDefault(
- "sql-gateway.endpoint.hiveserver2.thrift.port",
- "10000");
- try (Connection connection =
- DriverManager.getConnection(
- String.format(
- "jdbc:hive2://%s:%s/default;auth=noSasl;",
- host, port));
- Statement statement = connection.createStatement()) {
- for (String jar : job.getJars()) {
- statement.execute(String.format("ADD JAR '%s'", jar));
- }
- for (String sql : job.getSqlLines()) {
- statement.execute(sql);
- }
+ // register HiveDriver to the DriverManager
+ Class.forName(HIVE_DRIVER);
+ Map<String, String> configMap =
+ GlobalConfiguration.loadConfiguration(conf.toAbsolutePath().toString()).toMap();
+ String host =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.hiveserver2.host",
+ InetAddress.getByName("localhost").getHostAddress());
+ String port =
+ configMap.getOrDefault("sql-gateway.endpoint.hiveserver2.thrift.port", "10000");
+
+ submitSQL(
+ () -> {
+ try (Connection connection =
+ DriverManager.getConnection(
+ String.format(
+ "jdbc:hive2://%s:%s/default;auth=noSasl;",
+ host, port));
+ Statement statement = connection.createStatement()) {
+ for (String jar : job.getJars()) {
+ statement.execute(String.format("ADD JAR '%s'", jar));
+ }
+ for (String sql : job.getSqlLines()) {
+ statement.execute(sql);
+ }
+ }
+ },
+ timeout);
+ } else if (job.getClientMode() == SQLJobSubmission.ClientMode.REST) {
+ Map<String, String> configMap =
+ GlobalConfiguration.loadConfiguration(conf.toAbsolutePath().toString()).toMap();
+ String host =
+ configMap.getOrDefault(
+ "sql-gateway.endpoint.rest.address",
+ InetAddress.getByName("localhost").getHostAddress());
+ String port = configMap.getOrDefault("sql-gateway.endpoint.rest.port", "8083");
+ submitSQL(
+ () -> {
+ // Open a session
+ String sessionHandle = openSession(host, port);
+ List<String> sqlLines = new ArrayList<>();
+ for (String jar : job.getJars()) {
+ sqlLines.add(String.format("ADD JAR '%s'", jar));
+ }
+ sqlLines.addAll(job.getSqlLines());
+ // Execute statement
+ for (String sql : sqlLines) {
+ String operationHandle =
+ executeStatement(sessionHandle, sql, host, port);
+ long nextToken = 0L;
+ while (true) {
+ // Fetch results
+ String results =
+ fetchResults(
+ sessionHandle,
+ operationHandle,
+ host,
+ port,
+ nextToken);
+ if (results.contains("EOS")) {
+ break;
+ } else if (results.contains("PAYLOAD")) {
+ ++nextToken;
}
- });
- new Thread(future).start();
- future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
+ }
+ }
+ },
+ timeout);
+ }
+ }
+
+ private void submitSQL(RunnableWithException command, Duration timeout) throws Exception {
+ FutureTaskWithException<Void> future = new FutureTaskWithException<>(command);
+ new Thread(future).start();
+ future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
+ }
+
+ private String openSession(String host, String port) throws Exception {
+ FormBody.Builder builder = new FormBody.Builder();
+ FormBody requestBody = builder.build();
+ final Request request =
+ new Request.Builder()
+ .post(requestBody)
+ .url(String.format("http://%s:%s/v1/sessions/", host, port))
+ .build();
+ final JsonNode jsonNode = OBJECT_MAPPER.readTree(sendRequest(request));
+ return jsonNode.get("sessionHandle").asText();
+ }
+
+ private String executeStatement(String sessionHandle, String sql, String host, String port)
+ throws Exception {
+ ObjectNode objectNode = OBJECT_MAPPER.createObjectNode();
+ objectNode.put("statement", sql);
+ RequestBody requestBody =
+ RequestBody.create(
+ MediaType.parse("application/json; charset=utf-8"),
+ OBJECT_MAPPER.writeValueAsString(objectNode));
+ final Request request =
+ new Request.Builder()
+ .post(requestBody)
+ .url(
+ String.format(
+ "http://%s:%s/v1/sessions/%s/statements",
+ host, port, sessionHandle))
+ .build();
+ final JsonNode jsonNode = OBJECT_MAPPER.readTree(sendRequest(request));
+ return jsonNode.get("operationHandle").asText();
+ }
+
+ private String fetchResults(
+ String sessionHandle, String operationHandle, String host, String port, Long nextToken)
+ throws Exception {
+ final Request request =
+ new Request.Builder()
+ .get()
+ .url(
Review Comment:
Can you wrap this methods into a TestClient? I think it would be much clearer.
##########
flink-end-to-end-tests/flink-sql-gateway-test/src/test/java/org/apache/flink/table/gateway/SqlGatewayE2ECase.java:
##########
@@ -91,36 +94,52 @@ public static void beforeClass() {
@AfterClass
public static void afterClass() throws Exception {
- port.close();
+ hiveserver2Port.close();
+ restPort.close();
}
@Test
- public void testExecuteStatement() throws Exception {
- URL url = SqlGatewayE2ECase.class.getClassLoader().getResource(GATEWAY_E2E_SQL);
- if (url == null) {
- throw new FileNotFoundException(GATEWAY_E2E_SQL);
- }
+ public void testHiveserver2ExecuteStatement() throws Exception {
File result = FOLDER.newFolder("csv");
- String sql =
- Files.readAllLines(new File(url.getFile()).toPath()).stream()
- .filter(line -> !line.trim().startsWith("--"))
- .collect(Collectors.joining());
- List<String> lines =
- Arrays.stream(sql.split(";"))
- .map(line -> line.replace(RESULT_KEY, result.getAbsolutePath()))
- .collect(Collectors.toList());
-
try (GatewayController gateway = flinkResource.startSqlGateway();
ClusterController ignore = flinkResource.startCluster(1)) {
gateway.submitSQLJob(
- new SQLJobSubmission.SQLJobSubmissionBuilder(lines)
+ new SQLJobSubmission.SQLJobSubmissionBuilder(getSqlLines(result))
.setClientMode(SQLJobSubmission.ClientMode.HIVE_JDBC)
.build(),
Duration.ofSeconds(60));
}
assertEquals(Collections.singletonList("1"), readCsvResultFiles(result.toPath()));
}
+ @Test
+ public void testRestExecuteStatement() throws Exception {
+ File result = FOLDER.newFolder("csv");
+ try (GatewayController gateway = flinkResource.startSqlGateway();
+ ClusterController ignore = flinkResource.startCluster(1)) {
+ gateway.submitSQLJob(
+ new SQLJobSubmission.SQLJobSubmissionBuilder(getSqlLines(result))
+ .setClientMode(SQLJobSubmission.ClientMode.REST)
+ .build(),
+ Duration.ofSeconds(60));
+ }
+ assertEquals(Collections.singletonList("1"), readCsvResultFiles(result.toPath()));
Review Comment:
The `testRestExecuteStatement` and `testHiveserver2ExecuteStatement` is much similar. Can we add a helper method like `runExecuteStatement(ClientMode clientMode)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] WencongLiu commented on pull request #20609: [FLINK-27773][sql-gateway]Introduce the rest E2E tests for SQL Gateway
Posted by GitBox <gi...@apache.org>.
WencongLiu commented on PR #20609:
URL: https://github.com/apache/flink/pull/20609#issuecomment-1227104472
@flinkbot run azure
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org