From a764e9a7a49ba1ed42fd914b295a0db2597bf755 Mon Sep 17 00:00:00 2001 From: Vinod Kumar Vavilapalli Date: Sat, 22 Mar 2014 00:25:27 +0000 Subject: [PATCH] YARN-1863. Fixed test failure in TestRMFailover after YARN-1859. Contributed by Xuan Gong. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1580094 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../hadoop/yarn/client/TestRMFailover.java | 24 ++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 4e91d7a354..7d24f0f02e 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -546,6 +546,9 @@ Release 2.4.0 - UNRELEASED YARN-1849. Fixed NPE in ResourceTrackerService#registerNodeManager for UAM (Karthik Kambatla via jianhe ) + YARN-1863. Fixed test failure in TestRMFailover after YARN-1859. (Xuan Gong + via vinodkv) + Release 2.3.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailover.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailover.java index 1269f89ea8..40350bc42b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailover.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailover.java @@ -39,7 +39,6 @@ import org.apache.hadoop.yarn.client.api.YarnClient; import org.apache.hadoop.yarn.conf.HAUtil; import org.apache.hadoop.yarn.conf.YarnConfiguration; -import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.server.MiniYARNCluster; import org.apache.hadoop.yarn.server.resourcemanager.AdminService; @@ -208,17 +207,19 @@ public void testWebAppProxyInStandAloneMode() throws YarnException, webAppProxyServer.start(); Assert.assertEquals(STATE.STARTED, webAppProxyServer.getServiceState()); + // send httpRequest with fakeApplicationId + // expect to get "Not Found" response and 404 response code URL wrongUrl = new URL("http://0.0.0.0:9099/proxy/" + fakeAppId); HttpURLConnection proxyConn = (HttpURLConnection) wrongUrl .openConnection(); proxyConn.connect(); - verifyExpectedException(proxyConn.getResponseMessage()); + verifyResponse(proxyConn); explicitFailover(); verifyConnections(); proxyConn.connect(); - verifyExpectedException(proxyConn.getResponseMessage()); + verifyResponse(proxyConn); } finally { webAppProxyServer.stop(); } @@ -233,25 +234,26 @@ public void testEmbeddedWebAppProxy() throws YarnException, getAdminService(0).transitionToActive(req); assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex()); verifyConnections(); + + // send httpRequest with fakeApplicationId + // expect to get "Not Found" response and 404 response code URL wrongUrl = new URL("http://0.0.0.0:18088/proxy/" + fakeAppId); HttpURLConnection proxyConn = (HttpURLConnection) wrongUrl .openConnection(); proxyConn.connect(); - verifyExpectedException(proxyConn.getResponseMessage()); + verifyResponse(proxyConn); explicitFailover(); verifyConnections(); proxyConn.connect(); - verifyExpectedException(proxyConn.getResponseMessage()); + verifyResponse(proxyConn); } - private void verifyExpectedException(String exceptionMessage){ - assertTrue(exceptionMessage.contains(ApplicationNotFoundException.class - .getName())); - assertTrue(exceptionMessage - .contains("Application with id '" + fakeAppId + "' " + - "doesn't exist in RM.")); + private void verifyResponse(HttpURLConnection response) + throws IOException { + assertEquals("Not Found", response.getResponseMessage()); + assertEquals(404, response.getResponseCode()); } @Test