diff options
author | Linus Nordberg <linus@nordu.net> | 2016-11-25 23:50:37 +0100 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2016-11-25 23:50:37 +0100 |
commit | c070573e5cc6bc21653ebb82d8f64b7ef44ae9ef (patch) | |
tree | 75d855e348cba5f11c0032eee93743c0ceab08df /test | |
parent | ab0550f8f0c8f544b5878746ea963180551192d7 (diff) |
Sleep less in tests.
Diffstat (limited to 'test')
-rwxr-xr-x | test/scripts/continuous-merge-test-run-1.sh | 18 | ||||
-rw-r--r-- | test/scripts/testutils.sh | 10 |
2 files changed, 14 insertions, 14 deletions
diff --git a/test/scripts/continuous-merge-test-run-1.sh b/test/scripts/continuous-merge-test-run-1.sh index 1a1dae6..92e8596 100755 --- a/test/scripts/continuous-merge-test-run-1.sh +++ b/test/scripts/continuous-merge-test-run-1.sh @@ -3,8 +3,6 @@ set -o nounset set -o errexit -SLEEP=40 - top_srcdir=$(cd $(dirname $0)/../..; pwd) . ${top_srcdir}/test/scripts/testutils.sh @@ -17,12 +15,9 @@ for certfile in ${top_srcdir}/tools/testcerts/cert[1-5].txt ${top_srcdir}/tools/ python ${top_srcdir}/tools/submitcert.py --parallel=1 --store $certfile --check-sct --sct-file=submittedcerts ${BASEURL} --publickey=keys/logkey.pem --cafile httpsca/demoCA/cacert.pem || fail "Submission failed" done python ${top_srcdir}/tools/storagegc.py --config ${top_srcdir}/test/catlfish-test.cfg --localconfig ${top_srcdir}/test/catlfish-test-local-1.cfg || fail "GC failed" -echo "$0: sleeping for $SLEEP seconds" -sleep $SLEEP +wait_for_equal "Tree size" "get_treesize" 7 15 check_sth -assert_equal "Tree size" "$(get_treesize)" 7 - mkdir fetchcertstore python ${top_srcdir}/tools/fetchallcerts.py ${BASEURL} --store fetchcertstore --publickey=keys/logkey.pem --cafile httpsca/demoCA/cacert.pem || fail "Verification failed" (cd fetchcertstore && unzip 0000.zip) @@ -39,11 +34,9 @@ echo NOTE: merge backup should fail with 111 Connection refused ${top_srcdir}/tools/to_catlfish.py to_erl nodes/merge-2/ "init:stop()" python ${top_srcdir}/tools/submitcert.py --parallel=1 --store ${top_srcdir}/tools/testcerts/cert6.txt --check-sct --sct-file=submittedcerts ${BASEURL} --publickey=keys/logkey.pem --cafile httpsca/demoCA/cacert.pem || fail "Submission failed" -echo "$0: sleeping for $SLEEP seconds" -sleep $SLEEP -assert_equal "Tree size" "$(get_treesize)" 7 - +wait_for_equal "Tree size" "get_treesize" 7 15 check_sth + ../bin/run_erl -daemon nodes/merge-2/ nodes/merge-2/log/ "exec ../bin/erl -config merge-2" for i in 1 2 3 4 5 6 7 8 9 10; do echo "waiting for system to start" ; \ @@ -51,8 +44,5 @@ for i in 1 2 3 4 5 6 7 8 9 10; do if curl -s --cacert httpsca/demoCA/cacert.pem -4 https://localhost:8181 > /dev/null ; then break; fi done -echo "$0: sleeping for $SLEEP seconds" -sleep $SLEEP -assert_equal "Tree size" "$(get_treesize)" 8 - +wait_for_equal "Tree size" "get_treesize" 8 15 check_sth diff --git a/test/scripts/testutils.sh b/test/scripts/testutils.sh index d264464..faa7026 100644 --- a/test/scripts/testutils.sh +++ b/test/scripts/testutils.sh @@ -9,6 +9,16 @@ assert_equal() { test "$2" = "$3" || fail "$1 $2 != expected $3" } +wait_for_equal() { + n=$4 + while [ $n -gt 0 ]; do + [ $(eval "$2") = "$3" ] && return + n=$((n-1)) + sleep 1 + done + assert_equal "$1" "$(eval "$2")" "$3" +} + get_treesize() { ${top_srcdir}/tools/loginfo.py --config ${top_srcdir}/test/catlfish-test.cfg --localconfig ${top_srcdir}/test/catlfish-test-local-merge.cfg --treesize https://localhost:8080/ } |