From 0b6d390d66a9840ebc81e28181ec58d736cb14ba Mon Sep 17 00:00:00 2001 From: Dong Chen Date: Tue, 26 Jan 2016 18:46:08 -0800 Subject: [PATCH] swarm_manage should confirm nodes pass validation. Signed-off-by: Dong Chen --- test/integration/helpers.bash | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/integration/helpers.bash b/test/integration/helpers.bash index 82d0acdf13..9d7767297f 100644 --- a/test/integration/helpers.bash +++ b/test/integration/helpers.bash @@ -85,7 +85,7 @@ function wait_until_reachable() { retry 15 1 docker -H $1 info } -# Returns true if all nodes have joined the swarm. +# Returns true if all nodes have been added to swarm. Note some may be in pending state. function discovery_check_swarm_info() { local total="$1" [ -z "$total" ] && total="${#HOSTS[@]}" @@ -95,6 +95,12 @@ function discovery_check_swarm_info() { retry 10 1 eval "docker -H $host info | grep -q -e \"Nodes: $total\" -e \"Offers: $total\"" } +# Return true if all nodes has been validated +function nodes_validated() { + # Nodes are not in Pending state + [[ $(docker_swarm info | grep -c "Status: Pending") -eq 0 ]] +} + function swarm_manage() { local i=${#SWARM_MANAGE_PID[@]} @@ -102,6 +108,9 @@ function swarm_manage() { # Wait for nodes to be discovered discovery_check_swarm_info "${#HOSTS[@]}" "${SWARM_HOSTS[$i]}" + + # All nodes passes pending state + retry 5 1 nodes_validated } # Start the swarm manager in background.