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 2016/01/21 17:36:07 UTC
knox git commit: [KNOX-656] - Test GatewayLdapPosixGroupFuncTest
failing intermittently
Repository: knox
Updated Branches:
refs/heads/master 784aac55d -> f95528434
[KNOX-656] - Test GatewayLdapPosixGroupFuncTest failing intermittently
Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/f9552843
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/f9552843
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/f9552843
Branch: refs/heads/master
Commit: f95528434e055a4db8f75cd9c370ec7af88dd21a
Parents: 784aac5
Author: Kevin Minder <ke...@hortonworks.com>
Authored: Thu Jan 21 11:35:48 2016 -0500
Committer: Kevin Minder <ke...@hortonworks.com>
Committed: Thu Jan 21 11:35:59 2016 -0500
----------------------------------------------------------------------
gateway-test-release/pom.xml | 17 ++++++++
.../java/org/apache/hadoop/test/TestUtils.java | 41 ++++++++++++++++++++
gateway-test/pom.xml | 16 +++++---
.../GatewayLdapDynamicGroupFuncTest.java | 21 ++++------
.../gateway/GatewayLdapGroupFuncTest.java | 22 ++++-------
.../gateway/GatewayLdapPosixGroupFuncTest.java | 27 ++++++-------
.../apache/hadoop/gateway/Knox242FuncTest.java | 21 ++++------
pom.xml | 9 +++--
8 files changed, 110 insertions(+), 64 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/knox/blob/f9552843/gateway-test-release/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-test-release/pom.xml b/gateway-test-release/pom.xml
index 887939d..8e3b660 100644
--- a/gateway-test-release/pom.xml
+++ b/gateway-test-release/pom.xml
@@ -188,6 +188,23 @@
<inherited>true</inherited>
<extensions>true</extensions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire-version}</version>
+ <configuration>
+ <forkCount>1</forkCount>
+ <reuseForks>false</reuseForks>
+ <systemPropertyVariables>
+ <gateway-version>${gateway-version}</gateway-version>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>${failsafe-version}</version>
+ </plugin>
</plugins>
</build>
http://git-wip-us.apache.org/repos/asf/knox/blob/f9552843/gateway-test-utils/src/main/java/org/apache/hadoop/test/TestUtils.java
----------------------------------------------------------------------
diff --git a/gateway-test-utils/src/main/java/org/apache/hadoop/test/TestUtils.java b/gateway-test-utils/src/main/java/org/apache/hadoop/test/TestUtils.java
index b52aeba..2a78364 100644
--- a/gateway-test-utils/src/main/java/org/apache/hadoop/test/TestUtils.java
+++ b/gateway-test-utils/src/main/java/org/apache/hadoop/test/TestUtils.java
@@ -40,6 +40,9 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
+import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
+import java.net.Socket;
import java.net.URL;
import java.util.UUID;
@@ -125,4 +128,42 @@ public class TestUtils {
System.out.println( String.format( "Exiting %s#%s", caller.getClassName(), caller.getMethodName() ) );
}
+ public static void awaitPortOpen( InetSocketAddress address, int timeout, int delay ) throws InterruptedException {
+ long maxTime = System.currentTimeMillis() + timeout;
+ do {
+ try {
+ Socket socket = new Socket();
+ socket.connect( address, delay );
+ socket.close();
+ return;
+ } catch ( IOException e ) {
+ //e.printStackTrace();
+ }
+ } while( System.currentTimeMillis() < maxTime );
+ throw new IllegalStateException( "Timed out " + timeout + " waiting for port " + address );
+ }
+
+ public static void awaitNon404HttpStatus( URL url, int timeout, int delay ) throws InterruptedException {
+ long maxTime = System.currentTimeMillis() + timeout;
+ do {
+ Thread.sleep( delay );
+ HttpURLConnection conn = null;
+ try {
+ conn = (HttpURLConnection)url.openConnection();
+ conn.getInputStream().close();
+ return;
+ } catch ( IOException e ) {
+ //e.printStackTrace();
+ try {
+ if( conn != null && conn.getResponseCode() != 404 ) {
+ return;
+ }
+ } catch ( IOException ee ) {
+ //ee.printStackTrace();
+ }
+ }
+ } while( System.currentTimeMillis() < maxTime );
+ throw new IllegalStateException( "Timed out " + timeout + " waiting for URL " + url );
+ }
+
}
http://git-wip-us.apache.org/repos/asf/knox/blob/f9552843/gateway-test/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-test/pom.xml b/gateway-test/pom.xml
index b0016e0..f6f194b 100644
--- a/gateway-test/pom.xml
+++ b/gateway-test/pom.xml
@@ -155,12 +155,13 @@
</dependency>
</dependencies>
-
- <build>
+
+ <build>
<plugins>
- <plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.16</version>
+ <version>${surefire-version}</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
@@ -169,7 +170,12 @@
</systemPropertyVariables>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>${failsafe-version}</version>
+ </plugin>
</plugins>
+ </build>
- </build>
</project>
http://git-wip-us.apache.org/repos/asf/knox/blob/f9552843/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapDynamicGroupFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapDynamicGroupFuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapDynamicGroupFuncTest.java
index bcede37..b94cb34 100755
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapDynamicGroupFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapDynamicGroupFuncTest.java
@@ -30,6 +30,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
+import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.URL;
import java.util.Enumeration;
@@ -46,6 +47,7 @@ import org.apache.hadoop.gateway.services.GatewayServices;
import org.apache.hadoop.gateway.services.ServiceLifecycleException;
import org.apache.hadoop.gateway.services.security.AliasService;
import org.apache.hadoop.gateway.util.KnoxCLI;
+import org.apache.hadoop.test.TestUtils;
import org.apache.http.HttpStatus;
import org.apache.log4j.Appender;
import org.hamcrest.MatcherAssert;
@@ -78,6 +80,7 @@ public class GatewayLdapDynamicGroupFuncTest {
public static GatewayServer gateway;
public static String gatewayUrl;
public static String clusterUrl;
+ public static String serviceUrl;
public static SimpleLdapDirectoryServer ldap;
public static TcpTransport ldapTransport;
@@ -87,6 +90,8 @@ public class GatewayLdapDynamicGroupFuncTest {
//appenders = NoOpAppender.setUp();
int port = setupLdap();
setupGateway(port);
+ TestUtils.awaitPortOpen( new InetSocketAddress( "localhost", port ), 10000, 100 );
+ TestUtils.awaitNon404HttpStatus( new URL( serviceUrl ), 10000, 100 );
LOG_EXIT();
}
@@ -126,11 +131,6 @@ public class GatewayLdapDynamicGroupFuncTest {
File deployDir = new File( testConfig.getGatewayDeploymentDir() );
deployDir.mkdirs();
- File descriptor = new File( topoDir, "testdg-cluster.xml" );
- FileOutputStream stream = new FileOutputStream( descriptor );
- createTopology(ldapPort).toStream( stream );
- stream.close();
-
DefaultGatewayServices srvcs = new DefaultGatewayServices();
Map<String,String> options = new HashMap<String,String>();
options.put( "persist-master", "false" );
@@ -169,6 +169,7 @@ public class GatewayLdapDynamicGroupFuncTest {
gatewayUrl = "http://localhost:" + gateway.getAddresses()[0].getPort() + "/" + config.getGatewayPath();
clusterUrl = gatewayUrl + "/testdg-cluster";
+ serviceUrl = clusterUrl + "/test-service-path/test-service-resource";
///*
GatewayServices services = GatewayServer.getGatewayServices();
@@ -178,17 +179,11 @@ public class GatewayLdapDynamicGroupFuncTest {
char[] password1 = aliasService.getPasswordFromAliasForCluster( "testdg-cluster", "ldcSystemPassword");
//System.err.println("SETUP password 10: " + ((password1 == null) ? "NULL" : new String(password1)));
- descriptor = new File( topoDir, "testdg-cluster.xml" );
- stream = new FileOutputStream( descriptor );
+ File descriptor = new File( topoDir, "testdg-cluster.xml" );
+ FileOutputStream stream = new FileOutputStream( descriptor );
createTopology(ldapPort).toStream( stream );
stream.close();
- try {
- Thread.sleep(5000);
- } catch (Exception e) {
-
- }
- //*/
}
private static XMLTag createTopology(int ldapPort) {
http://git-wip-us.apache.org/repos/asf/knox/blob/f9552843/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapGroupFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapGroupFuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapGroupFuncTest.java
index 8719473..c9cecab 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapGroupFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapGroupFuncTest.java
@@ -30,6 +30,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
+import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.URL;
import java.util.Enumeration;
@@ -46,6 +47,7 @@ import org.apache.hadoop.gateway.services.GatewayServices;
import org.apache.hadoop.gateway.services.ServiceLifecycleException;
import org.apache.hadoop.gateway.services.security.AliasService;
import org.apache.hadoop.gateway.util.KnoxCLI;
+import org.apache.hadoop.test.TestUtils;
import org.apache.http.HttpStatus;
import org.apache.log4j.Appender;
import org.hamcrest.MatcherAssert;
@@ -78,6 +80,7 @@ public class GatewayLdapGroupFuncTest {
public static GatewayServer gateway;
public static String gatewayUrl;
public static String clusterUrl;
+ public static String serviceUrl;
public static SimpleLdapDirectoryServer ldap;
public static TcpTransport ldapTransport;
@@ -87,6 +90,8 @@ public class GatewayLdapGroupFuncTest {
//appenders = NoOpAppender.setUp();
int port = setupLdap();
setupGateway(port);
+ TestUtils.awaitPortOpen( new InetSocketAddress( "localhost", port ), 10000, 100 );
+ TestUtils.awaitNon404HttpStatus( new URL( serviceUrl ), 10000, 100 );
LOG_EXIT();
}
@@ -126,11 +131,6 @@ public class GatewayLdapGroupFuncTest {
File deployDir = new File( testConfig.getGatewayDeploymentDir() );
deployDir.mkdirs();
- File descriptor = new File( topoDir, "test-cluster.xml" );
- FileOutputStream stream = new FileOutputStream( descriptor );
- createTopology(ldapPort).toStream( stream );
- stream.close();
-
DefaultGatewayServices srvcs = new DefaultGatewayServices();
Map<String,String> options = new HashMap<String,String>();
options.put( "persist-master", "true" );
@@ -170,6 +170,7 @@ public class GatewayLdapGroupFuncTest {
gatewayUrl = "http://localhost:" + gateway.getAddresses()[0].getPort() + "/" + config.getGatewayPath();
clusterUrl = gatewayUrl + "/test-cluster";
+ serviceUrl = clusterUrl + "/test-service-path/test-service-resource";
///*
GatewayServices services = GatewayServer.getGatewayServices();
@@ -179,17 +180,10 @@ public class GatewayLdapGroupFuncTest {
char[] password1 = aliasService.getPasswordFromAliasForCluster( "test-cluster", "ldcSystemPassword");
//System.err.println("SETUP password 10: " + ((password1 == null) ? "NULL" : new String(password1)));
- descriptor = new File( topoDir, "test-cluster.xml" );
- stream = new FileOutputStream( descriptor );
+ File descriptor = new File( topoDir, "test-cluster.xml" );
+ FileOutputStream stream = new FileOutputStream( descriptor );
createTopology(ldapPort).toStream( stream );
stream.close();
-
- try {
- Thread.sleep(5000);
- } catch (Exception e) {
-
- }
- //*/
}
private static XMLTag createTopology(int ldapPort) {
http://git-wip-us.apache.org/repos/asf/knox/blob/f9552843/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapPosixGroupFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapPosixGroupFuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapPosixGroupFuncTest.java
index 186e585..6698888 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapPosixGroupFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayLdapPosixGroupFuncTest.java
@@ -26,7 +26,8 @@ import org.apache.hadoop.gateway.services.DefaultGatewayServices;
import org.apache.hadoop.gateway.services.GatewayServices;
import org.apache.hadoop.gateway.services.ServiceLifecycleException;
import org.apache.hadoop.gateway.services.security.AliasService;
-import org.apache.hadoop.test.category.VerifyTest;
+import org.apache.hadoop.test.TestUtils;
+import org.apache.hadoop.test.category.ReleaseTest;
import org.apache.http.HttpStatus;
import org.apache.log4j.Appender;
import org.hamcrest.MatcherAssert;
@@ -43,6 +44,8 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.URL;
import java.util.Enumeration;
@@ -63,7 +66,7 @@ import static org.junit.Assert.fail;
* and using them in acl authorization checks
*
*/
-@Category(VerifyTest.class)
+@Category(ReleaseTest.class)
public class GatewayLdapPosixGroupFuncTest {
private static final long SHORT_TIMEOUT = 2000L;
@@ -77,6 +80,7 @@ public class GatewayLdapPosixGroupFuncTest {
public static GatewayServer gateway;
public static String gatewayUrl;
public static String clusterUrl;
+ public static String serviceUrl;
public static SimpleLdapDirectoryServer ldap;
public static TcpTransport ldapTransport;
@@ -86,6 +90,8 @@ public class GatewayLdapPosixGroupFuncTest {
//appenders = NoOpAppender.setUp();
int port = setupLdap();
setupGateway(port);
+ TestUtils.awaitPortOpen( new InetSocketAddress( "localhost", port ), 10000, 100 );
+ TestUtils.awaitNon404HttpStatus( new URL( serviceUrl ), 10000, 100 );
LOG_EXIT();
}
@@ -125,11 +131,6 @@ public class GatewayLdapPosixGroupFuncTest {
File deployDir = new File( testConfig.getGatewayDeploymentDir() );
deployDir.mkdirs();
- File descriptor = new File( topoDir, "test-cluster.xml" );
- FileOutputStream stream = new FileOutputStream( descriptor );
- createTopology(ldapPort).toStream( stream );
- stream.close();
-
DefaultGatewayServices srvcs = new DefaultGatewayServices();
Map<String,String> options = new HashMap<String,String>();
options.put( "persist-master", "true" );
@@ -148,6 +149,7 @@ public class GatewayLdapPosixGroupFuncTest {
gatewayUrl = "http://localhost:" + gateway.getAddresses()[0].getPort() + "/" + config.getGatewayPath();
clusterUrl = gatewayUrl + "/test-cluster";
+ serviceUrl = clusterUrl + "/test-service-path/test-service-resource";
GatewayServices services = GatewayServer.getGatewayServices();
AliasService aliasService = (AliasService)services.getService(GatewayServices.ALIAS_SERVICE);
@@ -155,16 +157,11 @@ public class GatewayLdapPosixGroupFuncTest {
char[] password1 = aliasService.getPasswordFromAliasForCluster( "test-cluster", "ldcSystemPassword");
- descriptor = new File( topoDir, "test-cluster.xml" );
- stream = new FileOutputStream( descriptor );
+ File descriptor = new File( topoDir, "test-cluster.xml" );
+ OutputStream stream = new FileOutputStream( descriptor );
createTopology(ldapPort).toStream( stream );
stream.close();
- try {
- Thread.sleep(5000);
- } catch (Exception e) {
-
- }
}
private static XMLTag createTopology(int ldapPort) {
@@ -282,7 +279,6 @@ public class GatewayLdapPosixGroupFuncTest {
LOG_ENTER();
String username = "sam";
String password = "sam-password";
- String serviceUrl = clusterUrl + "/test-service-path/test-service-resource";
given()
//.log().all()
.auth().preemptive().basic( username, password )
@@ -300,7 +296,6 @@ public class GatewayLdapPosixGroupFuncTest {
LOG_ENTER();
String username = "guest";
String password = "guest-password";
- String serviceUrl = clusterUrl + "/test-service-path/test-service-resource";
given()
//.log().all()
.auth().preemptive().basic( username, password )
http://git-wip-us.apache.org/repos/asf/knox/blob/f9552843/gateway-test/src/test/java/org/apache/hadoop/gateway/Knox242FuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/Knox242FuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/Knox242FuncTest.java
index 29f60b5..feeb08f 100755
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/Knox242FuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/Knox242FuncTest.java
@@ -30,6 +30,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
+import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.URL;
import java.util.Enumeration;
@@ -46,6 +47,7 @@ import org.apache.hadoop.gateway.services.GatewayServices;
import org.apache.hadoop.gateway.services.ServiceLifecycleException;
import org.apache.hadoop.gateway.services.security.AliasService;
import org.apache.hadoop.gateway.util.KnoxCLI;
+import org.apache.hadoop.test.TestUtils;
import org.apache.http.HttpStatus;
import org.apache.log4j.Appender;
import org.hamcrest.MatcherAssert;
@@ -79,6 +81,7 @@ public class Knox242FuncTest {
public static GatewayServer gateway;
public static String gatewayUrl;
public static String clusterUrl;
+ public static String serviceUrl;
public static SimpleLdapDirectoryServer ldap;
public static TcpTransport ldapTransport;
@@ -88,6 +91,8 @@ public class Knox242FuncTest {
//appenders = NoOpAppender.setUp();
int port = setupLdap();
setupGateway(port);
+ TestUtils.awaitPortOpen( new InetSocketAddress( "localhost", port ), 10000, 100 );
+ TestUtils.awaitNon404HttpStatus( new URL( serviceUrl ), 10000, 100 );
LOG_EXIT();
}
@@ -127,11 +132,6 @@ public class Knox242FuncTest {
File deployDir = new File( testConfig.getGatewayDeploymentDir() );
deployDir.mkdirs();
- File descriptor = new File( topoDir, "testdg-cluster.xml" );
- FileOutputStream stream = new FileOutputStream( descriptor );
- createTopology(ldapPort).toStream( stream );
- stream.close();
-
DefaultGatewayServices srvcs = new DefaultGatewayServices();
Map<String,String> options = new HashMap<String,String>();
options.put( "persist-master", "false" );
@@ -149,6 +149,7 @@ public class Knox242FuncTest {
gatewayUrl = "http://localhost:" + gateway.getAddresses()[0].getPort() + "/" + config.getGatewayPath();
clusterUrl = gatewayUrl + "/testdg-cluster";
+ serviceUrl = clusterUrl + "/test-service-path/test-service-resource";
GatewayServices services = GatewayServer.getGatewayServices();
AliasService aliasService = (AliasService)services.getService(GatewayServices.ALIAS_SERVICE);
@@ -157,16 +158,10 @@ public class Knox242FuncTest {
char[] password1 = aliasService.getPasswordFromAliasForCluster( "testdg-cluster", "ldcSystemPassword");
//System.err.println("SETUP password 10: " + ((password1 == null) ? "NULL" : new String(password1)));
- descriptor = new File( topoDir, "testdg-cluster.xml" );
- stream = new FileOutputStream( descriptor );
+ File descriptor = new File( topoDir, "testdg-cluster.xml" );
+ FileOutputStream stream = new FileOutputStream( descriptor );
createTopology(ldapPort).toStream( stream );
stream.close();
-
- try {
- Thread.sleep(5000);
- } catch (Exception e) {
-
- }
}
private static XMLTag createTopology(int ldapPort) {
http://git-wip-us.apache.org/repos/asf/knox/blob/f9552843/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 385ef39..14e3079 100644
--- a/pom.xml
+++ b/pom.xml
@@ -100,6 +100,8 @@
<gateway-group>org.apache.knox</gateway-group>
<hadoop-version>2.2.0</hadoop-version>
<jetty-version>8.1.14.v20131031</jetty-version>
+ <surefire-version>2.16</surefire-version>
+ <failsafe-version>2.19.1</failsafe-version>
</properties>
<licenses>
@@ -270,7 +272,7 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.16</version>
+ <version>${surefire-version}</version>
<configuration>
<excludedGroups>
org.apache.hadoop.test.category.SlowTests,org.apache.hadoop.test.category.ManualTests,org.apache.hadoop.test.category.VerifyTest,org.apache.hadoop.test.category.ReleaseTest
@@ -281,8 +283,9 @@
</configuration>
</plugin>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
- <version>2.19.1</version>
+ <version>${failsafe-version}</version>
<configuration>
<groups>${failsafe.group}</groups>
</configuration>
@@ -294,7 +297,7 @@
</goals>
<configuration>
<includes>
- <include>**/*.class</include>
+ <include>**/*.java</include>
</includes>
</configuration>
</execution>