2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
11 kill ${arvboot_PID} ${consume_stdout_PID} ${wb2_PID} ${consume_wb2_stdout_PID}
12 wait ${arvboot_PID} ${consume_stdout_PID} ${wb2_PID} ${consume_wb2_stdout_PID} || true
17 while port=$(shuf -n1 -i $(cat /proc/sys/net/ipv4/ip_local_port_range | tr '\011' '-'))
18 netstat -atun | grep -q ":$port\s" ; do
25 echo "Usage: ${0} [options]"
27 echo " -i Run Cypress in interactive mode."
28 echo " -a PATH Arvados dir. If PATH doesn't exist, a repo clone is downloaded there."
29 echo " -w PATH Workbench2 dir. Default: Current working directory"
33 # Allow self-signed certs on 'wait-on'
34 export NODE_TLS_REJECT_UNAUTHORIZED=0
40 while getopts "ia:w:" o; do
53 echo "Invalid Option: -$OPTARG" 1>&2
60 if [ "${ARVADOS_DIR}" = "unset" ]; then
61 echo "ARVADOS_DIR is unset, using git working dir"
62 ARVADOS_DIR=$(env -C "$WB2_DIR" git rev-parse --show-toplevel)
65 echo "ARVADOS_DIR is ${ARVADOS_DIR}"
67 ARVADOS_LOG=${ARVADOS_DIR}/arvados.log
68 ARVADOS_CONF=${WB2_DIR}/tools/arvados_config.yml
69 VOCABULARY_CONF=${WB2_DIR}/tools/example-vocabulary.json
71 if [ ! -f "${WB2_DIR}/src/index.tsx" ]; then
72 echo "ERROR: '${WB2_DIR}' isn't workbench2's directory"
76 if [ ! -f ${ARVADOS_CONF} ]; then
77 echo "ERROR: Arvados config file ${ARVADOS_CONF} not found"
81 if [ -f "${WB2_DIR}/public/config.json" ]; then
82 echo "ERROR: Please move public/config.json file out of the way"
86 GOPATH="$(go env GOPATH)"
88 if [ ! -x ${GOPATH}/bin/arvados-server ]; then
89 echo "Building & installing arvados-server..."
91 GOFLAGS=-buildvcs=false go mod download || exit 1
93 GOFLAGS=-buildvcs=false go install
96 echo "Installing dev dependencies..."
97 ${GOPATH}/bin/arvados-server install -type test || exit 1
100 echo "Launching arvados in test mode..."
101 TMPSUBDIR=$(mktemp -d -p /tmp | cut -d \/ -f3) # Removes the /tmp/ part for the regex below
102 TMPDIR=/tmp/${TMPSUBDIR}
103 cp ${VOCABULARY_CONF} ${TMPDIR}/voc.json
104 cp ${ARVADOS_CONF} ${TMPDIR}/arvados.yml
105 sed -i "s/VocabularyPath: \".*\"/VocabularyPath: \"\/tmp\/${TMPSUBDIR}\/voc.json\"/" ${TMPDIR}/arvados.yml
106 coproc arvboot (${GOPATH}/bin/arvados-server boot \
108 -source "${ARVADOS_DIR}" \
109 -config ${TMPDIR}/arvados.yml \
112 -own-temporary-database \
113 -timeout 20m 2> ${ARVADOS_LOG})
114 trap cleanup ERR EXIT
116 read controllerInfo <&"${arvboot[0]}" || exit 1
117 controllerURL=`echo "$controllerInfo" | awk '{print $1;}'`;
118 echo "Arvados up and running at ${controllerURL}"
119 IFS='/' ; read -ra controllerHostPort <<< "${controllerURL}" ; unset IFS
120 controllerHostPort=${controllerHostPort[2]}
122 # Copy coproc's stdout to stderr, to ensure `arvados-server boot`
123 # doesn't get blocked trying to write stdout.
124 exec 7<&"${arvboot[0]}"; coproc consume_stdout (cat <&7 >&2)
127 echo "Launching workbench2..."
128 WB2_PORT=`random_free_port`
129 coproc wb2 (PORT=${WB2_PORT} \
130 REACT_APP_ARVADOS_API_HOST=${controllerHostPort} \
132 exec 8<&"${wb2[0]}"; coproc consume_wb2_stdout (cat <&8 >&2)
134 # Wait for workbench2 to be up.
135 # Using https-get to avoid false positive 'ready' detection.
136 yarn run wait-on --timeout 300000 https-get://127.0.0.1:${WB2_PORT} || exit 1
138 echo "Running tests..."
139 CYPRESS_system_token=systemusertesttoken1234567890aoeuidhtnsqjkxbmwvzpy \
140 CYPRESS_controller_url=${controllerURL} \
141 CYPRESS_BASE_URL=https://127.0.0.1:${WB2_PORT} \
142 yarn run cypress ${CYPRESS_MODE} "$@"