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/19406fbd Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/19406fbd Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/19406fbd Branch: refs/heads/v0.5.1 Commit: 19406fbd2fcdf46a845f495a8c817094b3ffbe37 Parents: 642a106 Author: Kevin Minder <kevin.min...@hortonworks.com> Authored: Mon Nov 3 22:40:37 2014 -0500 Committer: Larry McCay <lmc...@hortonworks.com> Committed: Fri Nov 21 15:59:22 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/19406fbd/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/19406fbd/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(); }