mirror of https://github.com/docker/docs.git
Adding zk tests for swarm-mesos integration
Signed-off-by: Isabel Jimenez <contact@isabeljimenez.com>
This commit is contained in:
parent
c86de629a8
commit
a250ded715
|
@ -27,6 +27,24 @@ function start_mesos() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function start_mesos_zk() {
|
||||||
|
local current=${#DOCKER_CONTAINERS[@]}
|
||||||
|
MESOS_MASTER=$(
|
||||||
|
docker_host run -d --name mesos-master --net=host \
|
||||||
|
$MESOS_IMAGE mesos-master --ip=127.0.0.1 --work_dir=/var/lib/mesos --registry=in_memory --quorum=2 --zk=$1 --port=$MESOS_MASTER_PORT
|
||||||
|
)
|
||||||
|
|
||||||
|
retry 10 1 eval "docker_host ps | grep 'mesos-master'"
|
||||||
|
for ((i=0; i < current; i++)); do
|
||||||
|
local docker_port=$(echo ${HOSTS[$i]} | cut -d: -f2)
|
||||||
|
MESOS_SLAVES[$i]=$(
|
||||||
|
docker_host run --privileged -d --name mesos-slave-$i --volumes-from node-$i -e DOCKER_HOST="${HOSTS[$i]}" -v /sys/fs/cgroup:/sys/fs/cgroup --net=host \
|
||||||
|
$MESOS_IMAGE mesos-slave --master=127.0.0.1:$MESOS_MASTER_PORT --containerizers=docker --attributes="docker_port:$docker_port" --hostname=127.0.0.1 --port=$(($MESOS_MASTER_PORT + (1 + $i))) --docker=/usr/local/bin/docker --executor_environment_variables="{\"DOCKER_HOST\":\"${HOSTS[$i]}\"}"
|
||||||
|
)
|
||||||
|
retry 10 1 eval "docker_host ps | grep 'mesos-slave-$i'"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Stop mesos master and slave.
|
# Stop mesos master and slave.
|
||||||
function stop_mesos() {
|
function stop_mesos() {
|
||||||
echo "Stopping $MESOS_MASTER"
|
echo "Stopping $MESOS_MASTER"
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load ../mesos_helpers
|
||||||
|
|
||||||
|
# Address on which the store will listen (random port between 8000 and 9000).
|
||||||
|
STORE_HOST=127.0.0.1:$(( ( RANDOM % 1000 ) + 7000 ))
|
||||||
|
|
||||||
|
# Discovery parameter for Swarm
|
||||||
|
DISCOVERY="zk://${STORE_HOST}/test"
|
||||||
|
|
||||||
|
# Container name for integration test
|
||||||
|
CONTAINER_NAME=swarm_integration_zk
|
||||||
|
|
||||||
|
function start_store() {
|
||||||
|
docker_host run --name $CONTAINER_NAME -p $STORE_HOST:2181 -d dnephin/docker-zookeeper:3.4.6
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop_store() {
|
||||||
|
docker_host rm -f -v $CONTAINER_NAME
|
||||||
|
}
|
||||||
|
|
||||||
|
function teardown() {
|
||||||
|
swarm_manage_cleanup
|
||||||
|
stop_mesos
|
||||||
|
stop_docker
|
||||||
|
stop_store
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "mesos - zookeeper" {
|
||||||
|
start_store
|
||||||
|
start_docker 2
|
||||||
|
start_mesos_zk $DISCOVERY
|
||||||
|
|
||||||
|
swarm_manage --cluster-driver mesos-experimental $DISCOVERY
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
run docker_swarm info
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[[ "${output}" == *'Offers: 2'* ]]
|
||||||
|
}
|
|
@ -12,7 +12,7 @@ function execute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tests to run. Defaults to all.
|
# Tests to run. Defaults to all.
|
||||||
TESTS=${@:-. compose discovery api mesos/api mesos/compose}
|
TESTS=${@:-. compose discovery api mesos/api mesos/compose mesos/zk}
|
||||||
|
|
||||||
# Generate a temporary binary for the tests.
|
# Generate a temporary binary for the tests.
|
||||||
export SWARM_BINARY=`mktemp`
|
export SWARM_BINARY=`mktemp`
|
||||||
|
|
Loading…
Reference in New Issue