JUnit test reporting incorrect duration
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
JUnit test report with time="1,038.628" is reported as 1.00s in Pipeline => Tests view
Steps to reproduce
- New Project
- Add example report as
rspec.xml .gitlab-ci.ymlwithjunit: rspec.xml
- Add example report as
- Run Pipeline
- View Pipeline Tests
Example Report
<?xml version="1.0" encoding="UTF-8"?>
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="test" time="1,043.988" tests="1" errors="0" skipped="0" failures="0">
<properties>
</properties>
<testcase name="TestCase" classname="TestCaseClass" time="1,038.628">
<system-out><![CDATA[DEBUG INFO]]></system-out>
<system-err><![CDATA[ERROR INFO]]></system-err>
</testcase>
</testsuite>
Reproduced on 15.1.2,15.3.3 and GitLab.com
Example Project
Example Project / Reproduced Issue test project here: https://gitlab.com/davinwalker/324182-junit-duration-test https://gitlab.com/davinwalker/324182-junit-duration-test/-/pipelines/635028183/test_report
What is the current bug behavior?
Report is showing duration of 1.00s
Relevant logs and/or screenshots
Root cause
Ruby's String#to_f doc:
Returns the result of interpreting leading characters in str as a floating point number. Extraneous characters past the end of a valid number are ignored.
In this case, , is considered extraneous characters and anything beyond that is ignored.
Proposal
The execution_time in TestCase needs to be able to parse various formats of a float-like string. https://gitlab.com/gitlab-org/gitlab/blob/a33cecb92208a43d99936d77744d4e1250493f90/lib/gitlab/ci/reports/test_case.rb#L20-20
Implementation notes:
- Look for any existing utility methods in
Gitlab::Utilsto parse a string into float that we can reuse in the codebase before creating a new one.
Related Issues / Links
- Prior issue with test execution time problem: #26247 (closed)
- ZD Internal Link
