summaryrefslogtreecommitdiff
path: root/tools/testcase1.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testcase1.py')
-rwxr-xr-xtools/testcase1.py43
1 files changed, 29 insertions, 14 deletions
diff --git a/tools/testcase1.py b/tools/testcase1.py
index 5192074..12079c8 100755
--- a/tools/testcase1.py
+++ b/tools/testcase1.py
@@ -148,13 +148,28 @@ def get_and_check_entry(timestamp, chain, leaf_index, baseurl):
len(submittedcertchain),
len(submittedcertchain))
-def merge():
- rv = subprocess.call([toolsdir + "/merge", "--config", testdir + "/catlfish-test.cfg",
- "--localconfig", testdir + "/catlfish-test-local-merge.cfg"])
- sleep(5) # FIXME: Just wait for dist instead.
- return rv
-
-mergeresult = merge()
+def correct_tree_size(expected):
+ for baseurl in baseurls:
+ sth = get_sth(baseurl)
+ tree_size = sth["tree_size"]
+ if tree_size != expected:
+ return False
+ return True
+
+def merge(expected=None, wait=0):
+ for i in range(10):
+ rv = subprocess.call([toolsdir + "/merge", "--config", testdir + "/catlfish-test.cfg",
+ "--localconfig", testdir + "/catlfish-test-local-merge.cfg"])
+ if rv:
+ return rv
+ if i < wait:
+ sleep(1)
+ continue
+ if correct_tree_size(expected):
+ return 0
+ return 0
+
+mergeresult = merge(expected=0, wait=3)
assert_equal(mergeresult, 0, "merge", quiet=True, fatal=True)
for baseurl in baseurls:
@@ -164,7 +179,7 @@ testgroup("cert1")
result1 = do_add_chain(cc1, baseurls[0])
-mergeresult = merge()
+mergeresult = merge(expected=1)
assert_equal(mergeresult, 0, "merge", quiet=True, fatal=True)
size_sth = {}
@@ -177,7 +192,7 @@ result2 = do_add_chain(cc1, baseurls[0])
assert_equal(result2["timestamp"], result1["timestamp"], "timestamp")
-mergeresult = merge()
+mergeresult = merge(expected=1, wait=3)
assert_equal(mergeresult, 0, "merge", quiet=True, fatal=True)
for baseurl in baseurls:
@@ -195,7 +210,7 @@ testgroup("cert2")
result3 = do_add_chain(cc2, baseurls[0])
-mergeresult = merge()
+mergeresult = merge(expected=2)
assert_equal(mergeresult, 0, "merge", quiet=True, fatal=True)
for baseurl in baseurls:
@@ -209,7 +224,7 @@ testgroup("cert3")
result4 = do_add_chain(cc3, baseurls[0])
-mergeresult = merge()
+mergeresult = merge(expected=3)
assert_equal(mergeresult, 0, "merge", quiet=True, fatal=True)
for baseurl in baseurls:
@@ -224,7 +239,7 @@ testgroup("cert4")
result5 = do_add_chain(cc4, baseurls[0])
-mergeresult = merge()
+mergeresult = merge(expected=4)
assert_equal(mergeresult, 0, "merge", quiet=True, fatal=True)
for baseurl in baseurls:
@@ -240,7 +255,7 @@ testgroup("cert5")
result6 = do_add_chain(cc5, baseurls[0])
-mergeresult = merge()
+mergeresult = merge(expected=5)
assert_equal(mergeresult, 0, "merge", quiet=True, fatal=True)
for baseurl in baseurls:
@@ -253,7 +268,7 @@ get_and_validate_proof(result4["timestamp"], cc3, 2, 3, baseurls[0])
get_and_validate_proof(result5["timestamp"], cc4, 3, 3, baseurls[0])
get_and_validate_proof(result6["timestamp"], cc5, 4, 1, baseurls[0])
-mergeresult = merge()
+mergeresult = merge(expected=5, wait=3)
assert_equal(mergeresult, 0, "merge", quiet=True, fatal=True)
for first_size in range(1, 5):