HADOOP-14752. TestCopyFromLocal#testCopyFromLocalWithThreads is fleaky. Contributed by Andras Bokor.
This commit is contained in:
parent
ceca9694f9
commit
442ea85545
|
@ -115,10 +115,10 @@ public class TestCopyFromLocal {
|
||||||
Path dir = new Path("dir" + RandomStringUtils.randomNumeric(4));
|
Path dir = new Path("dir" + RandomStringUtils.randomNumeric(4));
|
||||||
int numFiles = TestCopyFromLocal.initialize(dir);
|
int numFiles = TestCopyFromLocal.initialize(dir);
|
||||||
int maxThreads = Runtime.getRuntime().availableProcessors() * 2;
|
int maxThreads = Runtime.getRuntime().availableProcessors() * 2;
|
||||||
int randThreads = RandomUtils.nextInt(maxThreads);
|
int randThreads = RandomUtils.nextInt(maxThreads - 1) + 1;
|
||||||
int numActualThreads = randThreads == 0 ? 1 : randThreads;
|
String numThreads = Integer.toString(randThreads);
|
||||||
String numThreads = Integer.toString(numActualThreads);
|
run(new TestMultiThreadedCopy(randThreads,
|
||||||
run(new TestMultiThreadedCopy(numActualThreads, numFiles), "-t", numThreads,
|
randThreads == 1 ? 0 : numFiles), "-t", numThreads,
|
||||||
new Path(dir, FROM_DIR_NAME).toString(),
|
new Path(dir, FROM_DIR_NAME).toString(),
|
||||||
new Path(dir, TO_DIR_NAME).toString());
|
new Path(dir, TO_DIR_NAME).toString());
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,7 @@ public class TestCopyFromLocal {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestMultiThreadedCopy extends CopyFromLocal {
|
private class TestMultiThreadedCopy extends CopyFromLocal {
|
||||||
|
public static final String NAME = "testCopyFromLocal";
|
||||||
private int expectedThreads;
|
private int expectedThreads;
|
||||||
private int expectedCompletedTaskCount;
|
private int expectedCompletedTaskCount;
|
||||||
|
|
||||||
|
@ -164,9 +165,9 @@ public class TestCopyFromLocal {
|
||||||
// 2) There are no active tasks in the executor
|
// 2) There are no active tasks in the executor
|
||||||
// 3) Executor has shutdown correctly
|
// 3) Executor has shutdown correctly
|
||||||
ThreadPoolExecutor executor = getExecutor();
|
ThreadPoolExecutor executor = getExecutor();
|
||||||
Assert.assertEquals(executor.getCompletedTaskCount(),
|
Assert.assertEquals(expectedCompletedTaskCount,
|
||||||
expectedCompletedTaskCount);
|
executor.getCompletedTaskCount());
|
||||||
Assert.assertEquals(executor.getActiveCount(), 0);
|
Assert.assertEquals(0, executor.getActiveCount());
|
||||||
Assert.assertTrue(executor.isTerminated());
|
Assert.assertTrue(executor.isTerminated());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue