This repository has been archived by the owner on Apr 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathstandalone_test
78 lines (62 loc) · 1.52 KB
/
standalone_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
#!/bin/sh
# set -x
PORTO_BIN=$(pwd)
PORTO_SRC=$(dirname $(dirname $0))
die() {
echo FAIL: $@
exit 2
}
stopper() {
if [ -n "$PORTOD_PID" ] ; then
kill -INT $PORTOD_PID
wait $PORTOD_PID
unset PORTOD_PID
fi
exit 0
}
starter() {
trap stopper TERM INT QUIT EXIT
while test -x $PORTO_BIN/portod ; do
$PORTO_BIN/portod --verbose &
PORTOD_PID=$!
wait $PORTOD_PID
echo "portod exit code:" $?
done
}
poke_porto() {
$PORTO_BIN/portoctl get / state >/dev/null 2>&1
}
start_porto() {
starter &
STARTER_PID=$!
while ! poke_porto ; do
kill -0 $STARTER_PID || die "cannot start porto"
sleep 1
done
}
stop_porto() {
if [ -n "$STARTER_PID" ] ; then
kill $STARTER_PID
wait $STARTER_PID
unset STARTER_PID
fi
poke_porto && die "cannot stop porto"
}
kill_porto() {
if poke_porto ; then
service yandex-porto stop || true
killall -9 portod || true
sleep 1
poke_porto && die "cannot kill porto"
fi
}
test $(id -u) = "0" || die "current user not root"
trap stop_porto TERM INT QUIT EXIT
kill_porto
rm -f /var/log/portod.log
start_porto
$PORTO_BIN/portotest $@ || die "portotest failed"
for pytest in $PORTO_SRC/test/test-*.py; do
PYTHONPATH=$PORTO_SRC/src/api/python python $pytest || die "$pytest failed"
done
PYTHONPATH=$PORTO_SRC/src/api/python python -u $PORTO_SRC/test/porto_fuzzer/porto_fuzzer.py --timeout 300 --progress 32 2000 || die "fuzzer failed"