-
Notifications
You must be signed in to change notification settings - Fork 272
/
test.sh
61 lines (48 loc) · 1.62 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
#!/usr/bin/env bats
WELCOME_PAGE_TEXT="Welcome to WordPress"
MARIADB_IMAGE_NAME=bitnami/mariadb
MARIADB_CONTAINER_NAME=bitnami-mariadb-test
# source the helper script
APP_NAME=wordpress
SLEEP_TIME=30
VOLUMES=/bitnami/$APP_NAME:/bitnami/apache
load tests/docker_helper
# Cleans up all running/stopped containers and host mounted volumes
cleanup_environment() {
if docker ps -a | grep $MARIADB_CONTAINER_NAME; then
docker rm -fv $MARIADB_CONTAINER_NAME
fi
container_remove_full default
}
# Teardown called at the end of each test
teardown() {
cleanup_environment
}
# cleanup the environment of any leftover containers and volumes before starting the tests
cleanup_environment
create_mariadb_container() {
docker run --name $MARIADB_CONTAINER_NAME -d $MARIADB_IMAGE_NAME
sleep $SLEEP_TIME
}
@test "Port 80 and 443 is exposed and accepting connections" {
create_mariadb_container
container_create default -d \
--link $MARIADB_CONTAINER_NAME:mariadb \
--env MARIADB_HOST=mariadb \
--env MARIADB_PORT=3306
run container_exec default curl --noproxy 127.0.0.1 http://127.0.0.1:80
[[ "$output" =~ "$WELCOME_PAGE_TEXT" ]]
run container_exec default curl -k --noproxy 127.0.0.1 https://127.0.0.1:443
[[ "$output" =~ "$WELCOME_PAGE_TEXT" ]]
}
@test "Logs to stdout" {
create_mariadb_container
container_create default -d \
--link $MARIADB_CONTAINER_NAME:mariadb \
--env MARIADB_HOST=mariadb \
--env MARIADB_PORT=3306
run container_exec default curl --noproxy 127.0.0.1 http://127.0.0.1:80
[[ "$output" =~ "$WELCOME_PAGE_TEXT" ]]
run container_logs default
[[ "$output" =~ "GET / HTTP" ]]
}