-
Notifications
You must be signed in to change notification settings - Fork 2
/
stage-test
executable file
·152 lines (120 loc) · 4.63 KB
/
stage-test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
!/bin/bash
#usage: stage-test -s system -n name
datetime () { date +"%Y-%m-%d %H:%M:%S"; }
[[ -t 1 ]] && interm=yes
red () { echo "\e[1;31m$1\e[m"; }
yellow () { echo "\e[1;33m$1\e[m"; }
log () { printf "$(yellow "[log $(datetime)]") $1\n"; }
err () { printf "$(red "[error $(datetime)]") $1\n"; exit 1; }
exit_without_error () { printf "$(yellow "[log $(datetime)]") $1\n"; exit 0; }
usage () {
echo "usage: reframe-run -n name -s system -m mount"
echo ""
echo "where:"
echo " name: the name of the stack"
echo " uarch: microarchitecture \(one of a100, zen2, zen3, mi200, gh200\)"
echo " system: the cluster name \(e.g. of balfrin, todi, eiger\)"
echo " mount: the mount point of the image"
echo ""
[[ "" == "$1" ]] && exit 0
err "$1"
}
system="-"
name="-"
uarch="-"
mount="-"
ci_path="$CI_PROJECT_DIR"
test_path="$ci_path/$CI_JOB_ID"
while getopts n:s:u:m: flag
do
case "${flag}" in
n) name=${OPTARG};;
s) system=${OPTARG};;
u) uarch=${OPTARG};;
m) mount=${OPTARG};;
esac
done
[[ "-" == "${system}" ]] && usage "missing system argument"
[[ "-" == "${name}" ]] && usage "missing name argument"
[[ "-" == "${uarch}" ]] && usage "missing uarch argument"
[[ "-" == "${mount}" ]] && usage "missing mount argument"
build_id=${CI_PIPELINE_ID}
pipeline_path=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
log "SCRATCH ${SCRATCH}"
log "USER ${USER}"
log "name ${name}"
log "system ${system}"
log "uarch ${uarch}"
log "mount ${mount}"
log "build_id ${build_id}"
log "ci_path ${ci_path}"
log "test_path ${test_path}"
log "pipeline_path ${pipeline_path}"
# configure oras
source ${pipeline_path}/util/setup-oras
# create the path in which tests will run...
mkdir -p ${test_path}
cd ${test_path}
artifact_path="${test_path}/artifacts"
mkdir -p $artifact_path
rego=jfrog.svc.cscs.ch/uenv
#repo_base=build/${system}/${uarch}/${name}/${build_id}
#repo=${repo_base}:latest
repo_base=build/${system}/${uarch}/${name}
repo=${repo_base}:${build_id}
#
# Download the meta data from jfrog
#
# step 1: look up the digest of the meta data
log "looking for meta data for image at $rego/$repo"
meta_digest=$(oras discover --registry-config ${jfrog_creds_path} --output json --artifact-type 'uenv/meta' $rego/$repo | jq -r '.manifests[0].digest')
log "found metadata digest $meta_digest"
# step 2: download the meta data
log "downloading meta data image from ${rego}/${repo_base}@$meta_digest"
oras pull --registry-config ${jfrog_creds_path} --output "${artifact_path}" "${rego}/${repo_base}@$meta_digest"
[[ $? -eq 0 ]] || err "failed to download meta data"
rfm_meta_path="${artifact_path}/meta/extra/reframe.yaml"
log "Using artifacts in $artifact_path"
find "${artifact_path}"
log "looking for reframe metadata in ${rfm_meta_path}"
[[ -f "${rfm_meta_path}" ]] || exit_without_error "no reframe meta data provided: skipping tests"
# copy the meta data to the location where reframe expects to find it.
cp $rfm_meta_path "${artifact_path}/store.yaml"
#
# download the squashfs image from jfrog
#
log "downloading squashfs image from ${rego}/${repo}"
oras pull --registry-config ${jfrog_creds_path} --output "${artifact_path}" "${rego}/${repo}"
[[ $? -eq 0 ]] || err "failed to download squashfs"
squashfs_path="${artifact_path}/store.squashfs"
log "set up a python venv and pip install reframe"
[[ -z "${SLURM_PARTITION}" ]] && RFM_SYSTEM="${system}" || RFM_SYSTEM="${system}:${SLURM_PARTITION}"
rm -rf rfm_venv
python3 -m venv rfm_venv
source rfm_venv/bin/activate
#pip install --upgrade reframe-hpc
git clone https://github.com/reframe-hpc/reframe.git
(cd reframe; git checkout v4.6.1; ./bootstrap.sh)
export PATH="$(pwd)/reframe/bin:$PATH"
log "clone cscs-reframe-tests"
rm -rf cscs-reframe-tests
git clone -b alps https://github.com/eth-cscs/cscs-reframe-tests.git
pip install python-hostlist
export UENV="${squashfs_path}:${mount}"
export RFM_AUTODETECT_METHODS="cat /etc/xthostname,hostname"
export RFM_USE_LOGIN_SHELL=1
REFRAME_COMMAND="reframe -C cscs-reframe-tests/config/cscs.py --report-junit=report.xml -c cscs-reframe-tests/checks/ -r --system=${RFM_SYSTEM}"
log "running reframe: ${REFRAME_COMMAND}"
${REFRAME_COMMAND}
exitcode=$?
if [ "$exitcode" -eq 0 ];
then
report_path=$(find -type f -name report.xml)
log "report generated in $report_path"
cat $report_path
oras attach --registry-config ${jfrog_creds_path} --artifact-type uenv/reframe "${rego}/${repo}" "${report_path}"
else
err "Reframe test run failed - no report artifact pushed"
fi
deactivate
exit ${exitcode}