forked from cachethq/Docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.mysql.bats
executable file
·87 lines (69 loc) · 2.78 KB
/
test.mysql.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
#!/usr/bin/env bats
load test_helpers
load docker_helpers
load "lib/batslib"
load "lib/output"
@test "[$TEST_FILE] docker-compose up" {
command docker-compose -f test/docker-compose-mysql.yml up -d
}
@test "[$TEST_FILE] check for container init" {
docker_wait_for_log test_cachet_1 15 "Initializing Cachet container ..."
}
@test "[$TEST_FILE] check for database startup" {
docker_wait_for_log test_mysql_1 120 "mysqld: ready for connections."
}
@test "[$TEST_FILE] check for empty sessions table" {
docker_wait_for_log test_cachet_1 15 "Table chq_sessions does not exist! ..."
}
@test "[$TEST_FILE] check for DB init" {
docker_wait_for_log test_cachet_1 15 "Initializing Cachet database ..."
}
@test "[$TEST_FILE] check for populated sessions table" {
docker_wait_for_log test_cachet_1 15 "Table chq_sessions exists! ..."
}
@test "[$TEST_FILE] check for container start message" {
docker_wait_for_log test_cachet_1 15 "Starting Cachet! ..."
}
@test "[$TEST_FILE] check for nginx startup" {
docker_wait_for_log test_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 test_cachet_1 15 "INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)"
}
@test "[$TEST_FILE] php artisan cachet:seed" {
run docker exec test_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 test_cachet_1 :8000/auth/login --head
assert_output -l 0 $'HTTP/1.1 200 OK\r'
}
@test "[$TEST_FILE] login test" {
run curl_container test_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 test_cachet_1 :8000/api/v1/ping
assert_output -l 0 $'{"data":"Pong!"}'
}
@test "[$TEST_FILE] restart cachet" {
command docker-compose -f test/docker-compose-mysql.yml stop cachet
command docker-compose -f test/docker-compose-mysql.yml rm -f cachet
command docker-compose -f test/docker-compose-mysql.yml up -d
docker_wait_for_log test_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 test_cachet_1 :8000/api/v1/ping
assert_output -l 0 $'{"data":"Pong!"}'
}
@test "[$TEST_FILE] post-restart login test" {
run curl_container test_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 test_cachet_1
docker_clean test_mysql_1
}