Note
Please see Tutorials Setup before you proceed with this section
Buildtest Spack Integration¶
Note
This feature is in active development.
buildtest can use spack to build test where one can use
spack to install packages followed by running any test. You must set type: spack
in buildspec to use the spack schema for validating the buildspec test. Currently, we have
spack.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.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "spack schema version",
"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"
],
"additionalProperties": false,
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. In the second test,
we run the same example except we clone spack and install zlib. When root
property is not specified buildtest
will clone spack and automatically source the spack setup script (source $SPACK_ROOT/share/spack/setup-env.sh).
The schema is designed to mimic spack commands which will be clear with more examples.
buildspecs:
install_specs_example:
type: spack
executor: generic.local.bash
description: "Install zlib from an existing spack instance"
tags: [spack]
spack:
root: $HOME/spack
install:
specs: ['zlib']
clone_spack_and_install_zlib:
type: spack
executor: generic.local.bash
description: "Clone spack and install zlib spec"
tags: [spack]
spack:
install:
specs: ['zlib']
Let’s build this test by running the following
buildtest build -b /home/spack/buildtest/examples/spack/install_specs.yml
$ 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: f215b09d0d2f │
│ Platform: Linux │
│ Current Time: 2023/02/06 21:13:55 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 1.1 │
│ 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 │
│ Report File: /home/spack/buildtest/var/report.json │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/install_specs.yml │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
───────────────────────────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ─────────────────────────────────────────────────────────────────────────────────────────────────────────
Discovered buildspecs
╔════════════════════════════════════════════════════════╗
║ buildspec ║
╟────────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/install_specs.yml ║
╚════════════════════════════════════════════════════════╝
Total Discovered Buildspecs: 1
Total Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
─────────────────────────────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ────────────────────────────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/install_specs.yml: VALID
Total builder objects created: 2
Builders by type=spack
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ builder ┃ type ┃ executor ┃ compiler ┃ nodes ┃ procs ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ install_specs_example/e19633f1 │ spack │ generic.local.bash │ None │ None │ None │ Install zlib from an existing spack instance │ /home/spack/buildtest/examples/spack/install_specs.yml │
├───────────────────────────────────────┼───────┼────────────────────┼──────────┼───────┼───────┼──────────────────────────────────────────────┼────────────────────────────────────────────────────────┤
│ clone_spack_and_install_zlib/a29977c5 │ spack │ generic.local.bash │ None │ None │ None │ Clone spack and install zlib spec │ /home/spack/buildtest/examples/spack/install_specs.yml │
└───────────────────────────────────────┴───────┴────────────────────┴──────────┴───────┴───────┴──────────────────────────────────────────────┴────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────────────── Building Test ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
install_specs_example/e19633f1: Creating test directory: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/e19633f1
install_specs_example/e19633f1: Creating the stage directory: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/e19633f1/stage
install_specs_example/e19633f1: Writing build script: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/e19633f1/install_specs_example_build.sh
clone_spack_and_install_zlib/a29977c5: Creating test directory: /home/spack/runs/generic.local.bash/install_specs/clone_spack_and_install_zlib/a29977c5
clone_spack_and_install_zlib/a29977c5: Creating the stage directory: /home/spack/runs/generic.local.bash/install_specs/clone_spack_and_install_zlib/a29977c5/stage
clone_spack_and_install_zlib/a29977c5: Writing build script: /home/spack/runs/generic.local.bash/install_specs/clone_spack_and_install_zlib/a29977c5/clone_spack_and_install_zlib_build.sh
────────────────────────────────────────────────────────────────────────────────────────────────────────────── Running Tests ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
Spawning 4 processes for processing builders
─────────────────────────────────────────────────────────────────────────────────────────────────────────────── Iteration 1 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
clone_spack_and_install_zlib/a29977c5 does not have any dependencies adding test to queue
install_specs_example/e19633f1 does not have any dependencies adding test to queue
clone_spack_and_install_zlib/a29977c5: Current Working Directory : /home/spack/runs/generic.local.bash/install_specs/clone_spack_and_install_zlib/a29977c5/stage
install_specs_example/e19633f1: Current Working Directory : /home/spack/runs/generic.local.bash/install_specs/install_specs_example/e19633f1/stage
install_specs_example/e19633f1: Running Test via command: bash --norc --noprofile -eo pipefail install_specs_example_build.sh
clone_spack_and_install_zlib/a29977c5: Running Test via command: bash --norc --noprofile -eo pipefail clone_spack_and_install_zlib_build.sh
install_specs_example/e19633f1: Test completed in 1.391641 seconds
install_specs_example/e19633f1: Test completed with returncode: 0
install_specs_example/e19633f1: Writing output file - /home/spack/runs/generic.local.bash/install_specs/install_specs_example/e19633f1/install_specs_example.out
install_specs_example/e19633f1: Writing error file - /home/spack/runs/generic.local.bash/install_specs/install_specs_example/e19633f1/install_specs_example.err
clone_spack_and_install_zlib/a29977c5: Test completed in 88.434209 seconds
clone_spack_and_install_zlib/a29977c5: Test completed with returncode: 0
clone_spack_and_install_zlib/a29977c5: Writing output file - /home/spack/runs/generic.local.bash/install_specs/clone_spack_and_install_zlib/a29977c5/clone_spack_and_install_zlib.out
clone_spack_and_install_zlib/a29977c5: Writing error file - /home/spack/runs/generic.local.bash/install_specs/clone_spack_and_install_zlib/a29977c5/clone_spack_and_install_zlib.err
In this iteration we are going to run the following tests: [clone_spack_and_install_zlib/a29977c5, install_specs_example/e19633f1]
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ builder ┃ executor ┃ status ┃ checks (ReturnCode, Regex, Runtime) ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ install_specs_example/e19633f1 │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 1.391641 │
├───────────────────────────────────────┼────────────────────┼────────┼─────────────────────────────────────┼────────────┼───────────┤
│ clone_spack_and_install_zlib/a29977c5 │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 88.434209 │
└───────────────────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴───────────┘
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_3ufksmr5.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. In the second test
we clone spack and it will install zlib from source.
buildtest inspect query -o -t install_specs_example clone_spack_and_install_zlib
$ buildtest inspect query -o -t install_specs_example clone_spack_and_install_zlib
─────────────────────────────────────────────────────────────────────────────────────── install_specs_example/e19633f1-8ecd-4e30-b931-f2102038942c ────────────────────────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Install zlib from an existing spack instance
State: PASS
Returncode: 0
Runtime: 1.391641 sec
Starttime: 2023/02/06 21:13:55
Endtime: 2023/02/06 21:13:56
Command: bash --norc --noprofile -eo pipefail install_specs_example_build.sh
Test Script: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/e19633f1/install_specs_example.sh
Build Script: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/e19633f1/install_specs_example_build.sh
Output File: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/e19633f1/install_specs_example.out
Error File: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/e19633f1/install_specs_example.err
Log File: /home/spack/buildtest/var/logs/buildtest_3ufksmr5.log
───────────────────────────────────────────────────────── Output File: /home/spack/runs/generic.local.bash/install_specs/install_specs_example/e19633f1/install_specs_example.out ─────────────────────────────────────────────────────────
[+] /home/spack/spack-workspace/software/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/e19633f1/install_specs_example.sh ───────────────────────────────────────────────────────────
#!/bin/bash
source /home/spack/spack/share/spack/setup-env.sh
spack install zlib
──────────────────────────────────────────────────────────────────────────────────── clone_spack_and_install_zlib/a29977c5-c71f-4123-b445-fcc3bc068b04 ────────────────────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Clone spack and install zlib spec
State: PASS
Returncode: 0
Runtime: 88.434209 sec
Starttime: 2023/02/06 21:13:55
Endtime: 2023/02/06 21:15:23
Command: bash --norc --noprofile -eo pipefail clone_spack_and_install_zlib_build.sh
Test Script: /home/spack/runs/generic.local.bash/install_specs/clone_spack_and_install_zlib/a29977c5/clone_spack_and_install_zlib.sh
Build Script: /home/spack/runs/generic.local.bash/install_specs/clone_spack_and_install_zlib/a29977c5/clone_spack_and_install_zlib_build.sh
Output File: /home/spack/runs/generic.local.bash/install_specs/clone_spack_and_install_zlib/a29977c5/clone_spack_and_install_zlib.out
Error File: /home/spack/runs/generic.local.bash/install_specs/clone_spack_and_install_zlib/a29977c5/clone_spack_and_install_zlib.err
Log File: /home/spack/buildtest/var/logs/buildtest_3ufksmr5.log
────────────────────────────────────────────────── Output File: /home/spack/runs/generic.local.bash/install_specs/clone_spack_and_install_zlib/a29977c5/clone_spack_and_install_zlib.out ──────────────────────────────────────────────────
==> Installing zlib-1.2.13-fp4hlchxmdydxrhdkxh3q3buwtlcrc7k
==> No binary for zlib-1.2.13-fp4hlchxmdydxrhdkxh3q3buwtlcrc7k found: installing from source
==> Fetching https://mirror.spack.io/_source-cache/archive/b3/b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30.tar.gz
==> No patches needed for zlib
==> zlib: Executing phase: 'edit'
==> zlib: Executing phase: 'build'
==> zlib: Executing phase: 'install'
==> zlib: Successfully installed zlib-1.2.13-fp4hlchxmdydxrhdkxh3q3buwtlcrc7k
Stage: 0.31s. Edit: 0.80s. Build: 1.49s. Install: 0.30s. Total: 2.99s
[+] /home/spack/runs/generic.local.bash/install_specs/clone_spack_and_install_zlib/a29977c5/stage/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/zlib-1.2.13-fp4hlchxmdydxrhdkxh3q3buwtlcrc7k
─────────────────────────────────────────────────── Test File: /home/spack/runs/generic.local.bash/install_specs/clone_spack_and_install_zlib/a29977c5/clone_spack_and_install_zlib.sh ────────────────────────────────────────────────────
#!/bin/bash
git clone https://github.com/spack/spack
source ./spack/share/spack/setup-env.sh
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.
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 build -b /home/spack/buildtest/examples/spack/env_install.yml
╭────────────────────────────────────────────────── buildtest summary ──────────────────────────────────────────────────╮
│ │
│ User: spack │
│ Hostname: f215b09d0d2f │
│ Platform: Linux │
│ Current Time: 2023/02/06 21:15:24 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 1.1 │
│ 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 │
│ Report File: /home/spack/buildtest/var/report.json │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/env_install.yml │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
───────────────────────────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ─────────────────────────────────────────────────────────────────────────────────────────────────────────
Discovered buildspecs
╔══════════════════════════════════════════════════════╗
║ buildspec ║
╟──────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/env_install.yml ║
╚══════════════════════════════════════════════════════╝
Total Discovered Buildspecs: 1
Total Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
─────────────────────────────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ────────────────────────────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/env_install.yml: VALID
Total builder objects created: 1
Builders by type=spack
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ builder ┃ type ┃ executor ┃ compiler ┃ nodes ┃ procs ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ install_in_spack_env/9f0c2e5d │ spack │ generic.local.bash │ None │ None │ None │ 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/9f0c2e5d: Creating test directory: /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/9f0c2e5d
install_in_spack_env/9f0c2e5d: Creating the stage directory: /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/9f0c2e5d/stage
install_in_spack_env/9f0c2e5d: Writing build script: /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/9f0c2e5d/install_in_spack_env_build.sh
────────────────────────────────────────────────────────────────────────────────────────────────────────────── Running Tests ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
Spawning 4 processes for processing builders
─────────────────────────────────────────────────────────────────────────────────────────────────────────────── Iteration 1 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
install_in_spack_env/9f0c2e5d does not have any dependencies adding test to queue
install_in_spack_env/9f0c2e5d: Current Working Directory : /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/9f0c2e5d/stage
install_in_spack_env/9f0c2e5d: Running Test via command: bash --norc --noprofile -eo pipefail install_in_spack_env_build.sh
install_in_spack_env/9f0c2e5d: Test completed in 4.618925 seconds
install_in_spack_env/9f0c2e5d: Test completed with returncode: 0
install_in_spack_env/9f0c2e5d: Writing output file - /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/9f0c2e5d/install_in_spack_env.out
install_in_spack_env/9f0c2e5d: Writing error file - /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/9f0c2e5d/install_in_spack_env.err
In this iteration we are going to run the following tests: [install_in_spack_env/9f0c2e5d]
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ builder ┃ executor ┃ status ┃ checks (ReturnCode, Regex, Runtime) ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ install_in_spack_env/9f0c2e5d │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 4.618925 │
└───────────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴──────────┘
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_thv679v3.log
buildtest inspect query -t install_in_spack_env
$ buildtest inspect query -t install_in_spack_env
──────────────────────────────────────────────────────────────────────────────────────── install_in_spack_env/9f0c2e5d-0974-4881-8066-c79aa2ed352f ────────────────────────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Install m4 and zlib in a spack environment named m4_zlib
State: PASS
Returncode: 0
Runtime: 4.618925 sec
Starttime: 2023/02/06 21:15:25
Endtime: 2023/02/06 21:15:29
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/9f0c2e5d/install_in_spack_env.sh
Build Script: /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/9f0c2e5d/install_in_spack_env_build.sh
Output File: /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/9f0c2e5d/install_in_spack_env.out
Error File: /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/9f0c2e5d/install_in_spack_env.err
Log File: /home/spack/buildtest/var/logs/buildtest_thv679v3.log
──────────────────────────────────────────────────────────── Test File: /home/spack/runs/generic.local.bash/env_install/install_in_spack_env/9f0c2e5d/install_in_spack_env.sh ─────────────────────────────────────────────────────────────
#!/bin/bash
source /home/spack/spack/share/spack/setup-env.sh
spack compiler find
spack env create m4_zlib
spack env activate m4_zlib
spack add m4
spack add zlib
spack concretize -f
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
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 build -b /home/spack/buildtest/examples/spack/env_create_directory.yml
╭────────────────────────────────────────────────────── buildtest summary ───────────────────────────────────────────────────────╮
│ │
│ User: spack │
│ Hostname: f215b09d0d2f │
│ Platform: Linux │
│ Current Time: 2023/02/06 21:15:30 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 1.1 │
│ 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 │
│ Report File: /home/spack/buildtest/var/report.json │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/env_create_directory.yml │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
───────────────────────────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ─────────────────────────────────────────────────────────────────────────────────────────────────────────
Discovered buildspecs
╔═══════════════════════════════════════════════════════════════╗
║ buildspec ║
╟───────────────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/env_create_directory.yml ║
╚═══════════════════════════════════════════════════════════════╝
Total Discovered Buildspecs: 1
Total Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
─────────────────────────────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ────────────────────────────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/env_create_directory.yml: VALID
Total builder objects created: 1
Builders by type=spack
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ builder ┃ type ┃ executor ┃ compiler ┃ nodes ┃ procs ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ spack_env_directory/c5e078b9 │ spack │ generic.local.bash │ None │ None │ None │ create spack environment in directory │ /home/spack/buildtest/examples/spack/env_create_directory.yml │
└──────────────────────────────┴───────┴────────────────────┴──────────┴───────┴───────┴───────────────────────────────────────┴───────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────────────── Building Test ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
spack_env_directory/c5e078b9: Creating test directory: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/c5e078b9
spack_env_directory/c5e078b9: Creating the stage directory: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/c5e078b9/stage
spack_env_directory/c5e078b9: Writing build script: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/c5e078b9/spack_env_directory_build.sh
────────────────────────────────────────────────────────────────────────────────────────────────────────────── Running Tests ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
Spawning 4 processes for processing builders
─────────────────────────────────────────────────────────────────────────────────────────────────────────────── Iteration 1 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
spack_env_directory/c5e078b9 does not have any dependencies adding test to queue
spack_env_directory/c5e078b9: Current Working Directory : /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/c5e078b9/stage
spack_env_directory/c5e078b9: Running Test via command: bash --norc --noprofile -eo pipefail spack_env_directory_build.sh
spack_env_directory/c5e078b9: Test completed in 2.792924 seconds
spack_env_directory/c5e078b9: Test completed with returncode: 0
spack_env_directory/c5e078b9: Writing output file - /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/c5e078b9/spack_env_directory.out
spack_env_directory/c5e078b9: Writing error file - /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/c5e078b9/spack_env_directory.err
In this iteration we are going to run the following tests: [spack_env_directory/c5e078b9]
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ builder ┃ executor ┃ status ┃ checks (ReturnCode, Regex, Runtime) ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ spack_env_directory/c5e078b9 │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 2.792924 │
└──────────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴──────────┘
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_449ujhuy.log
buildtest inspect query -o -t spack_env_directory
$ buildtest inspect query -o -t spack_env_directory
──────────────────────────────────────────────────────────────────────────────────────── spack_env_directory/c5e078b9-e1a7-44a7-b00c-662e89d196db ─────────────────────────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: create spack environment in directory
State: PASS
Returncode: 0
Runtime: 2.792924 sec
Starttime: 2023/02/06 21:15:30
Endtime: 2023/02/06 21:15:33
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/c5e078b9/spack_env_directory.sh
Build Script: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/c5e078b9/spack_env_directory_build.sh
Output File: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/c5e078b9/spack_env_directory.out
Error File: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/c5e078b9/spack_env_directory.err
Log File: /home/spack/buildtest/var/logs/buildtest_449ujhuy.log
─────────────────────────────────────────────────────── Output File: /home/spack/runs/generic.local.bash/env_create_directory/spack_env_directory/c5e078b9/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=linux-ubuntu18.04-x86_64
[+] 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/c5e078b9/spack_env_directory.sh ─────────────────────────────────────────────────────────
#!/bin/bash
source /home/spack/spack/share/spack/setup-env.sh
spack env create -d /home/spack/spack-envs/m4
spack env activate -d /home/spack/spack-envs/m4
spack add m4
spack install
######## START OF POST COMMANDS ########
spack find
rm -rf $HOME/spack-envs/m4
######## END OF POST COMMANDS ########
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.
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 build -b /home/spack/buildtest/examples/spack/env_create_manifest.yml
╭────────────────────────────────────────────────────── buildtest summary ──────────────────────────────────────────────────────╮
│ │
│ User: spack │
│ Hostname: f215b09d0d2f │
│ Platform: Linux │
│ Current Time: 2023/02/06 21:15:34 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 1.1 │
│ 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 │
│ Report File: /home/spack/buildtest/var/report.json │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/env_create_manifest.yml │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
───────────────────────────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ─────────────────────────────────────────────────────────────────────────────────────────────────────────
Discovered buildspecs
╔══════════════════════════════════════════════════════════════╗
║ buildspec ║
╟──────────────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/env_create_manifest.yml ║
╚══════════════════════════════════════════════════════════════╝
Total Discovered Buildspecs: 1
Total Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
─────────────────────────────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ────────────────────────────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/env_create_manifest.yml: VALID
Total builder objects created: 1
Builders by type=spack
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ builder ┃ type ┃ executor ┃ compiler ┃ nodes ┃ procs ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ spack_env_create_from_manifest/28fc5836 │ spack │ generic.local.bash │ None │ None │ None │ Create spack environment from spack.yaml │ /home/spack/buildtest/examples/spack/env_create_manifest.yml │
└─────────────────────────────────────────┴───────┴────────────────────┴──────────┴───────┴───────┴──────────────────────────────────────────┴──────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────────────── Building Test ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
spack_env_create_from_manifest/28fc5836: Creating test directory: /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/28fc5836
spack_env_create_from_manifest/28fc5836: Creating the stage directory: /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/28fc5836/stage
spack_env_create_from_manifest/28fc5836: Writing build script: /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/28fc5836/spack_env_create_from_manifest_build.sh
────────────────────────────────────────────────────────────────────────────────────────────────────────────── Running Tests ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
Spawning 4 processes for processing builders
─────────────────────────────────────────────────────────────────────────────────────────────────────────────── Iteration 1 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
spack_env_create_from_manifest/28fc5836 does not have any dependencies adding test to queue
spack_env_create_from_manifest/28fc5836: Current Working Directory : /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/28fc5836/stage
spack_env_create_from_manifest/28fc5836: Running Test via command: bash --norc --noprofile -eo pipefail spack_env_create_from_manifest_build.sh
spack_env_create_from_manifest/28fc5836: Test completed in 5.213226 seconds
spack_env_create_from_manifest/28fc5836: Test completed with returncode: 0
spack_env_create_from_manifest/28fc5836: Writing output file - /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/28fc5836/spack_env_create_from_manifest.out
spack_env_create_from_manifest/28fc5836: Writing error file - /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/28fc5836/spack_env_create_from_manifest.err
In this iteration we are going to run the following tests: [spack_env_create_from_manifest/28fc5836]
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ builder ┃ executor ┃ status ┃ checks (ReturnCode, Regex, Runtime) ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ spack_env_create_from_manifest/28fc5836 │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 5.213226 │
└─────────────────────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴──────────┘
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_ygsddohd.log
buildtest inspect query -o -t spack_env_create_from_manifest
$ buildtest inspect query -o -t spack_env_create_from_manifest
─────────────────────────────────────────────────────────────────────────────────── spack_env_create_from_manifest/28fc5836-60b1-41d2-9b72-677bb011d12f ───────────────────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Create spack environment from spack.yaml
State: PASS
Returncode: 0
Runtime: 5.213226 sec
Starttime: 2023/02/06 21:15:34
Endtime: 2023/02/06 21:15:39
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/28fc5836/spack_env_create_from_manifest.sh
Build Script: /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/28fc5836/spack_env_create_from_manifest_build.sh
Output File: /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/28fc5836/spack_env_create_from_manifest.out
Error File: /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/28fc5836/spack_env_create_from_manifest.err
Log File: /home/spack/buildtest/var/logs/buildtest_ygsddohd.log
───────────────────────────────────────────── Output File: /home/spack/runs/generic.local.bash/env_create_manifest/spack_env_create_from_manifest/28fc5836/spack_env_create_from_manifest.out ─────────────────────────────────────────────
==> Concretized m4
- mkc3u4x m4@1.4.18%gcc@7.5.0+sigsegv patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 arch=linux-ubuntu18.04-x86_64
- 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=0d98e93189bc278fbc37a50ed7f183bd8aaf249a8e1670a465f0db6bb4f8c
- 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/28fc5836/spack_env_create_from_manifest.sh ───────────────────────────────────────────────
#!/bin/bash
source /home/spack/spack/share/spack/setup-env.sh
spack env create manifest_example /home/spack/buildtest/examples/spack/example/spack.yaml
spack env activate manifest_example
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.
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 build -b /home/spack/buildtest/examples/spack/remove_environment_example.yml
╭───────────────────────────────────────────────────────── buildtest summary ──────────────────────────────────────────────────────────╮
│ │
│ User: spack │
│ Hostname: f215b09d0d2f │
│ Platform: Linux │
│ Current Time: 2023/02/06 21:15:40 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 1.1 │
│ 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 │
│ Report File: /home/spack/buildtest/var/report.json │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/remove_environment_example.yml │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
───────────────────────────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ─────────────────────────────────────────────────────────────────────────────────────────────────────────
Discovered buildspecs
╔═════════════════════════════════════════════════════════════════════╗
║ buildspec ║
╟─────────────────────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/remove_environment_example.yml ║
╚═════════════════════════════════════════════════════════════════════╝
Total Discovered Buildspecs: 1
Total Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
─────────────────────────────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ────────────────────────────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/remove_environment_example.yml: VALID
Total builder objects created: 2
Builders by type=spack
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ builder ┃ type ┃ executor ┃ compiler ┃ nodes ┃ procs ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ remove_environment_automatically/e9de2b6c │ spack │ generic.local.bash │ None │ None │ None │ remove spack environment automatically before creating a new │ /home/spack/buildtest/examples/spack/remove_environment_example… │
│ │ │ │ │ │ │ environment │ │
├───────────────────────────────────────────┼───────┼────────────────────┼──────────┼───────┼───────┼──────────────────────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────┤
│ remove_environment_explicit/fb964c28 │ spack │ generic.local.bash │ None │ None │ None │ remove spack environment explicitly using the 'rm' property │ /home/spack/buildtest/examples/spack/remove_environment_example… │
└───────────────────────────────────────────┴───────┴────────────────────┴──────────┴───────┴───────┴──────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────────────── Building Test ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
remove_environment_automatically/e9de2b6c: Creating test directory: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/e9de2b6c
remove_environment_automatically/e9de2b6c: Creating the stage directory: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/e9de2b6c/stage
remove_environment_automatically/e9de2b6c: Writing build script: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/e9de2b6c/remove_environment_automatically_build.sh
remove_environment_explicit/fb964c28: Creating test directory: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/fb964c28
remove_environment_explicit/fb964c28: Creating the stage directory: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/fb964c28/stage
remove_environment_explicit/fb964c28: Writing build script: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/fb964c28/remove_environment_explicit_build.sh
────────────────────────────────────────────────────────────────────────────────────────────────────────────── Running Tests ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
Spawning 4 processes for processing builders
─────────────────────────────────────────────────────────────────────────────────────────────────────────────── Iteration 1 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
remove_environment_explicit/fb964c28 does not have any dependencies adding test to queue
remove_environment_automatically/e9de2b6c does not have any dependencies adding test to queue
remove_environment_explicit/fb964c28: Current Working Directory : /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/fb964c28/stage
remove_environment_automatically/e9de2b6c: Current Working Directory : /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/e9de2b6c/stage
remove_environment_explicit/fb964c28: Running Test via command: bash --norc --noprofile -eo pipefail remove_environment_explicit_build.sh
remove_environment_automatically/e9de2b6c: Running Test via command: bash --norc --noprofile -eo pipefail remove_environment_automatically_build.sh
remove_environment_explicit/fb964c28: Test completed in 3.209879 seconds
remove_environment_automatically/e9de2b6c: Test completed in 3.209501 seconds
remove_environment_explicit/fb964c28: Test completed with returncode: 0
remove_environment_automatically/e9de2b6c: Test completed with returncode: 0
remove_environment_explicit/fb964c28: Writing output file - /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/fb964c28/remove_environment_explicit.out
remove_environment_automatically/e9de2b6c: Writing output file - /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/e9de2b6c/remove_environment_automatically.out
remove_environment_explicit/fb964c28: Writing error file - /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/fb964c28/remove_environment_explicit.err
remove_environment_automatically/e9de2b6c: Writing error file - /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/e9de2b6c/remove_environment_automatically.err
In this iteration we are going to run the following tests: [remove_environment_explicit/fb964c28, remove_environment_automatically/e9de2b6c]
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ builder ┃ executor ┃ status ┃ checks (ReturnCode, Regex, Runtime) ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ remove_environment_automatically/e9de2b6c │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 3.209501 │
├───────────────────────────────────────────┼────────────────────┼────────┼─────────────────────────────────────┼────────────┼──────────┤
│ remove_environment_explicit/fb964c28 │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 3.209879 │
└───────────────────────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴──────────┘
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_irqqj0d_.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
$ buildtest inspect query -t remove_environment_automatically remove_environment_explicit
────────────────────────────────────────────────────────────────────────────────── remove_environment_automatically/e9de2b6c-8d1e-4859-b15d-2a3cfc34ad34 ──────────────────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: remove spack environment automatically before creating a new environment
State: PASS
Returncode: 0
Runtime: 3.209501 sec
Starttime: 2023/02/06 21:15:40
Endtime: 2023/02/06 21:15:44
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/e9de2b6c/remove_environment_automatically.sh
Build Script: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/e9de2b6c/remove_environment_automatically_build.sh
Output File: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/e9de2b6c/remove_environment_automatically.out
Error File: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/e9de2b6c/remove_environment_automatically.err
Log File: /home/spack/buildtest/var/logs/buildtest_irqqj0d_.log
───────────────────────────────────────── Test File: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_automatically/e9de2b6c/remove_environment_automatically.sh ─────────────────────────────────────────
#!/bin/bash
source /home/spack/spack/share/spack/setup-env.sh
spack env rm -y remove_environment
spack env create remove_environment
spack env activate remove_environment
spack add bzip2
spack concretize -f
──────────────────────────────────────────────────────────────────────────────────── remove_environment_explicit/fb964c28-0a52-436a-88c6-a8898426dc2d ─────────────────────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: remove spack environment explicitly using the 'rm' property
State: PASS
Returncode: 0
Runtime: 3.209879 sec
Starttime: 2023/02/06 21:15:40
Endtime: 2023/02/06 21:15:44
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/fb964c28/remove_environment_explicit.sh
Build Script: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/fb964c28/remove_environment_explicit_build.sh
Output File: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/fb964c28/remove_environment_explicit.out
Error File: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/fb964c28/remove_environment_explicit.err
Log File: /home/spack/buildtest/var/logs/buildtest_irqqj0d_.log
────────────────────────────────────────────── Test File: /home/spack/runs/generic.local.bash/remove_environment_example/remove_environment_explicit/fb964c28/remove_environment_explicit.sh ──────────────────────────────────────────────
#!/bin/bash
source /home/spack/spack/share/spack/setup-env.sh
spack env rm -y dummy
spack env create dummy
spack env activate dummy
spack add bzip2
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.
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 build -b /home/spack/buildtest/examples/spack/pre_post_cmds.yml
╭─────────────────────────────────────────────────── buildtest summary ───────────────────────────────────────────────────╮
│ │
│ User: spack │
│ Hostname: f215b09d0d2f │
│ Platform: Linux │
│ Current Time: 2023/02/06 21:15:45 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 1.1 │
│ 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 │
│ Report File: /home/spack/buildtest/var/report.json │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/pre_post_cmds.yml │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
───────────────────────────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ─────────────────────────────────────────────────────────────────────────────────────────────────────────
Discovered buildspecs
╔════════════════════════════════════════════════════════╗
║ buildspec ║
╟────────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/pre_post_cmds.yml ║
╚════════════════════════════════════════════════════════╝
Total Discovered Buildspecs: 1
Total Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
─────────────────────────────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ────────────────────────────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/pre_post_cmds.yml: VALID
Total builder objects created: 1
Builders by type=spack
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ builder ┃ type ┃ executor ┃ compiler ┃ nodes ┃ procs ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ run_pre_post_commands/3462c60f │ spack │ generic.local.bash │ None │ None │ None │ Install zlib │ /home/spack/buildtest/examples/spack/pre_post_cmds.yml │
└────────────────────────────────┴───────┴────────────────────┴──────────┴───────┴───────┴──────────────┴────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────────────── Building Test ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
run_pre_post_commands/3462c60f: Creating test directory: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/3462c60f
run_pre_post_commands/3462c60f: Creating the stage directory: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/3462c60f/stage
run_pre_post_commands/3462c60f: Writing build script: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/3462c60f/run_pre_post_commands_build.sh
────────────────────────────────────────────────────────────────────────────────────────────────────────────── Running Tests ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
Spawning 4 processes for processing builders
─────────────────────────────────────────────────────────────────────────────────────────────────────────────── Iteration 1 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
run_pre_post_commands/3462c60f does not have any dependencies adding test to queue
run_pre_post_commands/3462c60f: Current Working Directory : /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/3462c60f/stage
run_pre_post_commands/3462c60f: Running Test via command: bash --norc --noprofile -eo pipefail run_pre_post_commands_build.sh
run_pre_post_commands/3462c60f: Test completed in 2.131195 seconds
run_pre_post_commands/3462c60f: Test completed with returncode: 0
run_pre_post_commands/3462c60f: Writing output file - /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/3462c60f/run_pre_post_commands.out
run_pre_post_commands/3462c60f: Writing error file - /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/3462c60f/run_pre_post_commands.err
In this iteration we are going to run the following tests: [run_pre_post_commands/3462c60f]
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ builder ┃ executor ┃ status ┃ checks (ReturnCode, Regex, Runtime) ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ run_pre_post_commands/3462c60f │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 2.131195 │
└────────────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴──────────┘
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_j5nd58l8.log
buildtest inspect query -o -t run_pre_post_commands
$ buildtest inspect query -o -t run_pre_post_commands
─────────────────────────────────────────────────────────────────────────────────────── run_pre_post_commands/3462c60f-14df-43a3-8729-59b3d12c06a0 ────────────────────────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Install zlib
State: PASS
Returncode: 0
Runtime: 2.131195 sec
Starttime: 2023/02/06 21:15:45
Endtime: 2023/02/06 21:15:47
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/3462c60f/run_pre_post_commands.sh
Build Script: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/3462c60f/run_pre_post_commands_build.sh
Output File: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/3462c60f/run_pre_post_commands.out
Error File: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/3462c60f/run_pre_post_commands.err
Log File: /home/spack/buildtest/var/logs/buildtest_j5nd58l8.log
───────────────────────────────────────────────────────── Output File: /home/spack/runs/generic.local.bash/pre_post_cmds/run_pre_post_commands/3462c60f/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-workspace/software/linux-ubuntu18.04-x86_64/gcc-7.5.0/zlib-1.2.11-smoyzzo2qhzpn6mg6rd3l2p7b23enshg
/home/spack/spack-workspace/software/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/3462c60f/run_pre_post_commands.sh ───────────────────────────────────────────────────────────
#!/bin/bash
######## START OF PRE COMMANDS ########
cat /etc/os-release
gcc --version
######## END OF PRE COMMANDS ########
source /home/spack/spack/share/spack/setup-env.sh
spack install zlib
######## START OF POST COMMANDS ########
spack location -i gcc@6.5.0
spack --version
######## END OF POST COMMANDS ########
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.
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
$ buildtest inspect query -o -t add_mirror add_mirror_in_spack_env
────────────────────────────────────────────────────────────────────────────────────── add_mirror_in_spack_env/a1846e85-149f-4efb-9c20-cab8fd43c5f0 ───────────────────────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Declare spack mirror in spack environment
State: PASS
Returncode: 0
Runtime: 2.472932 sec
Starttime: 2023/02/06 21:15:48
Endtime: 2023/02/06 21:15:50
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/a1846e85/add_mirror_in_spack_env.sh
Build Script: /home/spack/runs/generic.local.bash/mirror_example/add_mirror_in_spack_env/a1846e85/add_mirror_in_spack_env_build.sh
Output File: /home/spack/runs/generic.local.bash/mirror_example/add_mirror_in_spack_env/a1846e85/add_mirror_in_spack_env.out
Error File: /home/spack/runs/generic.local.bash/mirror_example/add_mirror_in_spack_env/a1846e85/add_mirror_in_spack_env.err
Log File: /home/spack/buildtest/var/logs/buildtest_4jngh05k.log
────────────────────────────────────────────────────── Output File: /home/spack/runs/generic.local.bash/mirror_example/add_mirror_in_spack_env/a1846e85/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/a1846e85/add_mirror_in_spack_env.sh ────────────────────────────────────────────────────────
#!/bin/bash
source /home/spack/spack/share/spack/setup-env.sh
spack env create spack_mirror
spack env activate spack_mirror
spack mirror add spack_tutorial_mirror /mirror
######## START OF POST COMMANDS ########
spack mirror list
spack config blame mirrors
######## END OF POST COMMANDS ########
───────────────────────────────────────────────────────────────────────────────────────────── add_mirror/bca31e22-6921-4e09-825a-b4b09ff433ae ─────────────────────────────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Declare spack mirror
State: PASS
Returncode: 0
Runtime: 1.648925 sec
Starttime: 2023/02/06 21:15:48
Endtime: 2023/02/06 21:15:49
Command: bash --norc --noprofile -eo pipefail add_mirror_build.sh
Test Script: /home/spack/runs/generic.local.bash/mirror_example/add_mirror/bca31e22/add_mirror.sh
Build Script: /home/spack/runs/generic.local.bash/mirror_example/add_mirror/bca31e22/add_mirror_build.sh
Output File: /home/spack/runs/generic.local.bash/mirror_example/add_mirror/bca31e22/add_mirror.out
Error File: /home/spack/runs/generic.local.bash/mirror_example/add_mirror/bca31e22/add_mirror.err
Log File: /home/spack/buildtest/var/logs/buildtest_4jngh05k.log
─────────────────────────────────────────────────────────────────── Output File: /home/spack/runs/generic.local.bash/mirror_example/add_mirror/bca31e22/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/bca31e22/add_mirror.sh ─────────────────────────────────────────────────────────────────────
#!/bin/bash
source /home/spack/spack/share/spack/setup-env.sh
spack mirror add spack_tutorial_mirror /mirror
######## START OF POST COMMANDS ########
spack mirror list
spack config blame mirrors
######## END OF POST COMMANDS ########
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.
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 build -b /home/spack/buildtest/examples/spack/spack_test.yml
╭───────────────────────────────────────────────── buildtest summary ──────────────────────────────────────────────────╮
│ │
│ User: spack │
│ Hostname: f215b09d0d2f │
│ Platform: Linux │
│ Current Time: 2023/02/06 21:15:51 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 1.1 │
│ 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 │
│ Report File: /home/spack/buildtest/var/report.json │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/spack_test.yml │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
───────────────────────────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ─────────────────────────────────────────────────────────────────────────────────────────────────────────
Discovered buildspecs
╔═════════════════════════════════════════════════════╗
║ buildspec ║
╟─────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/spack_test.yml ║
╚═════════════════════════════════════════════════════╝
Total Discovered Buildspecs: 1
Total Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
─────────────────────────────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ────────────────────────────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/spack_test.yml: VALID
Total builder objects created: 1
Builders by type=spack
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ builder ┃ type ┃ executor ┃ compiler ┃ nodes ┃ procs ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ spack_test_m4/460eadb0 │ spack │ generic.local.bash │ None │ None │ None │ Run spack test for m4 package and report results │ /home/spack/buildtest/examples/spack/spack_test.yml │
└────────────────────────┴───────┴────────────────────┴──────────┴───────┴───────┴──────────────────────────────────────────────────┴─────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────────────── Building Test ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
spack_test_m4/460eadb0: Creating test directory: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/460eadb0
spack_test_m4/460eadb0: Creating the stage directory: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/460eadb0/stage
spack_test_m4/460eadb0: Writing build script: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/460eadb0/spack_test_m4_build.sh
────────────────────────────────────────────────────────────────────────────────────────────────────────────── Running Tests ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
Spawning 4 processes for processing builders
─────────────────────────────────────────────────────────────────────────────────────────────────────────────── Iteration 1 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
spack_test_m4/460eadb0 does not have any dependencies adding test to queue
spack_test_m4/460eadb0: Current Working Directory : /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/460eadb0/stage
spack_test_m4/460eadb0: Running Test via command: bash --norc --noprofile -eo pipefail spack_test_m4_build.sh
spack_test_m4/460eadb0: Test completed in 2.1575 seconds
spack_test_m4/460eadb0: Test completed with returncode: 0
spack_test_m4/460eadb0: Writing output file - /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/460eadb0/spack_test_m4.out
spack_test_m4/460eadb0: Writing error file - /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/460eadb0/spack_test_m4.err
In this iteration we are going to run the following tests: [spack_test_m4/460eadb0]
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━┓
┃ builder ┃ executor ┃ status ┃ checks (ReturnCode, Regex, Runtime) ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━┩
│ spack_test_m4/460eadb0 │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 2.1575 │
└────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴─────────┘
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_bpf4x5c3.log
buildtest inspect query -o -t spack_test_m4
$ buildtest inspect query -o -t spack_test_m4
─────────────────────────────────────────────────────────────────────────────────────────── spack_test_m4/460eadb0-6966-41db-bc77-1a00af9fe500 ────────────────────────────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Run spack test for m4 package and report results
State: PASS
Returncode: 0
Runtime: 2.1575 sec
Starttime: 2023/02/06 21:15:51
Endtime: 2023/02/06 21:15:53
Command: bash --norc --noprofile -eo pipefail spack_test_m4_build.sh
Test Script: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/460eadb0/spack_test_m4.sh
Build Script: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/460eadb0/spack_test_m4_build.sh
Output File: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/460eadb0/spack_test_m4.out
Error File: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/460eadb0/spack_test_m4.err
Log File: /home/spack/buildtest/var/logs/buildtest_bpf4x5c3.log
────────────────────────────────────────────────────────────────── Output File: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/460eadb0/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
==> [2023-02-06-21:15:53.383170] test: ensuring m4 version is 1.4.18
==> [2023-02-06-21:15:53.384286] '/home/spack/spack-workspace/software/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
==> [2023-02-06-21:15:53.392419] test: ensuring m4 example succeeds
==> [2023-02-06-21:15:53.392722] '/home/spack/spack-workspace/software/linux-ubuntu18.04-x86_64/gcc-7.5.0/m4-1.4.18-mkc3u4x2p2wie6jfhuku7g5rkovcrxps/bin/m4' '/home/spack/.spack/test/5mpugnenojhehp5km573ucervxz46odi/m4-1.4.18-mkc3u4x/da
// macro is defined
Hello, World!
PASSED
──────────────────────────────────────────────────────────────────── Test File: /home/spack/runs/generic.local.bash/spack_test/spack_test_m4/460eadb0/spack_test_m4.sh ────────────────────────────────────────────────────────────────────
#!/bin/bash
source /home/spack/spack/share/spack/setup-env.sh
spack test run --alias spack_test_m4 m4
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.
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 build -b /home/spack/buildtest/examples/spack/spack_test_specs.yml
╭──────────────────────────────────────────────────── buildtest summary ─────────────────────────────────────────────────────╮
│ │
│ User: spack │
│ Hostname: f215b09d0d2f │
│ Platform: Linux │
│ Current Time: 2023/02/06 21:15:54 │
│ buildtest path: /home/spack/buildtest/bin/buildtest │
│ buildtest version: 1.1 │
│ 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 │
│ Report File: /home/spack/buildtest/var/report.json │
│ Command: /home/spack/buildtest/bin/buildtest build -b /home/spack/buildtest/examples/spack/spack_test_specs.yml │
│ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
───────────────────────────────────────────────────────────────────────────────────────────────────────── Discovering Buildspecs ─────────────────────────────────────────────────────────────────────────────────────────────────────────
Discovered buildspecs
╔═══════════════════════════════════════════════════════════╗
║ buildspec ║
╟───────────────────────────────────────────────────────────╢
║ /home/spack/buildtest/examples/spack/spack_test_specs.yml ║
╚═══════════════════════════════════════════════════════════╝
Total Discovered Buildspecs: 1
Total Excluded Buildspecs: 0
Detected Buildspecs after exclusion: 1
─────────────────────────────────────────────────────────────────────────────────────────────────────────── Parsing Buildspecs ────────────────────────────────────────────────────────────────────────────────────────────────────────────
Valid Buildspecs: 1
Invalid Buildspecs: 0
/home/spack/buildtest/examples/spack/spack_test_specs.yml: VALID
Total builder objects created: 1
Builders by type=spack
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ builder ┃ type ┃ executor ┃ compiler ┃ nodes ┃ procs ┃ description ┃ buildspecs ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ spack_test_results_specs_format/23f16eff │ spack │ generic.local.bash │ None │ None │ None │ Run spack test results with spec format │ /home/spack/buildtest/examples/spack/spack_test_specs.yml │
└──────────────────────────────────────────┴───────┴────────────────────┴──────────┴───────┴───────┴─────────────────────────────────────────┴───────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────────────── Building Test ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
spack_test_results_specs_format/23f16eff: Creating test directory: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/23f16eff
spack_test_results_specs_format/23f16eff: Creating the stage directory: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/23f16eff/stage
spack_test_results_specs_format/23f16eff: Writing build script: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/23f16eff/spack_test_results_specs_format_build.sh
────────────────────────────────────────────────────────────────────────────────────────────────────────────── Running Tests ──────────────────────────────────────────────────────────────────────────────────────────────────────────────
Spawning 4 processes for processing builders
─────────────────────────────────────────────────────────────────────────────────────────────────────────────── Iteration 1 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
spack_test_results_specs_format/23f16eff does not have any dependencies adding test to queue
spack_test_results_specs_format/23f16eff: Current Working Directory : /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/23f16eff/stage
spack_test_results_specs_format/23f16eff: Running Test via command: bash --norc --noprofile -eo pipefail spack_test_results_specs_format_build.sh
spack_test_results_specs_format/23f16eff: Test completed in 5.392834 seconds
spack_test_results_specs_format/23f16eff: Test completed with returncode: 0
spack_test_results_specs_format/23f16eff: Writing output file - /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/23f16eff/spack_test_results_specs_format.out
spack_test_results_specs_format/23f16eff: Writing error file - /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/23f16eff/spack_test_results_specs_format.err
In this iteration we are going to run the following tests: [spack_test_results_specs_format/23f16eff]
Test Summary
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ builder ┃ executor ┃ status ┃ checks (ReturnCode, Regex, Runtime) ┃ returncode ┃ runtime ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━┩
│ spack_test_results_specs_format/23f16eff │ generic.local.bash │ PASS │ N/A N/A N/A │ 0 │ 5.392834 │
└──────────────────────────────────────────┴────────────────────┴────────┴─────────────────────────────────────┴────────────┴──────────┘
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_rufrepjr.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
$ buildtest inspect query -o -t spack_test_results_specs_format
────────────────────────────────────────────────────────────────────────────────── spack_test_results_specs_format/23f16eff-ed9f-46d9-aabe-46e188eedb01 ───────────────────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: Run spack test results with spec format
State: PASS
Returncode: 0
Runtime: 5.392834 sec
Starttime: 2023/02/06 21:15:54
Endtime: 2023/02/06 21:16:00
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/23f16eff/spack_test_results_specs_format.sh
Build Script: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/23f16eff/spack_test_results_specs_format_build.sh
Output File: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/23f16eff/spack_test_results_specs_format.out
Error File: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/23f16eff/spack_test_results_specs_format.err
Log File: /home/spack/buildtest/var/logs/buildtest_rufrepjr.log
───────────────────────────────────────────── Output File: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/23f16eff/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
==> [2023-02-06-21:15:58.897861] test: Performing simple import test
==> [2023-02-06-21:15:58.898621] test: xml2-config: expect command status in [0]
==> [2023-02-06-21:15:58.898947] '/home/spack/spack-workspace/software/linux-ubuntu18.04-x86_64/gcc-7.5.0/libxml2-2.9.10-yn2r3wfhiilelyulh5toteicdtxjhw7d/bin/xml2-config' '--version'
2.9.10
PASSED
==> [2023-02-06-21:15:58.903287] test: xmllint: expect command status in [0]
==> [2023-02-06-21:15:58.903571] '/home/spack/spack-workspace/software/linux-ubuntu18.04-x86_64/gcc-7.5.0/libxml2-2.9.10-yn2r3wfhiilelyulh5toteicdtxjhw7d/bin/xmllint' '--auto' '-o' 'test.xml'
PASSED
==> [2023-02-06-21:15:58.913508] test: xmllint: expect command status in [3]
==> [2023-02-06-21:15:58.913870] '/home/spack/spack-workspace/software/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
==> [2023-02-06-21:15:58.918525] test: xmllint: expect command status in [3]
==> [2023-02-06-21:15:58.918906] '/home/spack/spack-workspace/software/linux-ubuntu18.04-x86_64/gcc-7.5.0/libxml2-2.9.10-yn2r3wfhiilelyulh5toteicdtxjhw7d/bin/xmllint' '--dtdvalid' '/home/spack/.spack/test/d6phm2ufma23flnqrts7vw7vidoawd
<?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
==> [2023-02-06-21:15:58.923161] test: xmllint: expect command status in [0]
==> [2023-02-06-21:15:58.923460] '/home/spack/spack-workspace/software/linux-ubuntu18.04-x86_64/gcc-7.5.0/libxml2-2.9.10-yn2r3wfhiilelyulh5toteicdtxjhw7d/bin/xmllint' '--dtdvalid' '/home/spack/.spack/test/d6phm2ufma23flnqrts7vw7vidoawd
<?xml version="1.0"?>
<info>
<data>abc</data>
</info>
PASSED
==> [2023-02-06-21:15:58.927500] test: xmlcatalog: expect command status in [0]
==> [2023-02-06-21:15:58.927894] '/home/spack/spack-workspace/software/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
==> [2023-02-06-21:15:59.225015] Multiple definitions of compiler gcc@7.5.0for architecture linux-ubuntu18.04-x86_64:
[gcc(/usr/bin/gcc
/usr/bin/g++
/usr/bin/gfortran
/usr/bin/gfortran
[]
ubuntu18.04), gcc(/usr/bin/gcc
/usr/bin/g++
/usr/bin/gfortran
/usr/bin/gfortran
[]
ubuntu18.04)]
==> [2023-02-06-21:15:59.225467] test: checking ability to link to the library
==> [2023-02-06-21:15:59.225789] '/home/spack/spack/lib/spack/env/cc' '-I/home/spack/spack-workspace/software/linux-ubuntu18.04-x86_64/gcc-7.5.0/libsigsegv-2.12-lbrx7lnfz46ukewxbhxnucmx76g23c6q/include' '/home/spack/.spack/test/d6phm2u
PASSED
==> [2023-02-06-21:15:59.289226] test: checking ability to use the library
==> [2023-02-06-21:15:59.289618] './smoke_test'
Caught sigsegv #1
Hello World!
PASSED
─────────────────────────────────────────────── Test File: /home/spack/runs/generic.local.bash/spack_test_specs/spack_test_results_specs_format/23f16eff/spack_test_results_specs_format.sh ───────────────────────────────────────────────
#!/bin/bash
source /home/spack/spack/share/spack/setup-env.sh
spack env create spack_test_example
spack env activate spack_test_example
spack install libxml2
spack install libsigsegv
spack test remove -y
spack test run --alias spack_test_results_specs_format libxml2 libsigsegv
spack test results -l -- libxml2
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.
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
$ buildtest inspect query -t spack_sbatch_example
──────────────────────────────────────────────────────────────────────────────────────── spack_sbatch_example/af908912-36f3-4722-a3ff-4c06bd292208 ────────────────────────────────────────────────────────────────────────────────────────
Executor: generic.local.bash
Description: sbatch directives can be defined in spack schema
State: PASS
Returncode: 0
Runtime: 1.462574 sec
Starttime: 2023/02/06 21:16:01
Endtime: 2023/02/06 21:16:02
Command: bash --norc --noprofile -eo pipefail spack_sbatch_example_build.sh
Test Script: /home/spack/runs/generic.local.bash/spack_sbatch/spack_sbatch_example/af908912/spack_sbatch_example.sh
Build Script: /home/spack/runs/generic.local.bash/spack_sbatch/spack_sbatch_example/af908912/spack_sbatch_example_build.sh
Output File: /home/spack/runs/generic.local.bash/spack_sbatch/spack_sbatch_example/af908912/spack_sbatch_example.out
Error File: /home/spack/runs/generic.local.bash/spack_sbatch/spack_sbatch_example/af908912/spack_sbatch_example.err
Log File: /home/spack/buildtest/var/logs/buildtest_mqsgyhgo.log
──────────────────────────────────────────────────────────── Test File: /home/spack/runs/generic.local.bash/spack_sbatch/spack_sbatch_example/af908912/spack_sbatch_example.sh ────────────────────────────────────────────────────────────
#!/bin/bash
#SBATCH -N 1
#SBATCH -n 8
#SBATCH -t 30
#SBATCH --job-name=spack_sbatch_example
#SBATCH --output=spack_sbatch_example.out
#SBATCH --error=spack_sbatch_example.err
source /home/spack/spack/share/spack/setup-env.sh
spack install zlib@1.2.11%clang
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
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"