forked from JanusGraph/janusgraph-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-image.sh
executable file
·55 lines (46 loc) · 1.35 KB
/
test-image.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
#
# Copyright 2019 JanusGraph Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -eu
IMAGE=$1
if [ -z "${IMAGE:-}" ]; then
echo "usage: test-image.sh image-name"
exit 1
fi
echo "Testing ${IMAGE}..."
ID=$(docker run --rm -d \
--health-cmd='./bin/gremlin.sh -e scripts/remote-connect.groovy' \
--health-interval=10s \
--health-retries=5 \
--health-start-period=10s \
${IMAGE})
for i in $(seq 1 10); do
res=$(docker ps --filter "id=$ID" --filter "health=healthy" -q)
if [ -z "${res:-}" ]; then
status=1
sleep 10
continue
fi
status=0
break
done
if [ -z "${res:-}" ]; then
echo "Timeout waiting for health check:"
res=$(docker inspect --format "{{json .State.Health }}" $ID)
# pretty print last output with jq if available
echo $res | jq --raw-output '.[-1].Output' || echo $res
fi
docker stop $ID
exit $status