18874: Use git root as default arvados tree.
[arvados.git] / services / workbench2 / tools / run-integration-tests.sh
index 1435bc50d5b7ef41e2ba3026699b9c1d43d7f5b6..b2745b3a6e1ca90cace7b5b797d05e8e4e4cd61b 100755 (executable)
@@ -10,9 +10,6 @@ cleanup() {
     set +e +o pipefail
     kill ${arvboot_PID} ${consume_stdout_PID} ${wb2_PID} ${consume_wb2_stdout_PID}
     wait ${arvboot_PID} ${consume_stdout_PID} ${wb2_PID} ${consume_wb2_stdout_PID} || true
-    if [ ${CLEANUP_ARVADOS_DIR} -eq 1 ]; then
-        rm -rf ${ARVADOS_DIR}
-    fi
     echo >&2 "done"
 }
 
@@ -37,7 +34,6 @@ usage() {
 export NODE_TLS_REJECT_UNAUTHORIZED=0
 
 ARVADOS_DIR="unset"
-CLEANUP_ARVADOS_DIR=0
 CYPRESS_MODE="run"
 WB2_DIR=`pwd`
 
@@ -62,8 +58,8 @@ done
 shift $((OPTIND-1))
 
 if [ "${ARVADOS_DIR}" = "unset" ]; then
-  echo "ARVADOS_DIR is unset, creating a temporary directory for new checkout"
-  ARVADOS_DIR=`mktemp -d`
+  echo "ARVADOS_DIR is unset, using git working dir"
+  ARVADOS_DIR=$(env -C "$WB2_DIR" git rev-parse --show-toplevel)
 fi
 
 echo "ARVADOS_DIR is ${ARVADOS_DIR}"
@@ -87,23 +83,18 @@ if [ -f "${WB2_DIR}/public/config.json" ]; then
     exit 1
 fi
 
-if [ ! -d "${ARVADOS_DIR}/.git" ]; then
-    mkdir -p ${ARVADOS_DIR} || exit 1
-    CLEANUP_ARVADOS_DIR=1
-    echo "Downloading arvados..."
-    git clone https://git.arvados.org/arvados.git ${ARVADOS_DIR} || exit 1
-fi
+GOPATH="$(go env GOPATH)"
 
-if [ ! -x ${GOPATH:-${HOME}/go}/bin/arvados-server ]; then
+if [ ! -x ${GOPATH}/bin/arvados-server ]; then
     echo "Building & installing arvados-server..."
     cd ${ARVADOS_DIR}
-    go mod download || exit 1
+    GOFLAGS=-buildvcs=false go mod download || exit 1
     cd cmd/arvados-server
-    go install
+    GOFLAGS=-buildvcs=false go install
     cd -
 
     echo "Installing dev dependencies..."
-    ${GOPATH:-${HOME}/go}/bin/arvados-server install -type test || exit 1
+    ${GOPATH}/bin/arvados-server install -type test || exit 1
 fi
 
 echo "Launching arvados in test mode..."
@@ -112,8 +103,9 @@ TMPDIR=/tmp/${TMPSUBDIR}
 cp ${VOCABULARY_CONF} ${TMPDIR}/voc.json
 cp ${ARVADOS_CONF} ${TMPDIR}/arvados.yml
 sed -i "s/VocabularyPath: \".*\"/VocabularyPath: \"\/tmp\/${TMPSUBDIR}\/voc.json\"/" ${TMPDIR}/arvados.yml
-coproc arvboot (${GOPATH:-${HOME}/go}/bin/arvados-server boot \
+coproc arvboot (${GOPATH}/bin/arvados-server boot \
     -type test \
+    -source "${ARVADOS_DIR}" \
     -config ${TMPDIR}/arvados.yml \
     -no-workbench1 \
     -no-workbench2 \
@@ -141,10 +133,10 @@ exec 8<&"${wb2[0]}"; coproc consume_wb2_stdout (cat <&8 >&2)
 
 # Wait for workbench2 to be up.
 # Using https-get to avoid false positive 'ready' detection.
-yarn run wait-on --timeout 300000 https-get://localhost:${WB2_PORT} || exit 1
+yarn run wait-on --timeout 300000 https-get://127.0.0.1:${WB2_PORT} || exit 1
 
 echo "Running tests..."
 CYPRESS_system_token=systemusertesttoken1234567890aoeuidhtnsqjkxbmwvzpy \
     CYPRESS_controller_url=${controllerURL} \
-    CYPRESS_BASE_URL=https://localhost:${WB2_PORT} \
-    yarn run cypress ${CYPRESS_MODE}
+    CYPRESS_BASE_URL=https://127.0.0.1:${WB2_PORT} \
+    yarn run cypress ${CYPRESS_MODE} "$@"