Merge pull request #1532 from jimenez/integration_tests

Adding integration tests for mesos
This commit is contained in:
Victor Vieux 2015-12-11 15:56:34 -08:00
commit 47d63f9b72
3 changed files with 114 additions and 0 deletions

View File

@ -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, <none>
run docker_swarm images -a
[ "${#lines[@]}" -ge 3 ]
}

View File

@ -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"* ]]
}

View File

@ -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
}