mirror of https://github.com/docker/docs.git
51 lines
1.2 KiB
Bash
51 lines
1.2 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load helpers
|
|
|
|
function teardown() {
|
|
swarm_manage_cleanup
|
|
stop_docker
|
|
}
|
|
|
|
@test "docker info should return the number of nodes" {
|
|
start_docker 3
|
|
swarm_manage
|
|
run docker_swarm info
|
|
[ "$status" -eq 0 ]
|
|
[[ "${lines[3]}" == *"Nodes: 3" ]]
|
|
}
|
|
|
|
@test "docker ps -n 3 should return the 3 last containers, including non running one" {
|
|
start_docker 1
|
|
swarm_manage
|
|
run docker_swarm run -d busybox sleep 42
|
|
run docker_swarm run -d busybox false
|
|
run docker_swarm ps -n 3
|
|
[ "${#lines[@]}" -eq 3 ]
|
|
|
|
run docker_swarm run -d busybox true
|
|
run docker_swarm ps -n 3
|
|
[ "${#lines[@]}" -eq 4 ]
|
|
|
|
run docker_swarm run -d busybox true
|
|
run docker_swarm ps -n 3
|
|
[ "${#lines[@]}" -eq 4 ]
|
|
}
|
|
|
|
@test "docker ps -l should return the last container, including non running one" {
|
|
start_docker 1
|
|
swarm_manage
|
|
run docker_swarm run -d busybox sleep 42
|
|
sleep 1 #sleep so the 2 containers don't start at the same second
|
|
run docker_swarm run -d busybox true
|
|
run docker_swarm ps -l
|
|
[ "${#lines[@]}" -eq 2 ]
|
|
[[ "${lines[1]}" == *"true"* ]]
|
|
|
|
sleep 1 #sleep so the container doesn't start at the same second as 'busybox true'
|
|
run docker_swarm run -d busybox false
|
|
run docker_swarm ps -l
|
|
[ "${#lines[@]}" -eq 2 ]
|
|
[[ "${lines[1]}" == *"false"* ]]
|
|
}
|