@@ -186,15 +186,48 @@ jobs:
186
186
- attach_workspace :
187
187
at : ~/
188
188
- run :
189
- name : Initialize REST tests
190
- command : ssh lightsail 'cd tator && make testinit'
189
+ name : Install xmlstarlet
190
+ command : sudo apt-get update && sudo apt-get install -y xmlstarlet
191
191
- run :
192
192
name : Run REST tests
193
193
command : |
194
- mkdir -p rest-test-results;
195
- ssh lightsail 'cd tator && for i in $(seq 1 3); do make rq-empty && make test && break || sleep 10; done;';
196
- ssh lightsail 'test -e tator/rest-junit.xml' && scp lightsail:tator/rest-junit.xml rest-test-results/ || exit 0;
197
- grep -q -E '\b[1-9][0-9]*\s+failed\b' rest-test-results/rest-junit.xml && exit 1 || exit 0;
194
+ # Disable exit-on-error to allow all commands to run
195
+ set +e
196
+
197
+ # Create directory for test results
198
+ mkdir -p rest-test-results
199
+
200
+ # Run test initialization
201
+ ssh -o "StrictHostKeyChecking=no" -o "ConnectTimeout=10" lightsail 'cd tator && make testinit'
202
+
203
+ # Run tests and capture exit status
204
+ ssh -o "StrictHostKeyChecking=no" -o "ConnectTimeout=10" lightsail 'cd tator && make rq-empty && make test'
205
+ TEST_EXIT_STATUS=$?
206
+
207
+ # Always attempt to copy the XML file
208
+ ssh -o "StrictHostKeyChecking=no" -o "ConnectTimeout=10" lightsail 'test -e tator/rest-junit.xml' && \
209
+ scp lightsail:tator/rest-junit.xml rest-test-results/ || echo "No test results found"
210
+
211
+ # Check if XML file was copied
212
+ if [ -f rest-test-results/rest-junit.xml ]; then
213
+ # Parse XML for failures or errors
214
+ FAILURES=$(xmlstarlet sel -t -v "//testsuite/@failures" rest-test-results/rest-junit.xml)
215
+ ERRORS=$(xmlstarlet sel -t -v "//testsuite/@errors" rest-test-results/rest-junit.xml)
216
+
217
+ if [ "$FAILURES" -gt 0 ] || [ "$ERRORS" -gt 0 ]; then
218
+ echo "Test failures or errors detected"
219
+ exit 1
220
+ else
221
+ echo "All tests passed"
222
+ exit 0
223
+ fi
224
+ else
225
+ echo "No test results found"
226
+ if [ $TEST_EXIT_STATUS -ne 0 ]; then
227
+ echo "Tests failed to run"
228
+ fi
229
+ exit 1
230
+ fi
198
231
- store_test_results :
199
232
path : rest-test-results
200
233
front-end-tests :
@@ -209,20 +242,38 @@ jobs:
209
242
rsync -a --ignore-existing /home/circleci/.ssh/ lightsail:/home/ubuntu/.ssh/;
210
243
ssh lightsail 'sed -i "s/circleci/ubuntu/g" ~/.ssh/config';
211
244
- run :
212
- name : Install sshfs
213
- command : sudo -E apt-get update && sudo -E apt-get -yq --no-install-suggests --no-install-recommends install sshfs
245
+ name : Install sshfs and xmlstarlet
246
+ command : sudo -E apt-get update && sudo -E apt-get -yq --no-install-suggests --no-install-recommends install sshfs xmlstarlet
214
247
- run :
215
248
name : Front end tests
216
249
no_output_timeout : 30m
217
250
command : |
218
- ssh lightsail 'cd tator && make rq-empty';
219
- mkdir -p /tmp/videos;
220
- mkdir -p frontend-test-results;
221
- ssh lightsail 'mkdir -p /tmp/videos';
222
- sshfs -o default_permissions lightsail:/tmp/videos /tmp/videos;
223
- ssh lightsail 'mkdir -p /tmp/videos && export PATH=$PATH:$HOME/.local/bin:/snap/bin && export PYTHONUNBUFFERED=1 && cd tator && for i in $(seq 1 1); do if [ -d "test-results" ]; then rm -f test-results/*; else mkdir -p test-results; fi; python3 scripts/test_support/pytest_parallel.py --num-workers 3 test -n 2 --keep --base-url=http://localhost:8080 --browser=chromium --username=admin --password=admin --videos=/tmp/videos -s --junitxml=test-results/frontend-junit.xml && break || sleep 10; done;';
224
- ssh lightsail 'test -e tator/test-results/frontend-junit.xml' && scp lightsail:tator/test-results/frontend-junit.xml frontend-test-results/ || exit 0;
225
- grep -q -E '\b[1-9][0-9]*\s+failed\b' frontend-test-results/frontend-junit.xml && exit 1 || exit 0;
251
+ set +e # Disable exit on error to ensure all commands run
252
+ ssh lightsail 'cd tator && make rq-empty'
253
+ mkdir -p /tmp/videos
254
+ mkdir -p frontend-test-results
255
+ ssh lightsail 'mkdir -p /tmp/videos'
256
+ sshfs -o default_permissions lightsail:/tmp/videos /tmp/videos
257
+ ssh lightsail 'export PATH=$PATH:$HOME/.local/bin:/snap/bin && export PYTHONUNBUFFERED=1 && cd tator && if [ -d "test-results" ]; then rm -f test-results/*; else mkdir -p test-results; fi; python3 scripts/test_support/pytest_parallel.py --num-workers 3 test -n 2 --keep --base-url=http://localhost:8080 --browser=chromium --username=admin --password=admin --videos=/tmp/videos -s --junitxml=test-results/frontend-junit.xml'
258
+ TEST_EXIT_STATUS=$?
259
+ ssh lightsail 'test -e tator/test-results/frontend-junit.xml' && scp lightsail:tator/test-results/frontend-junit.xml frontend-test-results/ || echo "No test results found"
260
+ if [ -f frontend-test-results/frontend-junit.xml ]; then
261
+ FAILURES=$(xmlstarlet sel -t -v "//testsuite/@failures" frontend-test-results/frontend-junit.xml)
262
+ ERRORS=$(xmlstarlet sel -t -v "//testsuite/@errors" frontend-test-results/frontend-junit.xml)
263
+ if [ "$FAILURES" -gt 0 ] || [ "$ERRORS" -gt 0 ]; then
264
+ echo "Test failures or errors detected"
265
+ exit 1
266
+ else
267
+ echo "All tests passed"
268
+ exit 0
269
+ fi
270
+ else
271
+ echo "No test results found"
272
+ if [ $TEST_EXIT_STATUS -ne 0 ]; then
273
+ echo "Tests failed to run"
274
+ fi
275
+ exit 1
276
+ fi
226
277
- store_test_results :
227
278
path : frontend-test-results
228
279
- store_artifacts :
@@ -235,22 +286,43 @@ jobs:
235
286
steps :
236
287
- attach_workspace :
237
288
at : ~/
289
+ - run :
290
+ name : Install xmlstarlet
291
+ command : sudo apt-get update && sudo apt-get install -y xmlstarlet
238
292
- run :
239
293
name : Copy test directories
240
294
command : |
241
295
ssh lightsail 'rm -rf ~/tator/tatorpy_test && cp -r ~/tator/scripts/packages/tator-py/test ~/tator/tatorpy_test && cp -r ~/tator/scripts/packages/tator-py/examples ~/tator/.';
242
296
- run :
243
297
name : Get API token
244
298
command : |
245
- ssh lightsail "curl -d '{"'" username"'": "'" admin"'", "'" password"'": "'" admin"'", "'" refresh"' ": true}' -H 'Content-Type: application/json' http://localhost:8080/rest/Token | jq '.token' | xargs printf '%b\n' | tee ~/token.txt;"
299
+ ssh lightsail "curl -d '{\" username\": \" admin\", \" password\": \" admin\", \" refresh\ ": true}' -H 'Content-Type: application/json' http://localhost:8080/rest/Token | jq '.token' | xargs printf '%b\n' | tee ~/token.txt;"
246
300
scp lightsail:~/token.txt ~/token.txt
247
301
- run :
248
302
name : Run tator-py tests
249
303
command : |
250
- mkdir -p tatorpy-test-results;
251
- ssh lightsail 'export TATOR_TOKEN='"'$(cat ~/token.txt)'"'; export TATOR_HOST=http://localhost:8080; export PATH=$PATH:$HOME/.local/bin:/snap/bin && cd tator && for i in $(seq 1 3); do if [ -d "test-results" ]; then rm -f test-results/*; else mkdir -p test-results; fi; pytest tatorpy_test --run-alt-bucket --ignore tatorpy_test/test_algorithm_launch.py --ignore tatorpy_test/test_job_cancel.py --ignore tatorpy_test/test_hosted_template.py -s --keep --junitxml=test-results/tatorpy-junit.xml && break || sleep 10; done;';
252
- ssh lightsail 'test -e tator/test-results/tatorpy-junit.xml' && scp lightsail:tator/test-results/tatorpy-junit.xml tatorpy-test-results/ || exit 0;
253
- grep -q -E '\b[1-9][0-9]*\s+failed\b' tatorpy-test-results/tatorpy-junit.xml && exit 1 || exit 0;
304
+ set +e # Disable exit on error to ensure all commands run
305
+ mkdir -p tatorpy-test-results
306
+ ssh lightsail 'export TATOR_TOKEN='"'$(cat ~/token.txt)'"'; export TATOR_HOST=http://localhost:8080; export PATH=$PATH:$HOME/.local/bin:/snap/bin && cd tator && if [ -d "test-results" ]; then rm -f test-results/*; else mkdir -p test-results; fi; pytest tatorpy_test --run-alt-bucket --ignore tatorpy_test/test_algorithm_launch.py --ignore tatorpy_test/test_job_cancel.py --ignore tatorpy_test/test_hosted_template.py -s --keep --junitxml=test-results/tatorpy-junit.xml'
307
+ TEST_EXIT_STATUS=$?
308
+ ssh lightsail 'test -e tator/test-results/tatorpy-junit.xml' && scp lightsail:tator/test-results/tatorpy-junit.xml tatorpy-test-results/ || echo "No test results found"
309
+ if [ -f tatorpy-test-results/tatorpy-junit.xml ]; then
310
+ FAILURES=$(xmlstarlet sel -t -v "//testsuite/@failures" tatorpy-test-results/tatorpy-junit.xml)
311
+ ERRORS=$(xmlstarlet sel -t -v "//testsuite/@errors" tatorpy-test-results/tatorpy-junit.xml)
312
+ if [ "$FAILURES" -gt 0 ] || [ "$ERRORS" -gt 0 ]; then
313
+ echo "Test failures or errors detected"
314
+ exit 1
315
+ else
316
+ echo "All tests passed"
317
+ exit 0
318
+ fi
319
+ else
320
+ echo "No test results found"
321
+ if [ $TEST_EXIT_STATUS -ne 0 ]; then
322
+ echo "Tests failed to run"
323
+ fi
324
+ exit 1
325
+ fi
254
326
- store_test_results :
255
327
path : tatorpy-test-results
256
328
- run :
0 commit comments