diff options
author | drebs <drebs@leap.se> | 2016-06-06 20:34:03 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2016-06-06 21:40:44 -0300 |
commit | 7ee12a38d6e8230525f3401abdbd3def4d81502b (patch) | |
tree | 47d843c1081e71f14df4a2129e8a560c3e4d0fe9 /scripts/docker/helper/run-tests.sh | |
parent | f25dc033f9456ea82be5330fe9a3e5145a78f361 (diff) |
[test] add rule and script to run soledad connection test
Diffstat (limited to 'scripts/docker/helper/run-tests.sh')
-rwxr-xr-x | scripts/docker/helper/run-tests.sh | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/scripts/docker/helper/run-tests.sh b/scripts/docker/helper/run-tests.sh index cee90f6b..bcd7a565 100755 --- a/scripts/docker/helper/run-tests.sh +++ b/scripts/docker/helper/run-tests.sh @@ -1,6 +1,48 @@ #!/bin/sh +# Run 2 docker images, one with soledad server and another with a soledad +# client running the tests. +# +# After launching the server, the script waits for TIMEOUT seconds for it to +# come up. If we fail to detect the server, the script exits with nonzero +# status. + + +# seconds to wait before giving up waiting from server +TIMEOUT=20 + +# some info from this script +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") + +# run the server tempfile=`mktemp -u` make run-server CONTAINER_ID_FILE=${tempfile} -sleep 5 + +# get server container info +container_id=`cat ${tempfile}` +server_ip=`${SCRIPTPATH}/get-container-ip.sh ${container_id}` + +# wait for server until timeout +start=`date +%s` +elapsed=0 + +while [ ${elapsed} -lt ${TIMEOUT} ]; do + result=`curl http://${server_ip}:2424` + if [ ${?} -eq 0 ]; then + break + else + sleep 1 + fi + now=`date +%s` + elapsed=`expr ${now} - ${start}` +done + +# exit with an error code if timed out waiting for server +if [ ${elapsed} -ge ${TIMEOUT} ]; then + echo "Error: server unreacheble at ${server_ip} after ${TIMEOUT} seconds." + exit 1 +fi + +# run the client make run-client-test CONTAINER_ID_FILE=${tempfile} |