Skip to content
This repository was archived by the owner on Feb 1, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/integration/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do a --volume-from in the mesos tests.

${DOCKER_IMAGE}:${DOCKER_VERSION} \
bash -c "\
hostname node-$i && \
Expand Down
20 changes: 20 additions & 0 deletions test/integration/mesos/api.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


35 changes: 32 additions & 3 deletions test/integration/mesos/mesos_helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added some new flags that you should definitely use for running mesos-slave in a docker contianer.
You should at least use --docker-mesos-image=$MESOS_IMAGE
This will create all the executors in docker containers, and you can recover all the tasks on slave restart.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add those new flags when we need them, it will require some changes in the tests: if a test does

docker run busybox ls
docker images

I'm expecting to see only one image (busybox), not two (busybox, jimenez/mesos-dev:clang)

)

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;
}
1 change: 1 addition & 0 deletions test/integration/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down