2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
10 kill ${arvboot_PID} ${consume_stdout_PID} ${wb2_PID} ${consume_wb2_stdout_PID}
11 wait ${arvboot_PID} ${consume_stdout_PID} ${wb2_PID} ${consume_wb2_stdout_PID} || true
12 if [ "${CLEANUP_ARVADOS_DIR}" -eq "1" ]; then
19 while port=$(shuf -n1 -i $(cat /proc/sys/net/ipv4/ip_local_port_range | tr '\011' '-'))
20 netstat -atun | grep -q ":$port\s" ; do
27 echo "Usage: ${0} [options]"
29 echo " -i Run Cypress in interactive mode."
30 echo " -a PATH Arvados dir. If PATH doesn't exist, a repo clone is downloaded there."
31 echo " -w PATH Workbench2 dir. Default: Current working directory"
35 # Allow self-signed certs on 'wait-on'
36 export NODE_TLS_REJECT_UNAUTHORIZED=0
40 ARVADOS_DIR=`mktemp -d`
43 while getopts "ia:w:" o; do
56 echo "Invalid Option: -$OPTARG" 1>&2
63 ARVADOS_LOG=${ARVADOS_DIR}/arvados.log
64 ARVADOS_CONF=${WB2_DIR}/tools/arvados_config.yml
66 if [ ! -f "${WB2_DIR}/src/index.tsx" ]; then
67 echo "ERROR: '${WB2_DIR}' isn't workbench2's directory"
71 if [ ! -f ${ARVADOS_CONF} ]; then
72 echo "ERROR: Arvados config file ${ARVADOS_CONF} not found"
76 if [ -f "${WB2_DIR}/public/config.json" ]; then
77 echo "ERROR: Please move public/config.json file out of the way"
81 if [ ! -d "${ARVADOS_DIR}/.git" ]; then
82 mkdir -p ${ARVADOS_DIR} || exit 1
84 echo "Downloading arvados..."
85 git clone https://git.arvados.org/arvados.git ${ARVADOS_DIR} || exit 1
88 echo "Building & installing arvados-server..."
90 go mod download || exit 1
95 echo "Installing dev dependencies..."
96 ~/go/bin/arvados-server install -type test || exit 1
98 echo "Launching arvados in test mode..."
99 coproc arvboot (~/go/bin/arvados-server boot \
101 -config ${ARVADOS_CONF} \
102 -own-temporary-database \
103 -timeout 20m 2> ${ARVADOS_LOG})
104 trap cleanup ERR EXIT
106 read controllerURL <&"${arvboot[0]}" || exit 1
107 echo "Arvados up and running at ${controllerURL}"
108 IFS='/' ; read -ra controllerHostPort <<< "${controllerURL}" ; unset IFS
109 controllerHostPort=${controllerHostPort[2]}
111 # Copy coproc's stdout to stderr, to ensure `arvados-server boot`
112 # doesn't get blocked trying to write stdout.
113 exec 7<&"${arvboot[0]}"; coproc consume_stdout (cat <&7 >&2)
116 echo "Launching workbench2..."
117 WB2_PORT=`random_free_port`
118 coproc wb2 (PORT=${WB2_PORT} \
119 REACT_APP_ARVADOS_API_HOST=${controllerHostPort} \
121 exec 8<&"${wb2[0]}"; coproc consume_wb2_stdout (cat <&8 >&2)
123 # Wait for workbench2 to be up.
124 # Using https-get to avoid false positive 'ready' detection.
125 yarn run wait-on --timeout 300000 https-get://localhost:${WB2_PORT} || exit 1
127 echo "Running tests..."
128 CYPRESS_system_token=systemusertesttoken1234567890aoeuidhtnsqjkxbmwvzpy \
129 CYPRESS_controller_url=${controllerURL} \
130 CYPRESS_BASE_URL=https://localhost:${WB2_PORT} \
131 yarn run cypress ${CYPRESS_MODE}