forked from EESSI/software-layer
-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (86 loc) · 4.43 KB
/
test_eessi_container_script.yml
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
# documentation: https://help.github.com/en/articles/workflow-syntax-for-github-actions
name: Tests for eessi_container.sh script
on: [push, pull_request, workflow_dispatch]
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
eessi_container_script:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
SCRIPT_TEST:
- help
- run
- shell
- container
- readwrite
- resume
- save
steps:
- name: Check out software-layer repository
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
- name: install Apptainer
run: |
./install_apptainer_ubuntu.sh
- name: Test eessi_container.sh script
run: |
test_cmd="cat /etc/os-release"
out_pattern="Debian GNU/Linux 11"
if [[ ${{matrix.SCRIPT_TEST}} == 'help' ]]; then
./eessi_container.sh --help
# test use of --mode run
elif [[ ${{matrix.SCRIPT_TEST}} == 'run' ]]; then
outfile=out_run.txt
echo "${test_cmd}" > test_script.sh
chmod u+x test_script.sh
export SINGULARITY_BIND="$PWD:/test"
./eessi_container.sh --mode run /test/test_script.sh | tee ${outfile}
grep "${out_pattern}" ${outfile}
# test use of --mode shell
elif [[ ${{matrix.SCRIPT_TEST}} == 'shell' ]]; then
outfile=out_shell.txt
./eessi_container.sh --mode shell <<< "${test_cmd}" 2>&1 | tee ${outfile}
grep "${out_pattern}" ${outfile}
# test use of --container option, using a totally different container;
# cfr. https://github.com/easybuilders/easybuild-containers
elif [[ ${{matrix.SCRIPT_TEST}} == 'container' ]]; then
outfile=out_container.txt
container="docker://ghcr.io/eessi/build-node:debian10"
./eessi_container.sh --container ${container} --mode shell <<< "${test_cmd}" 2>&1 | tee ${outfile}
grep "Debian GNU/Linux 10" ${outfile}
# test use of '--access rw' to get write access in container
elif [[ ${{matrix.SCRIPT_TEST}} == 'readwrite' ]]; then
outfile=out_readwrite.txt
fn="test_${RANDOM}.txt"
echo "touch /cvmfs/pilot.eessi-hpc.org/${fn}" > test_script.sh
chmod u+x test_script.sh
export SINGULARITY_BIND="$PWD:/test"
./eessi_container.sh --access rw --mode run /test/test_script.sh > ${outfile}
tmpdir=$(grep "\-\-resume" ${outfile} | sed "s/.*--resume \([^']*\).*/\1/g")
# note: must use '--access rw' again here, since touched file is in overlay upper dir
./eessi_container.sh --resume ${tmpdir} --access rw --mode shell <<< "ls -l /cvmfs/pilot.eessi-hpc.org/${fn}" > ${outfile}
grep "/cvmfs/pilot.eessi-hpc.org/${fn}$" $outfile
# test use of --resume
elif [[ ${{matrix.SCRIPT_TEST}} == 'resume' ]]; then
outfile=out_resume.txt
./eessi_container.sh --mode shell <<< "${test_cmd}" 2>&1 | tee ${outfile}
rm -f ${outfile}
tmpdir=$(grep "\-\-resume" ${outfile} | sed "s/.*--resume \([^']*\).*/\1/g")
./eessi_container.sh --resume ${tmpdir} --mode shell <<< "${test_cmd}" > ${outfile}
grep "Resuming from previous run using temporary storage at ${tmpdir}" ${outfile}
grep "${out_pattern}" ${outfile}
# test use of --save (+ --resume)
elif [[ ${{matrix.SCRIPT_TEST}} == 'save' ]]; then
outfile=out_save.txt
fn="test_${RANDOM}.txt"
test_cmd="touch /cvmfs/pilot.eessi-hpc.org/${fn}"
./eessi_container.sh --mode shell --access rw --save test-save.tar <<< "${test_cmd}" 2>&1 | tee ${outfile}
rm -f ${outfile}
./eessi_container.sh --mode shell --access rw --resume test-save.tar <<< "ls -l /cvmfs/pilot.eessi-hpc.org/${fn}" > ${outfile}
grep "/cvmfs/pilot.eessi-hpc.org/${fn}$" $outfile
tar tfv test-save.tar | grep "overlay-upper/${fn}"
else
echo "Unknown test case: ${{matrix.SCRIPT_TEST}}" >&2
exit 1
fi