lirui-apache commented on a change in pull request #10709: [FLINK-13437][test] 
Add Hive SQL E2E test
URL: https://github.com/apache/flink/pull/10709#discussion_r365150036
 
 

 ##########
 File path: 
flink-end-to-end-tests/flink-connector-hive-test/src/main/java/org/apache/flink/tests/util/hive/YarnClusterFlinkResource.java
 ##########
 @@ -0,0 +1,193 @@
+/*
+ * 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.hive;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.GlobalConfiguration;
+import org.apache.flink.configuration.UnmodifiableConfiguration;
+import org.apache.flink.tests.util.AutoClosableProcess;
+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.JobController;
+import org.apache.flink.tests.util.flink.JobSubmission;
+
+import org.apache.commons.lang3.StringUtils;
+import org.junit.Assert;
+import org.junit.rules.TemporaryFolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+
+/**
+ * YarnClusterFlinkResource use the {@link YarnClusterAndHiveResource} as the 
yarn cluster to submit flink job in
+ * per-job mode.
+ */
+public class YarnClusterFlinkResource implements FlinkResource {
+
+       private static final Logger LOG = 
LoggerFactory.getLogger(YarnClusterFlinkResource.class);
+       private final YarnClusterAndHiveResource yarnCluster;
+       private final TemporaryFolder temporaryFolder = new TemporaryFolder();
+       private final Path originalFlinkDir;
+       private boolean deployFlinkToRemote = false;
+       public final String remoteFlinkDir = "/home/hadoop-user/flink";
+       Path localFlinkDir;
+       private Configuration defaultConfig;
+       private Path conf;
+
+       public YarnClusterFlinkResource(YarnClusterAndHiveResource yarnCluster) 
{
+               this.yarnCluster = yarnCluster;
+               final String distDirProperty = System.getProperty("distDir");
+               if (distDirProperty == null) {
+                       Assert.fail("The distDir property was not set. You can 
set it when running maven via -DdistDir=<path> .");
+               }
+               originalFlinkDir = Paths.get(distDirProperty);
+       }
+
+       @Override
+       public void addConfiguration(Configuration config) throws IOException {
+               final Configuration mergedConfig = new Configuration();
+               mergedConfig.addAll(defaultConfig);
+               mergedConfig.addAll(config);
+
+               final List<String> configurationLines = 
mergedConfig.toMap().entrySet().stream()
+                               .map(entry -> entry.getKey() + ": " + 
entry.getValue())
+                               .collect(Collectors.toList());
+
+               Files.write(conf.resolve("flink-conf.yaml"), 
configurationLines);
+       }
+
+       @Override
+       public ClusterController startCluster(int numTaskManagers) throws 
IOException {
+               if (!deployFlinkToRemote) {
+                       
yarnCluster.copyLocalFileToYarnMaster(localFlinkDir.toAbsolutePath().toString(),
 remoteFlinkDir);
 
 Review comment:
   Instead of copying the dist dir to the container, can we instead mount the 
dir to container when it's started, with the `-v` option?

----------------------------------------------------------------
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

Reply via email to