mirror of https://github.com/docker/docs.git
integration: helpers cleanup.
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
3501e45f4f
commit
a2703e0562
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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[@]}
|
||||
|
||||
|
|
Loading…
Reference in New Issue