HDFS-8915. TestFSNamesystem.testFSLockGetWaiterCount fails intermittently. Contributed by Masatake Iwasaki.

(cherry picked from commit 13fb1b50e608558b2970184908ee5b9fcd7eb7b6)
This commit is contained in:
Kihwal Lee 2016-08-26 10:01:19 -05:00
parent b952ce854b
commit 1c5ecb6cc4

View File

@ -30,6 +30,7 @@
import java.net.URI; import java.net.URI;
import java.util.Collection; import java.util.Collection;
import com.google.common.base.Supplier;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileUtil; import org.apache.hadoop.fs.FileUtil;
@ -57,6 +58,7 @@
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeoutException;
public class TestFSNamesystem { public class TestFSNamesystem {
@ -272,9 +274,16 @@ public void run() {
} }
latch.await(); latch.await();
Thread.sleep(10); // Lets all threads get BLOCKED try {
Assert.assertEquals("Expected number of blocked thread not found", GenericTestUtils.waitFor(new Supplier<Boolean>() {
threadCount, rwLock.getQueueLength()); @Override
public Boolean get() {
return (threadCount == rwLock.getQueueLength());
}
}, 10, 1000);
} catch (TimeoutException e) {
fail("Expected number of blocked thread not found");
}
} }
/** /**