mirror of https://github.com/docker/docs.git
integration: Improved discovery testing.
Verify that swarm can see new nodes joining discovery. Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
9124f3a0c7
commit
3501e45f4f
|
@ -5,27 +5,30 @@ load helpers
|
|||
# create a blank temp file for discovery
|
||||
DISCOVERY_FILE=$(mktemp)
|
||||
|
||||
function setup() {
|
||||
start_docker 2
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
swarm_manage_cleanup
|
||||
stop_docker
|
||||
rm -f $DISCOVERY_FILE
|
||||
rm -f "$DISCOVERY_FILE"
|
||||
}
|
||||
|
||||
function setup_file_discovery() {
|
||||
rm -f "$DISCOVERY_FILE"
|
||||
for host in ${HOSTS[@]}; do
|
||||
echo "$host" >> $DISCOVERY_FILE
|
||||
done
|
||||
}
|
||||
|
||||
@test "file discovery" {
|
||||
# Start 2 engines, register them in a file, then start swarm and make sure
|
||||
# it sees them.
|
||||
start_docker 2
|
||||
setup_file_discovery
|
||||
swarm_manage file://$DISCOVERY_FILE
|
||||
swarm_manage "file://$DISCOVERY_FILE"
|
||||
all_nodes_registered_in_swarm
|
||||
|
||||
run docker_swarm info
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"Nodes: 2"* ]]
|
||||
# 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
|
||||
}
|
||||
|
|
|
@ -2,32 +2,38 @@
|
|||
|
||||
load helpers
|
||||
|
||||
function token_cleanup() {
|
||||
curl -X DELETE https://discovery-stage.hub.docker.com/v1/clusters/$1
|
||||
}
|
||||
TOKEN=""
|
||||
|
||||
function setup() {
|
||||
start_docker 2
|
||||
function token_cleanup() {
|
||||
[ -z "$TOKEN" ] && return
|
||||
echo "Removing $TOKEN"
|
||||
curl -X DELETE "https://discovery-stage.hub.docker.com/v1/clusters/$TOKEN"
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
swarm_join_cleanup
|
||||
swarm_manage_cleanup
|
||||
swarm_join_cleanup
|
||||
stop_docker
|
||||
token_cleanup
|
||||
}
|
||||
|
||||
@test "token discovery" {
|
||||
# Create a cluster and validate the token.
|
||||
run swarm create
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" =~ ^[0-9a-f]{32}$ ]]
|
||||
TOKEN="$output"
|
||||
|
||||
swarm_manage "token://$TOKEN"
|
||||
# Start 2 engines and make them join the cluster.
|
||||
start_docker 2
|
||||
swarm_join "token://$TOKEN"
|
||||
|
||||
run docker_swarm info
|
||||
echo $output
|
||||
[[ "$output" == *"Nodes: 2"* ]]
|
||||
# Start a manager and ensure it sees all the engines.
|
||||
swarm_manage "token://$TOKEN"
|
||||
all_nodes_registered_in_swarm
|
||||
|
||||
token_cleanup "$TOKEN"
|
||||
# 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
|
||||
}
|
||||
|
|
|
@ -9,31 +9,37 @@ ZK_HOST=127.0.0.1:$(( ( RANDOM % 1000 ) + 7000 ))
|
|||
ZK_CONTAINER_NAME=swarm_integration_zk
|
||||
|
||||
function start_zk() {
|
||||
run docker run --name $ZK_CONTAINER_NAME -p $ZK_HOST:2181 -d jplock/zookeeper
|
||||
run docker_host run --name $ZK_CONTAINER_NAME -p $ZK_HOST:2181 -d jplock/zookeeper
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
function stop_zk() {
|
||||
run docker rm -f -v $ZK_CONTAINER_NAME
|
||||
run docker_host rm -f -v $ZK_CONTAINER_NAME
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
function setup() {
|
||||
start_zk
|
||||
start_docker 2
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
swarm_join_cleanup
|
||||
swarm_manage_cleanup
|
||||
swarm_join_cleanup
|
||||
stop_docker
|
||||
stop_zk
|
||||
}
|
||||
|
||||
@test "zookeeperk discovery" {
|
||||
swarm_manage zk://${ZK_HOST}/test
|
||||
swarm_join zk://${ZK_HOST}/test
|
||||
@test "zookeeper discovery" {
|
||||
# Start 2 engines and make them join the cluster.
|
||||
start_docker 2
|
||||
swarm_join "zk://${ZK_HOST}/test"
|
||||
|
||||
run docker_swarm info
|
||||
[[ "$output" == *"Nodes: 2"* ]]
|
||||
# Start a manager and ensure it sees all the engines.
|
||||
swarm_manage "zk://${ZK_HOST}/test"
|
||||
all_nodes_registered_in_swarm
|
||||
|
||||
# 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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue