Merge pull request #257 from appropriate/osx-fix-test-suite
Fix running test suite under Docker Machine
This commit is contained in:
commit
f819a4e2e7
8 changed files with 146 additions and 131 deletions
|
@ -14,6 +14,8 @@ dependencies:
|
|||
- docker pull nginx
|
||||
- docker pull python:3
|
||||
- docker pull rancher/socat-docker
|
||||
- docker pull appropriate/curl
|
||||
- docker pull docker:1.7
|
||||
|
||||
test:
|
||||
override:
|
||||
|
|
|
@ -4,7 +4,10 @@ load test_helpers
|
|||
function setup {
|
||||
# make sure to stop any web container before each test so we don't
|
||||
# have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set
|
||||
docker ps -q --filter "label=bats-type=web" | xargs -r docker stop >&2
|
||||
CIDS=( $(docker ps -q --filter "label=bats-type=web") )
|
||||
if [ ${#CIDS[@]} -gt 0 ]; then
|
||||
docker stop ${CIDS[@]} >&2
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ load test_helpers
|
|||
-v /etc/nginx/certs/ \
|
||||
nginx:latest
|
||||
assert_success
|
||||
run retry 5 1s curl --silent --fail --head http://$(docker_ip bats-nginx)/
|
||||
run retry 5 1s docker run appropriate/curl --silent --fail --head http://$(docker_ip bats-nginx)/
|
||||
assert_output -l 0 $'HTTP/1.1 200 OK\r'
|
||||
|
||||
# WHEN docker-gen runs on our docker host
|
||||
|
|
|
@ -56,5 +56,5 @@ function docker_tcp {
|
|||
--expose 2375 \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
rancher/socat-docker
|
||||
docker -H tcp://$(docker_ip $container_name):2375 version
|
||||
docker run --link "$container_name:docker" docker:1.7 version
|
||||
}
|
||||
|
|
|
@ -5,7 +5,10 @@ SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}
|
|||
function setup {
|
||||
# make sure to stop any web container before each test so we don't
|
||||
# have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set
|
||||
docker ps -q --filter "label=bats-type=web" | xargs -r docker stop >&2
|
||||
CIDS=( $(docker ps -q --filter "label=bats-type=web") )
|
||||
if [ ${#CIDS[@]} -gt 0 ]; then
|
||||
docker stop ${CIDS[@]} >&2
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,10 @@ SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}
|
|||
function setup {
|
||||
# make sure to stop any web container before each test so we don't
|
||||
# have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set
|
||||
docker ps -q --filter "label=bats-type=web" | xargs -r docker stop >&2
|
||||
CIDS=( $(docker ps -q --filter "label=bats-type=web") )
|
||||
if [ ${#CIDS[@]} -gt 0 ]; then
|
||||
docker stop ${CIDS[@]} >&2
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# Test if requirements are met
|
||||
(
|
||||
type docker &>/dev/null || ( echo "docker is not available"; exit 1 )
|
||||
type curl &>/dev/null || ( echo "curl is not available"; exit 1 )
|
||||
)>&2
|
||||
|
||||
|
||||
|
@ -67,7 +66,7 @@ function curl_container {
|
|||
local -r container=$1
|
||||
local -r path=$2
|
||||
shift 2
|
||||
curl --silent \
|
||||
docker run appropriate/curl --silent \
|
||||
--connect-timeout 5 \
|
||||
--max-time 20 \
|
||||
"$@" \
|
||||
|
@ -87,6 +86,7 @@ function prepare_web_container {
|
|||
local -r options="$@"
|
||||
|
||||
local expose_option=""
|
||||
IFS=$' \t\n' # See https://github.com/sstephenson/bats/issues/89
|
||||
for port in $ports; do
|
||||
expose_option="${expose_option}--expose=$port "
|
||||
done
|
||||
|
@ -121,8 +121,9 @@ function prepare_web_container {
|
|||
assert_success
|
||||
|
||||
# THEN querying directly port works
|
||||
IFS=$' \t\n' # See https://github.com/sstephenson/bats/issues/89
|
||||
for port in $ports; do
|
||||
run retry 5 1s curl --silent --fail http://$(docker_ip $container_name):$port/data
|
||||
run retry 5 1s docker run appropriate/curl --silent --fail http://$(docker_ip $container_name):$port/data
|
||||
assert_output "answer from port $port"
|
||||
done
|
||||
}
|
|
@ -5,7 +5,10 @@ SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE}
|
|||
function setup {
|
||||
# make sure to stop any web container before each test so we don't
|
||||
# have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set
|
||||
docker ps -q --filter "label=bats-type=web" | xargs -r docker stop >&2
|
||||
CIDS=( $(docker ps -q --filter "label=bats-type=web") )
|
||||
if [ ${#CIDS[@]} -gt 0 ]; then
|
||||
docker stop ${CIDS[@]} >&2
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
|
Reference in a new issue