fix urls command when NO_VHOST=1 + tests. fixes #1294

This commit is contained in:
Michael Hobbs
2015-07-09 12:12:49 -07:00
parent aa55f027a4
commit 033a267573
3 changed files with 54 additions and 17 deletions

View File

@@ -180,6 +180,8 @@ case "$1" in
verify_app_name "$2" verify_app_name "$2"
APP="$2"; APP="$2";
[[ "$DOKKU_ROOT/$APP/ENV" ]] && source "$DOKKU_ROOT/$APP/ENV"
if [[ -s "$DOKKU_ROOT/$APP/URLS" ]]; then if [[ -s "$DOKKU_ROOT/$APP/URLS" ]]; then
case "$1" in case "$1" in
url) url)
@@ -198,7 +200,7 @@ case "$1" in
SCHEME="https" SCHEME="https"
fi fi
if [[ -f "$DOKKU_ROOT/VHOST" ]]; then if [[ -f "$DOKKU_ROOT/VHOST" ]] && [[ "$NO_VHOST" != "1" ]]; then
echo "$SCHEME://$(< "$DOKKU_ROOT/VHOST")" echo "$SCHEME://$(< "$DOKKU_ROOT/VHOST")"
else else
for PORT_FILE in $DOKKU_ROOT/$APP/PORT.*; do for PORT_FILE in $DOKKU_ROOT/$APP/PORT.*; do

View File

@@ -133,6 +133,10 @@ EOF
dokku_log_info1 "VHOST support disabled, deleting $APP/VHOST" dokku_log_info1 "VHOST support disabled, deleting $APP/VHOST"
rm "$DOKKU_ROOT/$APP/VHOST" rm "$DOKKU_ROOT/$APP/VHOST"
fi fi
if [[ -f "$DOKKU_ROOT/$APP/URLS" ]]; then
dokku_log_info1 "VHOST support disabled, deleting $APP/URLS"
rm "$DOKKU_ROOT/$APP/URLS"
fi
if [[ -f "$DOKKU_ROOT/$APP/nginx.conf" ]]; then if [[ -f "$DOKKU_ROOT/$APP/nginx.conf" ]]; then
dokku_log_info1 "VHOST support disabled, deleting nginx.conf" dokku_log_info1 "VHOST support disabled, deleting nginx.conf"
rm "$DOKKU_ROOT/$APP/nginx.conf" rm "$DOKKU_ROOT/$APP/nginx.conf"

View File

@@ -13,57 +13,80 @@ teardown() {
[[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME" [[ -f "$DOKKU_ROOT/HOSTNAME.bak" ]] && mv "$DOKKU_ROOT/HOSTNAME.bak" "$DOKKU_ROOT/HOSTNAME"
} }
check_urls() {
local PATTERN="$1"
run bash -c "dokku --quiet urls $TEST_APP | egrep \"${1}\""
echo "output: "$output
echo "status: "$status
assert_success
}
@test "(core) port exposure (with global VHOST)" { @test "(core) port exposure (with global VHOST)" {
echo "dokku.me" > "$DOKKU_ROOT/VHOST" echo "dokku.me" > "$DOKKU_ROOT/VHOST"
deploy_app deploy_app
CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }') CONTAINER_ID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'" run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep -q '[0-9]*'"
echo "output: "$output echo "output: "$output
echo "status: "$status echo "status: "$status
assert_failure assert_failure
check_urls http://${TEST_APP}.dokku.me
} }
@test "(core) port exposure (without global VHOST and real HOSTNAME)" { @test "(core) port exposure (without global VHOST and real HOSTNAME)" {
rm "$DOKKU_ROOT/VHOST" rm "$DOKKU_ROOT/VHOST"
echo "dokku.me" > "$DOKKU_ROOT/HOSTNAME" echo "${TEST_APP}.dokku.me" > "$DOKKU_ROOT/HOSTNAME"
deploy_app deploy_app
CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }') CONTAINER_ID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'" run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep -q '[0-9]*'"
echo "output: "$output echo "output: "$output
echo "status: "$status echo "status: "$status
assert_success assert_success
HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME")
check_urls http://${HOSTNAME}:[0-9]+
} }
@test "(core) port exposure (with NO_VHOST set)" { @test "(core) port exposure (with NO_VHOST set)" {
deploy_app deploy_app
dokku config:set $TEST_APP NO_VHOST=1 dokku config:set $TEST_APP NO_VHOST=1
CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }' | head -1) CONTAINER_ID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'" run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep -q '[0-9]*'"
echo "output: "$output echo "output: "$output
echo "status: "$status echo "status: "$status
assert_success assert_success
HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME")
check_urls http://${HOSTNAME}:[0-9]+
} }
@test "(core) port exposure (without global VHOST and IPv4 address as HOSTNAME)" { @test "(core) port exposure (without global VHOST and IPv4 address as HOSTNAME)" {
rm "$DOKKU_ROOT/VHOST" rm "$DOKKU_ROOT/VHOST"
echo "127.0.0.1" > "$DOKKU_ROOT/HOSTNAME" echo "127.0.0.1" > "$DOKKU_ROOT/HOSTNAME"
deploy_app deploy_app
CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }') CONTAINER_ID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'" run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep -q '[0-9]*'"
echo "output: "$output echo "output: "$output
echo "status: "$status echo "status: "$status
assert_success assert_success
HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME")
check_urls http://${HOSTNAME}:[0-9]+
} }
@test "(core) port exposure (without global VHOST and IPv6 address as HOSTNAME)" { @test "(core) port exposure (without global VHOST and IPv6 address as HOSTNAME)" {
rm "$DOKKU_ROOT/VHOST" rm "$DOKKU_ROOT/VHOST"
echo "fda5:c7db:a520:bb6d::aabb:ccdd:eeff" > "$DOKKU_ROOT/HOSTNAME" echo "fda5:c7db:a520:bb6d::aabb:ccdd:eeff" > "$DOKKU_ROOT/HOSTNAME"
deploy_app deploy_app
CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }') CONTAINER_ID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'" run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep -q '[0-9]*'"
echo "output: "$output echo "output: "$output
echo "status: "$status echo "status: "$status
assert_success assert_success
HOSTNAME=$(< "$DOKKU_ROOT/HOSTNAME")
check_urls http://${HOSTNAME}:[0-9]+
} }
@test "(core) port exposure (pre-deploy domains:add)" { @test "(core) port exposure (pre-deploy domains:add)" {
@@ -76,8 +99,8 @@ teardown() {
deploy_app deploy_app
sleep 5 # wait for nginx to reload sleep 5 # wait for nginx to reload
CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }') CONTAINER_ID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'" run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep -q '[0-9]*'"
echo "output: "$output echo "output: "$output
echo "status: "$status echo "status: "$status
assert_failure assert_failure
@@ -86,6 +109,8 @@ teardown() {
echo "output: "$output echo "output: "$output
echo "status: "$status echo "status: "$status
assert_success assert_success
check_urls http://www.test.app.dokku.me
} }
@test "(core) port exposure (no global VHOST and domains:add post deploy)" { @test "(core) port exposure (no global VHOST and domains:add post deploy)" {
@@ -102,8 +127,8 @@ teardown() {
echo "status: "$status echo "status: "$status
assert_success assert_success
CONTAINER_ID=$(docker ps --no-trunc| grep dokku/$TEST_APP | grep "start web" | awk '{ print $1 }' | head -1) CONTAINER_ID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep '[0-9]*'" run bash -c "docker port $CONTAINER_ID | sed 's/[0-9.]*://' | egrep -q '[0-9]*'"
echo "output: "$output echo "output: "$output
echo "status: "$status echo "status: "$status
assert_failure assert_failure
@@ -112,14 +137,18 @@ teardown() {
echo "output: "$output echo "output: "$output
echo "status: "$status echo "status: "$status
assert_success assert_success
check_urls http://www.test.app.dokku.me
} }
@test "(core) dockerfile port exposure" { @test "(core) dockerfile port exposure" {
deploy_app dockerfile deploy_app dockerfile
run bash -c "grep -A1 upstream $DOKKU_ROOT/$TEST_APP/nginx.conf | grep 3000" run bash -c "grep -A1 upstream $DOKKU_ROOT/$TEST_APP/nginx.conf | grep -q 3000"
echo "output: "$output echo "output: "$output
echo "status: "$status echo "status: "$status
assert_success assert_success
check_urls http://${TEST_APP}.dokku.me
} }
@test "(core) port exposure (xip.io style hostnames)" { @test "(core) port exposure (xip.io style hostnames)" {
@@ -130,4 +159,6 @@ teardown() {
echo "output: "$output echo "output: "$output
echo "status: "$status echo "status: "$status
assert_success assert_success
check_urls http://my-cool-guy-test-app.127.0.0.1.xip.io
} }