Skip to content

invalid timestamp format in xunit reports #4378

Closed

Description

@cladstrife911

Hello,

Robot Framework 5.0
Python 3.6.8 on linux

I tried to import the xunit file generated by robot in a Polarion (Siemens) instance and reported an error on the timestamp format:

2022-06-22 11:26:54,985 [Worker-1: Import of test results to Test Run 0 -non-reg | u:a.m | job: xUnitFileImport] ERROR root  - Sorry, there was an error processing xUnit file unit.xml: java.text.ParseException: Unparseable date: "2022-06-21T12:51:45.440000+0000"
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "2022-06-21T12:51:45.440000+0000"
	at com.polarion.alm.tracker.internal.testing.XUnitFileProcessor$CreateHandler.startElement(XUnitFileProcessor.java:205)

Here is the guilty xunit report generated:

<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="No Regression Test" tests="2" errors="0" failures="1" skipped="0" time="630.511" timestamp="2022-06-21T12:51:45.440000">
<testcase classname="No Regression Test" name="MCP Launch Test" time="43.995">
</testcase>
<testcase classname="No Regression Test" name="SCP Launch Test" time="209.313">
<failure message="IsADirectoryError: [Errno 21] Is a directory: '/backend/workspacerunner/'" type="AssertionError"/>
</testcase>
</testsuite>

Here the fixed version:

<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="No Regression Test" tests="2" errors="0" failures="1" skipped="0" time="630.511" timestamp="2022-06-21T12:51:45">
<testcase classname="No Regression Test" name="MCP Launch Test" time="43.995">
</testcase>
<testcase classname="No Regression Test" name="SCP Launch Test" time="209.313">
<failure message="IsADirectoryError: [Errno 21] Is a directory: '/backend/workspacerunner/'" type="AssertionError"/>
</testcase>
</testsuite>

I'm not sure weither the issue is caused by the Polarion or by the robot but I can propose a pull request to bypass it in the src/robot/reporting/xunitwriter.py

Activity

  1. pekkaklarck commented on Jun 22, 2022

    @pekkaklarck
    Member

    This seems to be a bug in Polarion rather than in Robot. When timestamps were added in RF 5.0 (#4074), we decided to use the same 2021-11-01T10:02:24.107000 format that PyTest uses and that is also ISO-8601 compatible. Could you report this to Polarion and see what they think about it? I'm sure there are also other tools out there than Robot Framework and PyTest that they aren't compatible with if they don't support ISO-8601.

    The real root cause for this issue is the fact that there is no official standard for the xUnit file format.

  2. pekkaklarck commented on Jun 22, 2022

    @pekkaklarck
    Member

    We obviously could make Robot's xUnit output compatible with Polarion by dropping fractions of seconds. I don't think that's a good idea, though, because some consumers of these outputs may be interested in this information. It ought to be as easy to change Polarion so that it accepts valid ISO-8601 values and just throws away fractions if it doesn't need them.

    If this cannot be fixed in Polarion, a workaround for you is modifying the xUnit output file produced by Robot yourself or generating a custom one based on output.xml.

  3. cladstrife911 commented on Jun 22, 2022

    @cladstrife911
    Author

    Yes thx for your feedback and tips.
    I'll report to Polarion and probably create my own xunit file.

  4. rikerfi commented on Jun 23, 2022

    @rikerfi
    Contributor

    Hi @cladstrife911,
    I am writing xunit modifier which tackles problems like this. It is soon ready for publication. If you are interested, I could invite you to try it. Just let me know.

    Meanwhile, I made it public: https://github.com/rikerfi/robotframework-xunitmodifier

    I think, your interest goes here: https://github.com/rikerfi/robotframework-xunitmodifier/blob/86b38bff186a5cf7ad2ee28454d2b323c9a827dc/xom.py#L152

  5. cladstrife911 commented on Jun 28, 2022

    @cladstrife911
    Author

    Thx I wll have a look.

  6. pekkaklarck commented on Jun 28, 2022

    @pekkaklarck
    Member

    Did you get any comments from Polarion?

  7. cladstrife911 commented on Jun 30, 2022

    @cladstrife911
    Author

    Hello, If you search for "xunit" in the document below you can find an example for the expected format:
    https://almdemo.polarion.com/polarion/help/index.jsp?topic=%2Fcom.polarion.xray.doc.user%2Fguide%2Fxid1570730.html)

    <!-- An example with the correct formatting: "2021-07-12T17:55:34+0200" -->
    
  8. pekkaklarck commented on Jun 30, 2022

    @pekkaklarck
    Member

    Do you know do they have some source to backup the claim that 2021-07-12T17:55:34+0200 is the correct formatting? As I wrote above, a problem here is that AFAIK there's no official xUnit format standard, but the ISO-8601 accepts fractions of seconds and I also find them useful. It ought to be easy to update Polarion so that it supports them. It's much harder to get different tools to produce exactly the format they want.

  9. rikerfi commented on Jul 1, 2022

    @rikerfi
    Contributor

    Hi,
    Polarion is referring to JUnit schema which is maintained here.

    <xs:simpleType name="ISO8601_DATETIME_PATTERN">
    	<xs:restriction base="xs:dateTime">
    		<xs:pattern value="[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}"/>
    	</xs:restriction>
    </xs:simpleType>
    ...
    <xs:attribute name="timestamp" type="ISO8601_DATETIME_PATTERN" use="required">
    	<xs:annotation>
    		<xs:documentation xml:lang="en">when the test was executed. Timezone may not be specified.</xs:documentation>
    	</xs:annotation>
    </xs:attribute>

    Seems that timezone information is not favored. I think, to tackle this timezone problem I could write the Polarion variant of xunit output modifier. @cladstrife911 would you like to test that?

  10. pekkaklarck commented on Jul 1, 2022

    @pekkaklarck
    Member

    The restricting regexp is buggy because it doesn't accept fractions of seconds or timezone which are both part of the ISO-8601 that it claims to support. AFAIK xs:datetime itself would support ISO-8601 so a simple fix would be removing the whole regexp. The problem is, again, that there's no official xUnit XML standard.

    When such a standard is missing, it's especially important that tools follow the robustness principle and "be liberal in what you accept". It could be argued that Robot (and PyTest) should "be conservative in what they do", but not including a fractions of seconds would loose information and I don't think that's a good idea.

  11. cladstrife911 commented on Jul 13, 2022

    @cladstrife911
    Author

    Polarion added a ticket to their backlog to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions