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 # create a blank temp file for discovery
DISCOVERY_FILE=$(mktemp) DISCOVERY_FILE=$(mktemp)
function setup() {
start_docker 2
}
function teardown() { function teardown() {
swarm_manage_cleanup swarm_manage_cleanup
rm -f $DISCOVERY_FILE
stop_docker stop_docker
rm -f $DISCOVERY_FILE
} }
function setup_file_discovery() { function setup_file_discovery() {
@ -18,7 +22,6 @@ function setup_file_discovery() {
} }
@test "file discovery" { @test "file discovery" {
start_docker 2
setup_file_discovery setup_file_discovery
swarm_manage file://$DISCOVERY_FILE 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 curl -X DELETE https://discovery-stage.hub.docker.com/v1/clusters/$1
} }
function setup() {
start_docker 2
}
function teardown() { function teardown() {
swarm_join_cleanup swarm_join_cleanup
swarm_manage_cleanup swarm_manage_cleanup
@ -13,18 +17,17 @@ function teardown() {
} }
@test "token discovery" { @test "token discovery" {
start_docker 2 run swarm create
TOKEN=$(swarm create)
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[[ ${TOKEN} =~ ^[0-9a-f]{32}$ ]] [[ "$output" =~ ^[0-9a-f]{32}$ ]]
TOKEN="$output"
swarm_manage token://$TOKEN swarm_manage "token://$TOKEN"
swarm_join token://$TOKEN swarm_join "token://$TOKEN"
run docker_swarm info run docker_swarm info
echo $output echo $output
[[ "$output" == *"Nodes: 2"* ]] [[ "$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 ZK_CONTAINER_NAME=swarm_integration_zk
function start_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() { 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() { function teardown() {
@ -23,13 +30,10 @@ function teardown() {
stop_zk stop_zk
} }
@test "zk discovery" { @test "zookeeperk discovery" {
start_zk
start_docker 1
swarm_manage zk://${ZK_HOST}/test swarm_manage zk://${ZK_HOST}/test
swarm_join zk://${ZK_HOST}/test swarm_join zk://${ZK_HOST}/test
run docker_swarm info run docker_swarm info
[[ "$output" == *"Nodes: 1"* ]] [[ "$output" == *"Nodes: 2"* ]]
} }

View File

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