keep is now called keepstore
[arvados.git] / jenkins / run-tests.sh
1 #!/bin/bash
2
3 EXITCODE=0
4
5 COLUMNS=80
6
7 ARVADOS_API_HOST=qr1hi.arvadosapi.com
8
9 title () {
10   printf "\n%*s\n\n" $(((${#title}+$COLUMNS)/2)) "********** $1 **********"
11 }
12
13 source /etc/profile.d/rvm.sh
14 echo $WORKSPACE
15
16 export GOPATH=$(mktemp -d)
17 mkdir -p "$GOPATH/src/git.curoverse.com"
18 ln -sfn "$WORKSPACE" "$GOPATH/src/git.curoverse.com/arvados.git"
19
20 VENVDIR=$(mktemp -d)
21 virtualenv --setuptools "$VENVDIR"
22 PATH="$VENVDIR/bin:$PATH"
23
24 # DOCS
25 title "Starting DOC build"
26 cd "$WORKSPACE"
27 cd doc
28 bundle install --deployment
29 rm -rf .site
30 # Make sure python-epydoc is installed or the next line won't do much good!
31 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
32
33 checkexit() {
34     ECODE=$?
35
36     if [[ "$ECODE" != "0" ]]; then
37         title "!!!!!! $1 FAILED !!!!!!"
38         EXITCODE=$(($EXITCODE + $ECODE))
39     fi
40 }
41
42 goget() {
43     go get -t "git.curoverse.com/arvados.git/$1"
44     checkexit "$1 install"
45 }
46
47 gotest() {
48     title "Starting $1 tests"
49     cd "$WORKSPACE"
50
51     go test "git.curoverse.com/arvados.git/$1"
52
53     checkexit "$1 tests"
54     title "$1 tests complete"
55 }
56
57 checkexit "Doc build"
58 title "DOC build complete"
59
60 # DOC linkchecker
61 title "Starting DOC linkchecker"
62 cd "$WORKSPACE"
63 cd doc
64 bundle exec rake linkchecker baseurl=file://$WORKSPACE/doc/.site/
65
66 checkexit "Doc linkchecker"
67 title "DOC linkchecker complete"
68
69 # API SERVER
70 title "Starting API server tests"
71 cd "$WORKSPACE"
72 cd services/api
73 bundle install --deployment
74
75 rm -f config/database.yml
76 rm -f config/environments/test.rb
77 cp config/environments/test.rb.example config/environments/test.rb
78
79 # Get test database config
80 cp $HOME/arvados-api-server/database.yml config/
81 # Get test application.yml file
82 cp $HOME/arvados-api-server/application.yml config/
83
84 # Fill in a random secret_token and blob_signing_key for testing
85 SECRET_TOKEN=`echo 'puts rand(2**512).to_s(36)' |ruby`
86 BLOB_SIGNING_KEY=`echo 'puts rand(2**512).to_s(36)' |ruby`
87
88 sed -i'' -e "s:SECRET_TOKEN:$SECRET_TOKEN:" config/application.yml
89 sed -i'' -e "s:BLOB_SIGNING_KEY:$BLOB_SIGNING_KEY:" config/application.yml
90
91 export RAILS_ENV=test
92
93 # Set up empty git repo (for git tests)
94 GITDIR=$WORKSPACE/tmpgit
95 rm -rf $GITDIR
96 mkdir $GITDIR
97 sed -i'' -e "s:/var/cache/git:$GITDIR:" config/application.default.yml
98
99 rm -rf $GITDIR
100 mkdir -p $GITDIR/test
101 cd $GITDIR/test
102 /usr/bin/git init
103 /usr/bin/git config user.email "jenkins@ci.curoverse.com"
104 /usr/bin/git config user.name "Jenkins, CI"
105 touch tmp
106 /usr/bin/git add tmp
107 /usr/bin/git commit -m 'initial commit'
108
109 cd "$WORKSPACE"
110 cd services/api
111
112 bundle exec rake db:drop
113 bundle exec rake db:create
114 bundle exec rake db:setup
115 bundle exec rake test
116
117 checkexit "API server tests"
118 title "API server tests complete"
119
120 # Install CLI gem's dependencies.
121
122 cd "$WORKSPACE/sdk/cli"
123 bundle install --deployment
124
125 cd "$WORKSPACE"
126 gostuff="services/keepstore services/keepproxy sdk/go/arvadosclient sdk/go/keepclient sdk/go/streamer"
127 for dir in $gostuff
128 do
129   goget "$dir"
130 done
131
132 # Install the Python SDK early. Various other test suites (like
133 # keepproxy) bring up run_test_server.py, which imports the arvados
134 # module. We can't actually *test* the Python SDK yet though, because
135 # its own test suite brings up some of those other programs (like
136 # keepproxy).
137
138 cd "$WORKSPACE/sdk/python"
139 python setup.py egg_info -b ".$(git log --format=format:%ct.%h -n1 .)" sdist rotate --keep=1 --match .tar.gz
140 pip install dist/arvados-python-client-0.1.*.tar.gz
141
142 checkexit "Python SDK install"
143
144 cd "$WORKSPACE/services/fuse"
145 python setup.py egg_info -b ".$(git log --format=format:%ct.%h -n1 .)" sdist rotate --keep=1 --match .tar.gz
146 pip install dist/arvados_fuse-0.1.*.tar.gz
147
148 checkexit "FUSE install"
149
150 # Python SDK. We test this before testing keepproxy: keepproxy runs
151 # run_test_server.py, which depends on the yaml package, which is in
152 # tests_require but not install_requires, and therefore does not get
153 # installed by setuptools until we run "setup.py test" *and* install
154 # the .egg files that setup.py downloads.
155
156 title "Starting Python SDK tests"
157 cd "$WORKSPACE/sdk/python"
158
159 python setup.py test
160 checkexit "Python SDK tests"
161 easy_install *.egg
162
163 title "Python tests complete"
164
165 # FUSE driver
166
167 title "Starting FUSE tests"
168 cd "$WORKSPACE/services/fuse"
169
170 python setup.py test
171 checkexit "FUSE tests"
172 easy_install *.egg
173
174 title "FUSE tests complete"
175
176
177 # Go SDK packages
178
179 for dir in $gostuff
180 do
181   gotest "$dir"
182 done
183
184 # Workbench
185 title "Starting workbench tests"
186 cd "$WORKSPACE"
187 cd apps/workbench
188 bundle install --deployment
189
190 echo $PATH
191
192 bundle exec rake test
193
194 checkexit "Workbench tests"
195 title "Workbench tests complete"
196
197 # Clean up temporary virtualenv and GOPATH
198 rm -rf "$VENVDIR"
199 rm -rf "$GOPATH"
200
201 # The CLI SDK tests require a working API server, so let's skip those for now.
202 exit $EXITCODE
203
204 ########################################################################
205
206 # CLI SDK
207 title "Starting SDK CLI tests"
208 cd "$WORKSPACE"
209 cd sdk/cli
210 bundle install --deployment
211
212 # Set up Python SDK and dependencies
213 cd ../python
214 rm -rf $HOME/lib/python
215 mkdir $HOME/lib/python
216 PYTHONPATH="$HOME/lib/python" easy_install --install-dir=$HOME/lib/python --upgrade google-api-python-client
217 PYTHONPATH="$HOME/lib/python" python setup.py install --home=$HOME
218
219 cd ../cli
220 mkdir -p /tmp/keep
221 export KEEP_LOCAL_STORE=/tmp/keep
222 PYTHONPATH="$HOME/lib/python" bundle exec rake test
223
224 checkexit "SDK CLI tests"
225 title "SDK CLI tests complete"
226
227 exit $EXITCODE