hadoop-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ion Barcan <ion.bar...@gmail.com>
Subject Conflicting mkdirs() behavior in abstract test classes from Hadoop Common
Date Tue, 23 Oct 2012 14:05:05 GMT
Hi,

I have a question related to 2 tests classes found in Hadoop Common
(both 1.0.4 and 1.1.0): FileSystemContractBaseTest.java and
FSMainOperationsBaseTest.java - which (as I understand) one could use
to verify that a specific FileSystem implementation does what it's
supposed to do.

I'm a bit puzzled by the method
testMkdirsFailsForSubdirectoryOfExistingFile() that is defined in both
places. To me it looks like they're contradicting one another, i.e.
one expects FileSystem.mkdirs() to fail if it encounters an existing
file, the other expects FileSystem.mkdirs() to return false in the
same situation. Which one is right? FileSystemContractBaseTest has 8
implementors as opposed to FSMainOperationsBaseTest which only has 2 -
but I still think this should be sorted out. For reference I've pasted
the source code at the end of message.

Thanks,
Ion

* FileSystemContractBaseTest.java
    118   public void testMkdirsFailsForSubdirectoryOfExistingFile()
throws Exception {
    119     Path testDir = path("/test/hadoop");
    120     assertFalse(fs.exists(testDir));
    121     assertTrue(fs.mkdirs(testDir));
    122     assertTrue(fs.exists(testDir));
    123
    124     createFile(path("/test/hadoop/file"));
    125
    126     Path testSubDir = path("/test/hadoop/file/subdir");
    127     try {
    128       fs.mkdirs(testSubDir);
    129       fail("Should throw IOException.");
    130     } catch (IOException e) {
    131       // expected
    132     }
    133     assertFalse(fs.exists(testSubDir));
    134
    135     Path testDeepSubDir = path("/test/hadoop/file/deep/sub/dir");
    136     try {
    137       fs.mkdirs(testDeepSubDir);
    138       fail("Should throw IOException.");
    139     } catch (IOException e) {
    140       // expected
    141     }
    142     assertFalse(fs.exists(testDeepSubDir));
    143
    144   }

* FSMainOperationsBaseTest.java
    198   @Test
    199   public void testMkdirsFailsForSubdirectoryOfExistingFile()
throws Exception {
    200     Path testDir = getTestRootPath(fSys, "test/hadoop");
    201     Assert.assertFalse(exists(fSys, testDir));
    202     fSys.mkdirs(testDir);
    203     Assert.assertTrue(exists(fSys, testDir));
    204
    205     createFile(getTestRootPath(fSys, "test/hadoop/file"));
    206
    207     Path testSubDir = getTestRootPath(fSys, "test/hadoop/file/subdir");
    208     Assert.assertFalse(fSys.mkdirs(testSubDir));
    209     Assert.assertFalse(exists(fSys, testSubDir));
    210
    211     Path testDeepSubDir = getTestRootPath(fSys,
"test/hadoop/file/deep/sub/dir");
    212     Assert.assertFalse(exists(fSys, testSubDir));
    213     Assert.assertFalse(fSys.mkdirs(testDeepSubDir));
    214     Assert.assertFalse(exists(fSys, testDeepSubDir));
    215
    216   }

Mime
View raw message