You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Ctest (Jira)" <ji...@apache.org> on 2020/04/10 22:02:00 UTC
[jira] [Created] (HADOOP-16967)
TestSequenceFile#testRecursiveSeqFileCreate failed to clean its data caused
failures in subsequent run
Ctest created HADOOP-16967:
------------------------------
Summary: TestSequenceFile#testRecursiveSeqFileCreate failed to clean its data caused failures 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
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-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org