mirror of https://github.com/docker/docs.git
integration helpers: Allow to run multiple managers.
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
c82a953422
commit
22dcdc245d
|
@ -17,8 +17,8 @@ DOCKER_IMAGE=${DOCKER_IMAGE:-dockerswarm/dind-master}
|
||||||
DOCKER_VERSION=${DOCKER_VERSION:-latest}
|
DOCKER_VERSION=${DOCKER_VERSION:-latest}
|
||||||
DOCKER_BINARY=${DOCKER_BINARY:-`command -v docker`}
|
DOCKER_BINARY=${DOCKER_BINARY:-`command -v docker`}
|
||||||
|
|
||||||
# Host on which the manager will listen to (random port between 6000 and 7000).
|
# Port on which the manager will listen to (random port between 6000 and 7000).
|
||||||
SWARM_HOST=127.0.0.1:$(( ( RANDOM % 1000 ) + 6000 ))
|
SWARM_BASE_PORT=$(( ( RANDOM % 1000 ) + 6000 ))
|
||||||
|
|
||||||
# Use a random base port (for engines) between 5000 and 6000.
|
# Use a random base port (for engines) between 5000 and 6000.
|
||||||
BASE_PORT=$(( ( RANDOM % 1000 ) + 5000 ))
|
BASE_PORT=$(( ( RANDOM % 1000 ) + 5000 ))
|
||||||
|
@ -50,7 +50,7 @@ function docker_host() {
|
||||||
|
|
||||||
# Run the docker CLI against swarm.
|
# Run the docker CLI against swarm.
|
||||||
function docker_swarm() {
|
function docker_swarm() {
|
||||||
docker -H $SWARM_HOST "$@"
|
docker -H ${SWARM_HOSTS[0]} "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run the swarm binary. You must NOT fork this command (swarm foo &) as the PID
|
# Run the swarm binary. You must NOT fork this command (swarm foo &) as the PID
|
||||||
|
@ -94,9 +94,15 @@ function swarm_manage() {
|
||||||
discovery="$@"
|
discovery="$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
"$SWARM_BINARY" -l debug manage -H "$SWARM_HOST" --heartbeat=1s "$discovery" &
|
local i=${#SWARM_MANAGE_PID[@]}
|
||||||
SWARM_PID=$!
|
local port=$(($SWARM_BASE_PORT + $i))
|
||||||
wait_until_reachable "$SWARM_HOST"
|
local host=127.0.0.1:$port
|
||||||
|
|
||||||
|
echo "$SWARM_BINARY" -l debug manage -H "$host" --heartbeat=1s $discovery
|
||||||
|
"$SWARM_BINARY" -l debug manage -H "$host" --heartbeat=1s $discovery &
|
||||||
|
SWARM_MANAGE_PID[$i]=$!
|
||||||
|
SWARM_HOSTS[$i]=$host
|
||||||
|
wait_until_reachable "$host"
|
||||||
}
|
}
|
||||||
|
|
||||||
# swarm join every engine created with `start_docker`.
|
# swarm join every engine created with `start_docker`.
|
||||||
|
@ -124,7 +130,9 @@ function swarm_join() {
|
||||||
|
|
||||||
# Stops the manager.
|
# Stops the manager.
|
||||||
function swarm_manage_cleanup() {
|
function swarm_manage_cleanup() {
|
||||||
kill $SWARM_PID || true
|
for pid in ${SWARM_MANAGE_PID[@]}; do
|
||||||
|
kill $pid || true
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Clean up Swarm join processes
|
# Clean up Swarm join processes
|
||||||
|
|
Loading…
Reference in New Issue