Repository: hadoop Updated Branches: refs/heads/trunk 50eeea130 -> 7e509f584
YARN-3722. Merge multiple TestWebAppUtils into o.a.h.yarn.webapp.util.TestWebAppUtils. Contributed by Masatake Iwasaki. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/7e509f58 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/7e509f58 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/7e509f58 Branch: refs/heads/trunk Commit: 7e509f58439b1089462f51f9a0f9782faec7d198 Parents: 50eeea1 Author: Devaraj K <deva...@apache.org> Authored: Thu May 28 15:35:06 2015 +0530 Committer: Devaraj K <deva...@apache.org> Committed: Thu May 28 15:35:06 2015 +0530 ---------------------------------------------------------------------- hadoop-yarn-project/CHANGES.txt | 3 + .../hadoop/yarn/util/TestWebAppUtils.java | 81 -------------------- .../yarn/webapp/util/TestWebAppUtils.java | 52 +++++++++++++ 3 files changed, 55 insertions(+), 81 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/7e509f58/hadoop-yarn-project/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 1d22076..8b8f390 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -277,6 +277,9 @@ Release 2.8.0 - UNRELEASED YARN-3700. Made generic history service load a number of latest applications according to the parameter or the configuration. (Xuan Gong via zjshen) + YARN-3722. Merge multiple TestWebAppUtils into o.a.h.yarn.webapp.util.TestWebAppUtils. + (Masatake Iwasaki via devaraj) + OPTIMIZATIONS YARN-3339. TestDockerContainerExecutor should pull a single image and not http://git-wip-us.apache.org/repos/asf/hadoop/blob/7e509f58/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestWebAppUtils.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestWebAppUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestWebAppUtils.java deleted file mode 100644 index 169787f..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestWebAppUtils.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * 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.hadoop.yarn.util; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.net.NetUtils; -import org.apache.hadoop.yarn.conf.YarnConfiguration; -import org.apache.hadoop.yarn.webapp.util.WebAppUtils; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.net.UnknownHostException; -import java.util.HashMap; -import java.util.Map; - -public class TestWebAppUtils { - - private static final String RM1_NODE_ID = "rm1"; - private static final String RM2_NODE_ID = "rm2"; - - // Because WebAppUtils#getResolvedAddress tries to resolve the hostname, we add a static mapping for dummy hostnames - // to make this test run anywhere without having to give some resolvable hostnames - private static String dummyHostNames[] = {"host1", "host2", "host3"}; - private static final String anyIpAddress = "1.2.3.4"; - private static Map<String, String> savedStaticResolution = new HashMap<>(); - - @BeforeClass - public static void initializeDummyHostnameResolution() throws Exception { - String previousIpAddress; - for (String hostName : dummyHostNames) { - if (null != (previousIpAddress = NetUtils.getStaticResolution(hostName))) { - savedStaticResolution.put(hostName, previousIpAddress); - } - NetUtils.addStaticResolution(hostName, anyIpAddress); - } - } - - @AfterClass - public static void restoreDummyHostnameResolution() throws Exception { - for (Map.Entry<String, String> hostnameToIpEntry : savedStaticResolution.entrySet()) { - NetUtils.addStaticResolution(hostnameToIpEntry.getKey(), hostnameToIpEntry.getValue()); - } - } - - @Test - public void TestRMWebAppURLRemoteAndLocal() throws UnknownHostException { - Configuration configuration = new Configuration(); - final String rmAddress = "host1:8088"; - configuration.set(YarnConfiguration.RM_WEBAPP_ADDRESS, rmAddress); - final String rm1Address = "host2:8088"; - final String rm2Address = "host3:8088"; - configuration.set(YarnConfiguration.RM_WEBAPP_ADDRESS + "." + RM1_NODE_ID, rm1Address); - configuration.set(YarnConfiguration.RM_WEBAPP_ADDRESS + "." + RM2_NODE_ID, rm2Address); - configuration.setBoolean(YarnConfiguration.RM_HA_ENABLED, true); - configuration.set(YarnConfiguration.RM_HA_IDS, RM1_NODE_ID + "," + RM2_NODE_ID); - - String rmRemoteUrl = WebAppUtils.getResolvedRemoteRMWebAppURLWithoutScheme(configuration); - Assert.assertEquals("ResolvedRemoteRMWebAppUrl should resolve to the first HA RM address", rm1Address, rmRemoteUrl); - - String rmLocalUrl = WebAppUtils.getResolvedRMWebAppURLWithoutScheme(configuration); - Assert.assertEquals("ResolvedRMWebAppUrl should resolve to the default RM webapp address", rmAddress, rmLocalUrl); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/7e509f58/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/util/TestWebAppUtils.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/util/TestWebAppUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/util/TestWebAppUtils.java index 2bd91b4..dcc8ba4 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/util/TestWebAppUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/util/TestWebAppUtils.java @@ -23,17 +23,69 @@ import static org.junit.Assert.assertEquals; import java.io.File; import java.io.IOException; +import java.net.UnknownHostException; +import java.util.HashMap; +import java.util.Map; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.http.HttpServer2; import org.apache.hadoop.http.HttpServer2.Builder; +import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.security.alias.CredentialProvider; import org.apache.hadoop.security.alias.CredentialProviderFactory; import org.apache.hadoop.security.alias.JavaKeyStoreProvider; +import org.apache.hadoop.yarn.conf.YarnConfiguration; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Assert; import org.junit.Test; public class TestWebAppUtils { + private static final String RM1_NODE_ID = "rm1"; + private static final String RM2_NODE_ID = "rm2"; + + // Because WebAppUtils#getResolvedAddress tries to resolve the hostname, we add a static mapping for dummy hostnames + // to make this test run anywhere without having to give some resolvable hostnames + private static String dummyHostNames[] = {"host1", "host2", "host3"}; + private static final String anyIpAddress = "1.2.3.4"; + private static Map<String, String> savedStaticResolution = new HashMap<>(); + + @BeforeClass + public static void initializeDummyHostnameResolution() throws Exception { + String previousIpAddress; + for (String hostName : dummyHostNames) { + if (null != (previousIpAddress = NetUtils.getStaticResolution(hostName))) { + savedStaticResolution.put(hostName, previousIpAddress); + } + NetUtils.addStaticResolution(hostName, anyIpAddress); + } + } + + @AfterClass + public static void restoreDummyHostnameResolution() throws Exception { + for (Map.Entry<String, String> hostnameToIpEntry : savedStaticResolution.entrySet()) { + NetUtils.addStaticResolution(hostnameToIpEntry.getKey(), hostnameToIpEntry.getValue()); + } + } + + @Test + public void TestRMWebAppURLRemoteAndLocal() throws UnknownHostException { + Configuration configuration = new Configuration(); + final String rmAddress = "host1:8088"; + configuration.set(YarnConfiguration.RM_WEBAPP_ADDRESS, rmAddress); + final String rm1Address = "host2:8088"; + final String rm2Address = "host3:8088"; + configuration.set(YarnConfiguration.RM_WEBAPP_ADDRESS + "." + RM1_NODE_ID, rm1Address); + configuration.set(YarnConfiguration.RM_WEBAPP_ADDRESS + "." + RM2_NODE_ID, rm2Address); + configuration.setBoolean(YarnConfiguration.RM_HA_ENABLED, true); + configuration.set(YarnConfiguration.RM_HA_IDS, RM1_NODE_ID + "," + RM2_NODE_ID); + + String rmRemoteUrl = WebAppUtils.getResolvedRemoteRMWebAppURLWithoutScheme(configuration); + Assert.assertEquals("ResolvedRemoteRMWebAppUrl should resolve to the first HA RM address", rm1Address, rmRemoteUrl); + + String rmLocalUrl = WebAppUtils.getResolvedRMWebAppURLWithoutScheme(configuration); + Assert.assertEquals("ResolvedRMWebAppUrl should resolve to the default RM webapp address", rmAddress, rmLocalUrl); + } @Test public void testGetPassword() throws Exception {