From c75992a3bd7ffc73920cd61c2a5df5bded252e9e Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Wed, 6 May 2015 01:36:43 -0700 Subject: [PATCH] integration: faster. faster. faster. - Use start_with_busybox everywhere it's possible. - Start only what we need. - Improved correctness of a few tests at the same time. Signed-off-by: Andrea Luzzardi --- test/integration/affinities.bats | 42 +++++++++++++------------- test/integration/api/attach.bats | 4 +-- test/integration/api/build.bats | 2 +- test/integration/api/commit.bats | 2 +- test/integration/api/cp.bats | 2 +- test/integration/api/create.bats | 2 +- test/integration/api/diff.bats | 2 +- test/integration/api/events.bats | 2 +- test/integration/api/exec.bats | 2 +- test/integration/api/export.bats | 2 +- test/integration/api/history.bats | 9 +++--- test/integration/api/images.bats | 50 ++++++++++++++----------------- test/integration/api/inspect.bats | 4 +-- test/integration/api/kill.bats | 2 +- test/integration/api/load.bats | 16 ++++++---- test/integration/api/logs.bats | 2 +- test/integration/api/pause.bats | 2 +- test/integration/api/port.bats | 2 +- test/integration/api/ps.bats | 6 ++-- test/integration/api/pull.bats | 8 ++--- test/integration/api/rename.bats | 2 +- test/integration/api/restart.bats | 2 +- test/integration/api/rm.bats | 4 +-- test/integration/api/rmi.bats | 33 ++++++++++++-------- test/integration/api/run.bats | 2 +- test/integration/api/save.bats | 13 ++++---- test/integration/api/search.bats | 2 +- test/integration/api/start.bats | 2 +- test/integration/api/stats.bats | 2 +- test/integration/api/stop.bats | 2 +- test/integration/api/tag.bats | 8 ++--- test/integration/api/top.bats | 2 +- test/integration/api/unpause.bats | 2 +- test/integration/api/version.bats | 3 +- test/integration/api/wait.bats | 2 +- test/integration/constraints.bats | 6 ++-- test/integration/dependency.bats | 18 +++++------ test/integration/port-filter.bats | 8 +---- test/stress/stress.bats | 2 +- 39 files changed, 141 insertions(+), 137 deletions(-) diff --git a/test/integration/affinities.bats b/test/integration/affinities.bats index c905a8af83..0f54205b8f 100644 --- a/test/integration/affinities.bats +++ b/test/integration/affinities.bats @@ -8,10 +8,10 @@ function teardown() { } @test "container affinty" { - start_docker 2 + start_docker_with_busybox 2 swarm_manage - run docker_swarm run --name c1 -e constraint:node==node-0 -d busybox:latest sh + run docker_swarm run --name c1 -e constraint:node==node-1 -d busybox:latest sh [ "$status" -eq 0 ] run docker_swarm run --name c2 -e affinity:container==c1 -d busybox:latest sh [ "$status" -eq 0 ] @@ -24,33 +24,35 @@ function teardown() { run docker_swarm inspect c1 [ "$status" -eq 0 ] - [[ "${output}" == *'"Name": "node-0"'* ]] + [[ "${output}" == *'"Name": "node-1"'* ]] run docker_swarm inspect c2 [ "$status" -eq 0 ] - [[ "${output}" == *'"Name": "node-0"'* ]] + [[ "${output}" == *'"Name": "node-1"'* ]] run docker_swarm inspect c3 [ "$status" -eq 0 ] - [[ "${output}" != *'"Name": "node-0"'* ]] + [[ "${output}" != *'"Name": "node-1"'* ]] run docker_swarm inspect c4 [ "$status" -eq 0 ] - [[ "${output}" == *'"Name": "node-0"'* ]] + [[ "${output}" == *'"Name": "node-1"'* ]] run docker_swarm inspect c5 [ "$status" -eq 0 ] - [[ "${output}" != *'"Name": "node-0"'* ]] + [[ "${output}" != *'"Name": "node-1"'* ]] } @test "image affinity" { - start_docker 2 + start_docker_with_busybox 2 swarm_manage - run docker -H ${HOSTS[0]} build -t test $TESTDATA/build + # Create a new image just on the second host. + run docker -H ${HOSTS[1]} tag busybox test [ "$status" -eq 0 ] # pull busybox to force the refresh images + # FIXME: this is slow. run docker_swarm pull busybox [ "$status" -eq 0 ] @@ -65,26 +67,26 @@ function teardown() { run docker_swarm inspect c1 [ "$status" -eq 0 ] - [[ "${output}" == *'"Name": "node-0"'* ]] + [[ "${output}" == *'"Name": "node-1"'* ]] run docker_swarm inspect c2 [ "$status" -eq 0 ] - [[ "${output}" != *'"Name": "node-0"'* ]] + [[ "${output}" != *'"Name": "node-1"'* ]] run docker_swarm inspect c3 [ "$status" -eq 0 ] - [[ "${output}" == *'"Name": "node-0"'* ]] + [[ "${output}" == *'"Name": "node-1"'* ]] run docker_swarm inspect c4 [ "$status" -eq 0 ] - [[ "${output}" != *'"Name": "node-0"'* ]] + [[ "${output}" != *'"Name": "node-1"'* ]] } @test "label affinity" { - start_docker 2 + start_docker_with_busybox 2 swarm_manage - run docker_swarm run --name c1 --label test.label=true -e constraint:node==node-0 -d busybox:latest sh + run docker_swarm run --name c1 --label test.label=true -e constraint:node==node-1 -d busybox:latest sh [ "$status" -eq 0 ] run docker_swarm run --name c2 -e affinity:test.label==true -d busybox:latest sh [ "$status" -eq 0 ] @@ -97,21 +99,21 @@ function teardown() { run docker_swarm inspect c1 [ "$status" -eq 0 ] - [[ "${output}" == *'"Name": "node-0"'* ]] + [[ "${output}" == *'"Name": "node-1"'* ]] run docker_swarm inspect c2 [ "$status" -eq 0 ] - [[ "${output}" == *'"Name": "node-0"'* ]] + [[ "${output}" == *'"Name": "node-1"'* ]] run docker_swarm inspect c3 [ "$status" -eq 0 ] - [[ "${output}" != *'"Name": "node-0"'* ]] + [[ "${output}" != *'"Name": "node-1"'* ]] run docker_swarm inspect c4 [ "$status" -eq 0 ] - [[ "${output}" == *'"Name": "node-0"'* ]] + [[ "${output}" == *'"Name": "node-1"'* ]] run docker_swarm inspect c5 [ "$status" -eq 0 ] - [[ "${output}" != *'"Name": "node-0"'* ]] + [[ "${output}" != *'"Name": "node-1"'* ]] } diff --git a/test/integration/api/attach.bats b/test/integration/api/attach.bats index 5d7a615526..b0479916d6 100644 --- a/test/integration/api/attach.bats +++ b/test/integration/api/attach.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker attach" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage # container run in background @@ -27,7 +27,7 @@ function teardown() { @test "docker attach through websocket" { CLIENT_API_VERSION="v1.17" - start_docker 2 + start_docker_with_busybox 2 swarm_manage #create a container diff --git a/test/integration/api/build.bats b/test/integration/api/build.bats index b48fb19c2b..90dd1eb440 100644 --- a/test/integration/api/build.bats +++ b/test/integration/api/build.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker build" { - start_docker 3 + start_docker 2 swarm_manage run docker_swarm images -q diff --git a/test/integration/api/commit.bats b/test/integration/api/commit.bats index f0011f523f..05a0555838 100644 --- a/test/integration/api/commit.bats +++ b/test/integration/api/commit.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker commit" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage run docker_swarm run -d --name test_container busybox sleep 500 diff --git a/test/integration/api/cp.bats b/test/integration/api/cp.bats index a5a43f24ec..8f7bfc704a 100644 --- a/test/integration/api/cp.bats +++ b/test/integration/api/cp.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker cp" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage test_file="/bin/busybox" diff --git a/test/integration/api/create.bats b/test/integration/api/create.bats index c64084ac12..83136d70b9 100644 --- a/test/integration/api/create.bats +++ b/test/integration/api/create.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker create" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage # make sure no contaienr exist diff --git a/test/integration/api/diff.bats b/test/integration/api/diff.bats index 594c8c7b8c..c60d9ac0d1 100644 --- a/test/integration/api/diff.bats +++ b/test/integration/api/diff.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker diff" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage run docker_swarm run -d --name test_container busybox sleep 500 [ "$status" -eq 0 ] diff --git a/test/integration/api/events.bats b/test/integration/api/events.bats index b27806b0a2..56796554c2 100644 --- a/test/integration/api/events.bats +++ b/test/integration/api/events.bats @@ -9,7 +9,7 @@ function teardown() { @test "docker events" { TEMP_FILE=$(mktemp) - start_docker 3 + start_docker_with_busybox 2 swarm_manage # start events, report real time events to TEMP_FILE diff --git a/test/integration/api/exec.bats b/test/integration/api/exec.bats index a78104db55..403047c2b1 100644 --- a/test/integration/api/exec.bats +++ b/test/integration/api/exec.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker exec" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage run docker_swarm create --name test_container busybox sleep 100 [ "$status" -eq 0 ] diff --git a/test/integration/api/export.bats b/test/integration/api/export.bats index 22c7b5695e..162745ada4 100644 --- a/test/integration/api/export.bats +++ b/test/integration/api/export.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker export" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage # run a container to export run docker_swarm run -d --name test_container busybox sleep 500 diff --git a/test/integration/api/history.bats b/test/integration/api/history.bats index a096e9503c..5eaeb3316e 100644 --- a/test/integration/api/history.bats +++ b/test/integration/api/history.bats @@ -8,13 +8,12 @@ function teardown() { } @test "docker history" { - start_docker 3 + # Start one empty host and one with busybox to ensure swarm selects the + # right one (and not one at random). + start_docker 1 + start_docker_with_busybox 1 swarm_manage - # pull busybox image - run docker_swarm pull busybox - [ "$status" -eq 0 ] - # make sure the image of busybox exists run docker_swarm images [ "$status" -eq 0 ] diff --git a/test/integration/api/images.bats b/test/integration/api/images.bats index f8c7bf8d5e..840283e2fd 100644 --- a/test/integration/api/images.bats +++ b/test/integration/api/images.bats @@ -8,41 +8,35 @@ function teardown() { } @test "docker images" { - start_docker 3 + # Start one empty host and two with busybox to ensure swarm selects the + # right ones. + start_docker 1 + start_docker_with_busybox 2 swarm_manage - # no image exist - run docker_swarm images -q - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] - # make sure every node has no image - for((i=0; i<3; i++)); do - run docker_swarm images --filter node=node-$i -q - [ "$status" -eq 0 ] - [ "${#lines[@]}" -eq 0 ] - done - # pull image - run docker_swarm pull busybox - [ "$status" -eq 0 ] - - # show all node images, including reduplicated + # we should get 2 busyboxes, plus the header. run docker_swarm images [ "$status" -eq 0 ] - # check pull busybox, if download sucessfully, the busybox have one tag(lastest) at least - # if there are 3 nodes, the output lines of "docker images" are greater or equal 4(1 header + 3 busybox:latest) - # so use -ge here, the following(pull/tag) is the same reason - [ "${#lines[@]}" -ge 4 ] - # Every line should contain "busybox" exclude the first head line + [ "${#lines[@]}" -eq 3 ] + # Every line should contain "busybox" except for the header for((i=1; i<${#lines[@]}; i++)); do [[ "${lines[i]}" == *"busybox"* ]] done - # verify - for((i=0; i<3; i++)); do - run docker_swarm images --filter node=node-$i - [ "$status" -eq 0 ] - [ "${#lines[@]}" -ge 2 ] - [[ "${lines[1]}" == *"busybox"* ]] - done + # Try with --filter. + run docker_swarm images --filter node=node-0 + echo $output + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 1 ] + + run docker_swarm images --filter node=node-1 + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"busybox"* ]] + + run docker_swarm images --filter node=node-2 + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"busybox"* ]] } diff --git a/test/integration/api/inspect.bats b/test/integration/api/inspect.bats index 819f90704e..ebc7ce49ad 100644 --- a/test/integration/api/inspect.bats +++ b/test/integration/api/inspect.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker inspect" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage # run container run docker_swarm run -d --name test_container busybox sleep 500 @@ -32,7 +32,7 @@ function teardown() { # FIXME: Broken in docker master. See #717 skip - start_docker 3 + start_docker_with_busybox 2 swarm_manage # run container run docker_swarm run -d --name test_container busybox sleep 500 diff --git a/test/integration/api/kill.bats b/test/integration/api/kill.bats index 3d0f01d857..da6b8245f5 100644 --- a/test/integration/api/kill.bats +++ b/test/integration/api/kill.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker kill" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage # run run docker_swarm run -d --name test_container busybox sleep 1000 diff --git a/test/integration/api/load.bats b/test/integration/api/load.bats index 3942025dbb..a2d1cf6bdb 100644 --- a/test/integration/api/load.bats +++ b/test/integration/api/load.bats @@ -8,30 +8,34 @@ function teardown() { } @test "docker load" { - # temp file for saving image + # pull the image only if not available on the host and save it somewhere. + [ "$(docker_host images -q busybox)" ] || docker_host pull busybox IMAGE_FILE=$(mktemp) - - # create a tar file - docker_host pull busybox:latest docker_host save -o $IMAGE_FILE busybox:latest start_docker 2 swarm_manage + # ensure we start from a clean cluster. run docker_swarm images -q [ "$status" -eq 0 ] [ "${#lines[@]}" -eq 0 ] run docker_swarm load -i $IMAGE_FILE [ "$status" -eq 0 ] + + # and now swarm should have cought the image just loaded. + run docker_swarm images -q + [ "$status" -eq 0 ] + [ "${#lines[@]}" -ge 1 ] # check node0 - run docker -H ${HOSTS[0]} images + run docker -H ${HOSTS[0]} images [ "${#lines[@]}" -eq 2 ] [[ "${lines[1]}" == *"busybox"* ]] # check node1 - run docker -H ${HOSTS[1]} images + run docker -H ${HOSTS[1]} images [ "${#lines[@]}" -eq 2 ] [[ "${lines[1]}" == *"busybox"* ]] diff --git a/test/integration/api/logs.bats b/test/integration/api/logs.bats index 284522fcfe..c9514b0dd9 100644 --- a/test/integration/api/logs.bats +++ b/test/integration/api/logs.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker logs" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage # run a container with echo command diff --git a/test/integration/api/pause.bats b/test/integration/api/pause.bats index 769c24c66a..7e7279ee32 100644 --- a/test/integration/api/pause.bats +++ b/test/integration/api/pause.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker pause" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage run docker_swarm run -d --name test_container busybox sleep 1000 diff --git a/test/integration/api/port.bats b/test/integration/api/port.bats index 5bdaeb2cb6..7f0010bb4e 100644 --- a/test/integration/api/port.bats +++ b/test/integration/api/port.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker port" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage run docker_swarm run -d -p 8000 --name test_container busybox sleep 500 [ "$status" -eq 0 ] diff --git a/test/integration/api/ps.bats b/test/integration/api/ps.bats index d782c26812..42d72af72b 100644 --- a/test/integration/api/ps.bats +++ b/test/integration/api/ps.bats @@ -8,8 +8,9 @@ function teardown() { } @test "docker ps -n" { - start_docker 1 + start_docker_with_busybox 2 swarm_manage + run docker_swarm run -d busybox sleep 42 run docker_swarm run -d busybox false run docker_swarm ps -n 3 @@ -26,8 +27,9 @@ function teardown() { } @test "docker ps -l" { - start_docker 1 + start_docker_with_busybox 2 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 diff --git a/test/integration/api/pull.bats b/test/integration/api/pull.bats index 81d1f1e019..8c945d590c 100644 --- a/test/integration/api/pull.bats +++ b/test/integration/api/pull.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker pull" { - start_docker 3 + start_docker 2 swarm_manage # make sure no image exists @@ -19,16 +19,16 @@ function teardown() { run docker_swarm pull busybox [ "$status" -eq 0 ] - # swarm verify + # we should get 2 busyboxes, plus the header. run docker_swarm images [ "$status" -eq 0 ] - [ "${#lines[@]}" -ge 4 ] + [ "${#lines[@]}" -eq 3 ] # every line should contain "busybox" exclude the first head line for((i=1; i<${#lines[@]}; i++)); do [[ "${lines[i]}" == *"busybox"* ]] done - # node verify + # verify on the nodes for host in ${HOSTS[@]}; do run docker -H $host images [ "$status" -eq 0 ] diff --git a/test/integration/api/rename.bats b/test/integration/api/rename.bats index e9bc551bcb..2bcc5dfcaa 100644 --- a/test/integration/api/rename.bats +++ b/test/integration/api/rename.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker rename" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage run docker_swarm run -d --name test_container busybox sleep 500 diff --git a/test/integration/api/restart.bats b/test/integration/api/restart.bats index 09fe1301fd..fac2a70ca9 100644 --- a/test/integration/api/restart.bats +++ b/test/integration/api/restart.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker restart" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage # run run docker_swarm run -d --name test_container busybox sleep 1000 diff --git a/test/integration/api/rm.bats b/test/integration/api/rm.bats index 2f0a853899..a347e3bf49 100644 --- a/test/integration/api/rm.bats +++ b/test/integration/api/rm.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker rm" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage run docker_swarm run -d --name test_container busybox @@ -28,7 +28,7 @@ function teardown() { } @test "docker rm -f" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage run docker_swarm run -d --name test_container busybox sleep 500 diff --git a/test/integration/api/rmi.bats b/test/integration/api/rmi.bats index a1206a028c..351fb57a46 100644 --- a/test/integration/api/rmi.bats +++ b/test/integration/api/rmi.bats @@ -8,25 +8,31 @@ function teardown() { } @test "docker rmi" { - start_docker 3 + # Start one empty host and two with busybox to ensure swarm selects the + # right ones and rmi doesn't fail if one host doesn't have the image. + start_docker 1 + start_docker_with_busybox 2 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 + # verify the nodes: the first one shouldn't have the image while the other + # two yes. + run docker -H ${HOSTS[0]} images + [ "$status" -eq 0 ] + [[ "${output}" != *"busybox"* ]] + run docker -H ${HOSTS[1]} images + [ "$status" -eq 0 ] + [[ "${output}" == *"busybox"* ]] + run docker -H ${HOSTS[1]} images + [ "$status" -eq 0 ] + [[ "${output}" == *"busybox"* ]] + + + # wipe busybox. run docker_swarm rmi busybox [ "$status" -eq 0 ] @@ -34,7 +40,8 @@ function teardown() { run docker_swarm images -q [ "$status" -eq 0 ] [ "${#lines[@]}" -eq 0 ] - # node verify + + # verify the image was actually removed from every node. for host in ${HOSTS[@]}; do run docker -H $host images -q [ "$status" -eq 0 ] diff --git a/test/integration/api/run.bats b/test/integration/api/run.bats index c83fef3f2e..045aac0f67 100644 --- a/test/integration/api/run.bats +++ b/test/integration/api/run.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker run" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage # make sure no container exist diff --git a/test/integration/api/save.bats b/test/integration/api/save.bats index 2d6a32276e..5c2e009644 100644 --- a/test/integration/api/save.bats +++ b/test/integration/api/save.bats @@ -8,19 +8,20 @@ function teardown() { } @test "docker save" { - start_docker 3 + # Start one empty host and one with busybox to ensure swarm selects the + # right one (and not one at random). + start_docker 1 + start_docker_with_busybox 1 swarm_manage - run docker_swarm pull busybox - [ "$status" -eq 0 ] - - temp_file_name=$(mktemp) - temp_file_name_o=$(mktemp) # make sure busybox image exists run docker_swarm images [ "$status" -eq 0 ] [[ "${output}" == *"busybox"* ]] + temp_file_name=$(mktemp) + temp_file_name_o=$(mktemp) + # save >, image->tar docker_swarm save busybox > $temp_file_name # save -o, image->tar diff --git a/test/integration/api/search.bats b/test/integration/api/search.bats index dca7d714da..2a3709c731 100644 --- a/test/integration/api/search.bats +++ b/test/integration/api/search.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker search" { - start_docker 3 + start_docker 2 swarm_manage # search image (not exist), the name of images only [a-z0-9-_.] are allowed diff --git a/test/integration/api/start.bats b/test/integration/api/start.bats index 41efe09e27..16ca854788 100644 --- a/test/integration/api/start.bats +++ b/test/integration/api/start.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker start" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage # create run docker_swarm create --name test_container busybox sleep 1000 diff --git a/test/integration/api/stats.bats b/test/integration/api/stats.bats index 817de5ff28..45387bd90f 100644 --- a/test/integration/api/stats.bats +++ b/test/integration/api/stats.bats @@ -9,7 +9,7 @@ function teardown() { @test "docker stats" { TEMP_FILE=$(mktemp) - start_docker 3 + start_docker_with_busybox 2 swarm_manage # stats running container diff --git a/test/integration/api/stop.bats b/test/integration/api/stop.bats index de40512bda..f4041570d4 100644 --- a/test/integration/api/stop.bats +++ b/test/integration/api/stop.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker stop" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage # run run docker_swarm run -d --name test_container busybox sleep 500 diff --git a/test/integration/api/tag.bats b/test/integration/api/tag.bats index 3e62cd9244..a7cb68feda 100644 --- a/test/integration/api/tag.bats +++ b/test/integration/api/tag.bats @@ -8,12 +8,12 @@ function teardown() { } @test "docker tag" { - start_docker 3 + # Start one empty host and one with busybox to ensure swarm selects the + # right one (and not one at random). + start_docker 1 + start_docker_with_busybox 1 swarm_manage - run docker_swarm pull busybox - [ "$status" -eq 0 ] - # make sure the image of busybox exists # the comming image of tag_busybox not exsit run docker_swarm images diff --git a/test/integration/api/top.bats b/test/integration/api/top.bats index 919c49fd9b..b893109659 100644 --- a/test/integration/api/top.bats +++ b/test/integration/api/top.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker top" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage run docker_swarm run -d --name test_container busybox sleep 500 diff --git a/test/integration/api/unpause.bats b/test/integration/api/unpause.bats index 17e0c8f45e..870e655bd2 100644 --- a/test/integration/api/unpause.bats +++ b/test/integration/api/unpause.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker unpause" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage run docker_swarm run -d --name test_container busybox sleep 1000 diff --git a/test/integration/api/version.bats b/test/integration/api/version.bats index af76171d0a..8add89f9dd 100644 --- a/test/integration/api/version.bats +++ b/test/integration/api/version.bats @@ -8,7 +8,8 @@ function teardown() { } @test "docker version" { - start_docker 3 + # FIXME: No reason here to start docker. + start_docker 1 swarm_manage # version diff --git a/test/integration/api/wait.bats b/test/integration/api/wait.bats index 6f7a79f0cf..021bcbe0fa 100644 --- a/test/integration/api/wait.bats +++ b/test/integration/api/wait.bats @@ -8,7 +8,7 @@ function teardown() { } @test "docker wait" { - start_docker 3 + start_docker_with_busybox 2 swarm_manage # run after 1 seconds, test_container will exit diff --git a/test/integration/constraints.bats b/test/integration/constraints.bats index 28b70b5d2a..e7aa15c73b 100644 --- a/test/integration/constraints.bats +++ b/test/integration/constraints.bats @@ -8,7 +8,7 @@ function teardown() { } @test "node constraint" { - start_docker 2 + start_docker_with_busybox 2 swarm_manage run docker_swarm run --name c1 -e constraint:node==node-0 -d busybox:latest sh @@ -38,8 +38,8 @@ function teardown() { } @test "label constraints" { - start_docker 1 --label foo=a - start_docker 1 --label foo=b + start_docker_with_busybox 1 --label foo=a + start_docker_with_busybox 1 --label foo=b swarm_manage run docker_swarm run --name c1 -e constraint:foo==a -d busybox:latest sh diff --git a/test/integration/dependency.bats b/test/integration/dependency.bats index 6ae8763282..7138a06081 100644 --- a/test/integration/dependency.bats +++ b/test/integration/dependency.bats @@ -8,11 +8,11 @@ function teardown() { } @test "shared volumes dependency" { - start_docker 2 + start_docker_with_busybox 2 swarm_manage # Running the second container with shared volumes. - run docker_swarm run --name b1 -e constraint:node==node-0 -d busybox:latest sleep 500 + run docker_swarm run --name b1 -e constraint:node==node-1 -d busybox:latest sleep 500 [ "$status" -eq 0 ] run docker_swarm run --name b2 --volumes-from=/b1 -d busybox:latest sh [ "$status" -eq 0 ] @@ -25,15 +25,15 @@ function teardown() { # check if both containers are started on the same node run docker_swarm inspect b1 [ "$status" -eq 0 ] - [[ "${output}" == *'"Name": "node-0"'* ]] + [[ "${output}" == *'"Name": "node-1"'* ]] run docker_swarm inspect b2 [ "$status" -eq 0 ] - [[ "${output}" == *'"Name": "node-0"'* ]] + [[ "${output}" == *'"Name": "node-1"'* ]] } @test "links dependency" { - start_docker 2 + start_docker_with_busybox 2 swarm_manage # Running the second container with link dependency. @@ -58,11 +58,11 @@ function teardown() { } @test "shared network stack dependency" { - start_docker 2 + start_docker_with_busybox 2 swarm_manage # Running the second container with network stack dependency. - run docker_swarm run --name b1 -e constraint:node==node-0 -d busybox:latest sleep 500 + run docker_swarm run --name b1 -e constraint:node==node-1 -d busybox:latest sleep 500 [ "$status" -eq 0 ] run docker_swarm run --name b2 --net=container:/b1 -d busybox:latest sh [ "$status" -eq 0 ] @@ -75,9 +75,9 @@ function teardown() { # check if both containers are started on the same node run docker_swarm inspect b1 [ "$status" -eq 0 ] - [[ "${output}" == *'"Name": "node-0"'* ]] + [[ "${output}" == *'"Name": "node-1"'* ]] run docker_swarm inspect b2 [ "$status" -eq 0 ] - [[ "${output}" == *'"Name": "node-0"'* ]] + [[ "${output}" == *'"Name": "node-1"'* ]] } diff --git a/test/integration/port-filter.bats b/test/integration/port-filter.bats index 3aec73b7c8..1457fb7215 100644 --- a/test/integration/port-filter.bats +++ b/test/integration/port-filter.bats @@ -8,28 +8,22 @@ function teardown() { } @test "docker should filter port in host mode correctly" { - start_docker 2 + start_docker_with_busybox 2 swarm_manage - # # Use busybox to save image pulling time for integration test. # Running the first 2 containers, it should be fine. - # run docker_swarm run -d --expose=80 --net=host busybox sh [ "$status" -eq 0 ] run docker_swarm run -d --expose=80 --net=host busybox sh [ "$status" -eq 0 ] - # # When trying to start the 3rd one, it should be error finding port 80. - # run docker_swarm run -d --expose=80 --net=host busybox sh [ "$status" -ne 0 ] [[ "${lines[0]}" == *"unable to find a node with port 80/tcp available in the Host mode"* ]] - # # And the number of running containers should be still 2. - # run docker_swarm ps -n 2 [ "${#lines[@]}" -eq 3 ] } diff --git a/test/stress/stress.bats b/test/stress/stress.bats index 18c4f79ad0..40ff9665e5 100644 --- a/test/stress/stress.bats +++ b/test/stress/stress.bats @@ -48,7 +48,7 @@ function wait_containers_exit { @test "spawning $CONTAINERS containers on $NODES nodes" { # Start N engines. - start_docker $NODES + start_docker_with_busybox $NODES # Start the manager and wait until all nodes join the cluster. swarm_manage