Skip to content

Commit

Permalink
Wait longer for etcd startup in integration tests
Browse files Browse the repository at this point in the history
Also, print etcd logs if integration test dies
  • Loading branch information
smarterclayton committed Nov 3, 2015
1 parent 2c6234e commit 8d07f5b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion hack/test-cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ os::util::sed "s/:7001$/:${ETCD_PEER_PORT}/g" ${SERVER_CONFIG_DIR}/master/master
OPENSHIFT_ON_PANIC=crash openshift start master \
--config=${MASTER_CONFIG_DIR}/master-config.yaml \
--loglevel=4 \
1>&2 2>"${LOG_DIR}/openshift.log" &
&>"${LOG_DIR}/openshift.log" &
OS_PID=$!

if [[ "${API_SCHEME}" == "https" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion hack/test-end-to-end.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ trap "cleanup" EXIT
TMPDIR="${TMPDIR:-"/tmp"}"
BASETMPDIR="${TMPDIR}/openshift-e2e"
setup_env_vars
reset_tmp_dir
reset_tmp_dir
configure_os_server
start_os_server

Expand Down
23 changes: 14 additions & 9 deletions hack/test-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ set -e


function cleanup() {
out=$?
set +e
if [[ $out -ne 0 && -f "${etcdlog}" ]]; then
cat "${etcdlog}"
fi
kill "${ETCD_PID}" 1>&2 2>/dev/null
echo
echo "Complete"
exit $out
}


Expand All @@ -59,34 +64,34 @@ echo "Test ${package} -tags='${tags}' ..."
echo

# setup the test dirs
export ETCD_DIR=${BASETMPDIR}/etcd
etcdlog="${ETCD_DIR}/etcd.log"
testdir="${OS_ROOT}/_output/testbin/${package}"
name="$(basename ${testdir})"
testexec="${testdir}/${name}.test"
mkdir -p "${testdir}"
mkdir -p "${ETCD_DIR}"

# build the test executable (cgo must be disabled to have the symbol table available)
pushd "${testdir}" 2>&1 >/dev/null
pushd "${testdir}" &>/dev/null
CGO_ENABLED=0 go test -c -tags="${tags}" "${OS_GO_PACKAGE}/${package}"
popd 2>&1 >/dev/null
popd &>/dev/null


# Start etcd
export ETCD_DIR=${BASETMPDIR}/etcd
etcd -name test -data-dir ${ETCD_DIR} \
--listen-peer-urls http://${ETCD_HOST}:${ETCD_PEER_PORT} \
--listen-client-urls http://${ETCD_HOST}:${ETCD_PORT} \
--initial-advertise-peer-urls http://${ETCD_HOST}:${ETCD_PEER_PORT} \
--initial-cluster test=http://${ETCD_HOST}:${ETCD_PEER_PORT} \
--advertise-client-urls http://${ETCD_HOST}:${ETCD_PORT} \
>/dev/null 2>/dev/null &
&>"${etcdlog}" &
export ETCD_PID=$!

wait_for_url "http://${ETCD_HOST}:${ETCD_PORT}/version" "etcd: " 0.25 80
wait_for_url "http://${ETCD_HOST}:${ETCD_PORT}/version" "etcd: " 0.25 160
curl -X PUT "http://${ETCD_HOST}:${ETCD_PORT}/v2/keys/_test"
echo



trap cleanup EXIT SIGINT

function exectest() {
Expand Down Expand Up @@ -132,10 +137,10 @@ export childargs
# hack/test-integration.sh "(WatchBuilds|Template)"

# run each test as its own process
pushd "./${package}" 2>&1 >/dev/null
pushd "./${package}" &>/dev/null
time go run "${OS_ROOT}/hack/listtests.go" -prefix="${OS_GO_PACKAGE}/${package}.Test" "${testdir}" \
| grep --color=never -E "${1-Test}" \
| xargs -I {} -n 1 bash -c "exectest {} ${@:2}" # "${testexec}" -test.run="^{}$" "${@:2}"
popd 2>&1 >/dev/null
popd &>/dev/null

ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret"
4 changes: 2 additions & 2 deletions hack/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function start_os_server {
--master-config=${MASTER_CONFIG_DIR}/master-config.yaml \
--node-config=${NODE_CONFIG_DIR}/node-config.yaml \
--loglevel=4 \
&> "${LOG_DIR}/openshift.log" &
&>"${LOG_DIR}/openshift.log" &
export OS_PID=$!

echo "[INFO] OpenShift server start at: "
Expand Down Expand Up @@ -181,7 +181,7 @@ function start_os_master {
${sudo} env "PATH=${PATH}" OPENSHIFT_PROFILE=web OPENSHIFT_ON_PANIC=crash openshift start master \
--config=${MASTER_CONFIG_DIR}/master-config.yaml \
--loglevel=4 \
&> "${LOG_DIR}/openshift.log" &
&>"${LOG_DIR}/openshift.log" &
export OS_PID=$!

echo "[INFO] OpenShift server start at: "
Expand Down

0 comments on commit 8d07f5b

Please sign in to comment.