forked from sedan07/CachetDocker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.full.bats
executable file
·105 lines (83 loc) · 3.48 KB
/
test.full.bats
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
#!/usr/bin/env bats
load test_helpers
load docker_helpers
load "lib/batslib"
load "lib/output"
@test "[$TEST_FILE] testing Cachet Docker image build" {
command docker-compose build --no-cache cachet
}
@test "[$TEST_FILE] testing Cachet docker-compose up" {
command docker-compose up -d
}
@test "[$TEST_FILE] check for container init" {
docker_wait_for_log cachetdocker_cachet_1 15 "Initializing Cachet container ..."
}
@test "[$TEST_FILE] check for postgres database startup" {
docker_wait_for_log cachetdocker_postgres_1 120 "LOG: database system is ready to accept connections"
}
@test "[$TEST_FILE] check for empty sessions table" {
docker_wait_for_log cachetdocker_cachet_1 15 "Table chq_sessions does not exist! ..."
}
@test "[$TEST_FILE] check for DB init" {
docker_wait_for_log cachetdocker_cachet_1 15 "Initializing Cachet database ..."
}
@test "[$TEST_FILE] check for populated sessions table" {
docker_wait_for_log cachetdocker_cachet_1 15 "Table chq_sessions exists! ..."
}
@test "[$TEST_FILE] check for container start message" {
docker_wait_for_log cachetdocker_cachet_1 15 "Starting Cachet! ..."
}
@test "[$TEST_FILE] check for nginx startup" {
docker_wait_for_log cachetdocker_cachet_1 15 "INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)"
}
@test "[$TEST_FILE] check for php-fpm startup" {
docker_wait_for_log cachetdocker_cachet_1 15 "INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)"
}
@test "[$TEST_FILE] check for queue-worker startup" {
docker_wait_for_log cachetdocker_cachet_1 15 "INFO success: queue-worker entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)"
}
@test "[$TEST_FILE] php artisan cachet:seed" {
run docker exec cachetdocker_cachet_1 php artisan cachet:seed
assert_output -l 0 $'Database seeded with demo data successfully!'
}
@test "[$TEST_FILE] curl 200 response test" {
run curl_container cachetdocker_cachet_1 :8000/auth/login --head
assert_output -l 0 $'HTTP/1.1 200 OK\r'
}
@test "[$TEST_FILE] login test" {
run curl_container cachetdocker_cachet_1 :8000/auth/login --head --user test:test123
assert_output -l 0 $'HTTP/1.1 200 OK\r'
}
@test "[$TEST_FILE] check for curl API pong" {
run curl_container cachetdocker_cachet_1 :8000/api/v1/ping
assert_output -l 0 $'{"data":"Pong!"}'
}
@test "[$TEST_FILE] check for pg_dump version mismatch" {
run docker exec cachetdocker_cachet_1 php artisan app:update
refute_output -l 5 $'pg_dump: aborting because of server version mismatch'
}
@test "[$TEST_FILE] ensure there are no volumes" {
run docker inspect -f '{{ .Mounts }}' cachetdocker_cachet_1
assert_output -l 0 $'[]'
}
@test "[$TEST_FILE] restart cachet" {
command docker-compose stop cachet
command docker-compose rm -f cachet
command docker-compose up -d
docker_wait_for_log cachetdocker_cachet_1 15 "INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)"
}
@test "[$TEST_FILE] post-restart API pong" {
run curl_container cachetdocker_cachet_1 :8000/api/v1/ping
assert_output -l 0 $'{"data":"Pong!"}'
}
@test "[$TEST_FILE] post-restart login test" {
run curl_container cachetdocker_cachet_1 :8000/auth/login --head --user test:test123
assert_output -l 0 $'HTTP/1.1 200 OK\r'
}
@test "[$TEST_FILE] stop all test containers" {
stop_bats_containers
}
@test "[$TEST_FILE] Cleanup test containers" {
docker_clean cachetdocker_cachet_1
docker_clean docker_postgres_1
}