knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject [1/2] git commit: KNOX-301: Attempt to stabilize deployment unit test on various platforms.
Date Thu, 13 Mar 2014 22:15:52 GMT
Repository: knox
Updated Branches:
  refs/heads/v0.4.0 e870e1855 -> be8cba05d


KNOX-301: Attempt to stabilize deployment unit test on various platforms.


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

Branch: refs/heads/v0.4.0
Commit: 2cc8b1ba15ef7e7394f5e4fc6d12698aded68730
Parents: e870e18
Author: Kevin Minder <kevin.minder@hortonworks.com>
Authored: Wed Mar 12 17:26:11 2014 -0400
Committer: Kevin Minder <kevin.minder@hortonworks.com>
Committed: Wed Mar 12 17:32:36 2014 -0400

----------------------------------------------------------------------
 .../hadoop/gateway/GatewayDeployFuncTest.java     | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/2cc8b1ba/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayDeployFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayDeployFuncTest.java
b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayDeployFuncTest.java
index 8d8f453..f253cf3 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayDeployFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/GatewayDeployFuncTest.java
@@ -218,6 +218,7 @@ public class GatewayDeployFuncTest {
     assertThat( deployDir.listFiles().length, is( 0 ) );
 
     File descriptor = writeTestTopology( "test-cluster", createTopology() );
+    long writeTime = System.currentTimeMillis();
 
     warDir = waitForFiles( deployDir, "test-cluster.war\\.[0-9A-Fa-f]+", 1, 0, sleep );
     for( File webInfDir : warDir.listFiles() ) {
@@ -225,9 +226,13 @@ public class GatewayDeployFuncTest {
     }
     waitForAccess( serviceUrl, username, password, sleep );
 
+    // Wait to make sure a second has passed to ensure the the file timestamps are different.
+    waitForElapsed( writeTime, 1000, 100 );
+
     // Redeploy and make sure the timestamp is updated.
     topoTimestampBefore = descriptor.lastModified();
     GatewayServer.redeployTopologies( config, null );
+    writeTime = System.currentTimeMillis();
     topoTimestampAfter = descriptor.lastModified();
     assertThat( topoTimestampAfter, greaterThan( topoTimestampBefore ) );
 
@@ -238,9 +243,13 @@ public class GatewayDeployFuncTest {
     }
     waitForAccess( serviceUrl, username, password, sleep );
 
+    // Wait to make sure a second has passed to ensure the the file timestamps are different.
+    waitForElapsed( writeTime, 1000, 100 );
+
     // Redeploy and make sure the timestamp is updated.
     topoTimestampBefore = descriptor.lastModified();
     GatewayServer.redeployTopologies( config, "test-cluster" );
+    writeTime = System.currentTimeMillis();
     topoTimestampAfter = descriptor.lastModified();
     assertThat( topoTimestampAfter, greaterThan( topoTimestampBefore ) );
 
@@ -254,6 +263,9 @@ public class GatewayDeployFuncTest {
     // Delete the test topology.
     assertThat( "Failed to delete the topology file.", descriptor.delete(), is( true ) );
 
+    // Wait to make sure a second has passed to ensure the the file timestamps are different.
+    waitForElapsed( writeTime, 1000, 100 );
+
     waitForFiles( deployDir, ".*", 0, -1, sleep );
 
     // Wait a bit more to make sure undeployment finished.
@@ -269,6 +281,12 @@ public class GatewayDeployFuncTest {
     assertThat( deployDir.listFiles().length, is( 0 ) );
   }
 
+  private void waitForElapsed( long from, long total, long sleep ) throws InterruptedException
{
+    while( System.currentTimeMillis() - from < total ) {
+      Thread.sleep( sleep );
+    }
+  }
+
   private File writeTestTopology( String name, XMLTag xml ) throws IOException {
     // Create the test topology.
     File tempFile = new File( config.getGatewayTopologyDir(), name + ".xml." + UUID.randomUUID()
);


Mime
View raw message