[
https://issues.apache.org/jira/browse/HADOOP-12610?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15035591#comment-15035591
]
Steve Loughran commented on HADOOP-12610:
-----------------------------------------
Thinking about this more, its not a dupe of HADOOP-12590; that's merely a
symptom of a problem which runs through a lot of the tests -and could be
addressed:
.h3 : Unit tests lose data when exceptions are caught and assertions made of it
there's lots of code fragments of the form
{code}
try {
something()
fail("something worked")
} catch( Exception ex) {
assertEquals("did not find user", ex.getMessage())
}
the assertion check here, as well as being brittle against changes in the
message (including the addition of extra details), loses that stack trace on a
failure. So all you get is some not-equals assertion, without anything about
what exception was actually raised.
{{GenericTestUtils.assertExceptionContains()}}, as of HADOOP-12472, nests the
original assertion in the failure string, so that the root cause is preserved.
Which means someone -—if they have the inclination— could go through the test
codebase, identify where the exception stacks are being lost, and fix them.
That's a big undertaking, but it could be done on a case by case basis.
Accordingly, how about we rename this issue "tests are losing exception stack
traces", and make 12590 an example of it?
> Make test failure messages more verbose and supportable
> -------------------------------------------------------
>
> Key: HADOOP-12610
> URL: https://issues.apache.org/jira/browse/HADOOP-12610
> Project: Hadoop Common
> Issue Type: Improvement
> Reporter: Wei-Chiu Chuang
> Assignee: Wei-Chiu Chuang
> Priority: Minor
> Labels: supportability
>
> I saw a test failure in TestCompressorDecompressor.testCompressorDecompressor
> with the output
> Error Message
> {noformat}
> testCompressorDecompressor error !!!java.lang.NullPointerException
> {noformat}
> Stacktrace
> {noformat}
> java.lang.AssertionError: testCompressorDecompressor error
> !!!java.lang.NullPointerException
> at org.junit.Assert.fail(Assert.java:88)
> at
> org.apache.hadoop.io.compress.TestCompressorDecompressor.testCompressorDecompressor(TestCompressorDecompressor.java:69)
> {noformat}
> However, this message does not expose the origin of the exception, nor does
> it print the error message. This makes debugging impossible. I also found the
> similar practice exists in multiple test files:
> {noformat}
> ~/hadoop/hadoop-common-project/hadoop-common ((c21a801...)) $ grep -r
> "fail(.*+ e" .|less
> ./src/test/java/org/apache/hadoop/net/TestNetworkTopologyWithNodeGroup.java:
> fail("Expecting IllegalArgumentException, but caught:" + e);
> ./src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java:
> fail("Got unexpected exception: " + e.getMessage());
> ./src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java:
> fail("Got unexpected exception: " + e.getMessage());
> ./src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java:
> fail("Got unexpected exception: " + e.getMessage());
> ./src/test/java/org/apache/hadoop/io/TestMapFile.java: fail("testRename
> error " + ex);
> ./src/test/java/org/apache/hadoop/io/compress/snappy/TestSnappyCompressorDecompressor.java:
> fail("testSnappyDirectBlockCompression ex !!!" + ex);
> ./src/test/java/org/apache/hadoop/io/compress/zlib/TestZlibCompressorDecompressor.java:
> fail("testCompressorDecompressor error !!!" + ex);
> ./src/test/java/org/apache/hadoop/io/compress/zlib/TestZlibCompressorDecompressor.java:
> fail("testCompressorDecompressorWithExeedBufferLimit error !!!" + ex);
> ./src/test/java/org/apache/hadoop/io/compress/zlib/TestZlibCompressorDecompressor.java:
> fail("testZlibCompressorDecompressorWithConfiguration ex error " +
> ex);
> ./src/test/java/org/apache/hadoop/io/compress/zlib/TestZlibCompressorDecompressor.java:
> fail("testZlibCompressDecompress ex !!!" + ex);
> ./src/test/java/org/apache/hadoop/io/compress/zlib/TestZlibCompressorDecompressor.java:
> fail("testZlibDirectCompressDecompress ex !!!" + ex);
> ./src/test/java/org/apache/hadoop/io/compress/zlib/TestZlibCompressorDecompressor.java:
> fail("testBuiltInGzipDecompressorExceptions npe error " + ex);
> ./src/test/java/org/apache/hadoop/io/compress/zlib/TestZlibCompressorDecompressor.java:
> fail("testBuiltInGzipDecompressorExceptions aioob error" + ex);
> ./src/test/java/org/apache/hadoop/io/compress/zlib/TestZlibCompressorDecompressor.java:
> fail("invalid 0 and 1 byte in gzip stream" + ex);
> ./src/test/java/org/apache/hadoop/io/compress/zlib/TestZlibCompressorDecompressor.java:
> fail("invalid 2 byte in gzip stream" + ex);
> ./src/test/java/org/apache/hadoop/io/compress/zlib/TestZlibCompressorDecompressor.java:
> fail("invalid 3 byte in gzip stream" + ex);
> ./src/test/java/org/apache/hadoop/io/compress/zlib/TestZlibCompressorDecompressor.java:
> fail("invalid 3 byte make hasExtraField" + ex);
> ./src/test/java/org/apache/hadoop/io/compress/TestCompressorDecompressor.java:
> fail("testCompressorDecompressor error !!!" + ex);
> ./src/test/java/org/apache/hadoop/io/compress/TestCompressorDecompressor.java:
> fail("testCompressorDecompressorWithExeedBufferLimit error !!!" + ex);
> ./src/test/java/org/apache/hadoop/io/compress/TestBlockDecompressorStream.java:
> fail("unexpected IOException : " + e);
> ./src/test/java/org/apache/hadoop/io/compress/bzip2/TestBzip2CompressorDecompressor.java:
> fail("testBzip2CompressDecompress ex !!!" + ex);
> ./src/test/java/org/apache/hadoop/util/bloom/BloomFilterCommonTester.java:
> Assert.fail("" + e);
> ./src/test/java/org/apache/hadoop/util/bloom/BloomFilterCommonTester.java:
> Assert.fail("" + e);
> ./src/test/java/org/apache/hadoop/util/bloom/BloomFilterCommonTester.java:
> Assert.fail("" + e);
> ./src/test/java/org/apache/hadoop/util/bloom/BloomFilterCommonTester.java:
> Assert.fail("" + e);
> ./src/test/java/org/apache/hadoop/util/bloom/BloomFilterCommonTester.java:
> Assert.fail("" + e);
> ./src/test/java/org/apache/hadoop/util/bloom/BloomFilterCommonTester.java:
> Assert.fail("" + e);
> ./src/test/java/org/apache/hadoop/util/bloom/BloomFilterCommonTester.java:
> Assert.fail("" + e);
> ./src/test/java/org/apache/hadoop/util/bloom/BloomFilterCommonTester.java:
> Assert.fail("" + e);
> ./src/test/java/org/apache/hadoop/util/bloom/BloomFilterCommonTester.java:
> Assert.fail("error ex !!!" + ex);
> ./src/test/java/org/apache/hadoop/util/TestShell.java: fail("Expected an
> exception with the text `" + expectedText + "`"
> ./src/test/java/org/apache/hadoop/util/TestShell.java: fail("Expected an
> exception with the text `" + expectedText + "`"
> ./src/test/java/org/apache/hadoop/tracing/SetSpanReceiver.java:
> Assert.fail("timed out to get expected spans: " + e.getMessage());
> ./src/test/java/org/apache/hadoop/tracing/SetSpanReceiver.java:
> Assert.fail("interrupted while waiting spans: " + e.getMessage());
> ./src/test/java/org/apache/hadoop/ipc/TestRPCCompatibility.java:
> fail("Expected version mismatch but got " + ex);
> ./src/test/java/org/apache/hadoop/ipc/TestRPC.java: fail("Expecting
> HadoopIllegalArgumentException but caught " + e);
> ./src/test/java/org/apache/hadoop/ipc/TestRPC.java: fail("Expecting
> HadoopIllegalArgumentException but caught " + e);
> ./src/test/java/org/apache/hadoop/ipc/TestRPC.java: fail("Expecting
> HadoopIllegalArgumentException but caught " + e);
> ./src/test/java/org/apache/hadoop/security/token/delegation/TestDelegationToken.java:
> Assert.fail("action did not throw " + except);
> {noformat}
> I am filing this JIRA to make failure messages more verbose and make
> debugging easier. There are of course similar patterns in other part of
> Hadoop codebase, but I am starting with this one because I do see test
> failures here.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)