Note
Please see Tutorials Setup before you proceed with this section
Spack Schema¶
Note
This feature is in active development.
buildtest can generate tests for the spack package manager which can be
used if you want to install or test packages as part of a repeatable process. You must set type: spack
property
in buildspec to use the spack schema for validating the buildspec test. Currently, we have
spack-v1.0.schema.json
JSON schema that defines the structure of how tests are to be written in buildspec. Shown below is the schema header. The
required properties are type
, executor
and spack
.
"$id": "spack-v1.0.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "spack schema version 1.0",
"description": "The spack schema is referenced using ``type: spack`` which is used for generating tests using spack package manager",
"type": "object",
"required": [
"type",
"executor",
"spack"
],
Install Specs¶
Let’s start off with a simple example where we create a test that can spack install zlib
. Shown below
is a test named install_zlib. The spack keyword is a JSON object, in this test we define the root
of spack using the root
keyword which informs buildtest where spack is located. buildtest will automatically
check the path and source the startup script. The install
field is a JSON object that
contains a specs
property which is a list of strings types that are name of spack packages to install. Each item in the
specs
property will be added as a separate spack install
command.
The schema is designed to mimic spack commands which will be clear with more examples.
version: "1.0"
buildspecs:
install_specs_example:
type: spack
executor: generic.local.bash
description: "Install zlib spec"
tags: [spack]
spack:
root: $HOME/spack
install:
specs: ['zlib']
Let’s build this test by running the following
$ buildtest build -b /home/spack/buildtest/examples/spack/install_specs.yml
Buildspec Paths: ['/home/spack/buildtest/examples']
Updating buildspec cache file: /home/spack/buildtest/var/buildspecs/cache.json
╭─────────────────────────────────────────────────── buildtest summary ───────────────────────────────────────────────────╮
│ │
│ User: spack │
│ Hostname: 2d93bd00cb98 │
│ Platform: Linux │
│ Current Time: 2022/01/14 15:18:42 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 0.12.0 │
│ python path: /home/spack/pyenv/buildtest/bin/python3 │
│ python version: 3.8.6 │
│ Configuration File: /home/spack/buildtest/buildtest/settings/spack_container.yml │
│ Test Directory: /home/spack/runs │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/install_specs.yml │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ──────────────────────────────────────────────────────────────────────────────────
Discovered Buildspecs: 1
Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
Discovered buildspecs
╔════════════════════════════════════════════════════════╗
║ Buildspecs ║
╟────────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/install_specs.yml ║
╚════════════════════════════════════════════════════════╝
──────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ─────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/install_specs.yml: VALID
Total builder objects created: 1
Total compiler builder: 0
Total script builder: 0
Total spack builder: 1
Spack Builder Details
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder ┃ Executor ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ install_specs_example/cd2519af │ generic.local.bash │ Install zlib spec │ /home/spack/buildtest/examples/spack/install_specs.yml │
└────────────────────────────────┴────────────────────┴───────────────────┴────────────────────────────────────────────────────────┘
─────────────────────────────────────────────────────────────────────────────────────── Building Test ───────────────────────────────────────────────────────────────────────────────────────
install_specs_example/cd2519af: Creating test directory: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/cd2519af
install_specs_example/cd2519af: Creating the stage directory: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/cd2519af/stage
install_specs_example/cd2519af: Writing build script: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/cd2519af/install_specs_example_build.sh
─────────────────────────────────────────────────────────────────────────────────────── Running Tests ───────────────────────────────────────────────────────────────────────────────────────
______________________________
Launching test: install_specs_example/cd2519af
install_specs_example/cd2519af: Running Test via command: bash --norc
--noprofile -eo pipefail install_specs_example_build.sh
install_specs_example/cd2519af: Test completed with returncode: 0
install_specs_example/cd2519af: Test completed in 1.141358 seconds
install_specs_example/cd2519af: Writing output file - /home/spack/runs/generic.
local.bash/install_specs/install_specs_example/cd2519af/install_specs_example.ou
t
install_specs_example/cd2519af: Writing error file - /home/spack/runs/generic.lo
cal.bash/install_specs/install_specs_example/cd2519af/install_specs_example.err
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Builder ┃ executor ┃ status ┃ Checks (ReturnCode, Regex, Runtime) ┃ ReturnCode ┃ Runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ install_specs_example/cd2519af │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 1.141358 │
└────────────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴──────────┘
Passed Tests: 1/1 Percentage: 100.000%
Failed Tests: 0/1 Percentage: 0.000%
Adding 1 test results to /home/spack/buildtest/var/report.json
Writing Logfile to: /home/spack/buildtest/var/logs/buildtest_fev0dxjf.log
Let’s inspect the generated script and output file via buildtest inspect query
command. We notice that buildtest
will source spack setup script and install zlib which is automatically installed from the buildcache.
$ buildtest inspect query -o -t install_specs_example
──────────────────────────────────────────────────────────────── install_specs_example/cd2519af-5730-40c6-b386-5ff6d9d9d1e6 ─────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Install zlib spec
State: PASS
Returncode: 0
Runtime: 1.141358 sec
Starttime: 2022/01/14 15:18:42
Endtime: 2022/01/14 15:18:43
Command: bash --norc --noprofile -eo pipefail install_specs_example_build.sh
Test Script: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/cd2519af/install_specs_example.sh
Build Script: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/cd2519af/install_specs_example_build.sh
Output File: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/cd2519af/install_specs_example.out
Error File: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/cd2519af/install_specs_example.err
Log File: /home/spack/buildtest/var/logs/buildtest_fev0dxjf.log
────────────────────────────────── Output File: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/cd2519af/install_specs_example.out ──────────────────────────────────
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/zlib-1.2.11-smoyzzo2qhzpn6mg6rd3l2p7b23enshg
─────────────────────────────────── Test File: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/cd2519af/install_specs_example.sh ────────────────────────────────────
1 #!/bin/bash
2 source /home/spack/spack/share/spack/setup-env.sh
3 spack install zlib
Spack Environment¶
buildtest can generate scripts to make use of spack environments which can be useful if you want to install or test specs in an isolated environment.
Currently, we can create spack environment (spack env create
) via name, directory and manifest file (spack.yaml
, spack.lock
) and pass any
options to spack env create command. Furthermore, we can activate existing spack environment via name or directory using
spack env activate
and pass options to the command. buildtest can remove spack environments automatically before creating spack environment
or one can explicitly specify by name.
Create a Spack Environment by name¶
In this next example, we will create a spack environment named m4_zlib
that will install
m4 and zlib spec. The create field is a JSON object that maps to spack env create
command which can pass some arguments in the form of key/value pairs. The name
property
in create section is used to create a spack environment by name. The activate
property maps
to spack env activate
command which is used to activate a spack environment. The name property is
of type: string
which is name of spack environment you want to activate.
The compiler_find: true
is a boolean that determines if we need to find compilers in spack via
spack compiler find
. This can be useful if you need to find compilers so spack can install specs
with a preferred compiler otherwise spack may have issues concretizing or install specs.
buildtest will run spack compiler find after sourcing spack.
Note
The compiler_find
option may not be useful if your compilers are already defined in
one of your configuration scopes or spack.yaml
that is part of your spack environment.
The option
field can pass any command line arguments to spack install
command
and this field is available for other properties.
version: "1.0"
buildspecs:
install_in_spack_env:
type: spack
executor: generic.local.bash
description: "Install m4 and zlib in a spack environment named m4_zlib"
tags: [spack]
spack:
root: $HOME/spack
compiler_find: true
env:
create:
name: 'm4_zlib'
specs:
- 'm4'
- 'zlib'
activate:
name: m4_zlib
concretize: true
install:
option: '--keep-prefix'
If we build this test and see generated test we see that buildtest will create a spack environment m4_zlib and activate the environment, add m4 and zlib, concretize the environment and install the specs.
$ buildtest build -b /home/spack/buildtest/examples/spack/env_install.yml
╭────────────────────────────────────────────────── buildtest summary ──────────────────────────────────────────────────╮
│ │
│ User: spack │
│ Hostname: 2d93bd00cb98 │
│ Platform: Linux │
│ Current Time: 2022/01/14 15:18:45 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 0.12.0 │
│ python path: /home/spack/pyenv/buildtest/bin/python3 │
│ python version: 3.8.6 │
│ Configuration File: /home/spack/buildtest/buildtest/settings/spack_container.yml │
│ Test Directory: /home/spack/runs │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/env_install.yml │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ──────────────────────────────────────────────────────────────────────────────────
Discovered Buildspecs: 1
Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
Discovered buildspecs
╔══════════════════════════════════════════════════════╗
║ Buildspecs ║
╟──────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/env_install.yml ║
╚══════════════════════════════════════════════════════╝
──────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ─────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/env_install.yml: VALID
Total builder objects created: 1
Total compiler builder: 0
Total script builder: 0
Total spack builder: 1
Spack Builder Details
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder ┃ Executor ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ install_in_spack_env/7383bea5 │ generic.local.bash │ Install m4 and zlib in a spack environment named m4_zlib │ /home/spack/buildtest/examples/spack/env_install.yml │
└───────────────────────────────┴────────────────────┴──────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────┘
─────────────────────────────────────────────────────────────────────────────────────── Building Test ───────────────────────────────────────────────────────────────────────────────────────
install_in_spack_env/7383bea5: Creating test directory: /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/7383bea5
install_in_spack_env/7383bea5: Creating the stage directory: /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/7383bea5/stage
install_in_spack_env/7383bea5: Writing build script: /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/7383bea5/install_in_spack_env_build.sh
─────────────────────────────────────────────────────────────────────────────────────── Running Tests ───────────────────────────────────────────────────────────────────────────────────────
______________________________
Launching test: install_in_spack_env/7383bea5
install_in_spack_env/7383bea5: Running Test via command: bash --norc --noprofile
-eo pipefail install_in_spack_env_build.sh
install_in_spack_env/7383bea5: Test completed with returncode: 0
install_in_spack_env/7383bea5: Test completed in 6.107433 seconds
install_in_spack_env/7383bea5: Writing output file - /home/spack/runs/generic.l
ocal.bash/env_install/install_in_spack_env/7383bea5/install_in_spack_env.out
install_in_spack_env/7383bea5: Writing error file - /home/spack/runs/generic.loc
al.bash/env_install/install_in_spack_env/7383bea5/install_in_spack_env.err
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Builder ┃ executor ┃ status ┃ Checks (ReturnCode, Regex, Runtime) ┃ ReturnCode ┃ Runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ install_in_spack_env/7383bea5 │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 6.107433 │
└───────────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴──────────┘
Passed Tests: 1/1 Percentage: 100.000%
Failed Tests: 0/1 Percentage: 0.000%
Adding 1 test results to /home/spack/buildtest/var/report.json
Writing Logfile to: /home/spack/buildtest/var/logs/buildtest_167lre5w.log
$ buildtest inspect query -t install_in_spack_env
───────────────────────────────────────────────────────────────── install_in_spack_env/7383bea5-1b39-4970-8db8-46b5b9e470bc ─────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Install m4 and zlib in a spack environment named m4_zlib
State: PASS
Returncode: 0
Runtime: 6.107433 sec
Starttime: 2022/01/14 15:18:45
Endtime: 2022/01/14 15:18:52
Command: bash --norc --noprofile -eo pipefail install_in_spack_env_build.sh
Test Script: /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/7383bea5/install_in_spack_env.sh
Build Script: /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/7383bea5/install_in_spack_env_build.sh
Output File: /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/7383bea5/install_in_spack_env.out
Error File: /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/7383bea5/install_in_spack_env.err
Log File: /home/spack/buildtest/var/logs/buildtest_167lre5w.log
───────────────────────────────────── Test File: /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/7383bea5/install_in_spack_env.sh ──────────────────────────────────────
1 #!/bin/bash
2 source /home/spack/spack/share/spack/setup-env.sh
3 spack compiler find
4 spack env create m4_zlib
5 spack env activate m4_zlib
6 spack add m4
7 spack add zlib
8 spack concretize -f
9 spack install --keep-prefix
Creating Spack Environment in Directory¶
We can create spack environment from a directory using the dir
property that
is available as part of create
and activate
field. In this next example we
create a spack environment in our $HOME directory and concretize m4 in the spack
environment
version: "1.0"
buildspecs:
spack_env_directory:
type: spack
executor: generic.local.bash
description: "create spack environment in directory"
tags: [spack]
spack:
root: $HOME/spack
env:
create:
dir: $HOME/spack-envs/m4
activate:
dir: $HOME/spack-envs/m4
specs:
- 'm4'
install:
option: ''
post_cmds: |
spack find
rm -rf $HOME/spack-envs/m4
When creating spack environment using directory, buildtest will automatically add the
-d
option which is required when creating spack environments. However, one can also pass
this using the option
field. Shown below is the build and generated script after running test.
$ buildtest build -b /home/spack/buildtest/examples/spack/env_create_directory.yml
╭────────────────────────────────────────────────────── buildtest summary ───────────────────────────────────────────────────────╮
│ │
│ User: spack │
│ Hostname: 2d93bd00cb98 │
│ Platform: Linux │
│ Current Time: 2022/01/14 15:18:53 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 0.12.0 │
│ python path: /home/spack/pyenv/buildtest/bin/python3 │
│ python version: 3.8.6 │
│ Configuration File: /home/spack/buildtest/buildtest/settings/spack_container.yml │
│ Test Directory: /home/spack/runs │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/env_create_directory.yml │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ──────────────────────────────────────────────────────────────────────────────────
Discovered Buildspecs: 1
Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
Discovered buildspecs
╔═══════════════════════════════════════════════════════════════╗
║ Buildspecs ║
╟───────────────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/env_create_directory.yml ║
╚═══════════════════════════════════════════════════════════════╝
──────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ─────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/env_create_directory.yml: VALID
Total builder objects created: 1
Total compiler builder: 0
Total script builder: 0
Total spack builder: 1
Spack Builder Details
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder ┃ Executor ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ spack_env_directory/79ca3ec8 │ generic.local.bash │ create spack environment in directory │ /home/spack/buildtest/examples/spack/env_create_directory.yml │
└──────────────────────────────┴────────────────────┴───────────────────────────────────────┴───────────────────────────────────────────────────────────────┘
─────────────────────────────────────────────────────────────────────────────────────── Building Test ───────────────────────────────────────────────────────────────────────────────────────
spack_env_directory/79ca3ec8: Creating test directory: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/79ca3ec8
spack_env_directory/79ca3ec8: Creating the stage directory: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/79ca3ec8/stage
spack_env_directory/79ca3ec8: Writing build script: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/79ca3ec8/spack_env_directory_build.sh
─────────────────────────────────────────────────────────────────────────────────────── Running Tests ───────────────────────────────────────────────────────────────────────────────────────
______________________________
Launching test: spack_env_directory/79ca3ec8
spack_env_directory/79ca3ec8: Running Test via command: bash --norc --noprofile
-eo pipefail spack_env_directory_build.sh
spack_env_directory/79ca3ec8: Test completed with returncode: 0
spack_env_directory/79ca3ec8: Test completed in 3.346589 seconds
spack_env_directory/79ca3ec8: Writing output file - /home/spack/runs/generic.lo
cal.bash/env_create_directory/spack_env_directory/79ca3ec8/spack_env_directory.o
ut
spack_env_directory/79ca3ec8: Writing error file - /home/spack/runs/generic.loca
l.bash/env_create_directory/spack_env_directory/79ca3ec8/spack_env_directory.err
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Builder ┃ executor ┃ status ┃ Checks (ReturnCode, Regex, Runtime) ┃ ReturnCode ┃ Runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ spack_env_directory/79ca3ec8 │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 3.346589 │
└──────────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴──────────┘
Passed Tests: 1/1 Percentage: 100.000%
Failed Tests: 0/1 Percentage: 0.000%
Adding 1 test results to /home/spack/buildtest/var/report.json
Writing Logfile to: /home/spack/buildtest/var/logs/buildtest_8sxi8dgb.log
$ buildtest inspect query -o -t spack_env_directory
───────────────────────────────────────────────────────────────── spack_env_directory/79ca3ec8-f1ec-4213-ac94-3ab36496c7b2 ──────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: create spack environment in directory
State: PASS
Returncode: 0
Runtime: 3.346589 sec
Starttime: 2022/01/14 15:18:53
Endtime: 2022/01/14 15:18:57
Command: bash --norc --noprofile -eo pipefail spack_env_directory_build.sh
Test Script: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/79ca3ec8/spack_env_directory.sh
Build Script: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/79ca3ec8/spack_env_directory_build.sh
Output File: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/79ca3ec8/spack_env_directory.out
Error File: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/79ca3ec8/spack_env_directory.err
Log File: /home/spack/buildtest/var/logs/buildtest_8sxi8dgb.log
──────────────────────────────── Output File: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/79ca3ec8/spack_env_directory.out ─────────────────────────────────
==> Updating view at /home/spack/spack-envs/m4/.spack-env/view
==> Created environment in /home/spack/spack-envs/m4
==> You can activate this environment with:
==> spack env activate /home/spack/spack-envs/m4
==> Adding m4 to environment /home/spack/spack-envs/m4
==> Updating view at /home/spack/spack-envs/m4/.spack-env/view
==> Concretized m4
[+] mkc3u4x m4@1.4.18%gcc@7.5.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linu
[+] lbrx7ln ^libsigsegv@2.12%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
==> Installing environment /home/spack/spack-envs/m4
==> All of the packages are already installed
==> Updating view at /home/spack/spack-envs/m4/.spack-env/view
==> In environment /home/spack/spack-envs/m4
==> Root specs
m4
-- linux-ubuntu18.04-x86_64 / gcc@7.5.0 -------------------------
libsigsegv@2.12
m4@1.4.18
────────────────────────────────── Test File: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/79ca3ec8/spack_env_directory.sh ──────────────────────────────────
1 #!/bin/bash
2 source /home/spack/spack/share/spack/setup-env.sh
3 spack env create -d /home/spack/spack-envs/m4
4 spack env activate -d /home/spack/spack-envs/m4
5 spack add m4
6 spack install
7
8
9 ######## START OF POST COMMANDS ########
10 spack find
11 rm -rf $HOME/spack-envs/m4
12 ######## END OF POST COMMANDS ########
13
14
Create Spack Environment from Manifest File (spack.yaml, spack.lock)¶
Spack can create environments from spack.yaml or spack.lock which can be used if you
have a spack configuration that works for your system and want to write a buildspec. While creating a spack environment,
you can use the manifest
property to specify path to your spack.yaml
or spack.lock
.
Note
buildtest will not enforce that manifest names be spack.yaml or spack.lock since spack allows one to create spack environment from arbitrary name so long as it is a valid spack configuration.
Shown below is an example buildspec that generates a test from a manifest file. The manifest
property
is of type: string
and this is only available as part of create
property.
version: "1.0"
buildspecs:
spack_env_create_from_manifest:
type: spack
executor: generic.local.bash
description: "Create spack environment from spack.yaml"
tags: [spack]
spack:
root: $HOME/spack
env:
create:
name: 'manifest_example'
manifest: "$BUILDTEST_ROOT/examples/spack/example/spack.yaml"
activate:
name: 'manifest_example'
concretize: true
If we build this test and inspect the generated script we see spack env create
command
will create an environment manifest_example using the manifest file that we provided from the spack.yaml.
$ buildtest build -b /home/spack/buildtest/examples/spack/env_create_manifest.yml
╭────────────────────────────────────────────────────── buildtest summary ──────────────────────────────────────────────────────╮
│ │
│ User: spack │
│ Hostname: 2d93bd00cb98 │
│ Platform: Linux │
│ Current Time: 2022/01/14 15:18:58 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 0.12.0 │
│ python path: /home/spack/pyenv/buildtest/bin/python3 │
│ python version: 3.8.6 │
│ Configuration File: /home/spack/buildtest/buildtest/settings/spack_container.yml │
│ Test Directory: /home/spack/runs │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/env_create_manifest.yml │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ──────────────────────────────────────────────────────────────────────────────────
Discovered Buildspecs: 1
Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
Discovered buildspecs
╔══════════════════════════════════════════════════════════════╗
║ Buildspecs ║
╟──────────────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/env_create_manifest.yml ║
╚══════════════════════════════════════════════════════════════╝
──────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ─────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/env_create_manifest.yml: VALID
Total builder objects created: 1
Total compiler builder: 0
Total script builder: 0
Total spack builder: 1
Spack Builder Details
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder ┃ Executor ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ spack_env_create_from_manifest/8160a82a │ generic.local.bash │ Create spack environment from spack.yaml │ /home/spack/buildtest/examples/spack/env_create_manifest.yml │
└─────────────────────────────────────────┴────────────────────┴──────────────────────────────────────────┴──────────────────────────────────────────────────────────────┘
─────────────────────────────────────────────────────────────────────────────────────── Building Test ───────────────────────────────────────────────────────────────────────────────────────
spack_env_create_from_manifest/8160a82a: Creating test directory: /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/8160a82a
spack_env_create_from_manifest/8160a82a: Creating the stage directory: /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/8160a82a/stage
spack_env_create_from_manifest/8160a82a: Writing build script:
/home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/8160a82a/spack_env_create_from_manifest_build.sh
─────────────────────────────────────────────────────────────────────────────────────── Running Tests ───────────────────────────────────────────────────────────────────────────────────────
______________________________
Launching test: spack_env_create_from_manifest/8160a82a
spack_env_create_from_manifest/8160a82a: Running Test via command: bash --norc
--noprofile -eo pipefail spack_env_create_from_manifest_build.sh
spack_env_create_from_manifest/8160a82a: Test completed with returncode: 0
spack_env_create_from_manifest/8160a82a: Test completed in 3.365728 seconds
spack_env_create_from_manifest/8160a82a: Writing output file - /home/spack/runs
/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/8160a82a/
spack_env_create_from_manifest.out
spack_env_create_from_manifest/8160a82a: Writing error file - /home/spack/runs/g
eneric.local.bash/env_create_manifest/spack_env_create_from_manifest/8160a82a/sp
ack_env_create_from_manifest.err
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Builder ┃ executor ┃ status ┃ Checks (ReturnCode, Regex, Runtime) ┃ ReturnCode ┃ Runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ spack_env_create_from_manifest/8160a82a │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 3.365728 │
└─────────────────────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴──────────┘
Passed Tests: 1/1 Percentage: 100.000%
Failed Tests: 0/1 Percentage: 0.000%
Adding 1 test results to /home/spack/buildtest/var/report.json
Writing Logfile to: /home/spack/buildtest/var/logs/buildtest_tafvdocq.log
$ buildtest inspect query -o -t spack_env_create_from_manifest
──────────────────────────────────────────────────────────── spack_env_create_from_manifest/8160a82a-e6da-46dc-94d2-a24e9f83d2fa ────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Create spack environment from spack.yaml
State: PASS
Returncode: 0
Runtime: 3.365728 sec
Starttime: 2022/01/14 15:18:58
Endtime: 2022/01/14 15:19:02
Command: bash --norc --noprofile -eo pipefail spack_env_create_from_manifest_build.sh
Test Script: /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/8160a82a/spack_env_create_from_manifest.sh
Build Script: /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/8160a82a/spack_env_create_from_manifest_build.sh
Output File: /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/8160a82a/spack_env_create_from_manifest.out
Error File: /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/8160a82a/spack_env_create_from_manifest.err
Log File: /home/spack/buildtest/var/logs/buildtest_tafvdocq.log
────────────────────── Output File: /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/8160a82a/spack_env_create_from_manifest.out ──────────────────────
==> Concretized m4
- mkc3u4x m4@1.4.18%gcc@7.5.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linu
- lbrx7ln ^libsigsegv@2.12%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
==> Concretized zlib
- smoyzzo zlib@1.2.11%gcc@7.5.0+optimize+pic+shared arch=linux-ubuntu18.04-x86_64
==> Concretized python
- szj7juk python@3.8.6%gcc@7.5.0+bz2+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tix~tkinter~ucs4+uuid+zlib patches=0d98e93189bc278
- fvfpt26 ^bzip2@1.0.8%gcc@7.5.0+shared arch=linux-ubuntu18.04-x86_64
- otkkten ^diffutils@3.7%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
- jearpk4 ^libiconv@1.16%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
- ba7brxj ^expat@2.2.10%gcc@7.5.0+libbsd arch=linux-ubuntu18.04-x86_64
- u6ue7vw ^libbsd@0.10.0%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
- 4av4gyw ^gdbm@1.18.1%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
- t54jzdy ^readline@8.0%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
- crhlefo ^ncurses@6.2%gcc@7.5.0~symlinks+termlib arch=linux-ubuntu18.04-x86_64
- 4sh6pym ^pkgconf@1.7.3%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
- lbb45to ^gettext@0.21%gcc@7.5.0+bzip2+curses+git~libunistring+libxml2+tar+xz arch=linux-ubuntu18.04-x86_64
- yn2r3wf ^libxml2@2.9.10%gcc@7.5.0~python arch=linux-ubuntu18.04-x86_64
- komekkm ^xz@5.2.5%gcc@7.5.0~pic arch=linux-ubuntu18.04-x86_64
- smoyzzo ^zlib@1.2.11%gcc@7.5.0+optimize+pic+shared arch=linux-ubuntu18.04-x86_64
- uwe6tb5 ^tar@1.32%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
- hyhbnrm ^libffi@3.3%gcc@7.5.0 patches=26f26c6f29a7ce9bf370ad3ab2610f99365b4bdd7b82e7c31df41a3370d685c0 arch=linux-ubuntu18.04-x86_64
- wuyj2ax ^libuuid@1.0.3%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
- es377uq ^openssl@1.1.1h%gcc@7.5.0+systemcerts arch=linux-ubuntu18.04-x86_64
- zfdvt2j ^perl@5.32.0%gcc@7.5.0+cpanm+shared+threads arch=linux-ubuntu18.04-x86_64
- 4ihuiaz ^berkeley-db@18.1.40%gcc@7.5.0 arch=linux-ubuntu18.04-x86_64
- rhv2o7b ^sqlite@3.33.0%gcc@7.5.0+column_metadata+fts~functions~rtree arch=linux-ubuntu18.04-x86_64
─────────────────────── Test File: /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/8160a82a/spack_env_create_from_manifest.sh ────────────────────────
1 #!/bin/bash
2 source /home/spack/spack/share/spack/setup-env.sh
3 spack env create manifest_example /home/spack/buildtest/examples/spack/example/spack.yaml
4 spack env activate manifest_example
5 spack concretize -f
Removing Spack Environments¶
buildtest can remove spack environments which can be used if you are periodically running the same test where one is
creating the same environment. buildtest can automatically remove spack environment using the property remove_environment
which will remove the environment before creating it with same name. This field is part of the create
field and only works if
one is creating spack environments by name.
Alternately, buildtest provides the rm
field which can be used for removing environment explicitly. In the rm
field, the name
is a required field which is the name of the spack environment to remove. The name
field is of type: string
Shown below are two example tests where we remove spack environment using the remove_environment and rm field.
version: "1.0"
buildspecs:
remove_environment_automatically:
type: spack
executor: generic.local.bash
description: "remove spack environment automatically before creating a new environment"
tags: [spack]
spack:
root: $HOME/spack
env:
create:
remove_environment: true
name: remove_environment
activate:
name: remove_environment
specs:
- 'bzip2'
concretize: true
remove_environment_explicit:
type: spack
executor: generic.local.bash
description: "remove spack environment explicitly using the 'rm' property"
tags: [spack]
spack:
root: $HOME/spack
env:
rm:
name: dummy
create:
name: dummy
activate:
name: dummy
specs:
- 'bzip2'
concretize: true
Let’s build this by running the following
$ buildtest build -b /home/spack/buildtest/examples/spack/remove_environment_example.yml
╭───────────────────────────────────────────────────────── buildtest summary ──────────────────────────────────────────────────────────╮
│ │
│ User: spack │
│ Hostname: 2d93bd00cb98 │
│ Platform: Linux │
│ Current Time: 2022/01/14 15:19:03 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 0.12.0 │
│ python path: /home/spack/pyenv/buildtest/bin/python3 │
│ python version: 3.8.6 │
│ Configuration File: /home/spack/buildtest/buildtest/settings/spack_container.yml │
│ Test Directory: /home/spack/runs │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/remove_environment_example.yml │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ──────────────────────────────────────────────────────────────────────────────────
Discovered Buildspecs: 1
Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
Discovered buildspecs
╔═════════════════════════════════════════════════════════════════════╗
║ Buildspecs ║
╟─────────────────────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/remove_environment_example.yml ║
╚═════════════════════════════════════════════════════════════════════╝
──────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ─────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/remove_environment_example.yml: VALID
Total builder objects created: 2
Total compiler builder: 0
Total script builder: 0
Total spack builder: 2
Spack Builder Details
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder ┃ Executor ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ remove_environment_automatically/767337a0 │ generic.local.bash │ remove spack environment automatically before creating a │ /home/spack/buildtest/examples/spack/remove_environment_ex │
│ │ │ new environment │ ample.yml │
├───────────────────────────────────────────┼────────────────────┼─────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ remove_environment_explicit/7f12c06c │ generic.local.bash │ remove spack environment explicitly using the 'rm' property │ /home/spack/buildtest/examples/spack/remove_environment_ex │
│ │ │ │ ample.yml │
└───────────────────────────────────────────┴────────────────────┴─────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────┘
─────────────────────────────────────────────────────────────────────────────────────── Building Test ───────────────────────────────────────────────────────────────────────────────────────
remove_environment_automatically/767337a0: Creating test directory: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/767337a0
remove_environment_automatically/767337a0: Creating the stage directory: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/767337a0/stage
remove_environment_automatically/767337a0: Writing build script:
/home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/767337a0/remove_environment_automatically_build.sh
remove_environment_explicit/7f12c06c: Creating test directory: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/7f12c06c
remove_environment_explicit/7f12c06c: Creating the stage directory: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/7f12c06c/stage
remove_environment_explicit/7f12c06c: Writing build script:
/home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/7f12c06c/remove_environment_explicit_build.sh
─────────────────────────────────────────────────────────────────────────────────────── Running Tests ───────────────────────────────────────────────────────────────────────────────────────
______________________________
Launching test: remove_environment_automatically/767337a0
______________________________
Launching test: remove_environment_explicit/7f12c06c
remove_environment_automatically/767337a0: Running Test via command: bash --norc
--noprofile -eo pipefail remove_environment_automatically_build.sh
remove_environment_explicit/7f12c06c: Running Test via command: bash --norc
--noprofile -eo pipefail remove_environment_explicit_build.sh
remove_environment_automatically/767337a0: Test completed with returncode: 0
remove_environment_automatically/767337a0: Test completed in 5.647617 seconds
remove_environment_automatically/767337a0: Writing output file - /home/spack/ru
ns/generic.local.bash/remove_environment_example/remove_environment_automaticall
y/767337a0/remove_environment_automatically.out
remove_environment_automatically/767337a0: Writing error file - /home/spack/runs
/generic.local.bash/remove_environment_example/remove_environment_automatically/
767337a0/remove_environment_automatically.err
remove_environment_explicit/7f12c06c: Test completed with returncode: 0
remove_environment_explicit/7f12c06c: Test completed in 5.977121 seconds
remove_environment_explicit/7f12c06c: Writing output file - /home/spack/runs/ge
neric.local.bash/remove_environment_example/remove_environment_explicit/7f12c06c
/remove_environment_explicit.out
remove_environment_explicit/7f12c06c: Writing error file - /home/spack/runs/gene
ric.local.bash/remove_environment_example/remove_environment_explicit/7f12c06c/r
emove_environment_explicit.err
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Builder ┃ executor ┃ status ┃ Checks (ReturnCode, Regex, Runtime) ┃ ReturnCode ┃ Runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ remove_environment_automatically/767337a0 │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 5.647617 │
├───────────────────────────────────────────┼────────────────────┼────────┼─────────────────────────────────────┼────────────┼──────────┤
│ remove_environment_explicit/7f12c06c │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 5.977121 │
└───────────────────────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴──────────┘
Passed Tests: 2/2 Percentage: 100.000%
Failed Tests: 0/2 Percentage: 0.000%
Adding 2 test results to /home/spack/buildtest/var/report.json
Writing Logfile to: /home/spack/buildtest/var/logs/buildtest_jzl0baul.log
If we build and look at the generated te, we notice that spack will remove environments names: remove_environment, dummy.
$ buildtest inspect query -t remove_environment_automatically remove_environment_explicit
───────────────────────────────────────────────────────────── remove_environment_explicit/7f12c06c-a02e-466a-87c9-6735f1227c62 ──────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: remove spack environment explicitly using the 'rm' property
State: PASS
Returncode: 0
Runtime: 5.977121 sec
Starttime: 2022/01/14 15:19:03
Endtime: 2022/01/14 15:19:09
Command: bash --norc --noprofile -eo pipefail remove_environment_explicit_build.sh
Test Script: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/7f12c06c/remove_environment_explicit.sh
Build Script: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/7f12c06c/remove_environment_explicit_build.sh
Output File: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/7f12c06c/remove_environment_explicit.out
Error File: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/7f12c06c/remove_environment_explicit.err
Log File: /home/spack/buildtest/var/logs/buildtest_jzl0baul.log
─────────────────────── Test File: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/7f12c06c/remove_environment_explicit.sh ───────────────────────
1 #!/bin/bash
2 source /home/spack/spack/share/spack/setup-env.sh
3 spack env rm -y dummy
4 spack env create dummy
5 spack env activate dummy
6 spack add bzip2
7 spack concretize -f
─────────────────────────────────────────────────────────── remove_environment_automatically/767337a0-9f3d-440d-8f54-d6164f019929 ───────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: remove spack environment automatically before creating a new environment
State: PASS
Returncode: 0
Runtime: 5.647617 sec
Starttime: 2022/01/14 15:19:03
Endtime: 2022/01/14 15:19:09
Command: bash --norc --noprofile -eo pipefail remove_environment_automatically_build.sh
Test Script: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/767337a0/remove_environment_automatically.sh
Build Script: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/767337a0/remove_environment_automatically_build.sh
Output File: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/767337a0/remove_environment_automatically.out
Error File: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/767337a0/remove_environment_automatically.err
Log File: /home/spack/buildtest/var/logs/buildtest_jzl0baul.log
────────────────── Test File: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/767337a0/remove_environment_automatically.sh ──────────────────
1 #!/bin/bash
2 source /home/spack/spack/share/spack/setup-env.sh
3 spack env rm -y remove_environment
4 spack env create remove_environment
5 spack env activate remove_environment
6 spack add bzip2
7 spack concretize -f
Pre and Post Commands¶
The spack schema supports ability to write arbitrary shell script content using the pre_cmds
and post_cmds
field that are of type: string
and buildtest will insert the content into the test exactly as it is defined by
these two fields.
In this next example, we will test an installation of zlib by cloning spack from upstream and use pre_cmds
field
to specify where we will clone spack. In this example, we will clone spack under /tmp. Since we don’t have a valid
root of spack since test hasn’t been run, we can ignore check for spack paths by specifying verify_spack: false
which
informs buildtest to skip spack path check. Generally, buildtest will raise an exception if path specified by root
is
invalid and if $SPACK_ROOT/share/spack/setup-env.sh
doesn’t exist since this is the file that must be sourced.
The pre_cmds
are shell commands that are run before sourcing spack, whereas the post_cmds
are run at the very
end of the script. In the post_cmds, we will spack find
that will be run after spack install
.
We remove spack root ($SPACK_ROOT
) so that this test can be rerun again.
version: "1.0"
buildspecs:
run_pre_post_commands:
type: spack
executor: generic.local.bash
description: "Install zlib"
tags: [spack]
pre_cmds: |
cat /etc/os-release
gcc --version
spack:
root: $HOME/spack
install:
specs: ['zlib']
post_cmds: |
spack location -i gcc@6.5.0
spack --version
If we build this test and inspect the generated script we should get the following result.
$ buildtest build -b /home/spack/buildtest/examples/spack/pre_post_cmds.yml
╭─────────────────────────────────────────────────── buildtest summary ───────────────────────────────────────────────────╮
│ │
│ User: spack │
│ Hostname: 2d93bd00cb98 │
│ Platform: Linux │
│ Current Time: 2022/01/14 15:19:11 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 0.12.0 │
│ python path: /home/spack/pyenv/buildtest/bin/python3 │
│ python version: 3.8.6 │
│ Configuration File: /home/spack/buildtest/buildtest/settings/spack_container.yml │
│ Test Directory: /home/spack/runs │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/pre_post_cmds.yml │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ──────────────────────────────────────────────────────────────────────────────────
Discovered Buildspecs: 1
Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
Discovered buildspecs
╔════════════════════════════════════════════════════════╗
║ Buildspecs ║
╟────────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/pre_post_cmds.yml ║
╚════════════════════════════════════════════════════════╝
──────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ─────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/pre_post_cmds.yml: VALID
Total builder objects created: 1
Total compiler builder: 0
Total script builder: 0
Total spack builder: 1
Spack Builder Details
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder ┃ Executor ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ run_pre_post_commands/5c1d99fb │ generic.local.bash │ Install zlib │ /home/spack/buildtest/examples/spack/pre_post_cmds.yml │
└────────────────────────────────┴────────────────────┴──────────────┴────────────────────────────────────────────────────────┘
─────────────────────────────────────────────────────────────────────────────────────── Building Test ───────────────────────────────────────────────────────────────────────────────────────
run_pre_post_commands/5c1d99fb: Creating test directory: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/5c1d99fb
run_pre_post_commands/5c1d99fb: Creating the stage directory: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/5c1d99fb/stage
run_pre_post_commands/5c1d99fb: Writing build script: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/5c1d99fb/run_pre_post_commands_build.sh
─────────────────────────────────────────────────────────────────────────────────────── Running Tests ───────────────────────────────────────────────────────────────────────────────────────
______________________________
Launching test: run_pre_post_commands/5c1d99fb
run_pre_post_commands/5c1d99fb: Running Test via command: bash --norc
--noprofile -eo pipefail run_pre_post_commands_build.sh
run_pre_post_commands/5c1d99fb: Test completed with returncode: 0
run_pre_post_commands/5c1d99fb: Test completed in 2.766844 seconds
run_pre_post_commands/5c1d99fb: Writing output file - /home/spack/runs/generic.
local.bash/pre_post_cmds/run_pre_post_commands/5c1d99fb/run_pre_post_commands.ou
t
run_pre_post_commands/5c1d99fb: Writing error file - /home/spack/runs/generic.lo
cal.bash/pre_post_cmds/run_pre_post_commands/5c1d99fb/run_pre_post_commands.err
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Builder ┃ executor ┃ status ┃ Checks (ReturnCode, Regex, Runtime) ┃ ReturnCode ┃ Runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ run_pre_post_commands/5c1d99fb │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 2.766844 │
└────────────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴──────────┘
Passed Tests: 1/1 Percentage: 100.000%
Failed Tests: 0/1 Percentage: 0.000%
Adding 1 test results to /home/spack/buildtest/var/report.json
Writing Logfile to: /home/spack/buildtest/var/logs/buildtest_1j7dbr8y.log
$ buildtest inspect query -o -t run_pre_post_commands
──────────────────────────────────────────────────────────────── run_pre_post_commands/5c1d99fb-493e-431b-b2ed-14991ba83640 ─────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Install zlib
State: PASS
Returncode: 0
Runtime: 2.766844 sec
Starttime: 2022/01/14 15:19:11
Endtime: 2022/01/14 15:19:14
Command: bash --norc --noprofile -eo pipefail run_pre_post_commands_build.sh
Test Script: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/5c1d99fb/run_pre_post_commands.sh
Build Script: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/5c1d99fb/run_pre_post_commands_build.sh
Output File: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/5c1d99fb/run_pre_post_commands.out
Error File: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/5c1d99fb/run_pre_post_commands.err
Log File: /home/spack/buildtest/var/logs/buildtest_1j7dbr8y.log
────────────────────────────────── Output File: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/5c1d99fb/run_pre_post_commands.out ──────────────────────────────────
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[+] /home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/zlib-1.2.11-smoyzzo2qhzpn6mg6rd3l2p7b23enshg
/home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/gcc-6.5.0-ol37lodnsnyso6w7gkg5naw7m6kbltxu
0.16.3
─────────────────────────────────── Test File: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/5c1d99fb/run_pre_post_commands.sh ────────────────────────────────────
1 #!/bin/bash
2
3
4 ######## START OF PRE COMMANDS ########
5 cat /etc/os-release
6 gcc --version
7
8 ######## END OF PRE COMMANDS ########
9
10
11 source /home/spack/spack/share/spack/setup-env.sh
12 spack install zlib
13
14
15 ######## START OF POST COMMANDS ########
16 spack location -i gcc@6.5.0
17 spack --version
18
19 ######## END OF POST COMMANDS ########
20
21
Configuring Spack Mirrors¶
We can add mirrors in the
spack instance or spack environment using the mirror
property which is available
in the spack
and env
section. If the mirrror
property is part of the env
section, the
mirror will be added to spack environment. The mirror
is an object that expects a Key/Value pair where
the key is the name of mirror and value is location of the spack mirror.
In this next example, we will define a mirror name e4s that points to https://cache.e4s.io as the mirror location.
Internally, this translates to spack mirror add e4s https://cache.e4s.io
command.
version: "1.0"
buildspecs:
add_mirror:
type: spack
executor: generic.local.bash
description: Declare spack mirror
tags: [spack]
spack:
root: $HOME/spack
mirror:
spack_tutorial_mirror: /mirror
post_cmds: |
spack mirror list
spack config blame mirrors
add_mirror_in_spack_env:
type: spack
executor: generic.local.bash
description: Declare spack mirror in spack environment
tags: [spack]
spack:
root: $HOME/spack
env:
create:
name: spack_mirror
activate:
name: spack_mirror
mirror:
spack_tutorial_mirror: /mirror
post_cmds: |
spack mirror list
spack config blame mirrors
This test can be built by running:
buildtest build -b $BUILDTEST_ROOT/examples/spack/mirror_example.yml
If we look at the generated script for both tests, we see that mirror is added for both tests. Note that
one can have mirrors defined in their spack.yaml
or one of the configuration scopes
defined by spack.
$ buildtest inspect query -o -t add_mirror add_mirror_in_spack_env
─────────────────────────────────────────────────────────────── add_mirror_in_spack_env/7b30aeb1-7455-4f49-b2aa-a263f63bb6a1 ────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Declare spack mirror in spack environment
State: PASS
Returncode: 0
Runtime: 2.874365 sec
Starttime: 2022/01/14 15:19:16
Endtime: 2022/01/14 15:19:19
Command: bash --norc --noprofile -eo pipefail add_mirror_in_spack_env_build.sh
Test Script: /home/spack/runs/generic.local.bash/mirror_example/add_mirror_in_spack_env/7b30aeb1/add_mirror_in_spack_env.sh
Build Script: /home/spack/runs/generic.local.bash/mirror_example/add_mirror_in_spack_env/7b30aeb1/add_mirror_in_spack_env_build.sh
Output File: /home/spack/runs/generic.local.bash/mirror_example/add_mirror_in_spack_env/7b30aeb1/add_mirror_in_spack_env.out
Error File: /home/spack/runs/generic.local.bash/mirror_example/add_mirror_in_spack_env/7b30aeb1/add_mirror_in_spack_env.err
Log File: /home/spack/buildtest/var/logs/buildtest_yxn6qyk7.log
─────────────────────────────── Output File: /home/spack/runs/generic.local.bash/mirror_example/add_mirror_in_spack_env/7b30aeb1/add_mirror_in_spack_env.out ────────────────────────────────
spack_tutorial_mirror file:///mirror
tutorial file:///mirror
spack-public https://mirror.spack.io
--- mirrors:
/home/spack/spack/var/spack/environments/spack_mirror/spack.yaml:10 spack_tutorial_mirror: file:///mirror
/home/spack/.spack/mirrors.yaml:3 tutorial: file:///mirror
/home/spack/spack/etc/spack/defaults/mirrors.yaml:2 spack-public: https://mirror.spack.io
───────────────────────────────── Test File: /home/spack/runs/generic.local.bash/mirror_example/add_mirror_in_spack_env/7b30aeb1/add_mirror_in_spack_env.sh ─────────────────────────────────
1 #!/bin/bash
2 source /home/spack/spack/share/spack/setup-env.sh
3 spack env create spack_mirror
4 spack env activate spack_mirror
5 spack mirror add spack_tutorial_mirror /mirror
6
7
8 ######## START OF POST COMMANDS ########
9 spack mirror list
10 spack config blame mirrors
11 ######## END OF POST COMMANDS ########
12
13
────────────────────────────────────────────────────────────────────── add_mirror/e5fe39c3-1f82-497d-b38e-360f4f147ebb ──────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Declare spack mirror
State: PASS
Returncode: 0
Runtime: 1.843078 sec
Starttime: 2022/01/14 15:19:16
Endtime: 2022/01/14 15:19:18
Command: bash --norc --noprofile -eo pipefail add_mirror_build.sh
Test Script: /home/spack/runs/generic.local.bash/mirror_example/add_mirror/e5fe39c3/add_mirror.sh
Build Script: /home/spack/runs/generic.local.bash/mirror_example/add_mirror/e5fe39c3/add_mirror_build.sh
Output File: /home/spack/runs/generic.local.bash/mirror_example/add_mirror/e5fe39c3/add_mirror.out
Error File: /home/spack/runs/generic.local.bash/mirror_example/add_mirror/e5fe39c3/add_mirror.err
Log File: /home/spack/buildtest/var/logs/buildtest_yxn6qyk7.log
──────────────────────────────────────────── Output File: /home/spack/runs/generic.local.bash/mirror_example/add_mirror/e5fe39c3/add_mirror.out ─────────────────────────────────────────────
spack_tutorial_mirror file:///mirror
tutorial file:///mirror
spack-public https://mirror.spack.io
--- mirrors:
/home/spack/.spack/mirrors.yaml:2 spack_tutorial_mirror: file:///mirror
/home/spack/.spack/mirrors.yaml:3 tutorial: file:///mirror
/home/spack/spack/etc/spack/defaults/mirrors.yaml:2 spack-public: https://mirror.spack.io
────────────────────────────────────────────── Test File: /home/spack/runs/generic.local.bash/mirror_example/add_mirror/e5fe39c3/add_mirror.sh ──────────────────────────────────────────────
1 #!/bin/bash
2 source /home/spack/spack/share/spack/setup-env.sh
3 spack mirror add spack_tutorial_mirror /mirror
4
5
6 ######## START OF POST COMMANDS ########
7 spack mirror list
8 spack config blame mirrors
9
10 ######## END OF POST COMMANDS ########
11
12
Spack Test¶
Note
spack test
requires version 0.16.0 or higher in order to use this feature.
buildtest can run tests using spack test run
that can be used for testing installed specs with
tests provided by spack. In order to run tests, you need to declare the test
section
which is of type: object
in JSON and run
is a required property. The run
section maps to spack test run
that is responsible for running tests for a list of specs that are specified using the specs
property.
Upon running the tests, we can retrieve results using spack test results
which is configured using the results
property. The results property expects one to specify the specs
or suite
or both in order to retrieve results.
The suite
property is used to retrieve test results based on suite name, whereas specs
property can be used to retrieve based
on spec format. Both properties are a list of string types.
In example below we will test m4 package by running spack test run m4
and report the results with log file.
version: "1.0"
buildspecs:
spack_test_m4:
type: spack
executor: generic.local.bash
description: "Run spack test for m4 package and report results"
tags: [spack]
spack:
root: $HOME/spack
test:
run:
specs: ['m4']
results:
suite: ['spack_test_m4']
option: "-l"
If we look at the generated test, buildtest will install m4 followed by running the test. The spack test run –alias
option is used to reference name of suitename which can be used to reference suitename when using spack test results
to search for test results. buildtest will create the suite name based on name of test. If –alias is not specified,
spack will generate a random text for suitename which you won’t know at time of writing test that is required by
spack test results
to fetch the results.
$ buildtest build -b /home/spack/buildtest/examples/spack/spack_test.yml
╭───────────────────────────────────────────────── buildtest summary ──────────────────────────────────────────────────╮
│ │
│ User: spack │
│ Hostname: 2d93bd00cb98 │
│ Platform: Linux │
│ Current Time: 2022/01/14 15:19:20 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 0.12.0 │
│ python path: /home/spack/pyenv/buildtest/bin/python3 │
│ python version: 3.8.6 │
│ Configuration File: /home/spack/buildtest/buildtest/settings/spack_container.yml │
│ Test Directory: /home/spack/runs │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/spack_test.yml │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ──────────────────────────────────────────────────────────────────────────────────
Discovered Buildspecs: 1
Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
Discovered buildspecs
╔═════════════════════════════════════════════════════╗
║ Buildspecs ║
╟─────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/spack_test.yml ║
╚═════════════════════════════════════════════════════╝
──────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ─────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/spack_test.yml: VALID
Total builder objects created: 1
Total compiler builder: 0
Total script builder: 0
Total spack builder: 1
Spack Builder Details
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder ┃ Executor ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ spack_test_m4/956a6b7d │ generic.local.bash │ Run spack test for m4 package and report results │ /home/spack/buildtest/examples/spack/spack_test.yml │
└────────────────────────┴────────────────────┴──────────────────────────────────────────────────┴─────────────────────────────────────────────────────┘
─────────────────────────────────────────────────────────────────────────────────────── Building Test ───────────────────────────────────────────────────────────────────────────────────────
spack_test_m4/956a6b7d: Creating test directory: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/956a6b7d
spack_test_m4/956a6b7d: Creating the stage directory: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/956a6b7d/stage
spack_test_m4/956a6b7d: Writing build script: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/956a6b7d/spack_test_m4_build.sh
─────────────────────────────────────────────────────────────────────────────────────── Running Tests ───────────────────────────────────────────────────────────────────────────────────────
______________________________
Launching test: spack_test_m4/956a6b7d
spack_test_m4/956a6b7d: Running Test via command: bash --norc --noprofile -eo
pipefail spack_test_m4_build.sh
spack_test_m4/956a6b7d: Test completed with returncode: 0
spack_test_m4/956a6b7d: Test completed in 1.570861 seconds
spack_test_m4/956a6b7d: Writing output file - /home/spack/runs/generic.local.ba
sh/spack_test/spack_test_m4/956a6b7d/spack_test_m4.out
spack_test_m4/956a6b7d: Writing error file - /home/spack/runs/generic.local.bash
/spack_test/spack_test_m4/956a6b7d/spack_test_m4.err
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Builder ┃ executor ┃ status ┃ Checks (ReturnCode, Regex, Runtime) ┃ ReturnCode ┃ Runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ spack_test_m4/956a6b7d │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 1.570861 │
└────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴──────────┘
Passed Tests: 1/1 Percentage: 100.000%
Failed Tests: 0/1 Percentage: 0.000%
Adding 1 test results to /home/spack/buildtest/var/report.json
Writing Logfile to: /home/spack/buildtest/var/logs/buildtest_r6c_wafs.log
$ buildtest inspect query -o -t spack_test_m4
──────────────────────────────────────────────────────────────────── spack_test_m4/956a6b7d-adca-49f4-aade-7abc3dde3173 ─────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Run spack test for m4 package and report results
State: PASS
Returncode: 0
Runtime: 1.570861 sec
Starttime: 2022/01/14 15:19:20
Endtime: 2022/01/14 15:19:22
Command: bash --norc --noprofile -eo pipefail spack_test_m4_build.sh
Test Script: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/956a6b7d/spack_test_m4.sh
Build Script: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/956a6b7d/spack_test_m4_build.sh
Output File: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/956a6b7d/spack_test_m4.out
Error File: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/956a6b7d/spack_test_m4.err
Log File: /home/spack/buildtest/var/logs/buildtest_r6c_wafs.log
─────────────────────────────────────────── Output File: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/956a6b7d/spack_test_m4.out ────────────────────────────────────────────
==> Spack test spack_test_m4
==> Testing package m4-1.4.18-mkc3u4x
==> Results for test suite 'spack_test_m4':
==> m4-1.4.18-mkc3u4x PASSED
==> Testing package m4-1.4.18-mkc3u4x
==> [2022-01-14-15:19:21.727461] test: ensuring m4 version is 1.4.18
==> [2022-01-14-15:19:21.728484] '/home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/m4-1.4.18-mkc3u4x2p2wie6jfhuku7g5rkovcrxps/bin/m4' '--version'
m4 (GNU M4) 1.4.18
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Rene' Seindal.
PASSED
==> [2022-01-14-15:19:21.732728] test: ensuring m4 example succeeds
==> [2022-01-14-15:19:21.732978] '/home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/m4-1.4.18-mkc3u4x2p2wie6jfhuku7g5rkovcrxps/bin/m4' '/home/spack/.spack/test/5mpugnenojhehp5k
// macro is defined
Hello, World!
PASSED
───────────────────────────────────────────── Test File: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/956a6b7d/spack_test_m4.sh ─────────────────────────────────────────────
1 #!/bin/bash
2 source /home/spack/spack/share/spack/setup-env.sh
3 spack test run --alias spack_test_m4 m4
4 spack test results -l spack_test_m4
We can search for test results using the spec format instead of suite name. In the results
property we can
use specs
field instead of suite
property to specify a list of spec names to run. In spack, you can retrieve
the results using spack test results -- <spec>
, note that double dash --
is in front of spec name. We can
pass options to spack test results
using the option property which is available for results
and
run
property. Currently, spack will write test results in $HOME/.spack/tests
and we can use spack test remove
to clear all test results. This can be done in buildspec using the remove_tests
field which
is a boolean. If this is set to True buildtest will run spack test remove -y
to remove all test suites before running
the tests.
In this next example, we will create a spack environment to install libxml2 and libsigsegv and test the package and report log after running test.
version: "1.0"
buildspecs:
spack_test_results_specs_format:
type: spack
executor: generic.local.bash
description: "Run spack test results with spec format"
tags: [spack]
spack:
root: $HOME/spack
env:
create:
name: spack_test_example
activate:
name: spack_test_example
install:
specs: ['libxml2', 'libsigsegv']
test:
remove_tests: true
run:
specs: ['libxml2', 'libsigsegv']
results:
option: '-l'
specs: ['libxml2', 'libsigsegv']
We can build this test by running the following
$ buildtest build -b /home/spack/buildtest/examples/spack/spack_test_specs.yml
╭──────────────────────────────────────────────────── buildtest summary ─────────────────────────────────────────────────────╮
│ │
│ User: spack │
│ Hostname: 2d93bd00cb98 │
│ Platform: Linux │
│ Current Time: 2022/01/14 15:19:23 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 0.12.0 │
│ python path: /home/spack/pyenv/buildtest/bin/python3 │
│ python version: 3.8.6 │
│ Configuration File: /home/spack/buildtest/buildtest/settings/spack_container.yml │
│ Test Directory: /home/spack/runs │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/spack_test_specs.yml │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ──────────────────────────────────────────────────────────────────────────────────
Discovered Buildspecs: 1
Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
Discovered buildspecs
╔═══════════════════════════════════════════════════════════╗
║ Buildspecs ║
╟───────────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/spack_test_specs.yml ║
╚═══════════════════════════════════════════════════════════╝
──────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ─────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/spack_test_specs.yml: VALID
Total builder objects created: 1
Total compiler builder: 0
Total script builder: 0
Total spack builder: 1
Spack Builder Details
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Builder ┃ Executor ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ spack_test_results_specs_format/5aed83a1 │ generic.local.bash │ Run spack test results with spec format │ /home/spack/buildtest/examples/spack/spack_test_specs.yml │
└──────────────────────────────────────────┴────────────────────┴─────────────────────────────────────────┴───────────────────────────────────────────────────────────┘
─────────────────────────────────────────────────────────────────────────────────────── Building Test ───────────────────────────────────────────────────────────────────────────────────────
spack_test_results_specs_format/5aed83a1: Creating test directory: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/5aed83a1
spack_test_results_specs_format/5aed83a1: Creating the stage directory: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/5aed83a1/stage
spack_test_results_specs_format/5aed83a1: Writing build script:
/home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/5aed83a1/spack_test_results_specs_format_build.sh
─────────────────────────────────────────────────────────────────────────────────────── Running Tests ───────────────────────────────────────────────────────────────────────────────────────
______________________________
Launching test: spack_test_results_specs_format/5aed83a1
spack_test_results_specs_format/5aed83a1: Running Test via command: bash --norc
--noprofile -eo pipefail spack_test_results_specs_format_build.sh
spack_test_results_specs_format/5aed83a1: Test completed with returncode: 0
spack_test_results_specs_format/5aed83a1: Test completed in 5.489641 seconds
spack_test_results_specs_format/5aed83a1: Writing output file - /home/spack/run
s/generic.local.bash/spack_test_specs/spack_test_results_specs_format/5aed83a1/s
pack_test_results_specs_format.out
spack_test_results_specs_format/5aed83a1: Writing error file - /home/spack/runs/
generic.local.bash/spack_test_specs/spack_test_results_specs_format/5aed83a1/spa
ck_test_results_specs_format.err
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Builder ┃ executor ┃ status ┃ Checks (ReturnCode, Regex, Runtime) ┃ ReturnCode ┃ Runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ spack_test_results_specs_format/5aed83a1 │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 5.489641 │
└──────────────────────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴──────────┘
Passed Tests: 1/1 Percentage: 100.000%
Failed Tests: 0/1 Percentage: 0.000%
Adding 1 test results to /home/spack/buildtest/var/report.json
Writing Logfile to: /home/spack/buildtest/var/logs/buildtest_ap77gg_s.log
Now let’s check the generated test and output file, we see buildtest will install libxml2 and libsigsegv
in spack environment followed by removing all testsuites using spack test remove -y
and run the test. Note that we can
query results in spec format (spack test results --l --libxml2
) where spack will try to match a result file that matches the
corresponding spec.
$ buildtest inspect query -o -t spack_test_results_specs_format
─────────────────────────────────────────────────────────── spack_test_results_specs_format/5aed83a1-6bb6-4382-9f03-a4736857d752 ────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Run spack test results with spec format
State: PASS
Returncode: 0
Runtime: 5.489641 sec
Starttime: 2022/01/14 15:19:23
Endtime: 2022/01/14 15:19:28
Command: bash --norc --noprofile -eo pipefail spack_test_results_specs_format_build.sh
Test Script: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/5aed83a1/spack_test_results_specs_format.sh
Build Script: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/5aed83a1/spack_test_results_specs_format_build.sh
Output File: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/5aed83a1/spack_test_results_specs_format.out
Error File: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/5aed83a1/spack_test_results_specs_format.err
Log File: /home/spack/buildtest/var/logs/buildtest_ap77gg_s.log
────────────────────── Output File: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/5aed83a1/spack_test_results_specs_format.out ───────────────────────
==> All of the packages are already installed
==> All of the packages are already installed
==> Spack test spack_test_results_specs_format
==> Testing package libxml2-2.9.10-yn2r3wf
==> Testing package libsigsegv-2.12-lbrx7ln
==> Results for test suite 'spack_test_results_specs_format', spec matching 'libxml2':
==> libxml2-2.9.10-yn2r3wf PASSED
==> Testing package libxml2-2.9.10-yn2r3wf
==> [2022-01-14-15:19:27.401832] test: Performing simple import test
==> [2022-01-14-15:19:27.402547] test: xml2-config: expect command status in [0]
==> [2022-01-14-15:19:27.402829] '/home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libxml2-2.9.10-yn2r3wfhiilelyulh5toteicdtxjhw7d/bin/xml2-config' '--version'
2.9.10
PASSED
==> [2022-01-14-15:19:27.406553] test: xmllint: expect command status in [0]
==> [2022-01-14-15:19:27.406920] '/home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libxml2-2.9.10-yn2r3wfhiilelyulh5toteicdtxjhw7d/bin/xmllint' '--auto' '-o' 'test.xml'
PASSED
==> [2022-01-14-15:19:27.411121] test: xmllint: expect command status in [3]
==> [2022-01-14-15:19:27.411562] '/home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libxml2-2.9.10-yn2r3wfhiilelyulh5toteicdtxjhw7d/bin/xmllint' '--postvalid' 'test.xml'
<?xml version="1.0"?>
<info>abc</info>
validity error : no DTD found!
Document test.xml does not validate
PASSED
==> [2022-01-14-15:19:27.416198] test: xmllint: expect command status in [3]
==> [2022-01-14-15:19:27.416631] '/home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libxml2-2.9.10-yn2r3wfhiilelyulh5toteicdtxjhw7d/bin/xmllint' '--dtdvalid' '/home/spack/.spac
<?xml version="1.0"?>
<info>abc</info>
test.xml:2: element info: validity error : Element info content does not follow the DTD, expecting (data), got (CDATA)
Document test.xml does not validate against /home/spack/.spack/test/d6phm2ufma23flnqrts7vw7vidoawdvg/libxml2-2.9.10-yn2r3wf/data/libxml2/info.dtd
PASSED
==> [2022-01-14-15:19:27.421012] test: xmllint: expect command status in [0]
==> [2022-01-14-15:19:27.421313] '/home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libxml2-2.9.10-yn2r3wfhiilelyulh5toteicdtxjhw7d/bin/xmllint' '--dtdvalid' '/home/spack/.spac
<?xml version="1.0"?>
<info>
<data>abc</data>
</info>
PASSED
==> [2022-01-14-15:19:27.425465] test: xmlcatalog: expect command status in [0]
==> [2022-01-14-15:19:27.425826] '/home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libxml2-2.9.10-yn2r3wfhiilelyulh5toteicdtxjhw7d/bin/xmlcatalog' '--create'
<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"/>
PASSED
==> Results for test suite 'spack_test_results_specs_format', spec matching 'libsigsegv':
==> libsigsegv-2.12-lbrx7ln PASSED
==> Testing package libsigsegv-2.12-lbrx7ln
==> [2022-01-14-15:19:27.764162] test: checking ability to link to the library
==> [2022-01-14-15:19:27.764601] '/home/spack/spack/lib/spack/env/cc' '-I/home/spack/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/libsigsegv-2.12-lbrx7lnfz46ukewxbhxnucmx76g23c6q/incl
PASSED
==> [2022-01-14-15:19:27.844662] test: checking ability to use the library
==> [2022-01-14-15:19:27.845032] './smoke_test'
Caught sigsegv #1
Hello World!
PASSED
──────────────────────── Test File: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/5aed83a1/spack_test_results_specs_format.sh ────────────────────────
1 #!/bin/bash
2 source /home/spack/spack/share/spack/setup-env.sh
3 spack env create spack_test_example
4 spack env activate spack_test_example
5 spack install libxml2
6 spack install libsigsegv
7 spack test remove -y
8 spack test run --alias spack_test_results_specs_format libxml2 libsigsegv
9 spack test results -l -- libxml2
10 spack test results -l -- libsigsegv
Specifying Scheduler Directives¶
The spack schema supports all of the scheduler scheduler directives such
as sbatch
, bsub
, pbs
, cobalt
, and batch
property in the buildspec.
The directives are applied at top of script. Shown below is a toy example that will define directives using sbatch property. Note, this test won’t submit job to scheduler since we are not using the a slurm executor.
version: "1.0"
buildspecs:
spack_sbatch_example:
type: spack
executor: generic.local.bash
description: "sbatch directives can be defined in spack schema"
tags: [spack]
sbatch: ["-N 1", "-n 8", "-t 30"]
spack:
root: $HOME/spack
install:
specs: ['zlib@1.2.11%clang', 'zlib@1.2.8%clang']
buildtest will generate the shell script with the job directives and set the name, output and error files based on name of test. If we build this test, and inspect the generated test we see that #SBATCH directives are written based on the sbatch field.
$ buildtest inspect query -t spack_sbatch_example
───────────────────────────────────────────────────────────────── spack_sbatch_example/ae2d83a2-3540-49af-b323-af16fc8e36d1 ─────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: sbatch directives can be defined in spack schema
State: PASS
Returncode: 0
Runtime: 1.436416 sec
Starttime: 2022/01/14 15:19:30
Endtime: 2022/01/14 15:19:31
Command: bash --norc --noprofile -eo pipefail spack_sbatch_example_build.sh
Test Script: /home/spack/runs/generic.local.bash/spack_sbatch/spack_sbatch_example/ae2d83a2/spack_sbatch_example.sh
Build Script: /home/spack/runs/generic.local.bash/spack_sbatch/spack_sbatch_example/ae2d83a2/spack_sbatch_example_build.sh
Output File: /home/spack/runs/generic.local.bash/spack_sbatch/spack_sbatch_example/ae2d83a2/spack_sbatch_example.out
Error File: /home/spack/runs/generic.local.bash/spack_sbatch/spack_sbatch_example/ae2d83a2/spack_sbatch_example.err
Log File: /home/spack/buildtest/var/logs/buildtest_1bzb07wd.log
───────────────────────────────────── Test File: /home/spack/runs/generic.local.bash/spack_sbatch/spack_sbatch_example/ae2d83a2/spack_sbatch_example.sh ─────────────────────────────────────
1 #!/bin/bash
2 ####### START OF SCHEDULER DIRECTIVES #######
3 #SBATCH -N 1
4 #SBATCH -n 8
5 #SBATCH -t 30
6 #SBATCH --job-name=spack_sbatch_example
7 #SBATCH --output=spack_sbatch_example.out
8 #SBATCH --error=spack_sbatch_example.err
9 ####### END OF SCHEDULER DIRECTIVES #######
10 source /home/spack/spack/share/spack/setup-env.sh
11 spack install zlib@1.2.11%clang
12 spack install zlib@1.2.8%clang
You can define multiple executors in your buildspec
with spack schema via executors
. This can be useful if you need to specify
different scheduler directives based on executor type since your executor will map to
a queue.
Shown below is an example buildspec that will specify sbatch
directives for
generic.local.sh
and generic.local.bash
version: "1.0"
buildspecs:
spack_sbatch_multi_executors:
type: spack
executor: "generic.local.(sh|bash)"
description: "sbatch directives can be defined in spack schema"
tags: [spack]
executors:
generic.local.sh:
sbatch: ["-N 1", "-t 30"]
generic.local.bash:
sbatch: ["-N 8", "-t 15"]
spack:
root: $HOME/spack
test:
run:
specs: ['libsigsegv']
results:
specs: ['libsigsegv']
option: "-l"