Skip to content

Cleaned up JUnit report generation on install#6977

Merged
tgamblin merged 2 commits intospack:developfrom
epfl-scitas:refactoring/cleanup_junit
Jan 28, 2018
Merged

Cleaned up JUnit report generation on install#6977
tgamblin merged 2 commits intospack:developfrom
epfl-scitas:refactoring/cleanup_junit

Conversation

@alalazo
Copy link
Copy Markdown
Member

@alalazo alalazo commented Jan 17, 2018

The generation of a JUnit report was previously part of the install command. This commit factors the logic into its own module, and uses a template for the generation of the report.

It also improves report generation, that now can deal with multiple specs installed at once. Finally, extending the list of supported formats is much easier than before, as it entails just writing a new template.

refers #2917

Example

Running this command:

spack install --log-format=junit --log-file=hdf5.xml szip  hdf5+szip~mpi tar

produces the following file:

<?xml version="1.0" encoding="UTF-8"?>
<!--
    This file has been modeled after the basic
    specifications at this url:

    http://help.catchsoftware.com/display/ET/JUnit+Format
-->
<testsuites>
    <testsuite name="libszip_qabk3nm"
               errors="0"
               tests="1"
               failures="0"
               time="5.741205215454102"
               timestamp="Thu, 18 Jan 2018 07:41:18" >
        <properties>
            <property name="architecture" value="linux-ubuntu14.04-x86_64" />
            <property name="compiler" value="[email protected]" />
        </properties>
        <testcase classname="libszip"
                  name="qabk3nme2645mmbpaqv7zbraddgv2w57"
                  time="5.741205215454102">
        </testcase>
    </testsuite>
    <testsuite name="hdf5_hrhfiap"
               errors="0"
               tests="3"
               failures="0"
               time="350.3296411037445"
               timestamp="Thu, 18 Jan 2018 07:41:18" >
        <properties>
            <property name="architecture" value="linux-ubuntu14.04-x86_64" />
            <property name="compiler" value="[email protected]" />
        </properties>
        <testcase classname="libszip"
                  name="qabk3nme2645mmbpaqv7zbraddgv2w57"
                  time="5.741205215454102">
        </testcase>
        <testcase classname="zlib"
                  name="eksallf6cymqkp6pkz6ymzjakqt6bqkx"
                  time="4.028627872467041">
        </testcase>
        <testcase classname="hdf5"
                  name="hrhfiapki6pmmhuxclzifoppum5od3x3"
                  time="340.55980801582336">
        </testcase>
    </testsuite>
    <testsuite name="tar_iajxpjo"
               errors="0"
               tests="1"
               failures="0"
               time="54.028172969818115"
               timestamp="Thu, 18 Jan 2018 07:41:18" >
        <properties>
            <property name="architecture" value="linux-ubuntu14.04-x86_64" />
            <property name="compiler" value="[email protected]" />
        </properties>
        <testcase classname="tar"
                  name="iajxpjomleps4atnydsr5r2dqgvlj5gs"
                  time="54.028172969818115">
        </testcase>
    </testsuite>
</testsuites>

@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Jan 18, 2018

Tried to import today the xml in the description and a couple of others into Jenkins, and it displayed fine.


def fetch_text(path):
if not os.path.exists(path):
return 'No such file or directory: {0}'.format(path)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the No such file or directory would end up in the report in place of the actual test's stdout when the latter is missing. When this happens, is there a way to tell the difference between this error message (a kind of internal error) and something emitted by the test itself?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the No such file or directory would end up in the report in place of the actual test's stdout when the latter is missing.

You're right on that. I am a bit undecided what to do, in the sense that I am trying to distinguish errors from failures based on the exception type. As we have the real stdout and stderr from the build process merged and dumped into build_log_path I was thinking to:

  1. map build_log_path to <stdout/>
  2. map the exception stackstrace to <stderr/> - still to be implemented
  3. map a fixed message (like I do right now) or maybe str(exc_val) to the message property.

The end result looks like this:

junitfailurejenkins

on the Jenkins JUnit plugin. Suggestions?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The report looks quite clear, imo as long as you have the stack trace any other data becomes (nice to have tho) decor.

@alalazo alalazo force-pushed the refactoring/cleanup_junit branch from 17306dc to e06e4cf Compare January 22, 2018 14:15
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Jan 22, 2018

@nazavode @tgamblin

Here's the latest output:
showcase

The PR is ready, as far as I am concerned, as soon as Travis gives green light.

The generation of a JUnit report was previously part of the install
command. This commit factors the logic into its own module, and uses
a template for the generation of the report.

It also improves report generation, that now can deal with multiple
specs installed at once. Finally, extending the list of supported
formats is much easier than before, as it entails just writing a
new template.
The generation of a JUnit report has been polished, so that the
stacktrace is correctly displayed with Jenkins JUnit plugin. Standard
error is still not used.

Added unit tests to cover for installation failures and installation
errors.
@alalazo alalazo force-pushed the refactoring/cleanup_junit branch from e06e4cf to 93dee1a Compare January 26, 2018 09:26
Copy link
Copy Markdown
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have minor comments on this, but in general this is great. I think it can be merged as-is.

The main question I've got is how we should factor this with respect to CDash support. CDash is more extensive; there are phases (update, configure, build, test, deploy) and it supports zooming in on specific errors in a log (as parsed by CTest or external/ctest_log_parser). I don't think JUnit will ever support all that; it's mostly for unit tests.

We're working with folks at Kitware so maybe they can base CDash support on this.

Another higher-level question, maybe for a new PR:

  1. From the CDash perspective (maybe not junit) it would be nice to show that certain tests failed to concretize. The JUnit support currently assumes that things concretized successfully.

  2. I think that eventually, do_install needs to be refactored to clean this up properly. Monkey-patching package is kind of nasty, and I think Package should really be providing hooks that this uses. Also, when we do parallel builds, it's going to require a refactor of how dependency installs are done, too.

start_time = time.time()
value = None
try:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why a blank line?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, got it, you don't like blank lines after function definition if there's no docstring 😄

)

def __exit__(self, exc_type, exc_val, exc_tb):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why blank?

@tgamblin tgamblin merged commit 5af9256 into spack:develop Jan 28, 2018
@alalazo alalazo deleted the refactoring/cleanup_junit branch January 28, 2018 20:11
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Jan 28, 2018

I think that eventually, do_install needs to be refactored to clean this up properly. Monkey-patching package is kind of nasty, and I think Package should really be providing hooks that this uses. Also, when we do parallel builds, it's going to require a refactor of how dependency installs are done, too.

👍 to all this. In fact, I have a refactoring in #6833 that extracts dependency installs. If you think it's a good start, we may continue working there.

ch741 pushed a commit to ch741/spack that referenced this pull request Apr 20, 2018
* Cleaned up JUnit report generation on install

The generation of a JUnit report was previously part of the install
command. This commit factors the logic into its own module, and uses
a template for the generation of the report.

It also improves report generation, that now can deal with multiple
specs installed at once. Finally, extending the list of supported
formats is much easier than before, as it entails just writing a
new template.

* Polished report generation + added tests for failures and errors

The generation of a JUnit report has been polished, so that the
stacktrace is correctly displayed with Jenkins JUnit plugin. Standard
error is still not used.

Added unit tests to cover for installation failures and installation
errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants