Commit 65b00fc9 by Luis Fernando Gomes

Add container_ip when run in boot2docker

parent c283ee66
......@@ -21,9 +21,9 @@ if (echo "$OSTYPE" | egrep -qs 'darwin'); then
! type -a "gmktemp" &>"/dev/null" || MKTEMP_EXEC="gmktemp"
fi
test_project=${1}
test_dir="$($READLINK_EXEC -zf $(dirname "${BASH_SOURCE[0]}"))"
test_dir="$($READLINK_EXEC -zf $(dirname "${0}"))"
image_dir=$($READLINK_EXEC -zf ${test_dir}/..)
scripts_url="file://${image_dir}/.sti/bin"
scripts_url="file://${image_dir}/.s2i/bin"
cid_file=$($MKTEMP_EXEC -u --suffix=.cid)
# Since we built the candidate image locally, we don't want S2I to attempt to pull
......@@ -53,8 +53,16 @@ container_ip() {
fi
}
container_port() {
if (echo "$OSTYPE" | egrep -qs 'darwin'); then
docker inspect --format='{{(index (index .NetworkSettings.Ports "8080/tcp") 0).HostPort}}' $(cat $cid_file)
else
echo $test_port
fi
}
run_s2i_build() {
s2i build --incremental=true ${sti_args} file://${test_dir}/${test_project} ${IMAGE_NAME} ${IMAGE_NAME}-${test_project}
s2i build --incremental=true ${s2i_args} file://${test_dir}/${test_project} ${IMAGE_NAME} ${IMAGE_NAME}-${test_project}
}
prepare() {
......@@ -114,7 +122,7 @@ wait_for_cid() {
test_s2i_usage() {
info "Testing the 'sti usage' command"
s2i usage ${sti_args} ${IMAGE_NAME} &>/dev/null
s2i usage ${s2i_args} ${IMAGE_NAME} &>/dev/null
}
test_docker_run_usage() {
......@@ -123,19 +131,19 @@ test_docker_run_usage() {
}
test_connection() {
info "Testing the HTTP connection (http://$(container_ip):${test_port})"
info "Testing the HTTP connection (http://$(container_ip):$(container_port))"
local max_attempts=10
local sleep_time=1
local attempt=1
local result=1
while [ $attempt -le $max_attempts ]; do
echo "Sending GET request to http://$(container_ip):${test_port}/"
info "Sending GET request to http://$(container_ip):$(container_port)/"
if (echo "$OSTYPE" | egrep -qs 'darwin'); then
echo "Warning for OSX users: if you can't access the container's IP ${container_ip} directly (because you use boot2docker for example)"
echo "you should run the curl command in a container, for example using:"
echo "docker run --rm -it sequenceiq/alpine-curl curl -s -w %{http_code} -o /dev/null http://$(container_ip):${test_port}/"
echo "docker run --rm -it sequenceiq/alpine-curl curl -s -w %{http_code} -o /dev/null http://$(container_ip):$(container_port)/"
fi
response_code=$(curl -s -w %{http_code} -o /dev/null http://$(container_ip):${test_port}/)
response_code=$(curl -s -w %{http_code} -o /dev/null http://$(container_ip):$(container_port)/)
status=$?
if [ $status -eq 0 ]; then
if [ $response_code -eq 200 ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment