JUnit feature should be able to parse JUnit.xml files with large nodes
Problem
As a developer (Sasha) when a JUnit XML file is created by my pipeline that contains very large system-output nodes (8MB +), I want the JUnit report to parse correctly so that I can see the output of my tests without downloading the file to view outside of GitLab.
Right now when there is one or more very large <system-out>
nodes in the JUnit report, nokogiri cannot successfully parse the XML file, and it throws an error to the UI.
Proposal
Extremely large nodes that might contain useful output sometimes fail to parse successfully. The attached file in this comment #25357 (comment 275846278) contains a single test run with an extremely large <system-out>
node. There may be value for some customers to have large outputs in their tests like this, and surfacing it partially or fully in the UI may add value.
The purpose of this issue is to add a setting in the /admin/application_settings/ci_cd
page to enable the nokogiri "huge" setting for Junit report parsing.
> Nokogiri::XML.parse(File.open("large.xml")).root.children.first.text.length
=> 9999894
> puts Nokogiri::XML.parse(File.open("large.xml")).errors
xmlSAX2Characters: huge text node
Extra content at the end of the document
... add the huge
option ...
> Nokogiri::XML.parse(File.open("large.xml")) {|c| c.huge}.root.children.first.text.length
=> 14065665
> puts Nokogiri::XML.parse(File.open("large.xml")) {|c| c.huge}.errors
=> nil
Stumbled across this here
Risks may be present in performance/memory usage, we should make note of that around the setting, and it should be defaulted to OFF.
Further Questions
Some questions that come to mind are:
- What is the maximum useful node size for
<system-out>
nodes? - Should we be treating
<system-out>
nodes in Junit.xml differently than other nodes because they may contain stack traces, etc? - Can we truncate the node and read the
tail
? Would thehead
make more sense? - If we do surface truncated data should we put a link to download the full report in the UI?
I'm running a CI/CD pipeline with a JUnit step, and I'd expect to have something like this image. This is what I'm seeing, even if my test actually failed. Setup this stage in your pipeline: The file in question is > 9.75MB and files smaller seem to be fine. See example file in comment below. I'm on a private instance, can't share anything. With a failed test I'm still seeing a green checkmark, and I'm not seeing test's names but only the stage that launched them. I'd expect to see something like this image, with my test name and status for each executed unit test. Uploading artifacts... target/surefire-reports/TEST-*.xml: found 1 matching files Uploading artifacts to coordinator... ok id=4253 responseStatus=201 Created token=zGhSmVnj ERROR: Job failed: exit code 1 (If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com) I'm not an admin on this instance so I can't provide more informations on that. I'm not an admin on this instance so I can't provide more informations on that.
Original Issue Content
Summary
Steps to reproducefeature_integration_tests:
stage: unit_tests
<<: *base_image
only:
- /^feature\/*/
script:
- mvn $MAVEN_CLI_OPTS verify
artifacts:
reports:
junit:
- target/surefire-reports/TEST-*.xml
Example Project
What is the current bug behavior?
What is the expected correct behavior?
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Results of GitLab application Check
Possible fixes / Plan to fix