testng-team / testng

TestNG testing framework
https://testng.org
Apache License 2.0
1.99k stars 1.02k forks source link

TestNG get java.lang.OutOfMemoryError: Java heap space ( OOME ) on testng-6.9.14-20161130 #1259

Open ghost opened 7 years ago

ghost commented 7 years ago

TestNG Version

Note: only the latest version is supported testng-6.9.14-20161130

Expected behavior

JLM_Tests_Suite Total tests run: 166, Failures: 0, Skips: 0

[TestNG] Time taken by org.testng.reporters.jq.Main@187c3681: 251 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@26e6de0: 55 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@e7896399: 57 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@e7798d62: 66 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@edcb7885: 27 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 0 ms

Actual behavior

JLM_Tests_Suite
Total tests run: 166, Failures: 0, Skips: 0
===============================================

[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@9d76475e: 106 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@95ff6bfa: 33 ms
JVMDUMP039I Processing dump event "systhrow", detail "java/lang/OutOfMemoryError" at 2016/12/02 19:46:00 - please wait.
JVMDUMP032I JVM requested System dump using '/tmp/bld_328360/core.20161202.194600.29058.0001.dmp' in response to an event
JVMPORT030W /proc/sys/kernel/core_pattern setting "|/usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t e" specifies that the core dump is to be piped to an external program.  Attempting to rename either core or core.29082.

JVMDUMP010I System dump written to /tmp/bld_328360/core.20161202.194600.29058.0001.dmp
JVMDUMP032I JVM requested Heap dump using '/tmp/bld_328360/heapdump.20161202.194600.29058.0002.phd' in response to an event
JVMDUMP010I Heap dump written to /tmp/bld_328360/heapdump.20161202.194600.29058.0002.phd
JVMDUMP032I JVM requested Java dump using '/tmp/bld_328360/javacore.20161202.194600.29058.0003.txt' in response to an event
JVMDUMP010I Java dump written to /tmp/bld_328360/javacore.20161202.194600.29058.0003.txt
JVMDUMP032I JVM requested Snap dump using '/tmp/bld_328360/Snap.20161202.194600.29058.0004.trc' in response to an event
JVMDUMP010I Snap dump written to /tmp/bld_328360/Snap.20161202.194600.29058.0004.trc
JVMDUMP013I Processed dump event "systhrow", detail "java/lang/OutOfMemoryError".
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at sun.nio.cs.StreamEncoder.write(java.base/StreamEncoder.java:144)
    at java.io.Writer.write(java.base/Writer.java:154)
    at java.io.OutputStreamWriter.append(java.base/OutputStreamWriter.java:297)
    at org.testng.reporters.FileStringBuffer.flushToFile(FileStringBuffer.java:115)
    at org.testng.reporters.FileStringBuffer.append(FileStringBuffer.java:51)
    at org.testng.reporters.FileStringBuffer.append(FileStringBuffer.java:28)
    at org.testng.reporters.XMLUtils.xmlClose(XMLUtils.java:115)
    at org.testng.reporters.XMLStringBuffer.pop(XMLStringBuffer.java:182)
    at org.testng.reporters.jq.BaseMultiSuitePanel.generate(BaseMultiSuitePanel.java:25)
    at org.testng.reporters.jq.Main.generateReport(Main.java:63)
    at org.testng.TestNG.generateReports(TestNG.java:1184)
    at org.testng.TestNG.run(TestNG.java:1109)
    at org.testng.TestNG.privateMain(TestNG.java:1434)
    at org.testng.TestNG.main(TestNG.java:1403)

Another failure on a different run and failed on different line (the third line.)

Expected behavior

JLM_Tests_Suite
Total tests run: 166, Failures: 0, Skips: 0
===============================================

[TestNG] Time taken by org.testng.reporters.jq.Main@187c3681: 251 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@26e6de0: 55 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@e7896399: 57 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@e7798d62: 66 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@edcb7885: 27 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 0 ms

Actual behavior

JLM_Tests_Suite
Total tests run: 166, Failures: 0, Skips: 0
===============================================

[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@7cfd766d: 132 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@1997b051: 185 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@97a2d45: 89 ms
JVMDUMP039I Processing dump event "systhrow", detail "java/lang/OutOfMemoryError" at 2016/12/02 19:46:25 - please wait.
JVMDUMP032I JVM requested System dump using '/tmp/bld_328360/core.20161202.194625.10223720.0001.dmp' in response to an event
JVMDUMP010I System dump written to /tmp/bld_328360/core.20161202.194625.10223720.0001.dmp
JVMDUMP032I JVM requested Heap dump using '/tmp/bld_328360/heapdump.20161202.194625.10223720.0002.phd' in response to an event
JVMDUMP010I Heap dump written to /tmp/bld_328360/heapdump.20161202.194625.10223720.0002.phd
JVMDUMP032I JVM requested Java dump using '/tmp/bld_328360/javacore.20161202.194625.10223720.0003.txt' in response to an event
JVMDUMP010I Java dump written to /tmp/bld_328360/javacore.20161202.194625.10223720.0003.txt
JVMDUMP032I JVM requested Snap dump using '/tmp/bld_328360/Snap.20161202.194625.10223720.0004.trc' in response to an event
JVMDUMP010I Snap dump written to /tmp/bld_328360/Snap.20161202.194625.10223720.0004.trc
JVMDUMP013I Processed dump event "systhrow", detail "java/lang/OutOfMemoryError".
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at sun.nio.cs.StreamEncoder.write(java.base/StreamEncoder.java:144)
        at java.io.Writer.write(java.base/Writer.java:154)
        at java.io.OutputStreamWriter.append(java.base/OutputStreamWriter.java:297)
        at org.testng.reporters.FileStringBuffer.flushToFile(FileStringBuffer.java:115)
        at org.testng.reporters.FileStringBuffer.append(FileStringBuffer.java:51)
        at org.testng.reporters.FileStringBuffer.append(FileStringBuffer.java:28)
        at org.testng.reporters.XMLUtils.xmlClose(XMLUtils.java:115)
        at org.testng.reporters.XMLStringBuffer.pop(XMLStringBuffer.java:182)
        at org.testng.reporters.jq.BaseMultiSuitePanel.generate(BaseMultiSuitePanel.java:25)
        at org.testng.reporters.jq.Main.generateReport(Main.java:63)
        at org.testng.TestNG.generateReports(TestNG.java:1184)
        at org.testng.TestNG.run(TestNG.java:1109)
        at org.testng.TestNG.privateMain(TestNG.java:1434)
        at org.testng.TestNG.main(TestNG.java:1403)

Is the issue reproductible on runner?

intermittent failure on shell

Test case sample

Please, share the test case (as small as possible) which shows the issue The OOME raised when the TestNG is generating the output. There are 166 test cases in the test suite, not sure which one is related to this OOME, but it is likely the TestNG itself raised this problem.

javacore.20161202.194600.29058.0003.txt

test-output.zip

ghost commented 7 years ago

Hi,

I was using "verbose = 2" in my testng.xml (this OOME wiil occur no matter in which verbose mode the testng is running) , so the exception and assertion can be shown in the console output.

I was wondering if this issue can be walked around by turning off the default reporters? And how can I turn off the default reporters?

EmailableReporter SuiteHTMLReporter XMLReporter JUnitReportReporter FailedReporter

jmetertea commented 6 years ago

turn off default reporters using:

myTestNG.setUseDefaultListeners(false);

See https://stackoverflow.com/questions/28041967/java-turn-off-testngs-default-reporters-programatically