From 6dc613416365a4fbf8957afcb6dd90a55951e9b5 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Tue, 2 Jun 2015 18:56:22 -0700 Subject: [PATCH] add mesos in the CI Signed-off-by: Victor Vieux --- test/integration/helpers.bash | 3 +- test/integration/mesos/api.bats | 20 +++++++++++++ test/integration/mesos/mesos_helpers.bash | 35 +++++++++++++++++++++-- test/integration/run.sh | 1 + test/integration/test_runner.sh | 2 +- 5 files changed, 56 insertions(+), 5 deletions(-) diff --git a/test/integration/helpers.bash b/test/integration/helpers.bash index 4c6085dfbd..787e6b876d 100644 --- a/test/integration/helpers.bash +++ b/test/integration/helpers.bash @@ -165,7 +165,8 @@ function start_docker() { # We have to manually call `hostname` since --hostname and --net cannot # be used together. DOCKER_CONTAINERS[$i]=$( - docker_host run -d --name node-$i --privileged -it --net=host \ + # -v /usr/local/bin -v /var/run/docker.sock are specific to mesos, so the slave can do a --volumes-from and use the docker cli + docker_host run -d --name node-$i --privileged -v /usr/local/bin -v /var/run/docker.sock -it --net=host \ ${DOCKER_IMAGE}:${DOCKER_VERSION} \ bash -c "\ hostname node-$i && \ diff --git a/test/integration/mesos/api.bats b/test/integration/mesos/api.bats index 0f7fd9f766..c2326ad338 100644 --- a/test/integration/mesos/api.bats +++ b/test/integration/mesos/api.bats @@ -4,13 +4,33 @@ load mesos_helpers function teardown() { swarm_manage_cleanup + stop_mesos + stop_docker } @test "docker info" { + start_docker 1 + start_mesos swarm_manage_mesos run docker_swarm info [ "$status" -eq 0 ] [[ "${output}" == *'Offers'* ]] } +@test "docker run no resources" { + start_docker 1 + start_mesos + swarm_manage_mesos + run docker_swarm run -d busybox ls + [ "$status" -ne 0 ] + [[ "${output}" == *'Task uses no resources'* ]] +} + +@test "docker run" { + start_docker_with_busybox 1 + start_mesos + swarm_manage_mesos + docker_swarm run -d -m 20m busybox ls +} + diff --git a/test/integration/mesos/mesos_helpers.bash b/test/integration/mesos/mesos_helpers.bash index 129e9cc996..7575d62d73 100644 --- a/test/integration/mesos/mesos_helpers.bash +++ b/test/integration/mesos/mesos_helpers.bash @@ -2,11 +2,40 @@ load ../helpers -MESOS_CLUSTER_ENTRYPOINT=${MESOS_CLUSTER_ENTRYPOINT:-0.0.0.0:5050} +MESOS_IMAGE=jimenez/mesos-dev:clang +MESOS_MASTER_PORT=$(( ( RANDOM % 1000 ) + 10000 )) +BASE_PORT=2375 + +# Start mesos master and slave. +function start_mesos() { + MESOS_MASTER=$( + docker_host run -d --name mesos-master --net=host \ + $MESOS_IMAGE /mesos/build/bin/mesos-master.sh --ip=127.0.0.1 --work_dir=/ --registry=in_memory --port=$MESOS_MASTER_PORT + ) + + retry 10 1 eval "docker_host ps | grep 'mesos-master'" + + MESOS_SLAVE=$( + docker_host run --privileged -d --name mesos-slave --volumes-from node-0 -e DOCKER_HOST="${HOSTS[0]}" -v /sys/fs/cgroup:/sys/fs/cgroup --net=host \ + $MESOS_IMAGE /mesos/build/bin/mesos-slave.sh --master=127.0.0.1:$MESOS_MASTER_PORT --containerizers=docker --hostname=127.0.0.1 --port=$(($MESOS_MASTER_PORT + 1)) + ) + + retry 10 1 eval "docker_host ps | grep 'mesos-slave'" +} # Start the swarm manager in background. function swarm_manage_mesos() { - "$SWARM_BINARY" -l debug manage -H "$SWARM_HOST" --cluster-driver mesos $MESOS_CLUSTER_ENTRYPOINT & + "$SWARM_BINARY" -l debug manage -H "$SWARM_HOST" --cluster-driver mesos-experimental --cluster-opt mesos.user=daemon 127.0.0.1:$MESOS_MASTER_PORT & SWARM_PID=$! - wait_until_reachable "$SWARM_HOST" + retry 10 1 eval "docker_swarm info | grep 'Offers: 1'" +} + +# Stop mesos master and slave. +function stop_mesos() { + echo "Stopping $DOCKER_CONTAINER" + docker_host rm -f -v $DOCKER_CONTAINER > /dev/null; + echo "Stopping $MESOS_MASTER" + docker_host rm -f -v $MESOS_MASTER > /dev/null; + echo "Stopping $MESOS_SLAVE" + docker_host rm -f -v $MESOS_SLAVE > /dev/null; } diff --git a/test/integration/run.sh b/test/integration/run.sh index 8216e8f9c5..a36db26620 100755 --- a/test/integration/run.sh +++ b/test/integration/run.sh @@ -14,6 +14,7 @@ INTEGRATION_IMAGE=${INTEGRATION_IMAGE:-dockerswarm/swarm-test-env} # Start the integration tests in a Docker container. ID=$(docker run -d -t --privileged \ + -v /sys/fs/cgroup:/sys/fs/cgroup:ro \ # this is specific to mesos -v ${SWARM_ROOT}:/go/src/github.com/docker/swarm \ -e "DOCKER_IMAGE=$DOCKER_IMAGE" \ -e "DOCKER_VERSION=$DOCKER_VERSION" \ diff --git a/test/integration/test_runner.sh b/test/integration/test_runner.sh index 65a2c7b316..ebae66e481 100755 --- a/test/integration/test_runner.sh +++ b/test/integration/test_runner.sh @@ -12,7 +12,7 @@ function execute() { } # Tests to run. Defaults to all. -TESTS=${@:-. discovery api} +TESTS=${@:-. discovery api mesos} # Generate a temporary binary for the tests. export SWARM_BINARY=`mktemp`