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
13 if [ "${CLEANUP_ARVADOS_DIR}" -eq "1" ]; then
20 while port=$(shuf -n1 -i $(cat /proc/sys/net/ipv4/ip_local_port_range | tr '\011' '-'))
21 netstat -atun | grep -q ":$port\s" ; do
28 echo "Usage: ${0} [options]"
30 echo " -i Run Cypress in interactive mode."
31 echo " -a PATH Arvados dir. If PATH doesn't exist, a repo clone is downloaded there."
32 echo " -w PATH Workbench2 dir. Default: Current working directory"
36 # Allow self-signed certs on 'wait-on'
37 export NODE_TLS_REJECT_UNAUTHORIZED=0
41 ARVADOS_DIR=`mktemp -d`
44 while getopts "ia:w:" o; do
57 echo "Invalid Option: -$OPTARG" 1>&2
64 ARVADOS_LOG=${ARVADOS_DIR}/arvados.log
65 ARVADOS_CONF=${WB2_DIR}/tools/arvados_config.yml
67 if [ ! -f "${WB2_DIR}/src/index.tsx" ]; then
68 echo "ERROR: '${WB2_DIR}' isn't workbench2's directory"
72 if [ ! -f ${ARVADOS_CONF} ]; then
73 echo "ERROR: Arvados config file ${ARVADOS_CONF} not found"
77 if [ -f "${WB2_DIR}/public/config.json" ]; then
78 echo "ERROR: Please move public/config.json file out of the way"
82 if [ ! -d "${ARVADOS_DIR}/.git" ]; then
83 mkdir -p ${ARVADOS_DIR} || exit 1
85 echo "Downloading arvados..."
86 git clone https://git.arvados.org/arvados.git ${ARVADOS_DIR} || exit 1
89 echo "Building & installing arvados-server..."
91 go mod download || exit 1
96 echo "Installing dev dependencies..."
97 ~/go/bin/arvados-server install -type test || exit 1
99 echo "Launching arvados in test mode..."
100 coproc arvboot (~/go/bin/arvados-server boot \
102 -config ${ARVADOS_CONF} \
103 -own-temporary-database \
104 -timeout 20m 2> ${ARVADOS_LOG})
105 trap cleanup ERR EXIT
107 read controllerURL <&"${arvboot[0]}" || exit 1
108 echo "Arvados up and running at ${controllerURL}"
109 IFS='/' ; read -ra controllerHostPort <<< "${controllerURL}" ; unset IFS
110 controllerHostPort=${controllerHostPort[2]}
112 # Copy coproc's stdout to stderr, to ensure `arvados-server boot`
113 # doesn't get blocked trying to write stdout.
114 exec 7<&"${arvboot[0]}"; coproc consume_stdout (cat <&7 >&2)
117 echo "Launching workbench2..."
118 WB2_PORT=`random_free_port`
119 coproc wb2 (PORT=${WB2_PORT} \
120 REACT_APP_ARVADOS_API_HOST=${controllerHostPort} \
122 exec 8<&"${wb2[0]}"; coproc consume_wb2_stdout (cat <&8 >&2)
124 # Wait for workbench2 to be up.
125 # Using https-get to avoid false positive 'ready' detection.
126 yarn run wait-on --timeout 300000 https-get://localhost:${WB2_PORT} || exit 1
128 echo "Running tests..."
129 CYPRESS_system_token=systemusertesttoken1234567890aoeuidhtnsqjkxbmwvzpy \
130 CYPRESS_controller_url=${controllerURL} \
131 CYPRESS_BASE_URL=https://localhost:${WB2_PORT} \
132 yarn run cypress ${CYPRESS_MODE}