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
44 while getopts "ia:w:" o; do
57 echo "Invalid Option: -$OPTARG" 1>&2
64 if [ "${ARVADOS_DIR}" = "unset" ]; then
65 echo "ARVADOS_DIR is unset, creating a temporary directory for new checkout"
66 ARVADOS_DIR=`mktemp -d`
69 echo "ARVADOS_DIR is ${ARVADOS_DIR}"
71 ARVADOS_LOG=${ARVADOS_DIR}/arvados.log
72 ARVADOS_CONF=${WB2_DIR}/tools/arvados_config.yml
73 VOCABULARY_CONF=${WB2_DIR}/tools/example-vocabulary.json
75 if [ ! -f "${WB2_DIR}/src/index.tsx" ]; then
76 echo "ERROR: '${WB2_DIR}' isn't workbench2's directory"
80 if [ ! -f ${ARVADOS_CONF} ]; then
81 echo "ERROR: Arvados config file ${ARVADOS_CONF} not found"
85 if [ -f "${WB2_DIR}/public/config.json" ]; then
86 echo "ERROR: Please move public/config.json file out of the way"
90 if [ ! -d "${ARVADOS_DIR}/.git" ]; then
91 mkdir -p ${ARVADOS_DIR} || exit 1
93 echo "Downloading arvados..."
94 git clone https://git.arvados.org/arvados.git ${ARVADOS_DIR} || exit 1
97 echo "Building & installing arvados-server..."
99 go mod download || exit 1
100 cd cmd/arvados-server
104 echo "Installing dev dependencies..."
105 ~/go/bin/arvados-server install -type test || exit 1
107 echo "Launching arvados in test mode..."
108 TMPSUBDIR=$(mktemp -d -p /tmp | cut -d \/ -f3) # Removes the /tmp/ part for the regex below
109 TMPDIR=/tmp/${TMPSUBDIR}
110 cp ${VOCABULARY_CONF} ${TMPDIR}/voc.json
111 cp ${ARVADOS_CONF} ${TMPDIR}/arvados.yml
112 sed -i "s/VocabularyPath: \".*\"/VocabularyPath: \"\/tmp\/${TMPSUBDIR}\/voc.json\"/" ${TMPDIR}/arvados.yml
113 coproc arvboot (~/go/bin/arvados-server boot \
115 -config ${TMPDIR}/arvados.yml \
117 -own-temporary-database \
118 -timeout 20m 2> ${ARVADOS_LOG})
119 trap cleanup ERR EXIT
121 read controllerInfo <&"${arvboot[0]}" || exit 1
122 controllerURL=`echo "$controllerInfo" | awk '{print $1;}'`;
123 echo "Arvados up and running at ${controllerURL}"
124 IFS='/' ; read -ra controllerHostPort <<< "${controllerURL}" ; unset IFS
125 controllerHostPort=${controllerHostPort[2]}
127 # Copy coproc's stdout to stderr, to ensure `arvados-server boot`
128 # doesn't get blocked trying to write stdout.
129 exec 7<&"${arvboot[0]}"; coproc consume_stdout (cat <&7 >&2)
132 echo "Launching workbench2..."
133 WB2_PORT=`random_free_port`
134 coproc wb2 (PORT=${WB2_PORT} \
135 REACT_APP_ARVADOS_API_HOST=${controllerHostPort} \
137 exec 8<&"${wb2[0]}"; coproc consume_wb2_stdout (cat <&8 >&2)
139 # Wait for workbench2 to be up.
140 # Using https-get to avoid false positive 'ready' detection.
141 yarn run wait-on --timeout 300000 https-get://localhost:${WB2_PORT} || exit 1
143 echo "Running tests..."
144 CYPRESS_system_token=systemusertesttoken1234567890aoeuidhtnsqjkxbmwvzpy \
145 CYPRESS_controller_url=${controllerURL} \
146 CYPRESS_BASE_URL=https://localhost:${WB2_PORT} \
147 yarn run cypress ${CYPRESS_MODE}