forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-17632][yarn] Always build the packaged program in the cluster …
…for application mode
- Loading branch information
1 parent
cd1f858
commit 04bcc25
Showing
5 changed files
with
169 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
flink-yarn-tests/src/test/java/org/apache/flink/yarn/YARNApplicationITCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* 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 | ||
* | ||
* https://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.yarn; | ||
|
||
import org.apache.flink.client.deployment.ClusterSpecification; | ||
import org.apache.flink.client.deployment.application.ApplicationConfiguration; | ||
import org.apache.flink.client.program.ClusterClient; | ||
import org.apache.flink.configuration.AkkaOptions; | ||
import org.apache.flink.configuration.Configuration; | ||
import org.apache.flink.configuration.DeploymentOptions; | ||
import org.apache.flink.configuration.JobManagerOptions; | ||
import org.apache.flink.configuration.MemorySize; | ||
import org.apache.flink.configuration.PipelineOptions; | ||
import org.apache.flink.configuration.TaskManagerOptions; | ||
import org.apache.flink.yarn.configuration.YarnConfigOptions; | ||
import org.apache.flink.yarn.configuration.YarnDeploymentTarget; | ||
|
||
import org.apache.hadoop.fs.Path; | ||
import org.apache.hadoop.yarn.api.records.ApplicationId; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.time.Duration; | ||
import java.util.Collections; | ||
|
||
import static org.apache.flink.yarn.configuration.YarnConfigOptions.CLASSPATH_INCLUDE_USER_JAR; | ||
import static org.apache.flink.yarn.util.YarnTestUtils.getTestJarPath; | ||
|
||
/** | ||
* Test cases for the deployment of Yarn Flink application clusters. | ||
*/ | ||
public class YARNApplicationITCase extends YarnTestBase { | ||
|
||
private static final Duration yarnAppTerminateTimeout = Duration.ofSeconds(30); | ||
private static final int sleepIntervalInMS = 100; | ||
|
||
@BeforeClass | ||
public static void setup() { | ||
YARN_CONFIGURATION.set(YarnTestBase.TEST_CLUSTER_NAME_KEY, "flink-yarn-tests-application"); | ||
startYARNWithConfig(YARN_CONFIGURATION, true); | ||
} | ||
|
||
@Test | ||
public void testApplicationClusterWithLocalUserJarAndFirstUserJarInclusion() throws Exception { | ||
runTest( | ||
() -> deployApplication( | ||
createDefaultConfiguration(getTestingJar(), YarnConfigOptions.UserJarInclusion.FIRST))); | ||
} | ||
|
||
@Test | ||
public void testApplicationClusterWithLocalUserJarAndDisableUserJarInclusion() throws Exception { | ||
runTest( | ||
() -> deployApplication( | ||
createDefaultConfiguration(getTestingJar(), YarnConfigOptions.UserJarInclusion.DISABLED))); | ||
} | ||
|
||
private void deployApplication(Configuration configuration) throws Exception { | ||
try (final YarnClusterDescriptor yarnClusterDescriptor = createYarnClusterDescriptor(configuration)) { | ||
|
||
final int masterMemory = yarnClusterDescriptor.getFlinkConfiguration().get(JobManagerOptions.TOTAL_PROCESS_MEMORY).getMebiBytes(); | ||
final ClusterSpecification clusterSpecification = new ClusterSpecification.ClusterSpecificationBuilder() | ||
.setMasterMemoryMB(masterMemory) | ||
.setTaskManagerMemoryMB(1024) | ||
.setSlotsPerTaskManager(1) | ||
.createClusterSpecification(); | ||
|
||
try (ClusterClient<ApplicationId> clusterClient = yarnClusterDescriptor | ||
.deployApplicationCluster( | ||
clusterSpecification, | ||
ApplicationConfiguration.fromConfiguration(configuration)) | ||
.getClusterClient()) { | ||
|
||
ApplicationId applicationId = clusterClient.getClusterId(); | ||
|
||
waitApplicationFinishedElseKillIt( | ||
applicationId, yarnAppTerminateTimeout, yarnClusterDescriptor, sleepIntervalInMS); | ||
} | ||
} | ||
} | ||
|
||
private Path getTestingJar() throws FileNotFoundException { | ||
return new Path(getTestJarPath("StreamingWordCount.jar").toURI()); | ||
} | ||
|
||
private Configuration createDefaultConfiguration(Path userJar, YarnConfigOptions.UserJarInclusion userJarInclusion) { | ||
Configuration configuration = new Configuration(); | ||
configuration.set(JobManagerOptions.TOTAL_PROCESS_MEMORY, MemorySize.ofMebiBytes(768)); | ||
configuration.set(TaskManagerOptions.TOTAL_PROCESS_MEMORY, MemorySize.parse("1g")); | ||
configuration.setString(AkkaOptions.ASK_TIMEOUT, "30 s"); | ||
configuration.set(DeploymentOptions.TARGET, YarnDeploymentTarget.APPLICATION.getName()); | ||
configuration.setString(CLASSPATH_INCLUDE_USER_JAR, userJarInclusion.toString()); | ||
configuration.set(PipelineOptions.JARS, Collections.singletonList(userJar.toString())); | ||
|
||
return configuration; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters