-
Notifications
You must be signed in to change notification settings - Fork 60
/
test.sh
84 lines (70 loc) · 2.01 KB
/
test.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
#!/usr/bin/env bats
CONTAINER_NAME=bitnami-apache-test
IMAGE_NAME=bitnami/apache
SLEEP_TIME=2
VOL_PREFIX=/bitnami/apache
cleanup_running_containers() {
if [ "$(docker ps -a | grep $CONTAINER_NAME)" ]; then
docker rm -fv $CONTAINER_NAME
fi
}
setup() {
cleanup_running_containers
}
teardown() {
cleanup_running_containers
}
create_container(){
docker run -d --name $CONTAINER_NAME \
--expose 81 $IMAGE_NAME
sleep $SLEEP_TIME
}
add_vhost() {
docker exec $CONTAINER_NAME sh -c "echo 'Listen 81
<VirtualHost *:81>
ServerName default
Redirect 405 /
</VirtualHost>' > $VOL_PREFIX/conf/vhosts/test.conf"
}
@test "We can connect to the port 80 and 443" {
create_container
run docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i http://apache:80
[[ "$output" =~ "200 OK" ]]
[ $status = 0 ]
run docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i -k https://apache:443
[[ "$output" =~ "200 OK" ]]
[ $status = 0 ]
}
@test "Returns default page" {
create_container
run docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i http://apache:80
[[ "$output" =~ "It works!" ]]
[ $status = 0 ]
run docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i -k https://apache:443
[[ "$output" =~ "It works!" ]]
[ $status = 0 ]
}
@test "Logs to stdout" {
create_container
docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i http://apache:80
run docker logs $CONTAINER_NAME
[[ "$output" =~ "GET / HTTP/1.1" ]]
[ $status = 0 ]
}
@test "All the volumes exposed" {
create_container
run docker inspect $CONTAINER_NAME
[[ "$output" =~ "$VOL_PREFIX/logs" ]]
[[ "$output" =~ "$VOL_PREFIX/conf" ]]
[[ "$output" =~ "/app" ]]
}
@test "Vhosts directory is imported" {
create_container
add_vhost
docker restart $CONTAINER_NAME
sleep $SLEEP_TIME
docker run --link $CONTAINER_NAME:apache --rm bitnami/apache curl -L -i http://apache:81 | {
run grep "405 Method Not Allowed"
[ $status = 0 ]
}
}