Add an integration test for etcd

This commit is contained in:
Clayton Coleman
2014-08-22 21:12:16 -04:00
parent 8a677b1226
commit b037989478
6 changed files with 297 additions and 62 deletions

View File

@@ -17,26 +17,7 @@
# This command checks that the built commands can function together for
# simple scenarios. It does not require Docker so it can run in travis.
function wait_for_url {
url=$1
prefix=${2:-}
wait=${3:-0.2}
times=${4:-10}
set +e
for i in $(seq 1 $times); do
out=$(curl -fs $url 2>/dev/null)
if [ $? -eq 0 ]; then
set -e
echo ${prefix}${out}
return 0
fi
sleep $wait
done
echo "ERROR: timed out for $url"
set -e
return 1
}
source $(dirname $0)/util.sh
function cleanup()
{
@@ -47,47 +28,31 @@ function cleanup()
kill ${PROXY_PID} 1>&2 2>/dev/null
kill ${ETCD_PID} 1>&2 2>/dev/null
rm -rf ${ETCD_DIR} 1>&2 2>/dev/null
echo
echo "Complete"
}
trap cleanup EXIT SIGINT
ETCD_HOST=127.0.0.1
ETCD_PORT=4001
set -e
# Start etcd
start_etcd
ETCD_HOST=${ETCD_HOST:-127.0.0.1}
ETCD_PORT=${ETCD_PORT:-4001}
API_PORT=${API_PORT:-8080}
API_HOST=${API_HOST:-127.0.0.1}
KUBELET_PORT=${KUBELET_PORT:-10250}
GO_OUT=$(dirname $0)/../output/go/bin
if [ "$(which etcd)" == "" ]; then
echo "etcd must be in your PATH"
exit 1
fi
running_etcd=$(ps -ef | grep etcd | grep -c name)
if [ "$running_etcd" != "0" ]; then
echo "etcd appears to already be running on this machine, please kill and restart the test."
exit 1
fi
# Stop on any failures
set -e
# Start etcd
ETCD_DIR=$(mktemp -d -t test-cmd.XXXXXX)
etcd -name test -data-dir ${ETCD_DIR} -bind-addr $ETCD_HOST:$ETCD_PORT >/dev/null 2>/dev/null &
ETCD_PID=$!
wait_for_url "http://localhost:4001/version" "etcd: "
# Check kubecfg
out=$(${GO_OUT}/kubecfg -version)
echo kubecfg: $out
# Start kubelet
${GO_OUT}/kubelet \
--etcd_servers="http://127.0.0.1:${ETCD_PORT}" \
--etcd_servers="http://${ETCD_HOST}:${ETCD_PORT}" \
--hostname_override="127.0.0.1" \
--address="127.0.0.1" \
--port="$KUBELET_PORT" 1>&2 &
@@ -99,7 +64,7 @@ wait_for_url "http://127.0.0.1:${KUBELET_PORT}/healthz" "kubelet: "
${GO_OUT}/apiserver \
--address="127.0.0.1" \
--port="${API_PORT}" \
--etcd_servers="http://127.0.0.1:${ETCD_PORT}" \
--etcd_servers="http://${ETCD_HOST}:${ETCD_PORT}" \
--machines="127.0.0.1" \
--minion_port=${KUBELET_PORT} 1>&2 &
APISERVER_PID=$!