-
Notifications
You must be signed in to change notification settings - Fork 1
/
no_ok_stats.bats
37 lines (30 loc) · 981 Bytes
/
no_ok_stats.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
#!/usr/bin/env bats
load helpers
function teardown(){
swarm_manage_cleanup
stop_docker
}
@test "docker show contianer stats" {
TEMP_FILE=$(mktmp)
start_docker 3
swarm_manage
# stats running container
run docker_swarm run -d --name test_container busybox sleep 50
[ "$status" -eq 0 ]
# make sure container is up
run docker_swarm ps -l
[ "${#lines[@]}" -eq 2 ]
[[ "${lines[1]}" == *"test_container"* ]]
[[ "${lines[1]}" == *"Up"* ]]
# storage the real time output of stats in TEMP_FILE
run docker_swarm stats test_container > $TEMP_FILE &
[ "$status" -eq 0 ]
# make sure TEMP_FILE is not empty
sleep 3
[ -s $TEMP_FILE ]
# if "CPU %" in TEMP_FILE, status is 0
run grep "CPU %" $TEMP_FILE
[ "$status" -eq 0 ]
run grep "MEM USAGE/LIMIT" $TEMP_FILE
[ "$status" -eq 0 ]
}