diff --git a/test/integration/mesos/api/images.bats b/test/integration/mesos/api/images.bats new file mode 100644 index 0000000000..764d577325 --- /dev/null +++ b/test/integration/mesos/api/images.bats @@ -0,0 +1,45 @@ +#!/usr/bin/env bats + +load ../mesos_helpers + +function teardown() { + swarm_manage_cleanup + stop_mesos + stop_docker +} + +@test "mesos - docker images" { + start_docker 1 + start_docker_with_busybox 2 + start_mesos + swarm_manage --cluster-driver mesos-experimental 127.0.0.1:$MESOS_MASTER_PORT + + # With grouping, we should get 1 busybox, plus the header. + run docker_swarm images + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 2 ] + # Every line should contain "busybox" except for the header + for((i=1; i<${#lines[@]}; i++)); do + [[ "${lines[i]}" == *"busybox"* ]] + done + + # Try with --filter. + run docker_swarm images --filter node=node-0 + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 1 ] + + run docker_swarm images --filter node=node-1 + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"busybox"* ]] + + run docker_swarm images --filter node=node-2 + [ "$status" -eq 0 ] + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"busybox"* ]] + + # Try images -a + # lines are: header, busybox, + run docker_swarm images -a + [ "${#lines[@]}" -ge 3 ] +} diff --git a/test/integration/mesos/api/logs.bats b/test/integration/mesos/api/logs.bats new file mode 100644 index 0000000000..a7369bcc20 --- /dev/null +++ b/test/integration/mesos/api/logs.bats @@ -0,0 +1,34 @@ +#!/usr/bin/env bats + +load ../mesos_helpers + +function teardown() { + swarm_manage_cleanup + stop_mesos + stop_docker +} + +@test "mesos - docker logs" { + start_docker_with_busybox 2 + start_mesos + swarm_manage --cluster-driver mesos-experimental 127.0.0.1:$MESOS_MASTER_PORT + + # make sure no container exist + run docker_swarm ps -qa + [ "${#lines[@]}" -eq 0 ] + + # run a container with echo command + docker_swarm run -d -m 20m --name test_container busybox /bin/sh -c "echo hello world; echo hello docker; echo hello swarm" + + # make sure container exists + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + + # verify + run docker_swarm logs test_container + [ "$status" -eq 0 ] + [[ "${lines[0]}" == *"hello world"* ]] + [[ "${lines[1]}" == *"hello docker"* ]] + [[ "${lines[2]}" == *"hello swarm"* ]] +} diff --git a/test/integration/mesos/api/stats.bats b/test/integration/mesos/api/stats.bats new file mode 100644 index 0000000000..8e3e165bde --- /dev/null +++ b/test/integration/mesos/api/stats.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats + +load ../mesos_helpers + +function teardown() { + swarm_manage_cleanup + stop_mesos + stop_docker +} + +@test "mesos - docker stats" { + TEMP_FILE=$(mktemp) + start_docker_with_busybox 2 + start_mesos + swarm_manage --cluster-driver mesos-experimental 127.0.0.1:$MESOS_MASTER_PORT + + # stats running container + docker_swarm run -d -m 20m --name test_container busybox sleep 50 + + # make sure container is up + [ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ] + + # storage the stats output in TEMP_FILE + # it will stop automatically when manager stop + docker_swarm stats test_container > $TEMP_FILE & + + # retry until TEMP_FILE is not empty + retry 5 1 eval "[ -s $TEMP_FILE ]" + + grep -q "CPU %" "$TEMP_FILE" + grep -q "MEM USAGE" "$TEMP_FILE" + grep -q "LIMIT" "$TEMP_FILE" + + rm -f $TEMP_FILE +}