From cf2d7b12b117d336ad3d2840b89e3050509c5d00 Mon Sep 17 00:00:00 2001 From: Dong Chen Date: Wed, 10 Feb 2016 14:02:46 -0800 Subject: [PATCH] Test reschedule back and forth. Signed-off-by: Dong Chen --- test/integration/helpers.bash | 1 + test/integration/rescheduling.bats | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/test/integration/helpers.bash b/test/integration/helpers.bash index f3a8c5d00f..a6bfcdf6f3 100644 --- a/test/integration/helpers.bash +++ b/test/integration/helpers.bash @@ -206,6 +206,7 @@ function start_docker() { docker_host run -d --name node-$i --privileged -v /usr/local/bin -v /var/run -it --net=host \ ${DOCKER_IMAGE}:${DOCKER_VERSION} \ bash -c "\ + rm /var/run/docker.pid ; \ hostname node-$i && \ docker daemon -H 127.0.0.1:$port \ -H=unix:///var/run/docker.sock \ diff --git a/test/integration/rescheduling.bats b/test/integration/rescheduling.bats index ce3f9eedd2..0bc5bb7c12 100644 --- a/test/integration/rescheduling.bats +++ b/test/integration/rescheduling.bats @@ -188,8 +188,27 @@ function teardown() { # Restart node-0 docker_host start ${DOCKER_CONTAINERS[0]} + sleep 6 + [[ $(docker_swarm info | grep -c "Status: Unhealthy") -eq 0 ]] - sleep 5 - run docker_swarm ps - [ "${#lines[@]}" -eq 3 ] + # Stop node-1 + docker_host stop ${DOCKER_CONTAINERS[1]} + + # Wait for Swarm to detect the node failure. + retry 5 1 eval "docker_swarm info | grep -q 'Unhealthy'" + + # Wait for the container to be rescheduled + retry 5 1 eval docker_swarm inspect c1 + + # c1 should have been rescheduled from node-1 to node-0 + run docker_swarm inspect c1 + [ "$status" -eq 0 ] + [[ "${output}" == *'"Name": "node-0"'* ]] + [[ "${output}" == *'"Status": "running"'* ]] + + # c2 should have been rescheduled from node-1 to node-0 + run docker_swarm inspect c2 + [ "$status" -eq 0 ] + [[ "${output}" == *'"Name": "node-0"'* ]] + [[ "${output}" == *'"Status": "running"'* ]] }