integration: cleanup discovery tests

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2015-05-05 14:05:19 -07:00
parent 92abcac33c
commit bca0e2e8c2
4 changed files with 27 additions and 17 deletions

View File

@ -5,10 +5,14 @@ load helpers
# create a blank temp file for discovery
DISCOVERY_FILE=$(mktemp)
function setup() {
start_docker 2
}
function teardown() {
swarm_manage_cleanup
rm -f $DISCOVERY_FILE
stop_docker
rm -f $DISCOVERY_FILE
}
function setup_file_discovery() {
@ -18,7 +22,6 @@ function setup_file_discovery() {
}
@test "file discovery" {
start_docker 2
setup_file_discovery
swarm_manage file://$DISCOVERY_FILE

View File

@ -6,6 +6,10 @@ function token_cleanup() {
curl -X DELETE https://discovery-stage.hub.docker.com/v1/clusters/$1
}
function setup() {
start_docker 2
}
function teardown() {
swarm_join_cleanup
swarm_manage_cleanup
@ -13,18 +17,17 @@ function teardown() {
}
@test "token discovery" {
start_docker 2
TOKEN=$(swarm create)
run swarm create
[ "$status" -eq 0 ]
[[ ${TOKEN} =~ ^[0-9a-f]{32}$ ]]
[[ "$output" =~ ^[0-9a-f]{32}$ ]]
TOKEN="$output"
swarm_manage token://$TOKEN
swarm_join token://$TOKEN
swarm_manage "token://$TOKEN"
swarm_join "token://$TOKEN"
run docker_swarm info
echo $output
[[ "$output" == *"Nodes: 2"* ]]
token_cleanup $TOKEN
token_cleanup "$TOKEN"
}

View File

@ -9,11 +9,18 @@ ZK_HOST=127.0.0.1:$(( ( RANDOM % 1000 ) + 7000 ))
ZK_CONTAINER_NAME=swarm_integration_zk
function start_zk() {
docker_host run --name $ZK_CONTAINER_NAME -p $ZK_HOST:2181 -d jplock/zookeeper
run docker run --name $ZK_CONTAINER_NAME -p $ZK_HOST:2181 -d jplock/zookeeper
[ "$status" -eq 0 ]
}
function stop_zk() {
docker_host rm -f -v $ZK_CONTAINER_NAME > /dev/null
run docker rm -f -v $ZK_CONTAINER_NAME
[ "$status" -eq 0 ]
}
function setup() {
start_zk
start_docker 2
}
function teardown() {
@ -23,13 +30,10 @@ function teardown() {
stop_zk
}
@test "zk discovery" {
start_zk
start_docker 1
@test "zookeeperk discovery" {
swarm_manage zk://${ZK_HOST}/test
swarm_join zk://${ZK_HOST}/test
run docker_swarm info
[[ "$output" == *"Nodes: 1"* ]]
[[ "$output" == *"Nodes: 2"* ]]
}

View File

@ -105,7 +105,7 @@ function swarm_join() {
# Stops the manager.
function swarm_manage_cleanup() {
kill $SWARM_PID
kill $SWARM_PID || true
}
# Clean up Swarm join processes