You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by km...@apache.org on 2014/11/04 04:40:49 UTC

git commit: KNOX-467: Unit tests failing on windows. Second attempt.

Repository: knox
Updated Branches:
  refs/heads/master 4c7ddb58f -> 56dd56dd1


KNOX-467: Unit tests failing on windows. Second attempt.


Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/56dd56dd
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/56dd56dd
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/56dd56dd

Branch: refs/heads/master
Commit: 56dd56dd1f5888f6c7bc4ec23e1d345156185401
Parents: 4c7ddb5
Author: Kevin Minder <ke...@hortonworks.com>
Authored: Mon Nov 3 22:40:37 2014 -0500
Committer: Kevin Minder <ke...@hortonworks.com>
Committed: Mon Nov 3 22:40:37 2014 -0500

----------------------------------------------------------------------
 .../hadoop/gateway/GatewayBasicFuncTest.java    | 36 +++++++++++---------
 .../hadoop/gateway/GatewayFuncTestDriver.java   |  3 +-
 2 files changed, 22 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/56dd56dd/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayBasicFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayBasicFuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayBasicFuncTest.java
index 830bcad..f99c10f 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayBasicFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayBasicFuncTest.java
@@ -288,8 +288,8 @@ public class GatewayBasicFuncTest {
     String username = "hdfs";
     String password = "hdfs-password";
     InetSocketAddress gatewayAddress = driver.gateway.getAddresses()[0];
-    String forwardHostName = gatewayAddress.getHostName();
-    String reverseHostName = InetAddress.getByName( forwardHostName ).getHostName();
+    String gatewayHostName = gatewayAddress.getHostName();
+    String gatewayAddrName = InetAddress.getByName( gatewayHostName ).getHostAddress();
 
     driver.getMock( "WEBHDFS" )
         .expect()
@@ -315,8 +315,8 @@ public class GatewayBasicFuncTest {
     log.debug( "Redirect location: " + response.getHeader( "Location" ) );
     if( driver.isUseGateway() ) {
       MatcherAssert.assertThat( location, anyOf(
-          startsWith( "http://" + forwardHostName + ":" + gatewayAddress.getPort() + "/" ),
-          startsWith( "http://" + reverseHostName + ":" + gatewayAddress.getPort() + "/" ) ) );
+          startsWith( "http://" + gatewayHostName + ":" + gatewayAddress.getPort() + "/" ),
+          startsWith( "http://" + gatewayAddrName + ":" + gatewayAddress.getPort() + "/" ) ) );
       MatcherAssert.assertThat( location, containsString( "?_=" ) );
     }
     MatcherAssert.assertThat( location, not( containsString( "host=" ) ) );
@@ -385,9 +385,8 @@ public class GatewayBasicFuncTest {
     String username = "hdfs";
     String password = "hdfs-password";
     InetSocketAddress gatewayAddress = driver.gateway.getAddresses()[0];
-
-    String forwardHostName = gatewayAddress.getHostName();
-    String reverseHostName = InetAddress.getByName( forwardHostName ).getHostName();
+    String gatewayHostName = gatewayAddress.getHostName();
+    String gatewayAddrName = InetAddress.getByName( gatewayHostName ).getHostAddress();
 
     // Attempt to delete the test directory in case a previous run failed.
     // Ignore any result.
@@ -556,8 +555,8 @@ public class GatewayBasicFuncTest {
     log.debug( "Redirect location: " + response.getHeader( "Location" ) );
     if( driver.isUseGateway() ) {
       MatcherAssert.assertThat( location, anyOf(
-          startsWith( "http://" + forwardHostName + ":" + gatewayAddress.getPort() + "/" ),
-          startsWith( "http://" + reverseHostName + ":" + gatewayAddress.getPort() + "/" ) ) );
+          startsWith( "http://" + gatewayHostName + ":" + gatewayAddress.getPort() + "/" ),
+          startsWith( "http://" + gatewayAddrName + ":" + gatewayAddress.getPort() + "/" ) ) );
       MatcherAssert.assertThat( location, containsString( "?_=" ) );
     }
     MatcherAssert.assertThat( location, not( containsString( "host=" ) ) );
@@ -576,8 +575,8 @@ public class GatewayBasicFuncTest {
     log.debug( "Created location: " + location );
     if( driver.isUseGateway() ) {
       MatcherAssert.assertThat( location, anyOf(
-          startsWith( "http://" + forwardHostName + ":" + gatewayAddress.getPort() + "/" ),
-          startsWith( "http://" + reverseHostName + ":" + gatewayAddress.getPort() + "/" ) ) );
+          startsWith( "http://" + gatewayHostName + ":" + gatewayAddress.getPort() + "/" ),
+          startsWith( "http://" + gatewayAddrName + ":" + gatewayAddress.getPort() + "/" ) ) );
     }
     driver.assertComplete();
 
@@ -2073,6 +2072,8 @@ public class GatewayBasicFuncTest {
     String gatewayPath = driver.getUrl( "RESOURCEMANAGER" ) + path;
     String gatewayPathQuery = driver.isUseGateway() ? "" : "?user.name=" + username;
     InetSocketAddress gatewayAddress = driver.gateway.getAddresses()[0];
+    String gatewayHostName = gatewayAddress.getHostName();
+    String gatewayAddrName = InetAddress.getByName( gatewayHostName ).getHostAddress();
 
     switch( contentType ) {
     case JSON:
@@ -2117,7 +2118,10 @@ public class GatewayBasicFuncTest {
         .statusCode( HttpStatus.SC_OK )
         .contentType( contentType )
         .content( "apps.app[0].trackingUrl", isEmptyString() )
-        .content( "apps.app[1].trackingUrl", startsWith( "http://" + gatewayAddress.getHostName() + ":" + gatewayAddress.getPort() + "/" ) )
+        .content( "apps.app[1].trackingUrl",
+            anyOf(
+                startsWith( "http://" + gatewayHostName + ":" + gatewayAddress.getPort() + "/" ),
+                startsWith( "http://" + gatewayAddrName + ":" + gatewayAddress.getPort() + "/" ) ) )
         .content( "apps.app[2].trackingUrl", isEmptyString() )
         .content( "apps.app[0].amContainerLogs", isEmptyString() )
         .content( "apps.app[1].amContainerLogs", isEmptyString() )
@@ -2229,6 +2233,8 @@ public class GatewayBasicFuncTest {
     }
     String gatewayPath = driver.getUrl( "RESOURCEMANAGER" ) + path + (driver.isUseGateway() ? "" : "?user.name=" + username);
     InetSocketAddress gatewayAddress = driver.gateway.getAddresses()[0];
+    String gatewayHostName = gatewayAddress.getHostName();
+    String gatewayAddrName = InetAddress.getByName( gatewayHostName ).getHostAddress();
 
     VelocityEngine velocity = new VelocityEngine();
     velocity.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.NullLogSystem" );
@@ -2262,13 +2268,11 @@ public class GatewayBasicFuncTest {
         .statusCode( HttpStatus.SC_OK )
         .contentType( contentType );
     if ( running ) {
-      String forwardHostName = gatewayAddress.getHostName();
-      String reverseHostName = InetAddress.getByName( forwardHostName ).getHostName();
       response.content(
           "app.trackingUrl",
           anyOf(
-              startsWith( "http://" + forwardHostName + ":" + gatewayAddress.getPort() + "/" ),
-              startsWith( "http://" + reverseHostName + ":" + gatewayAddress.getPort() + "/" ) ) );
+              startsWith( "http://" + gatewayHostName + ":" + gatewayAddress.getPort() + "/" ),
+              startsWith( "http://" + gatewayAddrName + ":" + gatewayAddress.getPort() + "/" ) ) );
     } else {
       response.content( "app.trackingUrl", isEmptyString() );
     }

http://git-wip-us.apache.org/repos/asf/knox/blob/56dd56dd/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayFuncTestDriver.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayFuncTestDriver.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayFuncTestDriver.java
index 1874b5a..6faccac 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayFuncTestDriver.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayFuncTestDriver.java
@@ -222,9 +222,10 @@ public class GatewayFuncTestDriver {
 
   public String getRealAddr( String role ) {
     String addr;
+    String localHostName = getLocalHostName();
     Service service = services.get( role );
     if( service.mock ) {
-      addr = "localhost:" + service.server.getPort();
+      addr = localHostName + ":" + service.server.getPort();
     } else {
       addr = service.realUrl.getHost() + ":" + service.realUrl.getPort();
     }