DashShen commented on a change in pull request #12369: URL: https://github.com/apache/flink/pull/12369#discussion_r437978305
########## File path: flink-end-to-end-tests/flink-end-to-end-tests-hbase/src/test/java/org/apache/flink/tests/util/hbase/SQLClientHBaseITCase.java ########## @@ -0,0 +1,158 @@ +/* + * 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.hbase; + +import org.apache.flink.tests.util.TestUtils; +import org.apache.flink.tests.util.cache.DownloadCache; +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.FlinkResourceSetup; +import org.apache.flink.tests.util.flink.LocalStandaloneFlinkResourceFactory; +import org.apache.flink.tests.util.flink.SQLJobSubmission; +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.Before; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TemporaryFolder; +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.nio.file.StandardOpenOption; +import java.util.List; + +import static org.hamcrest.Matchers.arrayContainingInAnyOrder; +import static org.hamcrest.Matchers.containsString; +import static org.junit.Assert.assertThat; + +/** + * End-to-end test for the HBase connectors. + */ +@Category(value = {TravisGroup1.class, PreCommit.class}) +public class SQLClientHBaseITCase extends TestLogger { + + private static final Logger LOG = LoggerFactory.getLogger(SQLClientHBaseITCase.class); + + private static final String HBASE_SOURCE_SINK_SCHEMA = "hbase_source_sink_schema.yaml"; + + @Rule + public final HBaseResource hbase; + + @Rule + public final FlinkResource flink = new LocalStandaloneFlinkResourceFactory() + .create(FlinkResourceSetup.builder().build()); + + @Rule + public final TemporaryFolder tmp = new TemporaryFolder(); + + @ClassRule + public static final DownloadCache DOWNLOAD_CACHE = DownloadCache.get(); + + private static final Path sqlToolBoxJar = TestUtils.getResourceJar(".*SqlToolbox.jar"); + private static final Path sqlConnectorHBaseJar = TestUtils.getResourceJar(".*SqlConnectorHbase.jar"); + private Path shadedHadoopJar; + private Path sqlClientSessionConf; + + public SQLClientHBaseITCase() { + this.hbase = HBaseResource.get(); + } + + @Before + public void before() throws Exception { + DOWNLOAD_CACHE.before(); + Path tmpPath = tmp.getRoot().toPath(); + LOG.info("The current temporary path: {}", tmpPath); + this.sqlClientSessionConf = tmpPath.resolve("sql-client-session.conf"); + + //download flink shaded hadoop jar for hbase e2e test using + shadedHadoopJar = DOWNLOAD_CACHE.getOrDownload( Review comment: @leonardBang ,Thks for ur advice. But I encountered a problem that how can I setup HADOOP_CLASSPATH before running sql-client.sh. Could you give me some suggestion. What I have done is below: ```java AtomicReference<String> atomicHadoopClasspath = new AtomicReference<>(""); AutoClosableProcess.create( hadoopDir.resolve(Paths.get("bin", "hadoop")).toString(), "classpath") .setStdoutProcessor(atomicHadoopClasspath::set) .runBlocking(); final String hadoopClasspath = atomicHadoopClasspath.get(); LOG.info("Hadoop Classpath: {}", hadoopClasspath); // how setup HADOOP_CLASSPATH? // I tried using AutoClosableProcess to run export HADOOP_CLASSPATH=<hadoopClasssPath>, but it doesn't work. ``` ---------------------------------------------------------------- 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: [email protected]
