summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2017-01-30 16:28:38 +0100
committerLinus Nordberg <linus@nordu.net>2017-01-30 16:28:38 +0100
commit8364712d93721816695b0faac8284307b6a9d43a (patch)
tree5dba8aab56d81c7e4b1580552d8080e845750413
parentb4c6ed49b3e5482fb5bae01861f6293cdfc151ba (diff)
Work with permdb too.
-rwxr-xr-xtest/scripts/light-system-test-prepare-merge-takeover.sh1
-rwxr-xr-xtest/scripts/light-system-test.sh3
-rw-r--r--test/scripts/testutils.sh4
-rwxr-xr-xtools/compileconfig.py1
-rwxr-xr-xtools/initlog.py75
5 files changed, 83 insertions, 1 deletions
diff --git a/test/scripts/light-system-test-prepare-merge-takeover.sh b/test/scripts/light-system-test-prepare-merge-takeover.sh
index c84a17e..085a6a2 100755
--- a/test/scripts/light-system-test-prepare-merge-takeover.sh
+++ b/test/scripts/light-system-test-prepare-merge-takeover.sh
@@ -9,6 +9,7 @@ top_srcdir=$(cd $(dirname $0)/../..; pwd)
mv mergedb mergedb-down
mv mergedb-secondary mergedb
+init_log
mkdir mergedb-secondary
touch mergedb-secondary/logorder
printf 0 > mergedb-secondary/verifiedsize
diff --git a/test/scripts/light-system-test.sh b/test/scripts/light-system-test.sh
index eee1078..816bd67 100755
--- a/test/scripts/light-system-test.sh
+++ b/test/scripts/light-system-test.sh
@@ -5,7 +5,7 @@ set -o errexit
top_srcdir=$(cd $(dirname $0)/../..; pwd)
-. ${top_srcdir}/test/test.shvars
+. ${top_srcdir}/test/scripts/testutils.sh
SCRIPTS=${top_srcdir}/test/scripts
@@ -18,6 +18,7 @@ tests_stop() {
}
${SCRIPTS}/light-system-test-prepare.sh
+init_log
tests_start
${SCRIPTS}/light-system-test-run-1.sh || (echo "Tests failed"; sleep 5; tests_stop; false)
sleep 5
diff --git a/test/scripts/testutils.sh b/test/scripts/testutils.sh
index 2aba2d1..ba4221c 100644
--- a/test/scripts/testutils.sh
+++ b/test/scripts/testutils.sh
@@ -39,3 +39,7 @@ do_merge() {
${top_srcdir}/tools/merge --config ${top_srcdir}/test/catlfish-test.cfg --timing --localconfig ${top_srcdir}/test/catlfish-test-local-merge.cfg || fail "Merge failed"
sleep 5 # FIXME: Just wait for dist instead.
}
+
+init_log() {
+ ${top_srcdir}/tools/initlog.py --config ${top_srcdir}/test/catlfish-test.cfg --localconfig ${top_srcdir}/test/catlfish-test-local-merge.cfg || fail "Log init failed"
+}
diff --git a/tools/compileconfig.py b/tools/compileconfig.py
index d6f9271..54e3b18 100755
--- a/tools/compileconfig.py
+++ b/tools/compileconfig.py
@@ -342,6 +342,7 @@ def gen_config(nodename, config, localconfig):
services.add(Symbol("ht"))
if nodename == primarymergenodename:
merge = localconfig["merge"]
+ plopconfig.append((Symbol("db_backend_opt"), [(Symbol("write_flag"), Symbol("read"))]))
plopconfig.append((Symbol("merge_delay"), merge["min-delay"]))
plopconfig.append((Symbol("merge_dist_winsize"), merge["dist-window-size"]))
plopconfig.append((Symbol("merge_dist_sendlog_chunksize"), merge["dist-sendlog-chunksize"]))
diff --git a/tools/initlog.py b/tools/initlog.py
new file mode 100755
index 0000000..e2e8dd1
--- /dev/null
+++ b/tools/initlog.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2017, NORDUnet A/S.
+# See LICENSE for licensing information.
+#
+# Initialise a new CT log.
+#
+
+import sys
+import os
+import argparse
+import yaml
+import errno
+from time import time
+from base64 import b64encode
+from certtools import build_merkle_tree, generate_tree_head_signature, \
+ write_file
+from mergetools import get_sth, perm, get_logorder
+
+def parse_args():
+ parser = argparse.ArgumentParser(description="")
+ parser.add_argument('--config', help="System configuration",
+ required=True)
+ parser.add_argument('--localconfig', help="Local configuration",
+ required=True)
+
+ args = parser.parse_args()
+ config = yaml.load(open(args.config))
+ localconfig = yaml.load(open(args.localconfig))
+
+ return (args, config, localconfig)
+
+def main():
+ """
+ Initialise a log by creating
+ - sth file
+ - must not exist before
+ - consulting 'logorder' if it exists
+ - perm database if it doesn't exist
+ """
+ args, config, localconfig = parse_args()
+ signingnodes = config["signingnodes"]
+ paths = localconfig["paths"]
+ own_key = (localconfig["nodename"],
+ "%s/%s-private.pem" % (paths["privatekeys"],
+ localconfig["nodename"]))
+ mergedb = paths["mergedb"]
+ logorderfile = mergedb + "/logorder"
+ sthfile = mergedb + "/sth"
+
+ # Don't do anything if there's already an sth file.
+ sth = get_sth(sthfile)
+ if sth['tree_size'] >= 0:
+ print >>sys.stderr, \
+ "This log has an STH file with tree size %s." % sth['tree_size']
+ print >>sys.stderr, "I refuse to destroy this log."
+ return 1
+
+ # Ensure that we can find our keyfile.
+ try:
+ os.stat(own_key[1])
+ except OSError, e:
+ if e.errno == errno.ENOENT:
+ print >>sys.stderr, "Unable to open keyfile: %s" % own_key[1]
+ return 1
+ raise
+
+ # Create a chains database.
+ chainsdb = perm(localconfig.get("dbbackend", "filedb"), mergedb + "/chains")
+
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())