summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/db_access/reset_db.py2
-rw-r--r--scripts/db_access/server_side_db.py4
-rw-r--r--scripts/ddocs/update_design_docs.py2
-rwxr-xr-xscripts/profiling/doc_put_memory_usage/find_max_upload_size.py2
-rw-r--r--scripts/profiling/mail/mx.py5
-rwxr-xr-xscripts/profiling/sync/benchmark-uploads.py60
-rwxr-xr-xscripts/profiling/sync/profile-sync.py11
-rw-r--r--scripts/profiling/sync/sample7
8 files changed, 83 insertions, 10 deletions
diff --git a/scripts/db_access/reset_db.py b/scripts/db_access/reset_db.py
index 7c6d281b..c48b511e 100644
--- a/scripts/db_access/reset_db.py
+++ b/scripts/db_access/reset_db.py
@@ -63,7 +63,7 @@ def get_url(empty):
if empty is False:
# get couch url
cp = ConfigParser()
- cp.read('/etc/leap/soledad-server.conf')
+ cp.read('/etc/soledad/soledad-server.conf')
url = cp.get('soledad-server', 'couch_url')
else:
with open('/etc/couchdb/couchdb.netrc') as f:
diff --git a/scripts/db_access/server_side_db.py b/scripts/db_access/server_side_db.py
index 18641a0f..fcdd14b6 100644
--- a/scripts/db_access/server_side_db.py
+++ b/scripts/db_access/server_side_db.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# This script gives server-side access to one Soledad user database by using
-# the configuration stored in /etc/leap/soledad-server.conf.
+# the configuration stored in /etc/soledad/soledad-server.conf.
#
# Use it like this:
#
@@ -20,7 +20,7 @@ uuid = sys.argv[1]
# get couch url
cp = ConfigParser()
-cp.read('/etc/leap/soledad-server.conf')
+cp.read('/etc/soledad/soledad-server.conf')
url = cp.get('soledad-server', 'couch_url')
# access user db
diff --git a/scripts/ddocs/update_design_docs.py b/scripts/ddocs/update_design_docs.py
index 2e2fa8f0..281482b8 100644
--- a/scripts/ddocs/update_design_docs.py
+++ b/scripts/ddocs/update_design_docs.py
@@ -50,7 +50,7 @@ def _parse_args():
def _get_url():
# get couch url
cp = ConfigParser()
- cp.read('/etc/leap/soledad-server.conf')
+ cp.read('/etc/soledad/soledad-server.conf')
url = urlparse(cp.get('soledad-server', 'couch_url'))
# get admin password
netloc = re.sub('^.*@', '', url.netloc)
diff --git a/scripts/profiling/doc_put_memory_usage/find_max_upload_size.py b/scripts/profiling/doc_put_memory_usage/find_max_upload_size.py
index 02c68015..1a603fd0 100755
--- a/scripts/profiling/doc_put_memory_usage/find_max_upload_size.py
+++ b/scripts/profiling/doc_put_memory_usage/find_max_upload_size.py
@@ -30,7 +30,7 @@ from socket import error as socket_error
from leap.soledad.common.couch import CouchDatabase
-SOLEDAD_CONFIG_FILE = '/etc/leap/soledad-server.conf'
+SOLEDAD_CONFIG_FILE = '/etc/soledad/soledad-server.conf'
PREFIX = '/tmp/soledad_test'
LOG_FORMAT = '%(asctime)s %(levelname)s %(message)s'
RETRIES = 3 # number of times to retry uploading a document of a certain
diff --git a/scripts/profiling/mail/mx.py b/scripts/profiling/mail/mx.py
index b6a1e5cf..55084a40 100644
--- a/scripts/profiling/mail/mx.py
+++ b/scripts/profiling/mail/mx.py
@@ -5,7 +5,7 @@ import timeit
from leap.keymanager import openpgp
-from leap.soledad.common.couch import CouchDocument
+from leap.soledad.common.document import ServerDocument
from leap.soledad.common.crypto import (
EncryptionSchemes,
ENC_JSON_KEY,
@@ -47,7 +47,7 @@ def get_enc_json(pubkey, message):
def get_new_doc(enc_json):
- doc = CouchDocument(doc_id=str(uuid.uuid4()))
+ doc = ServerDocument(doc_id=str(uuid.uuid4()))
doc.content = {
'incoming': True,
ENC_SCHEME_KEY: EncryptionSchemes.PUBKEY,
@@ -71,6 +71,7 @@ def put_lots_of_messages(db, number):
log("Populating database with %d encrypted messages... "
% number, line_break=False)
pubkey = get_pubkey()
+
def _put_one_message():
put_one_message(pubkey, db)
time = timeit.timeit(_put_one_message, number=number)
diff --git a/scripts/profiling/sync/benchmark-uploads.py b/scripts/profiling/sync/benchmark-uploads.py
new file mode 100755
index 00000000..d371bb1a
--- /dev/null
+++ b/scripts/profiling/sync/benchmark-uploads.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# benchmark_uploads.py
+# Copyright (C) 2015 LEAP
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+Run benchmarks for sync (uploads).
+"""
+import getpass
+import sys
+import datetime
+import subprocess
+
+NUM_ITER = 10
+NUM_UPLOADS = 10
+
+RESULTS = []
+
+
+if __name__ == "__main__":
+ user = sys.argv[1]
+ passwd = sys.argv[2]
+ opts = ("--no-stats --send-num %s --payload-file sample --repeat-payload -p "
+ "%s -b /tmp/profile-soledad-upload ") % (NUM_UPLOADS, passwd)
+
+ for i in xrange(NUM_ITER):
+ print "[+] ITERATION NUMBER: ", i
+ start = datetime.datetime.now()
+ cmd = "./profile-sync.py " + opts + user
+ print "CALLING", cmd
+ result = subprocess.check_call(cmd.split())
+ print "EXIT CODE:", result
+ end = datetime.datetime.now()
+ delta = (end - start)
+ RESULTS.append(delta)
+ print "[+] SYNC TOOK %s seconds" % delta.seconds
+
+ import numpy
+ res = [x.seconds for x in RESULTS]
+ print "-------------------------"
+ print "SYNC UPLOAD REPORT"
+ print "USER:", user
+ print "UPLOADS: %s 1K DOCS" % NUM_UPLOADS
+ print "ITERATIONS: %s" % NUM_ITER
+ print
+ print "mean :", numpy.mean(res)
+ print "stdev:", numpy.std(res)
+ print "-------------------------"
diff --git a/scripts/profiling/sync/profile-sync.py b/scripts/profiling/sync/profile-sync.py
index 9ef2ea92..8c18bde8 100755
--- a/scripts/profiling/sync/profile-sync.py
+++ b/scripts/profiling/sync/profile-sync.py
@@ -57,15 +57,17 @@ def create_docs(soledad, args):
bail('--payload-file does not exist!')
return
- numdocs = args.send_num
- docsize = args.send_size
+ numdocs = int(args.send_num)
+ docsize = int(args.send_size)
# XXX this will FAIL if the payload source is smaller to size * num
# XXX could use a cycle iterator
with open(sample_path, "r+b") as sample_f:
fmap = mmap.mmap(sample_f.fileno(), 0, prot=mmap.PROT_READ)
+ payload = fmap.read(docsize * 1024)
for index in xrange(numdocs):
- payload = fmap.read(docsize * 1024)
+ if not args.repeat_payload:
+ payload = fmap.read(docsize * 1024)
s.create_doc({payload: payload})
# main program
@@ -95,6 +97,9 @@ if __name__ == '__main__':
'--send-num', dest='send_num', default=10,
help='number of docs to send (default: 10)')
parser.add_argument(
+ '--repeat-payload', dest='repeat_payload', action='store_true',
+ default=False)
+ parser.add_argument(
'--payload-file', dest="payload_f", default=None,
help='path to a sample file to use for the payloads')
parser.add_argument(
diff --git a/scripts/profiling/sync/sample b/scripts/profiling/sync/sample
new file mode 100644
index 00000000..7b8fc8fa
--- /dev/null
+++ b/scripts/profiling/sync/sample
@@ -0,0 +1,7 @@
+ CAOS NUNCA MURIO. Bloque primordial sin esculpir, único excelentísimo monstruo, inerte y espontáneo, más ultravioleta que ninguna ideología (como las sombras antes de Babilonia), la homogénea unidad original del ser todavía irradia serena como los negros pendones de los Asesinos, perpetua y azarosamente ebria.
+
+ Caos precede a todo principio de orden y entropía, no es ni Dios ni gusano, sus deseos insensatos abarcan y definen toda posible coreografía, todo éter y flogisto sin sentido: sus máscaras son cristalizaciones de su propia falta de rostro, como las nubes.
+
+ Todo en la naturaleza es perfectamente real incluyendo la conciencia, no hay absolutamente nada de lo que preocuparse. No sólo se han roto las cadenas de la Ley, es que nunca existieron; los demonios nunca guardaron las estrellas, el Imperio jamás se fundó, a Eros nunca le creció la barba.
+
+No, escucha, lo que ocurrió fue esto: te mintieron, te vendieron ideas sobre el bien y el mal