-
Notifications
You must be signed in to change notification settings - Fork 56
/
test.sh
executable file
·108 lines (86 loc) · 3.11 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bats
TOMCAT_DEFAULT_USER=user
TOMCAT_USER=tomcat_user
TOMCAT_PASSWORD=test_password
# source the helper script
APP_NAME=tomcat
SLEEP_TIME=30
VOL_PREFIX=/bitnami/$APP_NAME
VOLUMES=$VOL_PREFIX
load tests/docker_helper
# Cleans up all running/stopped containers and host mounted volumes
cleanup_environment() {
container_remove_full default
}
# Teardown called at the end of each test
teardown() {
cleanup_environment
}
# cleanup the environment before starting the tests
cleanup_environment
@test "Port 8080 exposed and accepting external connections" {
container_create default -d
run curl_client default -i http://$APP_NAME:8080
[[ "$output" =~ '200 OK' ]]
}
@test "Default user is created without a password" {
container_create default -d
run curl_client default -i http://$TOMCAT_DEFAULT_USER@$APP_NAME:8080/manager/html
[[ "$output" =~ '200 OK' ]]
}
@test "Can assign custom password for the default user" {
container_create default -d \
-e TOMCAT_PASSWORD=$TOMCAT_PASSWORD
run curl_client default -i http://$TOMCAT_DEFAULT_USER:$TOMCAT_PASSWORD@$APP_NAME:8080/manager/html
[[ "$output" =~ '200 OK' ]]
}
@test "Can create custom user with manager role" {
container_create default -d \
-e TOMCAT_USER=$TOMCAT_USER \
-e TOMCAT_PASSWORD=$TOMCAT_PASSWORD
run curl_client default -i http://$TOMCAT_USER:$TOMCAT_PASSWORD@$APP_NAME:8080/manager/html
[[ "$output" =~ '200 OK' ]]
}
@test "Password and settings are preserved after restart" {
container_create default -d \
-e TOMCAT_USER=$TOMCAT_USER \
-e TOMCAT_PASSWORD=$TOMCAT_PASSWORD
container_restart default
run curl_client default -i http://$TOMCAT_USER:$TOMCAT_PASSWORD@$APP_NAME:8080/manager/html
[[ "$output" =~ '200 OK' ]]
}
@test "All the volumes exposed" {
container_create default -d
run container_inspect default --format {{.Mounts}}
[[ "$output" =~ "$VOL_PREFIX" ]]
}
@test "Data gets generated in volume if bind mounted in the host" {
container_create_with_host_volumes default -d \
-e TOMCAT_USER=$TOMCAT_USER \
-e TOMCAT_PASSWORD=$TOMCAT_PASSWORD
run container_exec default ls -la $VOL_PREFIX/conf/
[[ "$output" =~ "server.xml" ]]
[[ "$output" =~ "tomcat-users.xml" ]]
run container_exec default ls -la $VOL_PREFIX/data/
[[ "$output" =~ "ROOT" ]]
[[ "$output" =~ "manager" ]]
}
@test "If host mounted, password and settings are preserved after deletion" {
container_create_with_host_volumes default -d \
-e TOMCAT_USER=$TOMCAT_USER \
-e TOMCAT_PASSWORD=$TOMCAT_PASSWORD
container_remove default
container_create_with_host_volumes default -d
run curl_client default -i http://$TOMCAT_USER:$TOMCAT_PASSWORD@$APP_NAME:8080/manager/html
[[ "$output" =~ '200 OK' ]]
}
@test "Deploy sample application" {
container_create_with_host_volumes default -d \
-e TOMCAT_USER=$TOMCAT_USER \
-e TOMCAT_PASSWORD=$TOMCAT_PASSWORD
container_exec default curl --noproxy localhost --retry 5 \
http://localhost:8080/docs/appdev/sample/sample.war -o $VOL_PREFIX/data/sample.war
sleep 10
run curl_client default -i http://$APP_NAME:8080/sample/hello.jsp
[[ "$output" =~ '200 OK' ]]
}