mirror of https://github.com/docker/docs.git
Etcd Integration test
Signed-off-by: Sriram Natarajan <natarajan.sriram@gmail.com>
This commit is contained in:
parent
be62f36215
commit
e9f773f10f
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
# Address on which Etcd will listen (random port between 9000 and 10,000).
|
||||
ETCD_HOST=127.0.0.1:$(( ( RANDOM % 1000 ) + 9000 ))
|
||||
|
||||
# Container name for integration test
|
||||
CONTAINER_NAME=swarm_etcd
|
||||
|
||||
function check_leader() {
|
||||
# Confirm Cluster leader election
|
||||
docker_host logs $CONTAINER_NAME | grep "state changed from 'follower' to 'leader'"
|
||||
# Check leader event
|
||||
docker_host logs $CONTAINER_NAME | grep "leader changed from '' to"
|
||||
}
|
||||
|
||||
function start_etcd() {
|
||||
docker_host run -p $ETCD_HOST:4001 --name=$CONTAINER_NAME -d coreos/etcd
|
||||
# Check if etcd cluster leader is elected
|
||||
retry 30 1 check_leader
|
||||
}
|
||||
|
||||
function stop_etcd() {
|
||||
docker_host rm -f -v $CONTAINER_NAME
|
||||
}
|
||||
|
||||
function setup() {
|
||||
start_etcd
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
swarm_manage_cleanup
|
||||
swarm_join_cleanup
|
||||
stop_docker
|
||||
stop_etcd
|
||||
}
|
||||
|
||||
@test "etcd discovery" {
|
||||
# Start 2 engines and make them join the cluster.
|
||||
start_docker 2
|
||||
swarm_join "etcd://${ETCD_HOST}/test"
|
||||
|
||||
# Start a manager and ensure it sees all the engines.
|
||||
swarm_manage "etcd://${ETCD_HOST}/test"
|
||||
check_swarm_nodes
|
||||
|
||||
# Add another engine to the cluster and make sure it's picked up by swarm.
|
||||
start_docker 1
|
||||
swarm_join "etcd://${ETCD_HOST}/test"
|
||||
retry 30 1 check_swarm_nodes
|
||||
}
|
Loading…
Reference in New Issue