diff --git a/test/integration/api.bats b/test/integration/api.bats index c9766dc436..8bb1992e5e 100644 --- a/test/integration/api.bats +++ b/test/integration/api.bats @@ -198,9 +198,26 @@ function teardown() { skip } -# FIXME @test "docker logs" { - skip + start_docker 3 + swarm_manage + + # run a container with echo command + run docker_swarm run -d --name test_container busybox /bin/sh -c "echo hello world; echo hello docker; echo hello swarm" + [ "$status" -eq 0 ] + + # make sure container exists + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + + # verify + run docker_swarm logs test_container + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 3 ] + [[ "${lines[0]}" == *"hello world"* ]] + [[ "${lines[1]}" == *"hello docker"* ]] + [[ "${lines[2]}" == *"hello swarm"* ]] } @test "docker port" { @@ -300,19 +317,105 @@ function teardown() { [[ "${lines[1]}" == *"Up"* ]] } -# FIXME @test "docker rm" { - skip + start_docker 3 + swarm_manage + + run docker_swarm run -d --name test_container busybox + [ "$status" -eq 0 ] + + # make sure container exsists and is exited + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + [[ "${lines[1]}" == *"Exited"* ]] + + run docker_swarm rm test_container + [ "$status" -eq 0 ] + + # verify + run docker_swarm ps -aq + [ "${#lines[@]}" -eq 0 ] +} + +@test "docker rm -f" { + start_docker 3 + swarm_manage + + run docker_swarm run -d --name test_container busybox sleep 500 + [ "$status" -eq 0 ] + + # make sure container exsists and is up + run docker_swarm ps -a + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + [[ "${lines[1]}" == *"Up"* ]] + + # rm, remove a running container, return error + run docker_swarm rm test_container + [ "$status" -ne 0 ] + + # rm -f, remove a running container + run docker_swarm rm -f test_container + [ "$status" -eq 0 ] + + # verify + run docker_swarm ps -aq + [ "${#lines[@]}" -eq 0 ] } -# FIXME @test "docker rmi" { - skip + start_docker 3 + swarm_manage + + run docker_swarm pull busybox + [ "$status" -eq 0 ] + + # make sure image exists + # swarm check image + run docker_swarm images + [ "$status" -eq 0 ] + [[ "${output}" == *"busybox"* ]] + # node check image + for host in ${HOSTS[@]}; do + run docker -H $host images + [ "$status" -eq 0 ] + [[ "${output}" == *"busybox"* ]] + done + + # this test presupposition: do not run image + run docker_swarm rmi busybox + [ "$status" -eq 0 ] + + # swarm verify + run docker_swarm images -q + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 0 ] + # node verify + for host in ${HOSTS[@]}; do + run docker -H $host images -q + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 0 ] + done } -# FIXME @test "docker run" { - skip + start_docker 3 + swarm_manage + + # make sure no container exist + run docker_swarm ps -qa + [ "${#lines[@]}" -eq 0 ] + + # run + run docker_swarm run -d --name test_container busybox sleep 100 + [ "$status" -eq 0 ] + + # verify, container exists + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${output}" == *"test_container"* ]] + [[ "${output}" == *"Up"* ]] } # FIXME