Skip to content

Commit 846684b

Browse files
committed
travis tweaks continued
1 parent aaa9dfa commit 846684b

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ subprojects {
1818
test{
1919
testLogging{
2020
events 'started','passed', 'skipped', 'failed'
21+
exceptionFormat 'full'
2122
}
2223
}
2324

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,51 @@
11
#!/bin/bash
22

3+
#######################################################
4+
# taken from https://github.com/grtjn/mlvagrant/blob/master/opt/vagrant/setup-ml-master.sh
5+
#
6+
# restart_check(baseline_timestamp, caller_lineno)
7+
#
8+
# Use the timestamp service to detect a server restart, given a
9+
# a baseline timestamp. Use N_RETRY and RETRY_INTERVAL to tune
10+
# the test length. Include authentication in the curl command
11+
# so the function works whether or not security is initialized.
12+
# $1 : The baseline timestamp
13+
# $2 : Invokers LINENO, for improved error reporting
14+
# Returns 0 if restart is detected, exits with an error if not.
15+
#
16+
function restart_check {
17+
echo "Restart check for localhost..."
18+
LAST_START=`$AUTH_CURL --max-time 1 -s "http://localhost:8001/admin/v1/timestamp"`
19+
for i in `seq 1 ${N_RETRY}`; do
20+
# continue as long as timestamp didn't change, or no output was returned
21+
if [ "$1" == "$LAST_START" ] || [ "$LAST_START" == "" ]; then
22+
sleep ${RETRY_INTERVAL}
23+
echo "Retrying..."
24+
LAST_START=`$AUTH_CURL --max-time 1 -s "http://localhost:8001/admin/v1/timestamp"`
25+
else
26+
return 0
27+
fi
28+
done
29+
echo "ERROR: Line $2: Failed to restart localhost"
30+
exit 1
31+
}
32+
333
sudo /etc/init.d/MarkLogic start
434
sleep 30
535
curl -X POST -d "" http://localhost:8001/admin/v1/init
636
sleep 30
7-
curl -X POST -H "Content-type: application/x-www-form-urlencoded" \
37+
38+
TIMESTAMP=`curl -X POST \
39+
-H "Content-type: application/x-www-form-urlencoded" \
840
--data "admin-username=admin" \
941
--data "admin-password=admin" \
1042
--data "realm=public" \
11-
"http://localhost:8001/admin/v1/instance-admin"
12-
sleep 30
43+
"http://localhost:8001/admin/v1/instance-admin" \
44+
| grep "last-startup" \
45+
| sed 's%^.*<last-startup.*>\(.*\)</last-startup>.*$%\1%'`
46+
if [ "$TIMESTAMP" == "" ]; then
47+
echo "ERROR: Failed to get instance-admin timestamp." >&2
48+
exit 1
49+
fi
50+
51+
restart_check $TIMESTAMP $LINENO

0 commit comments

Comments
 (0)