MAPREDUCE-7011. TestClientDistributedCacheManager::testDetermineCacheVisibilities assumes all parent dirs set other exec

This commit is contained in:
Chris Douglas 2017-11-21 20:42:28 -08:00
parent 03c311eae3
commit 782ba3bf9d
1 changed files with 18 additions and 10 deletions

View File

@ -34,12 +34,15 @@
import org.apache.hadoop.io.SequenceFile.CompressionType;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.MRJobConfig;
import org.junit.After;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -97,15 +100,15 @@ public void testDetermineTimestamps() throws IOException {
FileStatus firstStatus = statCache.get(firstCacheFile.toUri());
FileStatus secondStatus = statCache.get(secondCacheFile.toUri());
Assert.assertNotNull(firstCacheFile + " was not found in the stats cache",
assertNotNull(firstCacheFile + " was not found in the stats cache",
firstStatus);
Assert.assertNotNull(secondCacheFile + " was not found in the stats cache",
assertNotNull(secondCacheFile + " was not found in the stats cache",
secondStatus);
Assert.assertEquals("Missing/extra entries found in the stas cache",
assertEquals("Missing/extra entries found in the stats cache",
2, statCache.size());
String expected = firstStatus.getModificationTime() + ","
+ secondStatus.getModificationTime();
Assert.assertEquals(expected, jobConf.get(MRJobConfig.CACHE_FILE_TIMESTAMPS));
assertEquals(expected, jobConf.get(MRJobConfig.CACHE_FILE_TIMESTAMPS));
job = Job.getInstance(conf);
job.addCacheFile(new Path(TEST_VISIBILITY_CHILD_DIR, "*").toUri());
@ -115,12 +118,12 @@ public void testDetermineTimestamps() throws IOException {
FileStatus thirdStatus = statCache.get(TEST_VISIBILITY_CHILD_DIR.toUri());
Assert.assertEquals("Missing/extra entries found in the stas cache",
assertEquals("Missing/extra entries found in the stats cache",
1, statCache.size());
Assert.assertNotNull(TEST_VISIBILITY_CHILD_DIR
assertNotNull(TEST_VISIBILITY_CHILD_DIR
+ " was not found in the stats cache", thirdStatus);
expected = Long.toString(thirdStatus.getModificationTime());
Assert.assertEquals("Incorrect timestamp for " + TEST_VISIBILITY_CHILD_DIR,
assertEquals("Incorrect timestamp for " + TEST_VISIBILITY_CHILD_DIR,
expected, jobConf.get(MRJobConfig.CACHE_FILE_TIMESTAMPS));
}
@ -141,6 +144,11 @@ public void testDetermineCacheVisibilities() throws IOException {
job.addCacheFile(relativePath.toUri());
jobConf = job.getConfiguration();
// skip test if scratch dir is not PUBLIC
assumeTrue(TEST_VISIBILITY_PARENT_DIR + " is not public",
ClientDistributedCacheManager.isPublic(
jobConf, TEST_VISIBILITY_PARENT_DIR.toUri(), statCache));
ClientDistributedCacheManager.determineCacheVisibilities(jobConf,
statCache);
// We use get() instead of getBoolean() so we can tell the difference