From 31b527a9acc8607e5e03927b3b646b7c832e7058 Mon Sep 17 00:00:00 2001 From: drebs Date: Mon, 2 May 2016 20:25:45 -0300 Subject: refactor and make complete test run with script --- scripts/preload_server_database.py | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 scripts/preload_server_database.py (limited to 'scripts/preload_server_database.py') diff --git a/scripts/preload_server_database.py b/scripts/preload_server_database.py new file mode 100755 index 0000000..95e8cfd --- /dev/null +++ b/scripts/preload_server_database.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python + +""" +Preload the server database with a certain amount of documents so we can +receive them during the sync process and gather meaningful statistics for that +specific phase of sync. + +Gets uuid, payload file path and amount of documents to preload from +"defaults.conf" config file: + + UUID = some-uuid + PAYLOAD = /path/to/payload/file + NUM_DOCS = 100 +""" + +import os +from ConfigParser import ConfigParser +from leap.soledad.common.couch import CouchDatabase + +parser = ConfigParser() +parser.read('defaults.conf') + +UUID = parser.get('client', 'uuid') +PAYLOAD = parser.get('sync', 'payload') +NUM_DOCS = int(parser.get('sync', 'num_docs')) + +db = CouchDatabase.open_database( + 'http://127.0.0.1:5984/user-%s' % UUID, + False) # should create database? + +payload = None +if os.path.isfile(PAYLOAD): + with open(PAYLOAD, 'r') as f: + payload = f.read() + +for i in xrange(NUM_DOCS): + db.create_doc({'payload': payload}) + +db.close() -- cgit v1.2.3