From a2703e05621c72da805e2c01d18aae2ce06cff18 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Tue, 5 May 2015 19:19:10 -0700 Subject: [PATCH] integration: helpers cleanup. Signed-off-by: Andrea Luzzardi --- test/integration/discovery-file.bats | 4 ++-- test/integration/discovery-token.bats | 8 ++++---- test/integration/discovery-zk.bats | 8 ++++---- test/integration/helpers.bash | 9 +++++---- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/test/integration/discovery-file.bats b/test/integration/discovery-file.bats index 0f8cd3521c..98b91557c9 100644 --- a/test/integration/discovery-file.bats +++ b/test/integration/discovery-file.bats @@ -24,11 +24,11 @@ function setup_file_discovery() { start_docker 2 setup_file_discovery swarm_manage "file://$DISCOVERY_FILE" - all_nodes_registered_in_swarm + check_swarm_nodes # Add another engine to the cluster, update the discovery file and make # sure it's picked up by swarm. start_docker 1 setup_file_discovery - retry 10 1 all_nodes_registered_in_swarm + retry 10 1 check_swarm_nodes } diff --git a/test/integration/discovery-token.bats b/test/integration/discovery-token.bats index f8802b7eaa..877954fbf9 100644 --- a/test/integration/discovery-token.bats +++ b/test/integration/discovery-token.bats @@ -26,14 +26,14 @@ function teardown() { # Start 2 engines and make them join the cluster. start_docker 2 - swarm_join "token://$TOKEN" + swarm_join "token://$TOKEN" # Start a manager and ensure it sees all the engines. swarm_manage "token://$TOKEN" - all_nodes_registered_in_swarm + check_swarm_nodes # Add another engine to the cluster and make sure it's picked up by swarm. start_docker 1 - swarm_join "token://$TOKEN" - retry 10 1 all_nodes_registered_in_swarm + swarm_join "token://$TOKEN" + retry 10 1 check_swarm_nodes } diff --git a/test/integration/discovery-zk.bats b/test/integration/discovery-zk.bats index 7118170e52..638e929fc8 100644 --- a/test/integration/discovery-zk.bats +++ b/test/integration/discovery-zk.bats @@ -32,14 +32,14 @@ function teardown() { @test "zookeeper discovery" { # Start 2 engines and make them join the cluster. start_docker 2 - swarm_join "zk://${ZK_HOST}/test" + swarm_join "zk://${ZK_HOST}/test" # Start a manager and ensure it sees all the engines. swarm_manage "zk://${ZK_HOST}/test" - all_nodes_registered_in_swarm + check_swarm_nodes # Add another engine to the cluster and make sure it's picked up by swarm. start_docker 1 - swarm_join "zk://${ZK_HOST}/test" - retry 30 1 all_nodes_registered_in_swarm + swarm_join "zk://${ZK_HOST}/test" + retry 30 1 check_swarm_nodes } diff --git a/test/integration/helpers.bash b/test/integration/helpers.bash index 329687f207..10e74753d8 100644 --- a/test/integration/helpers.bash +++ b/test/integration/helpers.bash @@ -77,7 +77,8 @@ function wait_until_reachable() { retry 10 1 docker -H $1 info } -function all_nodes_registered_in_swarm() { +# Returns true if all nodes have joined the swarm. +function check_swarm_nodes() { docker_swarm info | grep -q "Nodes: ${#HOSTS[@]}" } @@ -93,7 +94,7 @@ function swarm_manage() { "$SWARM_BINARY" manage -H "$SWARM_HOST" --heartbeat=1 "$discovery" & SWARM_PID=$! wait_until_reachable "$SWARM_HOST" - retry 10 1 all_nodes_registered_in_swarm + retry 10 1 check_swarm_nodes } # swarm join every engine created with `start_docker`. @@ -118,11 +119,11 @@ function swarm_join() { "$SWARM_BINARY" join --addr="$h" "$addr" & SWARM_JOIN_PID[$i]=$! done - retry 10 0.5 all_nodes_registered_in_discovery "$addr" + retry 10 0.5 check_discovery_nodes "$addr" } # Returns true if all nodes have joined the discovery. -function all_nodes_registered_in_discovery() { +function check_discovery_nodes() { local joined=`swarm list "$1" | wc -l` local total=${#HOSTS[@]}