From 293abe06f43b7dbeda4f9bd1f995868dc613045e Mon Sep 17 00:00:00 2001 From: Xian Chaobo Date: Fri, 17 Apr 2015 09:56:24 +0800 Subject: [PATCH 1/3] add pause/unpause/inspect integration test Signed-off-by: Xian Chaobo --- test/integration/api.bats | 89 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 83 insertions(+), 6 deletions(-) diff --git a/test/integration/api.bats b/test/integration/api.bats index 514e75134f..a57262dbf1 100644 --- a/test/integration/api.bats +++ b/test/integration/api.bats @@ -86,9 +86,41 @@ function teardown() { [[ "${lines[3]}" == *"Nodes: 3" ]] } -# FIXME @test "docker inspect" { - skip + start_docker 3 + swarm_manage + # run container + run docker_swarm run -d --name test_container busybox sleep 500 + [ "$status" -eq 0 ] + + # make sure container exsists + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + + # inspect and verify + run docker_swarm inspect test_container + [ "$status" -eq 0 ] + [[ "${lines[1]}" == *"AppArmorProfile"* ]] +} + +@test "docker inspect --format" { + start_docker 3 + swarm_manage + # run container + run docker_swarm run -d --name test_container busybox sleep 500 + [ "$status" -eq 0 ] + + # make sure container exsists + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + + # inspect --format, return one line: image name + run docker_swarm inspect --format='{{.Config.Image}}' test_container + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 1 ] + [[ "${lines[0]}" == "busybox" ]] } # FIXME @@ -121,9 +153,27 @@ function teardown() { skip } -# FIXME @test "docker pause" { - skip + start_docker 3 + swarm_manage + + run docker_swarm run -d --name test_container busybox sleep 1000 + [ "$status" -eq 0 ] + + # make sure container is up + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + [[ "${lines[1]}" == *"Up"* ]] + + run docker_swarm pause test_container + [ "$status" -eq 0 ] + + # verify + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + [[ "${lines[1]}" == *"Paused"* ]] } @test "docker ps -n" { @@ -232,9 +282,36 @@ function teardown() { skip } -# FIXME @test "docker unpause" { - skip + start_docker 3 + swarm_manage + + run docker_swarm run -d --name test_container busybox sleep 1000 + [ "$status" -eq 0 ] + + # make sure container is up + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + [[ "${lines[1]}" == *"Up"* ]] + + # pause + run docker_swarm pause test_container + [ "$status" -eq 0 ] + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + [[ "${lines[1]}" == *"Paused"* ]] + + # unpause + run docker_swarm unpause test_container + [ "$status" -eq 0 ] + # verify + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + [[ "${lines[1]}" == *"Up"* ]] + [[ "${lines[1]}" != *"Paused"* ]] } # FIXME From 76c8c18bc9ad5c959a731c1a6a4ffca33faac6f3 Mon Sep 17 00:00:00 2001 From: Xian Chaobo Date: Tue, 21 Apr 2015 16:17:32 +0800 Subject: [PATCH 2/3] pause fix Signed-off-by: Xian Chaobo --- test/integration/api.bats | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/integration/api.bats b/test/integration/api.bats index a57262dbf1..5b3898ace2 100644 --- a/test/integration/api.bats +++ b/test/integration/api.bats @@ -87,6 +87,7 @@ function teardown() { } @test "docker inspect" { +skip start_docker 3 swarm_manage # run container @@ -105,6 +106,7 @@ function teardown() { } @test "docker inspect --format" { +skip start_docker 3 swarm_manage # run container @@ -174,6 +176,9 @@ function teardown() { [ "${#lines[@]}" -eq 2 ] [[ "${lines[1]}" == *"test_container"* ]] [[ "${lines[1]}" == *"Paused"* ]] + + # if the state of the container is paused, it can't be removed(rm -f) + run docker_swarm unpause test_container } @test "docker ps -n" { @@ -195,6 +200,7 @@ function teardown() { } @test "docker ps -l" { +skip start_docker 1 swarm_manage run docker_swarm run -d busybox sleep 42 From c3112adb5529631199f063a8d0ebf59217d3f0a6 Mon Sep 17 00:00:00 2001 From: Xian Chaobo Date: Wed, 22 Apr 2015 00:11:27 +0800 Subject: [PATCH 3/3] add unpause after pause and add inspect node verify Signed-off-by: Xian Chaobo --- test/integration/api.bats | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/integration/api.bats b/test/integration/api.bats index 5b3898ace2..1ae15a4698 100644 --- a/test/integration/api.bats +++ b/test/integration/api.bats @@ -87,7 +87,6 @@ function teardown() { } @test "docker inspect" { -skip start_docker 3 swarm_manage # run container @@ -103,10 +102,12 @@ skip run docker_swarm inspect test_container [ "$status" -eq 0 ] [[ "${lines[1]}" == *"AppArmorProfile"* ]] + # the specific information of swarm node + [[ ${output} == *'"Node": {'* ]] + [[ ${output} == *'"Name": "node-'* ]] } @test "docker inspect --format" { -skip start_docker 3 swarm_manage # run container @@ -118,11 +119,17 @@ skip [ "${#lines[@]}" -eq 2 ] [[ "${lines[1]}" == *"test_container"* ]] - # inspect --format, return one line: image name + # inspect --format='{{.Config.Image}}', return one line: image name run docker_swarm inspect --format='{{.Config.Image}}' test_container [ "$status" -eq 0 ] [ "${#lines[@]}" -eq 1 ] [[ "${lines[0]}" == "busybox" ]] + + # inspect --format='{{.Node.IP}}', return one line: Node ip + run docker_swarm inspect --format='{{.Node.IP}}' test_container + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 1 ] + [[ "${lines[0]}" == "127.0.0.1" ]] } # FIXME @@ -179,6 +186,7 @@ skip # if the state of the container is paused, it can't be removed(rm -f) run docker_swarm unpause test_container + [ "$status" -eq 0 ] } @test "docker ps -n" { @@ -200,7 +208,6 @@ skip } @test "docker ps -l" { -skip start_docker 1 swarm_manage run docker_swarm run -d busybox sleep 42