From 805b8261617c71ae576a34db3df5d4161f9a39e2 Mon Sep 17 00:00:00 2001 From: Xian Chaobo Date: Thu, 16 Apr 2015 22:43:08 +0800 Subject: [PATCH 1/4] add create-start-stop-restart-kill integration test Signed-off-by: Xian Chaobo --- test/integration/api.bats | 75 +++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 10 deletions(-) diff --git a/test/integration/api.bats b/test/integration/api.bats index 732d0f24c6..e504b6fc10 100644 --- a/test/integration/api.bats +++ b/test/integration/api.bats @@ -38,9 +38,17 @@ function teardown() { skip } -# FIXME @test "docker create" { - skip + start_docker 3 + swarm_manage + + # create + run docker_swarm create --name test_container busybox sleep 1000 + [ "$status" -eq 0 ] + + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] } # FIXME @@ -91,9 +99,20 @@ function teardown() { skip } -# FIXME @test "docker kill" { - skip + start_docker 3 + swarm_manage + # run + run docker_swarm run -d --name test_container busybox sleep 1000 + [ "$status" -eq 0 ] + + # kill + run docker_swarm kill test_container + [ "$status" -eq 0 ] + # verify + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"Exited"* ]] } # FIXME @@ -177,9 +196,25 @@ function teardown() { skip } -# FIXME @test "docker restart" { - skip + start_docker 3 + swarm_manage + # run + 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]}" == *"Up"* ]] + + # restart + run docker_swarm restart test_container + [ "$status" -eq 0 ] + # verify + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"Up"* ]] } # FIXME @@ -207,9 +242,19 @@ function teardown() { skip } -# FIXME @test "docker start" { - skip + start_docker 3 + swarm_manage + # create + run docker_swarm create --name test_container busybox sleep 1000 + [ "$status" -eq 0 ] + + # start + run docker_swarm start test_container + [ "$status" -eq 0 ] + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"Up"* ]] } # FIXME @@ -217,9 +262,19 @@ function teardown() { skip } -# FIXME @test "docker stop" { - skip + start_docker 3 + swarm_manage + # run + run docker_swarm run -d --name test_container busybox sleep 500 + [ "$status" -eq 0 ] + + # stop + run docker_swarm stop test_container + [ "$status" -eq 0 ] + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"Exited"* ]] } # FIXME From 6d5e9af3430d6cac3f1edbf2d7ddfdece1f12328 Mon Sep 17 00:00:00 2001 From: Xian Chaobo Date: Fri, 17 Apr 2015 04:57:30 +0800 Subject: [PATCH 2/4] enhance test Signed-off-by: Xian Chaobo --- test/integration/api.bats | 114 ++++++++++++++++++++++++-------------- 1 file changed, 72 insertions(+), 42 deletions(-) diff --git a/test/integration/api.bats b/test/integration/api.bats index e504b6fc10..45e258be6f 100644 --- a/test/integration/api.bats +++ b/test/integration/api.bats @@ -42,10 +42,15 @@ function teardown() { start_docker 3 swarm_manage + # make sure no contaienr exist + run docker_swarm ps -qa + [ "${#lines[@]}" -eq 0 ] + # create run docker_swarm create --name test_container busybox sleep 1000 [ "$status" -eq 0 ] + # verify, created container exists run docker_swarm ps -l [ "${#lines[@]}" -eq 2 ] [[ "${lines[1]}" == *"test_container"* ]] @@ -86,13 +91,13 @@ function teardown() { skip } -@test "docker info" { - start_docker 3 - swarm_manage - run docker_swarm info - [ "$status" -eq 0 ] - [[ "${lines[3]}" == *"Nodes: 3" ]] -} +#@test "docker info" { +# start_docker 3 +# swarm_manage +# run docker_swarm info +# [ "$status" -eq 0 ] +# [[ "${lines[3]}" == *"Nodes: 3" ]] +#} # FIXME @test "docker inspect" { @@ -106,12 +111,19 @@ function teardown() { run docker_swarm run -d --name test_container busybox sleep 1000 [ "$status" -eq 0 ] + # make sure container is up before killing + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + [[ "${lines[1]}" == *"Up"* ]] + # kill run docker_swarm kill test_container [ "$status" -eq 0 ] # verify run docker_swarm ps -l [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] [[ "${lines[1]}" == *"Exited"* ]] } @@ -145,41 +157,41 @@ function teardown() { skip } -@test "docker ps -n" { - 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 - # Non-running containers should be included in ps -n - [ "${#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" { - 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 ] - # Last container should be "true", even though it's stopped. - [[ "${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"* ]] -} +#@test "docker ps -n" { +# 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 +# # Non-running containers should be included in ps -n +# [ "${#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" { +# 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 ] +# # Last container should be "true", even though it's stopped. +# [[ "${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"* ]] +#} # FIXME @test "docker pull" { @@ -206,6 +218,7 @@ function teardown() { # make sure container is up run docker_swarm ps -l [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] [[ "${lines[1]}" == *"Up"* ]] # restart @@ -214,6 +227,7 @@ function teardown() { # verify run docker_swarm ps -l [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] [[ "${lines[1]}" == *"Up"* ]] } @@ -249,11 +263,18 @@ function teardown() { run docker_swarm create --name test_container busybox sleep 1000 [ "$status" -eq 0 ] + # make sure created container exists + # new created container has no status + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + # start run docker_swarm start test_container [ "$status" -eq 0 ] run docker_swarm ps -l [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] [[ "${lines[1]}" == *"Up"* ]] } @@ -269,11 +290,20 @@ function teardown() { run docker_swarm run -d --name test_container busybox sleep 500 [ "$status" -eq 0 ] + # make sure container is up before stop + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + [[ "${lines[1]}" == *"Up"* ]] + # stop run docker_swarm stop test_container [ "$status" -eq 0 ] + + # verify run docker_swarm ps -l [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] [[ "${lines[1]}" == *"Exited"* ]] } From 7ac29486978ba3e5e18a3489dedf985989e7e129 Mon Sep 17 00:00:00 2001 From: Xian Chaobo Date: Fri, 17 Apr 2015 05:03:27 +0800 Subject: [PATCH 3/4] bug fix Signed-off-by: Xian Chaobo --- test/integration/api.bats | 84 +++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/test/integration/api.bats b/test/integration/api.bats index 45e258be6f..8953bf5214 100644 --- a/test/integration/api.bats +++ b/test/integration/api.bats @@ -91,13 +91,13 @@ function teardown() { skip } -#@test "docker info" { -# start_docker 3 -# swarm_manage -# run docker_swarm info -# [ "$status" -eq 0 ] -# [[ "${lines[3]}" == *"Nodes: 3" ]] -#} +@test "docker info" { + start_docker 3 + swarm_manage + run docker_swarm info + [ "$status" -eq 0 ] + [[ "${lines[3]}" == *"Nodes: 3" ]] +} # FIXME @test "docker inspect" { @@ -157,41 +157,41 @@ function teardown() { skip } -#@test "docker ps -n" { -# 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 -# # Non-running containers should be included in ps -n -# [ "${#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" { -# 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 ] -# # Last container should be "true", even though it's stopped. -# [[ "${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"* ]] -#} +@test "docker ps -n" { + 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 + # Non-running containers should be included in ps -n + [ "${#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" { + 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 ] + # Last container should be "true", even though it's stopped. + [[ "${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"* ]] +} # FIXME @test "docker pull" { From cb60e836157dd9eb3b90a2937da1d889cd20a121 Mon Sep 17 00:00:00 2001 From: Xian Chaobo Date: Fri, 17 Apr 2015 10:22:03 +0800 Subject: [PATCH 4/4] format fix Signed-off-by: Xian Chaobo --- test/integration/api.bats | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/integration/api.bats b/test/integration/api.bats index 8953bf5214..8ecdd7823e 100644 --- a/test/integration/api.bats +++ b/test/integration/api.bats @@ -48,7 +48,7 @@ function teardown() { # create run docker_swarm create --name test_container busybox sleep 1000 - [ "$status" -eq 0 ] + [ "$status" -eq 0 ] # verify, created container exists run docker_swarm ps -l @@ -123,7 +123,7 @@ function teardown() { # verify run docker_swarm ps -l [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] + [[ "${lines[1]}" == *"test_container"* ]] [[ "${lines[1]}" == *"Exited"* ]] } @@ -227,7 +227,7 @@ function teardown() { # verify run docker_swarm ps -l [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] + [[ "${lines[1]}" == *"test_container"* ]] [[ "${lines[1]}" == *"Up"* ]] } @@ -274,7 +274,7 @@ function teardown() { [ "$status" -eq 0 ] run docker_swarm ps -l [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] + [[ "${lines[1]}" == *"test_container"* ]] [[ "${lines[1]}" == *"Up"* ]] } @@ -291,10 +291,10 @@ function teardown() { [ "$status" -eq 0 ] # make sure container is up before stop - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + [[ "${lines[1]}" == *"Up"* ]] # stop run docker_swarm stop test_container @@ -303,7 +303,7 @@ function teardown() { # verify run docker_swarm ps -l [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] + [[ "${lines[1]}" == *"test_container"* ]] [[ "${lines[1]}" == *"Exited"* ]] }