-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathphd-run-with-args.sh
executable file
·100 lines (81 loc) · 2.35 KB
/
phd-run-with-args.sh
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
#!/bin/bash
# Unpacks and executes the PHD runner in the Buildomat environment, passing
# through to the runner any arguments that were passed to this script.
set -o errexit
set -o pipefail
set -o xtrace
indir="/input"
indir_suffix="phd-build/out/*.tar.gz"
phddir="$PWD/phd-test"
# Put artifacts on the runner's SSDs (the /work ramdisk is small by design, too
# small for images of any appreciable size).
pfexec zpool create -f phd-artifacts c1t1d0 c2t1d0
artifactdir="/phd-artifacts"
banner 'Inputs'
find $indir -ls
rm -rf "$phddir"
mkdir "$phddir"
for p in $indir/$indir_suffix; do
tar xzvf $p -C $phddir
for f in $(tar tf "$p"); do
chmod +x "$phddir/$f"
done
done
ls $phddir
banner 'Setup'
tmpdir="/tmp/propolis-phd"
if [ ! -d "$tmpdir" ]; then
mkdir $tmpdir
fi
# We'll be using the reservoir, so set it to something higher than the default
# 0MiB. Most tests would only need 512MiB (the default PHD guest VM memory
# size), some tests want to run multiple VMs concurrently (particularly around
# migration). 4096MiB is an arbitrary number intended to support the above and
# that we might want to run those tests concurrently at some point.
#
# Currently the lab host these tests will run on is well-known and has much
# more memory than this. Hopefully we won't have Propolis CI running on a
# machine with ~4GiB of memory, but this number could be tuned down if the need
# arises.
pfexec /usr/lib/rsrvrctl -s 4096
banner 'Tests'
runner="$phddir/phd-runner"
artifacts="$phddir/artifacts.toml"
propolis="$phddir/propolis-server"
ls $runner
ls $artifacts
ls $propolis
args=(
$runner '--emit-bunyan' 'run'
'--propolis-server-cmd' $propolis
'--crucible-downstairs-commit' 'auto'
'--artifact-toml-path' $artifacts
'--tmp-directory' $tmpdir
'--artifact-directory' $artifactdir
$@
)
# Disable errexit so that we still upload logs on failure
set +e
(RUST_BACKTRACE=1 RUST_LOG="info,phd=debug" ptime -m pfexec "${args[@]}" | \
tee /tmp/phd-runner.log)
failcount=$?
set -e
tar -czvf /tmp/phd-tmp-files.tar.gz \
-C /tmp/propolis-phd /tmp/propolis-phd/*.log
exitcode=0
if [ $failcount -eq 0 ]; then
echo
echo "ALL TESTS PASSED"
echo
else
echo
echo "SOME TESTS FAILED"
echo
exitcode=1
fi
if find /dev/vmm -mindepth 1 -maxdepth 1 | read ; then
echo "VMM handles leaked:"
find /dev/vmm -type c -exec basename {} \;
exitcode=2
fi
exit $exitcode