lsyldliu commented on code in PR #20361:
URL: https://github.com/apache/flink/pull/20361#discussion_r938372682


##########
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/SqlITCaseBase.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * 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.table.sql.codegen;
+
+import org.apache.flink.api.common.time.Deadline;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.tests.util.TestUtils;
+import org.apache.flink.tests.util.flink.ClusterController;
+import org.apache.flink.tests.util.flink.FlinkResource;
+import org.apache.flink.tests.util.flink.FlinkResourceSetup;
+import org.apache.flink.tests.util.flink.LocalStandaloneFlinkResourceFactory;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Before;
+import org.junit.Rule;
+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.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/** Base class for sql ITCase. */
+@RunWith(Parameterized.class)
+public abstract class SqlITCaseBase extends TestLogger {
+    private static final Logger LOG = 
LoggerFactory.getLogger(SqlITCaseBase.class);
+
+    @Parameterized.Parameters(name = "executionMode")
+    public static Collection<String> data() {
+        return Arrays.asList("streaming", "batch");
+    }
+
+    @Rule public final FlinkResource flink;
+
+    @Rule public final TemporaryFolder tmp = new TemporaryFolder();
+
+    private final String executionMode;
+
+    private Path result;
+
+    protected static final Path SQL_TOOL_BOX_JAR = 
TestUtils.getResource(".*SqlToolbox.jar");
+
+    public SqlITCaseBase(String executionMode, Configuration configuration) {
+        this.executionMode = executionMode;
+        this.flink =
+                new LocalStandaloneFlinkResourceFactory()
+                        .create(
+                                FlinkResourceSetup.builder()
+                                        .addConfiguration(configuration)
+                                        .build());
+    }
+
+    @Before
+    public void before() throws Exception {
+        Path tmpPath = tmp.getRoot().toPath();
+        LOG.info("The current temporary path: {}", tmpPath);
+        this.result = tmpPath.resolve(String.format("result-%s", 
UUID.randomUUID()));
+    }
+
+    public void runAndCheckSQL(
+            String sqlPath, Map<String, String> varsMap, int resultSize, 
List<String> resultItems)
+            throws Exception {
+        try (ClusterController clusterController = flink.startCluster(1)) {
+            List<String> sqlLines = initializeSqlLines(sqlPath, varsMap);
+
+            executeSqlStatements(clusterController, sqlLines);
+
+            // Wait until all the results flushed to the json file.
+            LOG.info("Verify the json result.");
+            checkJsonResultFile(resultSize, resultItems);
+            LOG.info("The codegen SQL client test run successfully.");

Review Comment:
   ```suggestion
               LOG.info("The SQL client test run successfully.");
   ```



##########
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/UsingRemoteJarITCaseBase.java:
##########
@@ -0,0 +1,162 @@
+/*
+ * 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.table.sql.codegen;
+
+import org.apache.flink.test.util.SQLJobSubmission;
+import org.apache.flink.tests.util.TestUtils;
+import org.apache.flink.tests.util.flink.ClusterController;
+import org.apache.flink.util.FileUtils;
+import org.apache.flink.util.OperatingSystem;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.time.Duration;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/** ITCase for adding remote jar. */
+public class UsingRemoteJarITCaseBase extends SqlITCaseBase {
+    private static final String SQL_PATH = "remote_jar_e2e.sql";
+    private static final int RESULT_SIZE = 1;
+    private static final List<String> RESULT_ITEMS =
+            Collections.singletonList(
+                    "{\"before\":null,\"after\":{\"id\":1,\"content\":\"Hello 
Flink\"},\"op\":\"c\"}");
+
+    private static final Path HADOOP_CLASSPATH = 
TestUtils.getResource(".*hadoop.classpath");
+
+    private MiniDFSCluster hdfsCluster;
+    private org.apache.hadoop.fs.Path hdPath;
+    private org.apache.hadoop.fs.FileSystem hdfs;
+
+    public UsingRemoteJarITCaseBase(String executionMode) {
+        super(executionMode, new 
org.apache.flink.configuration.Configuration());

Review Comment:
   Why here need to new a default `Configuration ` instead of reuse the 
configuration in parent class?



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/batch/sql/FunctionITCase.java:
##########
@@ -142,6 +147,23 @@ public void 
testUserDefinedTemporaryCatalogFunctionByUsingJar() throws Exception
         testUserDefinedFunctionByUsingJar(functionDDL, dropFunctionDDL);
     }
 
+    @Test
+    public void testUsingAddJar() throws Exception {
+        tEnv().executeSql(String.format("ADD JAR '%s'", jarPath));
+
+        TableResult tableResult = tEnv().executeSql("SHOW JARS");
+        assertThat(
+                        CollectionUtil.iteratorToList(tableResult.collect())
+                                .equals(
+                                        Collections.singletonList(
+                                                Row.of(new 
Path(jarPath).getPath()))))
+                .isTrue();
+
+        testUserDefinedFunctionByUsingJar(
+                String.format("create function lowerUdf as '%s' LANGUAGE 
JAVA", udfClassName),
+                null);

Review Comment:
   Please delete it, we has verified the result before drop it.



##########
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/UsingRemoteJarITCaseBase.java:
##########
@@ -0,0 +1,162 @@
+/*
+ * 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.table.sql.codegen;
+
+import org.apache.flink.test.util.SQLJobSubmission;
+import org.apache.flink.tests.util.TestUtils;
+import org.apache.flink.tests.util.flink.ClusterController;
+import org.apache.flink.util.FileUtils;
+import org.apache.flink.util.OperatingSystem;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.time.Duration;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/** ITCase for adding remote jar. */
+public class UsingRemoteJarITCaseBase extends SqlITCaseBase {

Review Comment:
   ```suggestion
   public class UsingRemoteJarITCase extends SqlITCaseBase {
   ```



##########
flink-end-to-end-tests/flink-end-to-end-tests-sql/src/test/java/org/apache/flink/table/sql/codegen/PlannerScalaFreeITCaseBase.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * 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.table.sql.codegen;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.test.util.SQLJobSubmission;
+import org.apache.flink.tests.util.flink.ClusterController;
+
+import org.junit.Test;
+
+import java.time.Duration;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * End to End tests for table planner scala-free since 1.15. Due to scala-free 
of table planner
+ * introduced, the class in table planner is not visible in distribution 
runtime, if we use these
+ * class in execution time, ClassNotFound exception will be thrown. ITCase in 
table planner can not
+ * cover it, so we should add E2E test for these case.
+ */
+public class PlannerScalaFreeITCaseBase extends SqlITCaseBase {

Review Comment:
   ```suggestion
   public class PlannerScalaFreeITCase extends SqlITCaseBase {
   ```



-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to