[GitHub] [flink] openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port the Kafka SQL related tests.

2019-12-16 Thread GitBox
openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port 
the Kafka SQL related tests.
URL: https://github.com/apache/flink/pull/10236#discussion_r358575061
 
 

 ##
 File path: 
flink-end-to-end-tests/flink-end-to-end-tests-common-kafka/src/test/java/org/apache/flink/tests/util/kafka/SQLClientKafkaITCase.java
 ##
 @@ -0,0 +1,248 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.tests.util.kafka;
+
+import org.apache.flink.tests.util.TestUtils;
+import org.apache.flink.tests.util.categories.PreCommit;
+import org.apache.flink.tests.util.categories.TravisGroup1;
+import org.apache.flink.tests.util.flink.ClusterController;
+import org.apache.flink.tests.util.flink.FlinkResource;
+import org.apache.flink.tests.util.flink.SQLJobSubmission;
+import org.apache.flink.testutils.junit.FailsOnJava11;
+import org.apache.flink.util.FileUtils;
+import org.apache.flink.util.TestLogger;
+
+import org.apache.flink.shaded.guava18.com.google.common.base.Charsets;
+
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.security.DigestInputStream;
+import java.security.MessageDigest;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.flink.util.StringUtils.byteToHexString;
+
+/**
+ * End-to-end test for the kafka SQL connectors.
+ */
+@RunWith(Parameterized.class)
+@Category(value = {TravisGroup1.class, PreCommit.class, FailsOnJava11.class})
+public class SQLClientKafkaITCase extends TestLogger {
+
+   private static final Logger LOG = 
LoggerFactory.getLogger(SQLClientKafkaITCase.class);
+
+   private static final String KAFKA_JSON_SOURCE_SCHEMA_YAML = 
"kafka_json_source_schema.yaml";
+
+   @Parameterized.Parameters(name = "{index}: kafka-version:{1} 
kafka-sql-version:{2} kafka-sql-jar-version:{3}")
+   public static Collection data() {
+   return Arrays.asList(new Object[][]{
+   {"0.10.2.0", "0.10", "kafka-0.10"},
+   {"0.11.0.2", "0.11", "kafka-0.11"},
+   {"2.2.0", "universal", "kafka_"}
+   });
+   }
+
+   @Rule
+   public final FlinkResource flink;
+
+   @Rule
+   public final KafkaResource kafka;
+
+   @Rule
+   public final TemporaryFolder tmp = new TemporaryFolder();
+
+   private final String kafkaSQLVersion;
+   private final Path result;
+   private final Path sqlClientSessionConf;
+
+   private final Path sqlAvroJar;
+
+   private final Path sqlJsonJar;
+   private final Path sqlToolBoxJar;
+   private final Path sqlConnectorKafkaJar;
+
+   public SQLClientKafkaITCase(String kafkaVersion, String 
kafkaSQLVersion, String kafkaSQLJarPattern) throws IOException {
+   this.flink = FlinkResource.get();
+
+   this.kafka = KafkaResource.get(kafkaVersion);
+   this.kafkaSQLVersion = kafkaSQLVersion;
+
+   tmp.create();
+   Path tmpPath = tmp.getRoot().toPath();
+   LOG.info("The current temporary path: {}", tmpPath);
+   this.sqlClientSessionConf = 
tmpPath.resolve("sql-client-session.conf");
+   this.result = tmpPath.resolve("result");
+
+   final Path parent = Paths.get("..");
+   this.sqlAvroJar = TestUtils.getResourceJar(parent, 
"flink-sql-client-test.*sql-jars.*avro");
+   this.sqlJsonJar = TestUtils.getResourceJar(parent, 
"flink-sql-client-test.*sql-jars.*json");
+   this.sqlToolBoxJar = TestUtils.getResourceJar(parent, 

[GitHub] [flink] openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port the Kafka SQL related tests.

2019-12-16 Thread GitBox
openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port 
the Kafka SQL related tests.
URL: https://github.com/apache/flink/pull/10236#discussion_r358573785
 
 

 ##
 File path: 
flink-end-to-end-tests/flink-end-to-end-tests-common-kafka/src/test/resources/kafka_json_source_schema.yaml
 ##
 @@ -0,0 +1,143 @@
+
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+tables:
+  - name: $TABLE_NAME
+type: source-table
+update-mode: append
+schema:
+  - name: rowtime
+type: TIMESTAMP
+rowtime:
+  timestamps:
+type: from-field
+from: timestamp
+  watermarks:
+type: periodic-bounded
+delay: 2000
+  - name: user
+type: VARCHAR
+  - name: event
+type: ROW
+connector:
+  type: kafka
+  version: "$KAFKA_SQL_VERSION"
+  topic: $TOPIC_NAME
+  startup-mode: earliest-offset
+  properties:
+- key: zookeeper.connect
+  value: localhost:2181
+- key: bootstrap.servers
+  value: localhost:9092
+format:
+  type: json
+  json-schema: >
+{
+  "type": "object",
+  "properties": {
+"timestamp": {
+  "type": "string",
+  "format": "date-time"
+},
+"user": {
+  "type": ["string", "null"]
+},
+"event": {
+  "type": "object",
+  "properties": {
+"type": {
+  "type": "string"
+},
+"message": {
+  "type": "string"
+}
+  }
+}
+  }
+}
+  - name: AvroBothTable
+type: source-sink-table
+update-mode: append
+schema:
+  - name: event_timestamp
+type: VARCHAR
+  - name: user
+type: VARCHAR
+  - name: message
+type: VARCHAR
+  - name: duplicate_count
+type: BIGINT
+connector:
+  type: kafka
+  version: "$KAFKA_SQL_VERSION"
+  topic: test-avro
+  startup-mode: earliest-offset
+  properties:
+- key: zookeeper.connect
+  value: localhost:2181
+- key: bootstrap.servers
 
 Review comment:
   Also sounds good here, will fix this.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port the Kafka SQL related tests.

2019-12-16 Thread GitBox
openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port 
the Kafka SQL related tests.
URL: https://github.com/apache/flink/pull/10236#discussion_r349406335
 
 

 ##
 File path: 
flink-end-to-end-tests/flink-end-to-end-tests-common-kafka/src/test/java/org/apache/flink/tests/util/kafka/SQLClientKafkaITCase.java
 ##
 @@ -0,0 +1,248 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.tests.util.kafka;
+
+import org.apache.flink.tests.util.TestUtils;
+import org.apache.flink.tests.util.categories.PreCommit;
+import org.apache.flink.tests.util.categories.TravisGroup1;
+import org.apache.flink.tests.util.flink.ClusterController;
+import org.apache.flink.tests.util.flink.FlinkResource;
+import org.apache.flink.tests.util.flink.SQLJobSubmission;
+import org.apache.flink.testutils.junit.FailsOnJava11;
+import org.apache.flink.util.FileUtils;
+import org.apache.flink.util.TestLogger;
+
+import org.apache.flink.shaded.guava18.com.google.common.base.Charsets;
+
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.security.DigestInputStream;
+import java.security.MessageDigest;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.flink.util.StringUtils.byteToHexString;
+
+/**
+ * End-to-end test for the kafka SQL connectors.
+ */
+@RunWith(Parameterized.class)
+@Category(value = {TravisGroup1.class, PreCommit.class, FailsOnJava11.class})
 
 Review comment:
   I see, will remove the PreCommit annotation.  Thanks.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port the Kafka SQL related tests.

2019-12-16 Thread GitBox
openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port 
the Kafka SQL related tests.
URL: https://github.com/apache/flink/pull/10236#discussion_r358587261
 
 

 ##
 File path: 
flink-end-to-end-tests/flink-end-to-end-tests-common-kafka/src/test/java/org/apache/flink/tests/util/kafka/SQLClientKafkaITCase.java
 ##
 @@ -0,0 +1,248 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.tests.util.kafka;
+
+import org.apache.flink.tests.util.TestUtils;
+import org.apache.flink.tests.util.categories.PreCommit;
+import org.apache.flink.tests.util.categories.TravisGroup1;
+import org.apache.flink.tests.util.flink.ClusterController;
+import org.apache.flink.tests.util.flink.FlinkResource;
+import org.apache.flink.tests.util.flink.SQLJobSubmission;
+import org.apache.flink.testutils.junit.FailsOnJava11;
+import org.apache.flink.util.FileUtils;
+import org.apache.flink.util.TestLogger;
+
+import org.apache.flink.shaded.guava18.com.google.common.base.Charsets;
+
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.security.DigestInputStream;
+import java.security.MessageDigest;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.flink.util.StringUtils.byteToHexString;
+
+/**
+ * End-to-end test for the kafka SQL connectors.
+ */
+@RunWith(Parameterized.class)
+@Category(value = {TravisGroup1.class, PreCommit.class, FailsOnJava11.class})
+public class SQLClientKafkaITCase extends TestLogger {
+
+   private static final Logger LOG = 
LoggerFactory.getLogger(SQLClientKafkaITCase.class);
+
+   private static final String KAFKA_JSON_SOURCE_SCHEMA_YAML = 
"kafka_json_source_schema.yaml";
+
+   @Parameterized.Parameters(name = "{index}: kafka-version:{1} 
kafka-sql-version:{2} kafka-sql-jar-version:{3}")
+   public static Collection data() {
+   return Arrays.asList(new Object[][]{
+   {"0.10.2.0", "0.10", "kafka-0.10"},
+   {"0.11.0.2", "0.11", "kafka-0.11"},
+   {"2.2.0", "universal", "kafka_"}
+   });
+   }
+
+   @Rule
+   public final FlinkResource flink;
+
+   @Rule
+   public final KafkaResource kafka;
+
+   @Rule
+   public final TemporaryFolder tmp = new TemporaryFolder();
+
+   private final String kafkaSQLVersion;
+   private final Path result;
+   private final Path sqlClientSessionConf;
+
+   private final Path sqlAvroJar;
+
+   private final Path sqlJsonJar;
+   private final Path sqlToolBoxJar;
+   private final Path sqlConnectorKafkaJar;
+
+   public SQLClientKafkaITCase(String kafkaVersion, String 
kafkaSQLVersion, String kafkaSQLJarPattern) throws IOException {
+   this.flink = FlinkResource.get();
+
+   this.kafka = KafkaResource.get(kafkaVersion);
+   this.kafkaSQLVersion = kafkaSQLVersion;
+
+   tmp.create();
+   Path tmpPath = tmp.getRoot().toPath();
+   LOG.info("The current temporary path: {}", tmpPath);
+   this.sqlClientSessionConf = 
tmpPath.resolve("sql-client-session.conf");
 
 Review comment:
   OK


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port the Kafka SQL related tests.

2019-12-16 Thread GitBox
openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port 
the Kafka SQL related tests.
URL: https://github.com/apache/flink/pull/10236#discussion_r349407393
 
 

 ##
 File path: 
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/SQLJobSubmission.java
 ##
 @@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.tests.util.flink;
+
+import org.apache.flink.util.Preconditions;
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Programmatic definition of a SQL job-submission.
+ */
+public class SQLJobSubmission {
+
+   private boolean embedded;
+   private String defaultEnvFile;
 
 Review comment:
   OK


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port the Kafka SQL related tests.

2019-12-16 Thread GitBox
openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port 
the Kafka SQL related tests.
URL: https://github.com/apache/flink/pull/10236#discussion_r358569066
 
 

 ##
 File path: 
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/FlinkDistribution.java
 ##
 @@ -236,6 +237,30 @@ public JobID submitJob(final JobSubmission jobSubmission) 
throws IOException {
}
}
 
+   public void submitSQLJob(SQLJobSubmission job) throws IOException {
+   final List commands = new ArrayList<>();
+   
commands.add(bin.resolve("sql-client.sh").toAbsolutePath().toString());
+   if (job.isEmbedded()) {
+   commands.add("embedded");
+   }
+   if (job.getDefaultEnvFile() != null) {
+   commands.add("--defaults");
+   commands.add(job.getDefaultEnvFile());
+   }
+   if (job.getSessionEnvFile() != null) {
+   commands.add("--environment");
+   commands.add(job.getSessionEnvFile());
+   }
+   for (String jar : job.getJars()) {
+   commands.add("--jar");
+   commands.add(jar);
+   }
+   commands.add("--update");
 
 Review comment:
   > Is the documentation of the sql client outdated? It doesn't list --update 
   
   Not outdated, the --update is used to execute one SQL statement in the 
client, such as:
   
   ```
   ./bin/sql-client.sh embedded --jar test.jar -u "select 1"
   ```
   
   > and embedded does not appear to be an optional argument.
   
   That's true, now it's a necessary argument, let me change this.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port the Kafka SQL related tests.

2019-12-16 Thread GitBox
openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port 
the Kafka SQL related tests.
URL: https://github.com/apache/flink/pull/10236#discussion_r349407413
 
 

 ##
 File path: 
flink-end-to-end-tests/flink-end-to-end-tests-common/src/main/java/org/apache/flink/tests/util/flink/SQLJobSubmission.java
 ##
 @@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.tests.util.flink;
+
+import org.apache.flink.util.Preconditions;
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Programmatic definition of a SQL job-submission.
+ */
+public class SQLJobSubmission {
+
+   private boolean embedded;
+   private String defaultEnvFile;
+   private String sessionEnvFile;
+   private List jars;
+   private String sql;
+
+   private SQLJobSubmission(
+   boolean embedded,
+   String defaultEnvFile,
+   String sessionEnvFile,
+   List jars,
+   String sql
+   ) {
+   Preconditions.checkNotNull(jars);
+   Preconditions.checkNotNull(sql);
+
+   this.embedded = embedded;
+   this.defaultEnvFile = defaultEnvFile;
+   this.sessionEnvFile = sessionEnvFile;
+   this.jars = jars;
+   this.sql = sql;
+   }
+
+   public boolean isEmbedded() {
+   return embedded;
+   }
+
+   public String getDefaultEnvFile() {
+   return defaultEnvFile;
+   }
+
+   public String getSessionEnvFile() {
+   return sessionEnvFile;
+   }
+
+   public List getJars() {
+   return this.jars;
+   }
+
+   public String getSQL(){
+   return this.sql;
+   }
+
+   /**
+* Builder for the {@link SQLJobSubmission}.
+*/
+   public static class SQLJobSubmissionBuilder {
+   private List jars = new ArrayList<>();
+   private boolean embedded = true;
+   private String defaultEnvFile = null;
+   private String sessionEnvFile = null;
+   private String sql = null;
+
+   public SQLJobSubmissionBuilder isEmbedded(boolean embedded) {
+   this.embedded = embedded;
+   return this;
+   }
+
+   public SQLJobSubmissionBuilder setDefaultEnvFile(String 
defaultEnvFile) {
+   this.defaultEnvFile = defaultEnvFile;
+   return this;
+   }
+
+   public SQLJobSubmissionBuilder setSessionEnvFile(String 
sessionEnvFile) {
+   this.sessionEnvFile = sessionEnvFile;
+   return this;
+   }
+
+   public SQLJobSubmissionBuilder addJar(Path jarFile) {
+   this.jars.add(jarFile.toAbsolutePath().toString());
+   return this;
+   }
+
+   public SQLJobSubmissionBuilder addSQL(String sql) {
 
 Review comment:
   OK


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port the Kafka SQL related tests.

2019-12-16 Thread GitBox
openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port 
the Kafka SQL related tests.
URL: https://github.com/apache/flink/pull/10236#discussion_r358587289
 
 

 ##
 File path: 
flink-end-to-end-tests/flink-end-to-end-tests-common-kafka/src/test/java/org/apache/flink/tests/util/kafka/SQLClientKafkaITCase.java
 ##
 @@ -0,0 +1,248 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.tests.util.kafka;
+
+import org.apache.flink.tests.util.TestUtils;
+import org.apache.flink.tests.util.categories.PreCommit;
+import org.apache.flink.tests.util.categories.TravisGroup1;
+import org.apache.flink.tests.util.flink.ClusterController;
+import org.apache.flink.tests.util.flink.FlinkResource;
+import org.apache.flink.tests.util.flink.SQLJobSubmission;
+import org.apache.flink.testutils.junit.FailsOnJava11;
+import org.apache.flink.util.FileUtils;
+import org.apache.flink.util.TestLogger;
+
+import org.apache.flink.shaded.guava18.com.google.common.base.Charsets;
+
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.security.DigestInputStream;
+import java.security.MessageDigest;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.flink.util.StringUtils.byteToHexString;
+
+/**
+ * End-to-end test for the kafka SQL connectors.
+ */
+@RunWith(Parameterized.class)
+@Category(value = {TravisGroup1.class, PreCommit.class, FailsOnJava11.class})
+public class SQLClientKafkaITCase extends TestLogger {
+
+   private static final Logger LOG = 
LoggerFactory.getLogger(SQLClientKafkaITCase.class);
+
+   private static final String KAFKA_JSON_SOURCE_SCHEMA_YAML = 
"kafka_json_source_schema.yaml";
+
+   @Parameterized.Parameters(name = "{index}: kafka-version:{1} 
kafka-sql-version:{2} kafka-sql-jar-version:{3}")
+   public static Collection data() {
+   return Arrays.asList(new Object[][]{
+   {"0.10.2.0", "0.10", "kafka-0.10"},
+   {"0.11.0.2", "0.11", "kafka-0.11"},
+   {"2.2.0", "universal", "kafka_"}
+   });
+   }
+
+   @Rule
+   public final FlinkResource flink;
+
+   @Rule
+   public final KafkaResource kafka;
+
+   @Rule
+   public final TemporaryFolder tmp = new TemporaryFolder();
+
+   private final String kafkaSQLVersion;
+   private final Path result;
+   private final Path sqlClientSessionConf;
+
+   private final Path sqlAvroJar;
+
+   private final Path sqlJsonJar;
+   private final Path sqlToolBoxJar;
+   private final Path sqlConnectorKafkaJar;
+
+   public SQLClientKafkaITCase(String kafkaVersion, String 
kafkaSQLVersion, String kafkaSQLJarPattern) throws IOException {
+   this.flink = FlinkResource.get();
+
+   this.kafka = KafkaResource.get(kafkaVersion);
+   this.kafkaSQLVersion = kafkaSQLVersion;
+
+   tmp.create();
+   Path tmpPath = tmp.getRoot().toPath();
+   LOG.info("The current temporary path: {}", tmpPath);
+   this.sqlClientSessionConf = 
tmpPath.resolve("sql-client-session.conf");
+   this.result = tmpPath.resolve("result");
 
 Review comment:
   Sounds good, will do.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache 

[GitHub] [flink] openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port the Kafka SQL related tests.

2019-12-16 Thread GitBox
openinx commented on a change in pull request #10236: [FLINK-14703][e2e] Port 
the Kafka SQL related tests.
URL: https://github.com/apache/flink/pull/10236#discussion_r358573710
 
 

 ##
 File path: 
flink-end-to-end-tests/flink-end-to-end-tests-common-kafka/src/test/resources/kafka_json_source_schema.yaml
 ##
 @@ -0,0 +1,143 @@
+
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+tables:
+  - name: $TABLE_NAME
+type: source-table
+update-mode: append
+schema:
+  - name: rowtime
+type: TIMESTAMP
+rowtime:
+  timestamps:
+type: from-field
+from: timestamp
+  watermarks:
+type: periodic-bounded
+delay: 2000
+  - name: user
+type: VARCHAR
+  - name: event
+type: ROW
+connector:
+  type: kafka
+  version: "$KAFKA_SQL_VERSION"
+  topic: $TOPIC_NAME
+  startup-mode: earliest-offset
+  properties:
+- key: zookeeper.connect
+  value: localhost:2181
+- key: bootstrap.servers
+  value: localhost:9092
+format:
+  type: json
+  json-schema: >
+{
+  "type": "object",
+  "properties": {
+"timestamp": {
+  "type": "string",
+  "format": "date-time"
+},
+"user": {
+  "type": ["string", "null"]
+},
+"event": {
+  "type": "object",
+  "properties": {
+"type": {
+  "type": "string"
+},
+"message": {
+  "type": "string"
+}
+  }
+}
+  }
+}
+  - name: AvroBothTable
+type: source-sink-table
+update-mode: append
+schema:
+  - name: event_timestamp
+type: VARCHAR
+  - name: user
+type: VARCHAR
+  - name: message
+type: VARCHAR
+  - name: duplicate_count
+type: BIGINT
+connector:
+  type: kafka
+  version: "$KAFKA_SQL_VERSION"
+  topic: test-avro
+  startup-mode: earliest-offset
+  properties:
+- key: zookeeper.connect
+  value: localhost:2181
 
 Review comment:
   Sounds good here, will fix this.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services