Author: sradia
Date: Tue May 22 07:23:55 2012
New Revision: 1341330
URL: http://svn.apache.org/viewvc?rev=1341330&view=rev
Log:
HADOOP-8412 TestModTime, TestDelegationToken and TestAuthenticationToken
fali
intermittently on Windows (Ivan Mitic via Sanjay Radia)
Modified:
hadoop/common/branches/branch-1-win/CHANGES.txt
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/hdfs/TestModTime.java
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/server/TestAuthenticationToken.java
Modified: hadoop/common/branches/branch-1-win/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/CHANGES.txt?rev=1341330&r1=1341329&r2=1341330&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1-win/CHANGES.txt Tue May 22 07:23:55 2012
@@ -15,6 +15,9 @@ branch-hadoop-1-win - unreleased
MAPREDUCE-4204 Refactor ProcfsBasedProcessTree to make the resource
collection object pluggable (Bikas Saha via Sanjay)
+ HADOOP-8412 TestModTime, TestDelegationToken and TestAuthenticationToken
fail
+ intermittently on Windows (Ivan Mitic via Sanjay Radia)
+
Release 1.1.0 - unreleased
NEW FEATURES
Modified:
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/hdfs/TestModTime.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/hdfs/TestModTime.java?rev=1341330&r1=1341329&r2=1341330&view=diff
==============================================================================
---
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/hdfs/TestModTime.java
(original)
+++
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/hdfs/TestModTime.java
Tue May 22 07:23:55 2012
@@ -73,8 +73,9 @@ public class TestModTime extends TestCas
/**
* Tests modification time in DFS.
+ * @throws InterruptedException
*/
- public void testModTime() throws IOException {
+ public void testModTime() throws IOException, InterruptedException {
Configuration conf = new Configuration();
MiniDFSCluster cluster = new MiniDFSCluster(conf, numDatanodes, true,
null);
@@ -134,6 +135,8 @@ public class TestModTime extends TestCas
//
Path newfile = new Path(dir2, "testnew.dat");
System.out.println("Moving " + file1 + " to " + newfile);
+ // Sleep for a while to make sure modification time changes
+ Thread.sleep(20);
fileSys.rename(file1, newfile);
//
// verify that modification time of file1 did not change.
@@ -155,6 +158,7 @@ public class TestModTime extends TestCas
// delete newfile
//
System.out.println("Deleting testdir2/testnew.dat.");
+ Thread.sleep(20);
assertTrue(fileSys.delete(newfile, true));
//
// verify that modification time of testdir1 has not changed.
Modified:
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java?rev=1341330&r1=1341329&r2=1341330&view=diff
==============================================================================
---
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java
(original)
+++
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapreduce/security/token/delegation/TestDelegationToken.java
Tue May 22 07:23:55 2012
@@ -86,7 +86,7 @@ public class TestDelegationToken {
System.out.println("create time: " + createTime);
System.out.println("current time: " + currentTime);
System.out.println("max time: " + maxTime);
- assertTrue("createTime < current", createTime < currentTime);
+ assertTrue("createTime <= current", createTime <= currentTime);
assertTrue("current < maxTime", currentTime < maxTime);
client.renewDelegationToken(token);
client.renewDelegationToken(token);
Modified:
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/server/TestAuthenticationToken.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/server/TestAuthenticationToken.java?rev=1341330&r1=1341329&r2=1341330&view=diff
==============================================================================
---
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/server/TestAuthenticationToken.java
(original)
+++
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/security/authentication/server/TestAuthenticationToken.java
Tue May 22 07:23:55 2012
@@ -18,6 +18,11 @@ import junit.framework.TestCase;
public class TestAuthenticationToken extends TestCase {
+ // System.currentTimeMillis has a 15ms resolution on Windows. Allowing
+ // latency of up to twice the resolution in the test.
+ public static long currentTimeMillisError =
+ System.getProperty("os.name").startsWith("Windows") ? 30 : 1;
+
public void testAnonymous() {
assertNotNull(AuthenticationToken.ANONYMOUS);
assertEquals(null, AuthenticationToken.ANONYMOUS.getUserName());
@@ -88,7 +93,7 @@ public class TestAuthenticationToken ext
assertEquals("t", token.getType());
assertEquals(expires, token.getExpires());
assertFalse(token.isExpired());
- Thread.sleep(51);
+ Thread.sleep(50 + TestAuthenticationToken.currentTimeMillisError);
assertTrue(token.isExpired());
}
@@ -102,7 +107,7 @@ public class TestAuthenticationToken ext
assertEquals("t", token.getType());
assertEquals(expires, token.getExpires());
assertFalse(token.isExpired());
- Thread.sleep(51);
+ Thread.sleep(50 + TestAuthenticationToken.currentTimeMillisError);
assertTrue(token.isExpired());
}