From 8f5259b6ce218f8ffeec57fc04cb5c2b782bd959 Mon Sep 17 00:00:00 2001 From: drebs Date: Wed, 8 Jun 2016 17:52:59 -0300 Subject: [test] add docker perf tests --- scripts/docker/helper/run-test.sh | 67 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 scripts/docker/helper/run-test.sh (limited to 'scripts/docker/helper/run-test.sh') diff --git a/scripts/docker/helper/run-test.sh b/scripts/docker/helper/run-test.sh new file mode 100755 index 00000000..5fd6e4f0 --- /dev/null +++ b/scripts/docker/helper/run-test.sh @@ -0,0 +1,67 @@ +#!/bin/sh + +# Run 2 docker images, one with soledad server and another with a soledad +# client running a test. +# +# As there are many possible, tests, you have to pass an argument to the +# script saying which test you want to run. Currently, possible values are +# "connect" and "perf". +# +# After launching the server container, 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 + +# get a test +if [ ${#} -ne 1 ]; then + "Usage: ${0} [perf|connect]" + exit 1 +fi + +TEST=${1} + +# get script name and path +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") + +# run the server +tempfile=`mktemp -u` +make run-server CONTAINER_ID_FILE=${tempfile} + +# 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 + +echo "Waiting for soledad server container to come up..." + +while [ ${elapsed} -lt ${TIMEOUT} ]; do + result=`curl -s http://${server_ip}:2424` + if [ ${?} -eq 0 ]; then + echo "Soledad server container is up!" + 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 unreachable at ${server_ip} after ${TIMEOUT} seconds." + exit 1 +fi + +# run the client +if [ "${TEST}" = "connect" ]; then + make run-client-test CONTAINER_ID_FILE=${tempfile} +elif [ "${TEST}" = "perf" ]; then + make run-perf-test CONTAINER_ID_FILE=${tempfile} + make cp-perf-result CONTAINER_ID_FILE=${tempfile} +fi -- cgit v1.2.3 From 5703d30d1789caa5705ed66f98a5b2f2dda78475 Mon Sep 17 00:00:00 2001 From: drebs Date: Fri, 10 Jun 2016 14:38:10 -0300 Subject: [test] update docker image before test --- scripts/docker/helper/run-test.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'scripts/docker/helper/run-test.sh') diff --git a/scripts/docker/helper/run-test.sh b/scripts/docker/helper/run-test.sh index 5fd6e4f0..0a2d6b6b 100755 --- a/scripts/docker/helper/run-test.sh +++ b/scripts/docker/helper/run-test.sh @@ -20,11 +20,14 @@ if [ ${#} -ne 1 ]; then exit 1 fi -TEST=${1} +test=${1} + +# make sure the image is up to date +make image # get script name and path -SCRIPT=$(readlink -f "$0") -SCRIPTPATH=$(dirname "$SCRIPT") +script=$(readlink -f "$0") +scriptpath=$(dirname "${script}") # run the server tempfile=`mktemp -u` @@ -32,7 +35,7 @@ make run-server CONTAINER_ID_FILE=${tempfile} # get server container info container_id=`cat ${tempfile}` -server_ip=`${SCRIPTPATH}/get-container-ip.sh ${container_id}` +server_ip=`${scriptpath}/get-container-ip.sh ${container_id}` # wait for server until timeout start=`date +%s` @@ -41,7 +44,7 @@ elapsed=0 echo "Waiting for soledad server container to come up..." while [ ${elapsed} -lt ${TIMEOUT} ]; do - result=`curl -s http://${server_ip}:2424` + curl -s http://${server_ip}:2424 > /dev/null if [ ${?} -eq 0 ]; then echo "Soledad server container is up!" break @@ -58,10 +61,12 @@ if [ ${elapsed} -ge ${TIMEOUT} ]; then exit 1 fi +set -e + # run the client -if [ "${TEST}" = "connect" ]; then +if [ "${test}" = "connect" ]; then make run-client-test CONTAINER_ID_FILE=${tempfile} -elif [ "${TEST}" = "perf" ]; then +elif [ "${test}" = "perf" ]; then make run-perf-test CONTAINER_ID_FILE=${tempfile} make cp-perf-result CONTAINER_ID_FILE=${tempfile} fi -- cgit v1.2.3 From e14f17247ce03f1c49cab3c944039ff9aba84f64 Mon Sep 17 00:00:00 2001 From: drebs Date: Fri, 10 Jun 2016 18:07:27 -0300 Subject: [test] improve docker run-test script --- scripts/docker/helper/run-test.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'scripts/docker/helper/run-test.sh') diff --git a/scripts/docker/helper/run-test.sh b/scripts/docker/helper/run-test.sh index 0a2d6b6b..1b0e3db7 100755 --- a/scripts/docker/helper/run-test.sh +++ b/scripts/docker/helper/run-test.sh @@ -14,14 +14,19 @@ # seconds to wait before giving up waiting from server TIMEOUT=20 -# get a test +# parse command if [ ${#} -ne 1 ]; then - "Usage: ${0} [perf|connect]" + echo "Usage: ${0} perf|connect" exit 1 fi test=${1} +if [ "${1}" != "perf" -a "${1}" != "perf" ]; then + echo "Usage: ${0} perf|connect" + exit 1 +fi + # make sure the image is up to date make image @@ -33,11 +38,9 @@ scriptpath=$(dirname "${script}") tempfile=`mktemp -u` make run-server CONTAINER_ID_FILE=${tempfile} -# get server container info +# wait for server until timeout container_id=`cat ${tempfile}` server_ip=`${scriptpath}/get-container-ip.sh ${container_id}` - -# wait for server until timeout start=`date +%s` elapsed=0 @@ -63,10 +66,6 @@ fi set -e -# run the client -if [ "${test}" = "connect" ]; then - make run-client-test CONTAINER_ID_FILE=${tempfile} -elif [ "${test}" = "perf" ]; then - make run-perf-test CONTAINER_ID_FILE=${tempfile} - make cp-perf-result CONTAINER_ID_FILE=${tempfile} -fi +# run the test +make run-${test}-test CONTAINER_ID_FILE=${tempfile} +rm -r ${tempfile} -- cgit v1.2.3 From 78d61dfaadf9bcac7258a33738c660b238b7bf27 Mon Sep 17 00:00:00 2001 From: drebs Date: Fri, 10 Jun 2016 22:07:35 -0300 Subject: [test] refactor of docker scripts --- scripts/docker/helper/run-test.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts/docker/helper/run-test.sh') diff --git a/scripts/docker/helper/run-test.sh b/scripts/docker/helper/run-test.sh index 1b0e3db7..c3bdd00c 100755 --- a/scripts/docker/helper/run-test.sh +++ b/scripts/docker/helper/run-test.sh @@ -16,14 +16,14 @@ TIMEOUT=20 # parse command if [ ${#} -ne 1 ]; then - echo "Usage: ${0} perf|connect" + echo "Usage: ${0} perf|bootstrap" exit 1 fi test=${1} -if [ "${1}" != "perf" -a "${1}" != "perf" ]; then - echo "Usage: ${0} perf|connect" +if [ "${test}" != "perf" -a "${test}" != "bootstrap" ]; then + echo "Usage: ${0} perf|bootstrap" exit 1 fi @@ -67,5 +67,5 @@ fi set -e # run the test -make run-${test}-test CONTAINER_ID_FILE=${tempfile} +make run-client-${test} CONTAINER_ID_FILE=${tempfile} rm -r ${tempfile} -- cgit v1.2.3 From e433353b877f9cfc735b4368d92b80d091264c65 Mon Sep 17 00:00:00 2001 From: drebs Date: Sun, 12 Jun 2016 13:26:34 -0300 Subject: [test] add commit/branch checkout to docker test running script --- scripts/docker/helper/run-test.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'scripts/docker/helper/run-test.sh') diff --git a/scripts/docker/helper/run-test.sh b/scripts/docker/helper/run-test.sh index c3bdd00c..9b3ec0c9 100755 --- a/scripts/docker/helper/run-test.sh +++ b/scripts/docker/helper/run-test.sh @@ -15,18 +15,22 @@ TIMEOUT=20 # parse command -if [ ${#} -ne 1 ]; then +if [ ${#} -lt 1 -o ${#} -gt 2 ]; then echo "Usage: ${0} perf|bootstrap" exit 1 fi test=${1} - if [ "${test}" != "perf" -a "${test}" != "bootstrap" ]; then echo "Usage: ${0} perf|bootstrap" exit 1 fi +branch="" +if [ ${#} -eq 2 ]; then + branch="SOLEDAD_BRANCH=${2}" +fi + # make sure the image is up to date make image @@ -36,7 +40,7 @@ scriptpath=$(dirname "${script}") # run the server tempfile=`mktemp -u` -make run-server CONTAINER_ID_FILE=${tempfile} +make run-server CONTAINER_ID_FILE=${tempfile} ${branch} # wait for server until timeout container_id=`cat ${tempfile}` @@ -67,5 +71,5 @@ fi set -e # run the test -make run-client-${test} CONTAINER_ID_FILE=${tempfile} +make run-client-${test} CONTAINER_ID_FILE=${tempfile} ${branch} rm -r ${tempfile} -- cgit v1.2.3