3 # Install and test Arvados components.
5 # Exit non-zero if any tests fail.
8 # --skip FOO Do not test the FOO component.
9 # --only FOO Do not test anything except the FOO component.
10 # envvar=value Set $envvar to value
12 # Regardless of which components are tested, install all components in
13 # the usual sequence. (Many test suites depend on other components
16 # Useful environment variables include $workbench_test, $apiserver_test and
17 # $cli_test. To run a specific test, use a command line such as:
19 # $ ./run-tests.sh --only workbench workbench_test=TEST=test/integration/pipeline_instances_test.rb
22 # First make sure to remove any ARVADOS_ variables from the calling environment
23 # that could interfer with the tests.
24 unset $(env | cut -d= -f1 | grep \^ARVADOS_)
28 export GOPATH=$(mktemp -d)
34 source /etc/profile.d/rvm.sh
38 echo >&2 "Fatal: $* in ${FUNCNAME[1]} at ${BASH_SOURCE[1]} line ${BASH_LINENO[0]}"
43 echo "WORKSPACE=$WORKSPACE"
44 [[ -n "$WORKSPACE" ]] || fatal "WORKSPACE not set"
46 # Set up temporary install dirs
47 mkdir -p "$GOPATH/src/git.curoverse.com"
48 ln -sfn "$WORKSPACE" "$GOPATH/src/git.curoverse.com/arvados.git" \
49 || fatal "symlink failed"
51 virtualenv --setuptools "$VENVDIR" || fatal "virtualenv $VENVDIR failed"
52 PATH="$VENVDIR/bin:$PATH"
57 # Always skip CLI tests. They don't know how to use run_test_server.py.
81 echo >&2 "$0: Unrecognized option: '$arg'"
88 if [[ "$?" != "0" ]]; then
89 title "!!!!!! $1 FAILED !!!!!!"
90 failures+=("$1 (`timer`)")
92 successes+=("$1 (`timer`)")
101 echo -n "$(($SECONDS - $t0))s"
105 if [[ -z "${skip[$1]}" ]] && ( [[ -z "$only" ]] || [[ "$only" == "$1" ]] )
107 title "Running $1 tests"
109 if [[ "$2" == "go" ]]
111 go test "git.curoverse.com/arvados.git/$1"
116 title "End of $1 tests (`timer`)"
118 title "Skipping $1 tests"
123 if [[ -z "$skip_install" ]]
125 title "Running $1 install"
127 if [[ "$2" == "go" ]]
129 go get -t "git.curoverse.com/arvados.git/$1"
133 checkexit "$1 install"
134 title "End of $1 install (`timer`)"
136 title "Skipping $1 install"
141 txt="********** $1 **********"
142 printf "\n%*s%s\n\n" $((($COLUMNS-${#txt})/2)) "" "$txt"
146 for t in "$VENVDIR" "$GOPATH"
148 if [[ -n "$t" && -z "$leave-temp" ]]
159 bundle install --deployment
161 # Make sure python-epydoc is installed or the next line won't do much good!
162 ARVADOS_API_HOST=qr1hi.arvadosapi.com
163 PYTHONPATH=$WORKSPACE/sdk/python/ bundle exec rake generate baseurl=file://$WORKSPACE/doc/.site/ arvados_workbench_host=workbench.$ARVADOS_API_HOST arvados_api_host=$ARVADOS_API_HOST
164 unset ARVADOS_API_HOST
168 test_doclinkchecker() {
170 bundle exec rake linkchecker baseurl=file://$WORKSPACE/doc/.site/
172 do_test doclinkchecker
174 install_apiserver() {
175 cd "$WORKSPACE/services/api"
176 bundle install --deployment
178 rm -f config/environments/test.rb
179 cp config/environments/test.rb.example config/environments/test.rb
181 cp $HOME/arvados-api-server/database.yml config/ || fatal "database.yml"
182 cp $HOME/arvados-api-server/application.yml config/ || fatal "application.yml"
184 # Fill in a random secret_token and blob_signing_key for testing
185 SECRET_TOKEN=`echo 'puts rand(2**512).to_s(36)' |ruby`
186 BLOB_SIGNING_KEY=`echo 'puts rand(2**512).to_s(36)' |ruby`
188 sed -i'' -e "s:SECRET_TOKEN:$SECRET_TOKEN:" config/application.yml
189 sed -i'' -e "s:BLOB_SIGNING_KEY:$BLOB_SIGNING_KEY:" config/application.yml
191 export RAILS_ENV=test
193 # Set up empty git repo (for git tests)
194 GITDIR="$WORKSPACE/tmpgit"
195 sed -i'' -e "s:/var/cache/git:$GITDIR:" config/application.default.yml
198 mkdir -p $GITDIR/test
201 && git config user.email "jenkins@ci.curoverse.com" \
202 && git config user.name "Jenkins, CI" \
205 && git commit -m 'initial commit'
207 cd "$WORKSPACE/services/api" \
208 && bundle exec rake db:drop \
209 && bundle exec rake db:create \
210 && bundle exec rake db:setup
215 cd "$WORKSPACE/services/api"
216 bundle exec rake test $apiserver_test
221 cd "$WORKSPACE/sdk/cli"
222 bundle install --deployment
234 for g in "${gostuff[@]}"
239 install_python_sdk() {
240 # Install the Python SDK early. Various other test suites (like
241 # keepproxy) bring up run_test_server.py, which imports the arvados
242 # module. We can't actually *test* the Python SDK yet though, because
243 # its own test suite brings up some of those other programs (like
246 cd "$WORKSPACE/sdk/python" \
247 && python setup.py egg_info -b ".$(git log --format=format:%ct.%h -n1 .)" sdist rotate --keep=1 --match .tar.gz \
248 && pip install dist/arvados-python-client-0.1.*.tar.gz
250 do_install python_sdk
253 cd "$WORKSPACE/services/fuse" \
254 && python setup.py egg_info -b ".$(git log --format=format:%ct.%h -n1 .)" sdist rotate --keep=1 --match .tar.gz \
255 && pip install dist/arvados_fuse-0.1.*.tar.gz
260 # Python SDK. We test this before testing keepproxy: keepproxy runs
261 # run_test_server.py, which depends on the yaml package, which is in
262 # tests_require but not install_requires, and therefore does not get
263 # installed by setuptools until we run "setup.py test" *and* install
264 # the .egg files that setup.py downloads.
266 cd "$WORKSPACE/sdk/python" \
267 && python setup.py test
275 # Install test dependencies here too, in case run_test_server needs them.
276 cd "$WORKSPACE/services/fuse" \
277 && python setup.py test
284 for g in "${gostuff[@]}"
290 cd "$WORKSPACE/apps/workbench" \
291 && bundle install --deployment \
292 && bundle exec rake test $workbench_test
297 title "Starting SDK CLI tests"
298 cd "$WORKSPACE/sdk/cli" \
299 && bundle install --deployment \
300 && mkdir -p /tmp/keep \
301 && KEEP_LOCAL_STORE=/tmp/keep bundle exec rake test $cli_test
307 for x in "${successes[@]}"
312 if [[ ${#failures[@]} == 0 ]]
314 echo "All test suites passed."
316 echo "Failures (${#failures[@]}):"
317 for x in "${failures[@]}"