summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/testcase1.py39
1 files changed, 25 insertions, 14 deletions
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)