-
Notifications
You must be signed in to change notification settings - Fork 39
/
runtests.sh
executable file
·65 lines (47 loc) · 1.02 KB
/
runtests.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
#!/bin/bash
IMAGES=(
"horneds/stouts-centos7"
"horneds/stouts-ubuntu14.04"
"horneds/stouts-debian8"
)
TESTS=(
"ansible-playbook -c local --syntax-check test.yml"
"ansible-playbook -c local test.yml"
"test -x /usr/bin/duply"
)
APPDIR=/var/tests
CURDIR=`pwd`
ARGS=("$@")
docker info || exit 1
assert () {
echo "ASSERT: $1"
execute "$@" || ( echo ${2-'Test is failed'} && exit 1 )
echo "SUCCESS"
}
execute () {
docker exec -it $RUNNER $1
return $?
}
suite () {
echo "================="
echo "RUN IMAGE: $1"
echo "================="
for TEST in "${TESTS[@]}"; do
assert "$TEST" || ( echo "FAILED" && exit 1 )
done
echo
}
for IMAGE in "${IMAGES[@]}"
do
RUNNER=`docker run -v $CURDIR:$APPDIR -w $APPDIR -dit $IMAGE bash`
suite $IMAGE || {
echo "Tests are failed $IMAGE"
docker stop $RUNNER
exit 1
}
if [[ "$1" = "shell" ]]; then
echo "Run shell"
execute /bin/bash
fi
docker stop $RUNNER
done