Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploading testcase leads to TypeError: unsupported operand type(s) for +: 'NoneType' and 'datetime.timedelta' #89

Closed
michaelkaye opened this issue Apr 4, 2023 · 3 comments

Comments

@michaelkaye
Copy link
Contributor

Was just testing out the 12.2 version of the junit.xml-plugin and got this:

https://github.com/michaelkaye/throwaway-test-repo/actions/runs/4609146419/jobs/8145874766

#88 may have introduced this.

Traceback (most recent call last):
  File "/home/runner/.local/bin/tcms-junit.xml-plugin", line 9, in <module>
    main(sys.argv)
  File "/home/runner/.local/lib/python3.10/site-packages/tcms_junit_plugin/__init__.py", line 179, in main
    plugin.parse(getattr(args, "filename.xml"))
  File "/home/runner/.local/lib/python3.10/site-packages/tcms_junit_plugin/__init__.py", line 140, in parse
    start_date, stop_date = self.testexecution_timestamps(xml_case)
  File "/home/runner/.local/lib/python3.10/site-packages/tcms_junit_plugin/__init__.py", line 75, in testexecution_timestamps
    stop_date = start_date + timedelta(seconds=xml_case.time)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'datetime.timedelta'

I'm guessing this is because the data is as so - https://github.com/michaelkaye/throwaway-test-repo/blob/main/junit-files/results-3d58a84d7a978de29ba10f2a6c03d7bf.xml

The timestamp is on the testSuite; the testCases have time (durations) but no individual timestamp. Who knows what the 'correct' format should be, but maybe we should be a bit defensive against bad requests.

@michaelkaye
Copy link
Contributor Author

I could have a go at merging times from the TestSuite into the TestCases, if that's what is wanted. I do want the actual times ending up in kiwi; it's better than having the timings (which are normally over ~15min for a test run) batched up into a few milliseconds.

@atodorov
Copy link
Member

atodorov commented Apr 4, 2023

The timestamp is on the testSuite; the testCases have time (durations) but no individual timestamp. Who knows what the 'correct' format should be, but maybe we should be a bit defensive against bad requests.

Sigh. The joy of having a "standard format" where nobody knows that the standard is.

Being defensive here is an easy fix which effectively negates the entire new functionality b/c Kiwi TCMS understands start_date & stop_date and the current information within the <testsuite> tag is currently lost during parsing. If we don't have the start time we can't set the stop time either.

I will add this issue on the backlog + a reference to the current XML file for further investigation.

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="73.132" tests="4" failures="0">
  <testsuite name="" timestamp="2023-03-06T13:18:40" tests="0" file="cypress/e2e/integration-manager/send_event.spec.ts" time="0.000" failures="0">
  </testsuite>
  <testsuite name="Root Suite Integration Manager: Send Event" timestamp="2023-03-06T13:18:40" tests="4" time="73.081" failures="0">
    <testcase name="Integration Manager: Send Event should send a state event" time="21.077" classname="should send a state event">
    </testcase>
    <testcase name="Integration Manager: Send Event should send a state event with empty content" time="16.205" classname="should send a state event with empty content">
    </testcase>
    <testcase name="Integration Manager: Send Event should send a state event with empty state key" time="16.372" classname="should send a state event with empty state key">
    </testcase>
    <testcase name="Integration Manager: Send Event should fail to send an event type which is not allowed" time="16.032" classname="should fail to send an event type which is not allowed">
    </testcase>
  </testsuite>
</testsuites>

@atodorov
Copy link
Member

atodorov commented Apr 4, 2023

I could have a go at merging times from the TestSuite into the TestCases, if that's what is wanted. I do want the actual times ending up in kiwi; it's better than having the timings (which are normally over ~15min for a test run) batched up into a few milliseconds.

Feel free to give it a try.

What's needed here IMO is properly looping over testsuite's instead of jumping over them and then after that's in place we can make a go at supporting the timestamps feature by passing the starting value from the testsuite tag.

atodorov added a commit that referenced this issue Apr 17, 2023
atodorov added a commit that referenced this issue Apr 17, 2023
also changes the signature of ``testexecution_timestamps()`` method
in backwards incompatible way
atodorov added a commit that referenced this issue Apr 17, 2023
also changes the signature of ``testexecution_timestamps()`` method
in backwards incompatible way
atodorov added a commit that referenced this issue Apr 18, 2023
- introduces parse_timestamp() method
- changes the signature of ``testexecution_timestamps()`` method
  in backwards incompatible way
atodorov added a commit that referenced this issue Apr 18, 2023
- introduces parse_timestamp() method
- changes the signature of ``testexecution_timestamps()`` method
  in backwards incompatible way
atodorov added a commit that referenced this issue Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants