diff options
-rwxr-xr-x | test/scripts/continuous-merge-test-run-1.sh | 18 | ||||
-rw-r--r-- | test/scripts/testutils.sh | 10 | ||||
-rwxr-xr-x | tools/testcase1.py | 39 |
3 files changed, 39 insertions, 28 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/ } diff --git a/tools/testcase1.py b/tools/testcase1.py index 885c24d..dbd143a 100755 --- a/tools/testcase1.py +++ b/tools/testcase1.py @@ -21,9 +21,13 @@ logpublickeyfile = sys.argv[2] cacertfile = sys.argv[3] toolsdir = os.path.dirname(sys.argv[0]) testdir = sys.argv[4] -do_merge = True + if len(sys.argv) > 5 and sys.argv[5] == '--nomerge': do_merge = False + TREESIZE_TIMEOUT = 25 +else: + do_merge = True + TREESIZE_TIMEOUT = 0 certfiles = [toolsdir + ("/testcerts/cert%d.txt" % e) for e in range(1, 6)] @@ -67,14 +71,20 @@ def assert_equal(actual, expected, name, quiet=False, nodata=False, fatal=False) def print_and_check_tree_size(expected, baseurl): global failures - sth = get_sth(baseurl) - try: - check_sth_signature(baseurl, sth, publickey=logpublickey) - except AssertionError, e: - print_error("%s", e) - except ecdsa.keys.BadSignatureError, e: - print_error("bad STH signature") - tree_size = sth["tree_size"] + n = TREESIZE_TIMEOUT + while True: + sth = get_sth(baseurl) + try: + check_sth_signature(baseurl, sth, publickey=logpublickey) + except AssertionError, e: + print_error("%s", e) + except ecdsa.keys.BadSignatureError, e: + print_error("bad STH signature") + tree_size = sth["tree_size"] + if n == 0 or tree_size == expected: + break + n -= 1 + sleep(1) assert_equal(tree_size, expected, "tree size", quiet=True) def do_add_chain(chain, baseurl): @@ -156,13 +166,14 @@ def merge(): return subprocess.call([toolsdir + "/merge", "--config", testdir + "/catlfish-test.cfg", "--localconfig", testdir + "/catlfish-test-local-merge.cfg"]) else: - n = 40 - print "testcase1.py: sleeping", n, "seconds waiting for merge" - sleep(n) return 0 -mergeresult = merge() -assert_equal(mergeresult, 0, "merge", quiet=True, fatal=True) +if do_merge: + mergeresult = merge() + assert_equal(mergeresult, 0, "merge", quiet=True, fatal=True) +else: + print "sleeping 15 seconds waiting for first merge" + sleep(15) for baseurl in baseurls: print_and_check_tree_size(0, baseurl) |