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

Add support for subresults (experimental flavor) to junit report plugin #3177

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

seberm
Copy link
Collaborator

@seberm seberm commented Aug 28, 2024

This PR adds a subresults junit report plugin flavor to show the tmt.result.SubResult instances within the tmt.Result. It tries to map the tmt.Result to <testsuite> and tmt.result.SubResult to <testcase> respectively.

Discussion from 10.9. 2024:

This flavor will be probably used by testing-farm to generate the results-junit.xml in the future.

There are two results files in Testing Farm:

  • results.xml (converted from tmt’s results.yaml)
  • results-junit.xml (in the future should be generated by tmt)

For more info see:

Related to:

TODO:

Pull Request Checklist

  • implement the feature
  • write the documentation
  • extend the test coverage
  • update the specification
  • adjust plugin docstring
  • modify the json schema
  • mention the version
  • include a release note

@seberm seberm added step | report Stuff related to the report step plugin | junit The junit report plugin labels Aug 28, 2024
@seberm seberm self-assigned this Aug 28, 2024
@seberm seberm changed the base branch from main to feature/generate-junit-using-jinja August 28, 2024 21:30
@seberm seberm force-pushed the feature/generate-junit-using-jinja branch 2 times, most recently from 4eef028 to a42e26a Compare August 29, 2024 12:26
@seberm seberm force-pushed the feature/generate-junit-using-jinja branch 2 times, most recently from 0ac068f to 81b54df Compare August 29, 2024 13:43
@seberm seberm force-pushed the feature/generate-junit-using-jinja branch from 81b54df to 7ee6f13 Compare September 2, 2024 11:08
@seberm seberm force-pushed the feature/generate-junit-using-jinja branch 6 times, most recently from 0d2969b to 8554165 Compare September 3, 2024 13:19
@seberm
Copy link
Collaborator Author

seberm commented Sep 3, 2024

@kkaarreell Hello,
I am studying various formats of JUnit. In this PR, I created a new subresults JUnit flavor with nested <testsuite> elements. Unfortunately, it seems that the <testsuite> elements cannot contain the same elements as <testcase> - especially tags like <error>, <failure>, and <skipped>. At least according to these specs/examples:

This basically means if there are failed/skipped/... tests that do not contain any subresults, we will be unable to export their result. This probably means that all the <testsuite> elements should contain <testcase> elements and we must somehow create a test hierarchy using class attributes.

The example of the currently generated JUnit subresults flavor:

<?xml version='1.0' encoding='utf-8'?>
<testsuites disabled="0" errors="0" failures="1" tests="3" time="0">
  <testsuite name="/tests/call-dmesg" disabled="0" errors="0" failures="0" skipped="0" tests="0" time="0" timestamp="2024-08-13T12:00:22.022008+00:00">
  </testsuite>
  <testsuite name="/tests/mine-rep-multi" disabled="0" errors="1" failures="1" skipped="0" tests="3" time="0" timestamp="2024-08-13T12:00:22.881823+00:00">
    <testcase name="/tests/mine-rep-multi/test/good">
    </testcase>
    <testcase name="/tests/mine-rep-multi/test/fail">
      <failure type="failure" message="fail"/>
    </testcase>
    <testcase name="/tests/mine-rep-multi/test/weird">
      <error type="error" message="warn"/>
    </testcase>
  </testsuite>
  <testsuite name="/tests/mine-rep-pass" disabled="0" errors="0" failures="0" skipped="0" tests="0" time="0" timestamp="2024-08-13T12:00:23.752135+00:00">
  </testsuite>
</testsuites>

Any hints / ideas?

@happz
Copy link
Collaborator

happz commented Sep 3, 2024

Maybe we could always include at least one testcase, representing the test itself?

@kkaarreell
Copy link
Collaborator

Hi @seberm ,
I think we have been discussing this topic in one of the mtgs. You are right that jUnit doesn't allow nested testsuites and therefore jUnit won't be able to implement this feature. There was a proposal to identify which parts of the pipeline (which apps, scripts etc.) would be using this "per-phase" reporting and based on this findings implement changes in tmt. Maybe we would end up producing brand new output file for this.

@seberm seberm force-pushed the feature/generate-junit-using-jinja branch 2 times, most recently from 222008f to 9ee1638 Compare September 6, 2024 09:15
@seberm seberm force-pushed the feature/generate-junit-using-jinja branch from 9ee1638 to e613189 Compare September 6, 2024 11:35
@seberm
Copy link
Collaborator Author

seberm commented Sep 9, 2024

Maybe we could always include at least one testcase, representing the test itself?

Yeah, I had the same idea - I did the modifications. The output is now:

<?xml version='1.0' encoding='utf-8'?>
<testsuites disabled="0" errors="0" failures="1" tests="3" time="0">
  <testsuite name="/tests/call-dmesg" disabled="0" errors="0" failures="0" skipped="0" tests="0" time="0" timestamp="2024-08-13T12:00:22.022008+00:00">
      <testcase name="/tests/call-dmesg">
      </testcase>
  </testsuite>

  <testsuite name="/tests/mine-rep-multi" disabled="0" errors="1" failures="1" skipped="0" tests="3" time="0" timestamp="2024-08-13T12:00:22.881823+00:00">
    <testcase name="/tests/mine-rep-multi">
      <failure type="failure" message="fail"/>
    </testcase>
    <testcase name="/tests/mine-rep-multi/test/good">
    </testcase>
    <testcase name="/tests/mine-rep-multi/test/fail">
      <failure type="failure" message="fail"/>
    </testcase>
    <testcase name="/tests/mine-rep-multi/test/weird">
      <error type="error" message="warn"/>
    </testcase>
  </testsuite>

  <testsuite name="/tests/mine-rep-pass" disabled="0" errors="0" failures="0" skipped="0" tests="0" time="0" timestamp="2024-08-13T12:00:23.752135+00:00">
    <testcase name="/tests/mine-rep-pass">
    </testcase>
  </testsuite>
</testsuites>

And now we need to test against the various systems/scripts which would be using this flavor. E.g. ReportPortal.

@kkaarreell
Copy link
Collaborator

I am sorry but this seems like introducing yet another jUnit format. What tools are expected to work such a XML file? Why not introducing new report plugin for it?

@seberm
Copy link
Collaborator Author

seberm commented Sep 9, 2024

I am sorry but this seems like introducing yet another jUnit format. What tools are expected to work such a XML file? Why not introducing new report plugin for it?

You’re basically right. It is another JUnit format. That’s why it’s implemented as an optional template/flavor (see #3150 for more info).

The challenge is that different systems (GitLab, Jenkins, ReportPortal, Polarion) support slightly different variants of JUnit formats. While these formats are largely similar, there are small differences. The current JUnit report plugin only supports a single, non-customizable JUnit "default" flavor. The changes in #3150 introduce support for custom flavors, allowing users to provide their own JUnit templates.

The motivation for this PR is that we plan to add support for tmt subresults and we need to have (based on requirements from Jira ticket) the ability to export subresults into the JUnit format.

I don’t think we need to merge this and officially support the format, but we should at least ensure that generating this kind of JUnit file is possible. I'll reach out to the people from the Jira ticket and try to clarify their specific needs and ask them for testing.

@happz happz force-pushed the feature/generate-junit-using-jinja branch from e613189 to d8c650a Compare September 10, 2024 09:05
@seberm seberm force-pushed the feature/generate-junit-using-jinja branch from d8c650a to 49a0604 Compare September 11, 2024 09:24
@seberm seberm force-pushed the feature/junit-subresults branch 2 times, most recently from c260ec0 to 844cf51 Compare September 12, 2024 07:17
@seberm seberm force-pushed the feature/generate-junit-using-jinja branch from 49a0604 to 597e000 Compare September 12, 2024 11:32
@happz happz force-pushed the feature/generate-junit-using-jinja branch from 597e000 to 38c9d87 Compare September 12, 2024 13:01
Base automatically changed from feature/generate-junit-using-jinja to main September 13, 2024 16:29
Define an experimental junit flavor for subresults.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin | junit The junit report plugin step | report Stuff related to the report step
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants