Use default www-prefix when proxy in test-cmd and fix some related bugs

This commit is contained in:
Janet Kuo 2015-10-14 15:47:52 -07:00
parent f47c2be539
commit c2eef6b3d6

View File

@ -33,8 +33,7 @@ function stop-proxy()
PROXY_PORT= PROXY_PORT=
} }
# Starts "kubect proxy" to test the client proxy. You may pass options, e.g. # Starts "kubect proxy" to test the client proxy. $1: api_prefix
# --api-prefix.
function start-proxy() function start-proxy()
{ {
stop-proxy stop-proxy
@ -45,15 +44,21 @@ function start-proxy()
PROXY_PORT=$(kube::util::get_random_port) PROXY_PORT=$(kube::util::get_random_port)
kube::log::status "On try ${retry}, use proxy port ${PROXY_PORT} if it's free" kube::log::status "On try ${retry}, use proxy port ${PROXY_PORT} if it's free"
if kube::util::test_host_port_free "127.0.0.1" "${PROXY_PORT}"; then if kube::util::test_host_port_free "127.0.0.1" "${PROXY_PORT}"; then
# the --www and --www-prefix are just to make something definitely show up for if [ $# -eq 0 ]; then
# wait_for_url to see. kubectl proxy -p ${PROXY_PORT} --www=. 1>&2 & break
kubectl proxy -p ${PROXY_PORT} --www=. --www-prefix=/healthz "$@" 1>&2 & break else
kubectl proxy -p ${PROXY_PORT} --www=. --api-prefix="$1" 1>&2 & break
fi
fi fi
sleep 1; sleep 1;
done done
PROXY_PID=$! PROXY_PID=$!
kube::util::wait_for_url "http://127.0.0.1:${PROXY_PORT}/healthz" "kubectl proxy $@" if [ $# -eq 0 ]; then
kube::util::wait_for_url "http://127.0.0.1:${PROXY_PORT}/healthz" "kubectl proxy"
else
kube::util::wait_for_url "http://127.0.0.1:${PROXY_PORT}/$1/healthz" "kubectl proxy --api-prefix=$1"
fi
} }
function cleanup() function cleanup()
@ -225,7 +230,7 @@ runTests() {
if [[ -n "${version}" ]]; then if [[ -n "${version}" ]]; then
check-curl-proxy-code /api/${version}/namespaces 200 check-curl-proxy-code /api/${version}/namespaces 200
fi fi
check-curl-proxy-code /healthz/ 200 check-curl-proxy-code /static/ 200
stop-proxy stop-proxy
# Make sure the in-development api is accessible by default # Make sure the in-development api is accessible by default
@ -235,7 +240,7 @@ runTests() {
stop-proxy stop-proxy
# Custom paths let you see everything. # Custom paths let you see everything.
start-proxy --api-prefix=/custom start-proxy /custom
check-curl-proxy-code /custom/ui 301 check-curl-proxy-code /custom/ui 301
check-curl-proxy-code /custom/metrics 200 check-curl-proxy-code /custom/metrics 200
if [[ -n "${version}" ]]; then if [[ -n "${version}" ]]; then