Skip to content

Commit b3d8ce3

Browse files
committedFeb 4, 2025
run test step with bot
1 parent c422bc9 commit b3d8ce3

File tree

1 file changed

+135
-0
lines changed

1 file changed

+135
-0
lines changed
 

‎bot/test.sh

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Script to run tests for the whole EESSI compatibility software layer.
4+
# Intended use is that it is called at the end of a (batch) job running on a compute node.
5+
#
6+
# This script is part of the EESSI compatibility layer, see
7+
# https://github.com/EESSI/compatibility-layer.git
8+
#
9+
# author: Thomas Roeblitz (@trz42)
10+
# author: Caspar van Leeuwen (@casparvl)
11+
# author: Bob Dröge (@bedroge)
12+
#
13+
# license: GPLv2
14+
#
15+
16+
# ASSUMPTIONs:
17+
# + assumption for the build step (as run through bot/build.sh which is provided
18+
# in this repository too)
19+
# - working directory has been prepared by the bot with a checkout of a
20+
# pull request (OR by some other means)
21+
# - the working directory contains a directory 'cfg' where the main config
22+
# file 'job.cfg' has been deposited
23+
# - the directory may contain any additional files referenced in job.cfg
24+
# + assumptions for the test step
25+
# - temporary storage is still available
26+
# example
27+
# Using /tmp/bot/EESSI/eessi.7l3zm2x7qH as temporary storage...
28+
# - run test/compat_layer.py with ReFrame inside build container using tmp storage from build step
29+
# plus possibly additional settings (repo, etc.)
30+
31+
# stop as soon as something fails
32+
set -e
33+
34+
# source utils.sh and cfg_files.sh
35+
source scripts/utils.sh
36+
source scripts/cfg_files.sh
37+
38+
# defaults
39+
export JOB_CFG_FILE="${JOB_CFG_FILE_OVERRIDE:=./cfg/job.cfg}"
40+
HOST_ARCH=$(uname -m)
41+
42+
# check if ${JOB_CFG_FILE} exists
43+
if [[ ! -r "${JOB_CFG_FILE}" ]]; then
44+
fatal_error "job config file (JOB_CFG_FILE=${JOB_CFG_FILE}) does not exist or not readable"
45+
fi
46+
echo "bot/test.sh: showing ${JOB_CFG_FILE} from software-layer side"
47+
cat ${JOB_CFG_FILE}
48+
49+
echo "bot/test.sh: obtaining configuration settings from '${JOB_CFG_FILE}'"
50+
cfg_load ${JOB_CFG_FILE}
51+
52+
# if http_proxy is defined in ${JOB_CFG_FILE} use it, if not use env var $http_proxy
53+
HTTP_PROXY=$(cfg_get_value "site_config" "http_proxy")
54+
HTTP_PROXY=${HTTP_PROXY:-${http_proxy}}
55+
echo "bot/test.sh: HTTP_PROXY='${HTTP_PROXY}'"
56+
57+
# if https_proxy is defined in ${JOB_CFG_FILE} use it, if not use env var $https_proxy
58+
HTTPS_PROXY=$(cfg_get_value "site_config" "https_proxy")
59+
HTTPS_PROXY=${HTTPS_PROXY:-${https_proxy}}
60+
echo "bot/test.sh: HTTPS_PROXY='${HTTPS_PROXY}'"
61+
62+
LOCAL_TMP=$(cfg_get_value "site_config" "local_tmp")
63+
echo "bot/test.sh: LOCAL_TMP='${LOCAL_TMP}'"
64+
65+
# try to determine tmp directory from build job
66+
EESSI_TMPDIR=$(grep -oP "To resume work add '--resume \K.*(?=')" slurm-${SLURM_JOB_ID}.out)
67+
68+
if [[ -z ${EESSI_TMPDIR} ]]; then
69+
echo "bot/test.sh: no information about tmp directory build step; --> giving up"
70+
exit 2
71+
fi
72+
73+
# obtain list of modules to be loaded
74+
LOAD_MODULES=$(cfg_get_value "site_config" "load_modules")
75+
echo "bot/test.sh: LOAD_MODULES='${LOAD_MODULES}'"
76+
77+
# load modules if LOAD_MODULES is not empty
78+
if [[ ! -z ${LOAD_MODULES} ]]; then
79+
for mod in $(echo ${LOAD_MODULES} | tr ',' '\n')
80+
do
81+
echo "bot/test.sh: loading module '${mod}'"
82+
module load ${mod}
83+
done
84+
else
85+
echo "bot/test.sh: no modules to be loaded"
86+
fi
87+
88+
cpu_target_arch=$(cfg_get_value "architecture" "software_subdir" | cut -d/ -f1)
89+
host_arch=$(uname -m)
90+
eessi_arch=${cpu_target_arch:-${host_arch}}
91+
eessi_os=linux
92+
job_version=$(cfg_get_value "repository" "repo_version")
93+
eessi_version=2025.01
94+
job_repo=$(cfg_get_value "repository" "repo_name")
95+
eessi_repo=${job_repo:-software.eessi.io}
96+
tar_topdir=/cvmfs/${eessi_repo}/versions
97+
eessi_version=$(ls -1 ${EESSI_TMPDIR}/${tar_topdir})
98+
99+
if [ "${eessi_arch}" != "${host_arch}" ]; then
100+
echo "Requested architecture (${eessi_arch}) is different from this machine's architecture ($(uname -m))!"
101+
exit 1
102+
fi
103+
104+
RUNTIME=$(get_container_runtime)
105+
exit_code=$?
106+
[[ ${VERBOSE} == '-vvv' ]] && echo "RUNTIME='${RUNTIME}'"
107+
check_exit_code ${exit_code} "using runtime ${RUNTIME}" "oh no, neither apptainer nor singularity available"
108+
109+
# Set up paths and mount points for Apptainer
110+
if [[ -z ${APPTAINER_CACHEDIR} ]]; then
111+
export APPTAINER_CACHEDIR=${EESSI_TMPDIR}/apptainer_cache
112+
[[ ${VERBOSE} == '-vvv' ]] && echo "APPTAINER_CACHEDIR='${APPTAINER_CACHEDIR}'"
113+
fi
114+
export APPTAINER_BIND="${EESSI_TMPDIR}/cvmfs:/cvmfs,${PWD}"
115+
export APPTAINER_BIND="${APPTAINER_BIND},${EESSI_TMPDIR}/tmp:/tmp"
116+
[[ ${VERBOSE} == '-vvv' ]] && echo "APPTAINER_BIND='${APPTAINER_BIND}'"
117+
export APPTAINER_HOME="${EESSI_TMPDIR}/home:/home/${USER}"
118+
[[ ${VERBOSE} == '-vvv' ]] && echo "APPTAINER_HOME='${APPTAINER_HOME}'"
119+
120+
# also define SINGULARITY_* env vars
121+
if [[ -z ${SINGULARITY_CACHEDIR} ]]; then
122+
export SINGULARITY_CACHEDIR=${EESSI_TMPDIR}/apptainer_cache
123+
[[ ${VERBOSE} == '-vvv' ]] && echo "SINGULARITY_CACHEDIR='${SINGULARITY_CACHEDIR}'"
124+
fi
125+
export SINGULARITY_BIND="${EESSI_TMPDIR}/cvmfs:/cvmfs,${PWD}"
126+
export SINGULARITY_BIND="${SINGULARITY_BIND},${EESSI_TMPDIR}/tmp:/tmp"
127+
[[ ${VERBOSE} == '-vvv' ]] && echo "SINGULARITY_BIND='${SINGULARITY_BIND}'"
128+
export SINGULARITY_HOME="${EESSI_TMPDIR}/home:/home/${USER}"
129+
[[ ${VERBOSE} == '-vvv' ]] && echo "SINGULARITY_HOME='${SINGULARITY_HOME}'"
130+
131+
CONTAINER=docker://ghcr.io/eessi/bootstrap-prefix:debian11
132+
133+
${RUNTIME} exec ${CONTAINER} ./test_compatibility_layer.sh -a ${host_arch} -o linux -r ${eessi_repo} -v ${eessi_version} --verbose
134+
135+
exit 0

0 commit comments

Comments
 (0)
Please sign in to comment.