[ https://issues.apache.org/jira/browse/HADOOP-16967?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17403129#comment-17403129 ]
Steve Loughran commented on HADOOP-16967: ----------------------------------------- unsure about this since getLocal retrieves the shared FS. Any other test in the same process -and remember, we do reuse the process- will get this. Prefer to just do a fs.delete(parentDir, true) in the finally clause > TestSequenceFile#testRecursiveSeqFileCreate fails in subsequent run > -------------------------------------------------------------------- > > Key: HADOOP-16967 > URL: https://issues.apache.org/jira/browse/HADOOP-16967 > Project: Hadoop Common > Issue Type: Bug > Components: common, test > Affects Versions: 3.2.1, 3.4.0 > Reporter: Ctest > Assignee: Ctest > Priority: Minor > Labels: easyfix, test > Fix For: 3.4.0 > > Attachments: HADOOP-16967.000.patch, HADOOP-16967.001.patch, > HADOOP-16967.002.patch > > > The test expects an IOException when creating a writer for file > `target/test/data/recursiveCreateDir/file` with `createParent=false`. And it > expects to create the writer successfully when `createParent=True`. > `createParent` means `create parent directory if non-existent`. > The test will pass if it is run for the first time, but it will fail for the > second run. This is because the test did not clean the parent directory > created during the first run. > The parent directory `recursiveCreateDir` was created, but it was not deleted > before the test finished. So, when the test was run again, it still treated > the parent directory `recursiveCreateDir` as non-existent and expected an > IOException from creating a writer with `createParent=false`. Then the test > did not get the expected IOException because `recursiveCreateDir` has been > created in the first test run. > {code:java} > @SuppressWarnings("deprecation") > @Test > public void testRecursiveSeqFileCreate() throws IOException { > FileSystem fs = FileSystem.getLocal(conf); > Path name = new Path(new Path(GenericTestUtils.getTempPath( > "recursiveCreateDir")), "file"); // FILE SUCCESSULLY CREATED HERE > boolean createParent = false; > try { > SequenceFile.createWriter(fs, conf, name, RandomDatum.class, > RandomDatum.class, 512, (short) 1, 4096, createParent, > CompressionType.NONE, null, new Metadata()); > fail("Expected an IOException due to missing parent"); > } catch (IOException ioe) { > // Expected > } > createParent = true; > SequenceFile.createWriter(fs, conf, name, RandomDatum.class, > RandomDatum.class, 512, (short) 1, 4096, createParent, > CompressionType.NONE, null, new Metadata()); > // should succeed, fails if exception thrown > } > {code} > Suggested patch: > > {code:java} > diff --git > a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java > > b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java > index 044824356ed..1aff2936264 100644 > --- > a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java > +++ > b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java > @@ -649,8 +649,9 @@ public void testCreateWriterOnExistingFile() throws > IOException { > @Test > public void testRecursiveSeqFileCreate() throws IOException { > FileSystem fs = FileSystem.getLocal(conf); > - Path name = new Path(new Path(GenericTestUtils.getTempPath( > - "recursiveCreateDir")), "file"); > + Path parentDir = new Path(GenericTestUtils.getTempPath( > + "recursiveCreateDir")); > + Path name = new Path(parentDir, "file"); > boolean createParent = false; > > try { > @@ -667,6 +668,9 @@ public void testRecursiveSeqFileCreate() throws > IOException { > RandomDatum.class, 512, (short) 1, 4096, createParent, > CompressionType.NONE, null, new Metadata()); > // should succeed, fails if exception thrown > + > + fs.deleteOnExit(parentDir); > + fs.close(); > } > > @Test{code} -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org