From 7e820b9965d2bf693a2f0c0c59a7cb23aa6169b3 Mon Sep 17 00:00:00 2001 From: Chris Nauroth Date: Sat, 26 Oct 2013 04:25:50 +0000 Subject: [PATCH] HADOOP-10072. TestNfsExports#testMultiMatchers fails due to non-deterministic timing around cache expiry check. Contributed by Chris Nauroth. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1535918 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../java/org/apache/hadoop/nfs/TestNfsExports.java | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 1ebdfa426a9..636a10a3ad1 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -449,6 +449,9 @@ Release 2.2.1 - UNRELEASED HADOOP-10055. FileSystemShell.apt.vm doc has typo "numRepicas". (Akira Ajisaka via cnauroth) + HADOOP-10072. TestNfsExports#testMultiMatchers fails due to non-deterministic + timing around cache expiry check. (cnauroth) + Release 2.2.0 - 2013-10-13 INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/TestNfsExports.java b/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/TestNfsExports.java index 9acb29e589a..30b6ff932ae 100644 --- a/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/TestNfsExports.java +++ b/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/TestNfsExports.java @@ -35,6 +35,7 @@ public class TestNfsExports { Nfs3Constant.EXPORTS_CACHE_EXPIRYTIME_MILLIS_DEFAULT * 1000 * 1000; private static final int CacheSize = Nfs3Constant.EXPORTS_CACHE_SIZE_DEFAULT; + private static final long NanosPerMillis = 1000000; @Test public void testWildcardRW() { @@ -185,7 +186,15 @@ public class TestNfsExports { Thread.sleep(1000); // no cache for address2 now - Assert.assertEquals(AccessPrivilege.NONE, - matcher.getAccessPrivilege(address2, address2)); + AccessPrivilege ap; + long startNanos = System.nanoTime(); + do { + ap = matcher.getAccessPrivilege(address2, address2); + if (ap == AccessPrivilege.NONE) { + break; + } + Thread.sleep(500); + } while ((System.nanoTime() - startNanos) / NanosPerMillis < 5000); + Assert.assertEquals(AccessPrivilege.NONE, ap); } }