Add spack test-suite command for posting combinatorial tests to CDash#2917
Add spack test-suite command for posting combinatorial tests to CDash#2917kielfriedt wants to merge 14 commits intodevelopfrom
Conversation
|
I thought the changes from @hegner for cdash were merged. I guess I have a conflict on install.py |
|
@kielfriedt: nope -- but they're in your branch, so they'll be included when we merge this. |
tgamblin
left a comment
There was a problem hiding this comment.
@kielfriedt: looks pretty good! Can you address the various inline comments and the following requests?
- Can you rename
spack testsuitetospack test-suite-- to match the formatting of the other commands? - Can you add docs on how to use the command and on the YAML format to the testing guide?
flake8is going to complain about formatting incmd/teststuite.pyso you'll need to fix the style errors. You can runspack flake8locally to fix that. See the contributor guide
lib/spack/spack/cmd/testsuite.py
Outdated
| Get the list of compilers from spack found on the system. | ||
| Compares the spack list to test file. | ||
| If a compiler is found on both lists its returned. | ||
| ''' |
lib/spack/spack/cmd/testsuite.py
Outdated
|
|
||
|
|
||
| ''' | ||
| fucntion Name: removeTests |
lib/spack/spack/cmd/testsuite.py
Outdated
| pkg = "" | ||
| compiler="" | ||
| teststoRemove = [] | ||
| if "%" in exclusion: |
There was a problem hiding this comment.
Parse this stuff using the Spec constructor? It should make your life easier and you don't have to do all the string analysis.
You can just pass it a string, e.g.:
from spack.spec import Spec
spec = Spec('foo @1.0 %[email protected]')Then you can do things like this:
print spec.satisfies('%clang@3')
>>> TrueThere was a problem hiding this comment.
Im not sure this is what I am doing. This is for exclusion, by doing the string analysis so I can determine how to properly test for the exclusion in the set of tests.
lib/spack/spack/cmd/testsuite.py
Outdated
| path = "" | ||
| dashboards = [] | ||
| #designed to use a single file and modify the enabled tests, thus requiring a single file modification. | ||
| for files in args.yamlFile: #read yaml files which contains description of tests |
There was a problem hiding this comment.
use a singular variable name -- each element in args.yamlFile is a file, not a "files". 😄
lib/spack/spack/cmd/testsuite.py
Outdated
| for files in args.yamlFile: #read yaml files which contains description of tests | ||
| with open(files, 'r') as stream: | ||
| try: | ||
| yamlFile= yaml.load(stream) |
There was a problem hiding this comment.
Convert this to use spack.util.spack_yaml, e.g.:
import spack.util.spack_yaml as syaml
with open(file) as stream:
syaml.load(stream)Spack's YAML adds support for a few nice things like line numbers (which you can use in error messages) and ordered dictionaries.
lib/spack/spack/cmd/testsuite.py
Outdated
| args = parser.parse_args([cdash]) #use cdash-complete if you want configure, build and test output. | ||
| args.package = test | ||
| install.install(parser, args) | ||
| except Exception as ex: |
There was a problem hiding this comment.
Whatever error occurs should probably go in the test log and get displayed as part of CDash output.
lib/spack/spack/cmd/testsuite.py
Outdated
| except Exception as ex: | ||
| template = "An exception of type {0} occured. Arguments:\n{1!r}" | ||
| message = template.format(type(ex).__name__, ex.args) | ||
| tty.msg(message) |
There was a problem hiding this comment.
Instead of printing, put errors in the XML.
There was a problem hiding this comment.
I will have to look into this. cdash files are produced by logging. I am not sure I can put it into the xml file but ill figure it out.
lib/spack/spack/hooks/dashboards.py
Outdated
| buildName = buildName.split('=') | ||
| template.set('BuildName',str(buildName[0]) + " " + str(buildName[1])) | ||
| template.set('BuildStamp', self.buildstamp) | ||
| tempcompiler = self.spec.short_spec.split('%')[1].split(' ')[0] |
There was a problem hiding this comment.
avoid using split and use the actual fields on . e.g. self.spec.compiler.name, self.spec.compiler.version, etc.
There was a problem hiding this comment.
done. Wasn't aware of that option.
lib/spack/spack/hooks/dashboards.py
Outdated
|
|
||
|
|
||
| def prepare_build_report(self): | ||
| report = self.create_template() |
There was a problem hiding this comment.
I'm curious whether the XML parts of this would be more maintainable if you just make an XML template with """, e.g.:
template = """\
<Build>
<StartDateTime>{date}</StartDateTime>
<StartDateTime>{log_text}</StartDateTime>
</Build>
"""
output = template.format(date=date, log_text=captured_output)
etc. You can get pretty far with Python's str.format() function.
What do you think? I think manually constructing the ElementTree is kind of tedious and hard to read or change.
There was a problem hiding this comment.
This is done by @hegner I did not redo it. I just adjusted the format to get it to output a file that would display on cdash. I will talk with hegner for advice.
lib/spack/spack/hooks/dashboards.py
Outdated
| return decorator | ||
|
|
||
|
|
||
|
|
|
Add done with changes as requested and tested on my end. |
|
@kielfriedt: can you rebase this and/or merge current develop? |
|
@tgamblin I am now using testing/wip_xsdk, I got rid of the wip branch. Should I make a new pull request? |
|
@kielfriedt: Well, you got rid of your local WIP branch, not the one on GitHub. We want to keep these features separate from the It sounds like you should cherry-pick your work on the |
tgamblin
left a comment
There was a problem hiding this comment.
@kielfriedt: This is looking better! I added a bunch of comments Can you:
- Address the comments
- Fix the PEP8 and doc warnings
Nice work!
lib/spack/spack/cmd/test_suite.py
Outdated
| return spec, "PackageStillNeededError" | ||
| return spec, "" | ||
|
|
||
| def installSpec(spec,cdash,test): |
lib/spack/spack/cmd/test_suite.py
Outdated
| cdash = '--log-format=cdash-simple' | ||
|
|
||
| cdash_root = "/var/spack/cdash/" | ||
| enabledTests = [] |
lib/spack/spack/cmd/test_suite.py
Outdated
| compilers = data['compilers'] | ||
| exclusions = data['exclusions'] | ||
| except: | ||
| tty.msg("Testing yaml files must contain atleast enable, packages, exclusions and compilers to produce results. Exclusions can be empty, IE []") |
There was a problem hiding this comment.
Isn't this warning unnecessary? The schema validation should ensure this never happens.
lib/spack/spack/schema/test.py
Outdated
| }, | ||
| }, | ||
| }, | ||
| 'exclusions': { |
There was a problem hiding this comment.
Exclusions should be optional (might not want to exclude anything, and requiring [] is tedious for the user)
lib/spack/spack/schema/test.py
Outdated
| 'default': [], | ||
| 'items': {'type': 'string'} | ||
| }, | ||
| 'dashboard': { |
There was a problem hiding this comment.
I think the dashboard ought to be optional, or maybe only specified at the command line.
Also, can you change this to use include and exclude instead of enable and exclusions? Each of those should take specs. Example:
spack-tests:
dashboard: # optional string
include: # use this instead of "enable"
# specs to include (any others are assumed excluded. Default to all included)
exclude:
# specs to exclude (from set of included specs)
packages:
# ...
compilers:
# ...
dependencies:
# TBD -- we need this, but ignore for now (we'll figure out how to factor in later)
variants:
# TBD -- need this too, but ignore for now. not clear if it is global or if it's a per-package setting or both.
lib/spack/spack/cmd/test_suite.py
Outdated
| help='using this option switches from simple cdash output to compelet: simple is only build, complete is configure, build and test xml output.') | ||
| subparser.add_argument( | ||
| 'yamlFile', nargs=argparse.REMAINDER, | ||
| help="yaml file that contains a list of tests, example yaml file can be found in /lib/spack/docs/tutorial/examples/test.yaml") |
There was a problem hiding this comment.
The file's really long and it's buried in the source -- I think we shouldn't assume that users can dig through the source directories. Can you remove the reference to the file and just say "see docs on test suites" for now?
There was a problem hiding this comment.
Since you're adding a new command, can you add tab completion as well? It would look like:
function _spack_test-suite {
if $list_options
then
compgen -W "-c --complete" -- "$cur"
fi
}| @@ -0,0 +1,2231 @@ | |||
| --- | |||
There was a problem hiding this comment.
The file is too long -- if it's this long it should really just be generated. Can you just remove this and link to the docs in the command help where this is referenced?
Also, lib/spack/docs/tutorial/examples is really just for our SC'16 tutorial. Examples like this should probably get their own directory separate from that.
lib/spack/docs/testing_guide.rst
Outdated
| with versions. Using the enabled field will allow you to focus on specific packages. | ||
| To narrow down the scope of a package or compiler, you can use the exclusion field. | ||
|
|
||
| --Example of a yaml file--- |
There was a problem hiding this comment.
Call this a "test suite file" or a "test suite YAML file" or something more specific.
There was a problem hiding this comment.
The file format should start with a top-level key like other YAML files in Spack. Can you make it start with test-suite: or something, to identify the type of file to Spack?
There was a problem hiding this comment.
For the yaml file, use:
.. code-block:: yamland indent it.
lib/spack/docs/testing_guide.rst
Outdated
|
|
||
| dashboard: ["https://spack.io/cdash/submit.php?project=spack"] | ||
|
|
||
| path: "~/home/username" |
There was a problem hiding this comment.
Output path should be a parameter of the command -- not a hard-coded value in the file. I think it should be possible to either specify an existing output directory on the command line, or to run without output and just spit the results out to a new directory within the current working dir, named, e.g., spack-tests-YYYY-MM-DD-timestamp. See spack mirror create for similar semantics.
There was a problem hiding this comment.
timestamp = datetime.now().strftime("%Y-%m-%d")
directory = 'spack-mirror-' + timestamp
current output from dashboard is similar to this now.
lib/spack/spack/cmd/test_suite.py
Outdated
| @@ -0,0 +1,322 @@ | |||
| #!/usr/bin/env python | |||
lib/spack/spack/cmd/test_suite.py
Outdated
| help='using this option switches from simple cdash output to compelet: simple is only build, complete is configure, build and test xml output.') | ||
| subparser.add_argument( | ||
| 'yamlFile', nargs=argparse.REMAINDER, | ||
| help="yaml file that contains a list of tests, example yaml file can be found in /lib/spack/docs/tutorial/examples/test.yaml") |
There was a problem hiding this comment.
Since you're adding a new command, can you add tab completion as well? It would look like:
function _spack_test-suite {
if $list_options
then
compgen -W "-c --complete" -- "$cur"
fi
}
lib/spack/docs/testing_guide.rst
Outdated
| with versions. Using the enabled field will allow you to focus on specific packages. | ||
| To narrow down the scope of a package or compiler, you can use the exclusion field. | ||
|
|
||
| --Example of a yaml file--- |
There was a problem hiding this comment.
For the yaml file, use:
.. code-block:: yamland indent it.
lib/spack/spack/cmd/test_suite.py
Outdated
| data=mydata, | ||
| headers={'content-type':'text/plain'}, | ||
| params={'file': cdash_path + file} | ||
| ) |
There was a problem hiding this comment.
4 space indentation, not tabs.
kielfriedt
left a comment
There was a problem hiding this comment.
changes have been completed
lib/spack/docs/testing_guide.rst
Outdated
|
|
||
| dashboard: ["https://spack.io/cdash/submit.php?project=spack"] | ||
|
|
||
| path: "~/home/username" |
There was a problem hiding this comment.
timestamp = datetime.now().strftime("%Y-%m-%d")
directory = 'spack-mirror-' + timestamp
current output from dashboard is similar to this now.
lib/spack/docs/testing_guide.rst
Outdated
| with versions. Using the enabled field will allow you to focus on specific packages. | ||
| To narrow down the scope of a package or compiler, you can use the exclusion field. | ||
|
|
||
| --Example of a yaml file--- |
| @@ -0,0 +1,2231 @@ | |||
| --- | |||
lib/spack/spack/cmd/test_suite.py
Outdated
| @@ -0,0 +1,322 @@ | |||
| #!/usr/bin/env python | |||
lib/spack/spack/cmd/test_suite.py
Outdated
| help='using this option switches from simple cdash output to compelet: simple is only build, complete is configure, build and test xml output.') | ||
| subparser.add_argument( | ||
| 'yamlFile', nargs=argparse.REMAINDER, | ||
| help="yaml file that contains a list of tests, example yaml file can be found in /lib/spack/docs/tutorial/examples/test.yaml") |
lib/spack/spack/cmd/test_suite.py
Outdated
| return spec, "PackageStillNeededError" | ||
| return spec, "" | ||
|
|
||
| def installSpec(spec,cdash,test): |
lib/spack/spack/cmd/test_suite.py
Outdated
| cdash = '--log-format=cdash-simple' | ||
|
|
||
| cdash_root = "/var/spack/cdash/" | ||
| enabledTests = [] |
lib/spack/spack/cmd/test_suite.py
Outdated
| compilers = data['compilers'] | ||
| exclusions = data['exclusions'] | ||
| except: | ||
| tty.msg("Testing yaml files must contain atleast enable, packages, exclusions and compilers to produce results. Exclusions can be empty, IE []") |
lib/spack/spack/schema/test.py
Outdated
| }, | ||
| }, | ||
| }, | ||
| 'exclusions': { |
lib/spack/spack/schema/test.py
Outdated
| 'default': [], | ||
| 'items': {'type': 'string'} | ||
| }, | ||
| 'dashboard': { |
|
@adamjstewart: are you ok with these changes? |
| @@ -0,0 +1,22 @@ | |||
| --- | |||
There was a problem hiding this comment.
I think that is the standard start of a YAML file (see http://yaml.org/), but all spack YAML files start with <name>:. We should change this.
There was a problem hiding this comment.
--- means: is this document part of a single stream (or not): https://en.wikipedia.org/wiki/YAML
| @@ -0,0 +1,22 @@ | |||
| --- | |||
| test-suite: | |||
| include: [ ape, atompaw, transset] | |||
There was a problem hiding this comment.
Can you remove the space between [ and ape?
| --- | ||
| test-suite: | ||
| include: [ ape, atompaw, transset] | ||
| exclude: [binutils,tk] |
There was a problem hiding this comment.
Can you add a space after the comma?
lib/spack/docs/testing_guide.rst
Outdated
|
|
||
| $ spack install --log-format=junit <spec> | ||
|
|
||
| Per default the log results will be placed into `var/<format>/test-<short_spec>.xml`. |
There was a problem hiding this comment.
Single backticks make things italic, you probably want double backticks to make it monospace.
lib/spack/docs/testing_guide.rst
Outdated
|
|
||
|
|
||
| ---------------- | ||
| using test-suite |
There was a problem hiding this comment.
Using should probably start with a capital U.
lib/spack/docs/testing_guide.rst
Outdated
|
|
||
| --- | ||
| test-suite: | ||
| enable: [bzip2, libelf, .. ,libdwarf] |
There was a problem hiding this comment.
Shouldn't everything after test-suite be indented further?
lib/spack/docs/testing_guide.rst
Outdated
|
|
||
| $ spack test-suite -c /location/of/yamlFile | ||
|
|
||
| Currently output files are stored in you current working directory. A folder name spack-test-YYYY-MM-DD this may change in the future. |
lib/spack/docs/testing_guide.rst
Outdated
| Junit | ||
| ^^^^^ | ||
|
|
||
| With |
lib/spack/docs/testing_guide.rst
Outdated
| ^^^^^ | ||
|
|
||
| Spack supports the XML format used by `CDash <http://www.cdash.org/>`_. | ||
| To create reports in this format, do |
lib/spack/docs/testing_guide.rst
Outdated
|
|
||
| $ spack install --log-file report --log-format=cdash <spec> | ||
|
|
||
| This will produce each one file for the configure, build, and test step. |
lib/spack/docs/testing_guide.rst
Outdated
|
|
||
| $ curl --upload-file report.build.xml <cdash url>/submit.php?project=<projectname> | ||
| $ curl --upload-file report.configure.xml <cdash url>/submit.php?project=<projectname> | ||
| $ curl --upload-file report.test.xml <cdash url>/submit.php?project=<projectname> |
There was a problem hiding this comment.
I wonder if we can add a Spack command to automate this?
|
@kielfriedt: The |
|
@kielfriedt: I reworked this. Can you look at the code and comments in 7b50e15 and let's go over it tomorrow. I think this is pretty close to ready. TODO:
|
| gcc: | ||
| versions: [4.9.0, 4.7.1, 4.6.3, 4.6.1] | ||
| clang: | ||
| versions: [7.3.0, 3.4, 3.1] |
There was a problem hiding this comment.
I was taking a brief look at this PR, and it looks great. Thanks @kielfriedt !
A random thought: if in the future we'll be able to extend this yaml file to treat virtual dependencies and similar things correctly, we may use it beyond build tests. What I am thinking is reproducing the build of an entire environment on a different machine. Roughly:
spack export ... # Exports a YAML file similar to this one
# Move to another machine...
spack install -f suite.yaml # Reinstall the "same" software, for some notion of "same"There was a problem hiding this comment.
I know a lot of Spack users are currently creating massive dummy-packages to do something similar to this. A suite.yaml file would be much cleaner.
There was a problem hiding this comment.
That's the intent with spack.util.spec_set. The way I've reworked it, you can basically cartesian-product arbitrary lists of specs. The compilers and packages elements are shorthand for particular types of spec lists.
The schema is currently written with spack test-suite in mind, but it can be factored out to a suite.yaml or maybe stack.yaml. Which do you like better? I kind of like stack.yaml and thought about calling the format spack-stack instead of test-suite.
|
@kielfriedt I think you need to update the command |
- Created new command called testsuite.
- Takes a yaml file describing tests, produces XML and sends to CDash.
- two XML formats: simple and complete
-. simple is only build
- complete is configure, build, test.
- added an example yaml file
- CDash builds display with platform icons.
- Added documentation to the testing_guide for the test-suite command
- document include, exclude, packages, compilers elements
- test-suite takes options to display multiple dashboards.
- added tests for test-suite command
- Split out CombinatorialSpecSet into its own spack.util.spec_set module.
- class is iterable and encaspulated YAML parsing and validation.
- Get rid of copy/pasted code in test-suite command.
- consolidate line-numbered YAML error code into spack.schema.
- Rework test-suite schema format
- previous format wasn't actually validating -- only had definitions.
- Adjust YAML format to be more generic
- YAML test-suite format now has a `matrix` section, which can contain
multiple lists of specs, generated different ways. Including:
- specs: a raw list of specs.
- packages: a list of package names and versions
- compilers: a list of compiler names and versions
- All of the elements of `matrix` are dimensions for the build matrix;
we take the cartesian product of these lists of specs to generate a
build matrix. This means we can add things like [^mpich, ^openmpi]
to get builds with different MPI versions. It also means we can
multiply the build matrix out with lots of different parameters.
- clean up logic in test-suite command
- Bug fixes:
- fix some bugs with compilers_for_arch()
- fix bug with constraining an anonymous spec by name, add a test.
|
@kielfriedt : this is awesome and would like to try! it would be great if pending issues solved and get merged. |
|
@pramodk: we're revising this and it'll be in by the end of the month. |
|
thanks @tgamblin. With the current format below, seems like not possible to specify spec saying I see that |
|
@pramodk: I pushed my WIP branch, which still needs rebasing on matrix:
- specs: ['hdf5%intel', 'hdf5%gcc']
- specs: ['^zlib%intel', '^zlib%gcc']That would concretize each of these (the products), and try to build the result: You could add another |
|
I was testing this today and come across following issues :
I should able to run test-suite without considering cdash server details?
what happens if I cancel test-suite in the middle?
(docs update) |
|
Superseded by #7114. |
Added testsuite which reads in a yaml file. Example yaml file is located in lib/spack/docs/tutorial/examples/. Changed dashboard to simple and complete versions. Current requirements are for build only, but in the future a complete configure, build and test would be needed. Testsuite is documented and tested.