Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 118 lines (90 sloc) 3.985 kb
#!/usr/bin/env python
import re
import os
import sys
import time
import datetime
try:
import json
except ImportError:
import simplejson as json
import couchdb
def process_file(db, upload, test, filename, run, build, ram_quota, replica_count, num_items, num_nodes, num_vbuckets,
val_size, item_type):
labels = []
details = []
f = open(filename)
for line in f:
if line.find('done. elapsed: ') > 0:
try:
# Example line == "# 6. view-building... done. elapsed: 0.10278"
#
parts = line.split(' ')
step = int(parts[1].rstrip('.'))
label = parts[2].rstrip('.')
elapsed = float(parts[-1])
labels.append(label)
details.append({ 'step': step, 'label': label, 'elapsed': elapsed })
except:
pass
f.close()
doc = { 'upload': upload, 'test': test,
'filename': filename, 'run': run, 'build': build,
'ram_quota': ram_quota, 'replica_count': replica_count,
'items': num_items, 'nodes': num_nodes,
'vbuckets': num_vbuckets,
'val_size': val_size,
'item_type': item_type,
'details': details,'date':datetime.datetime.ctime(datetime.datetime.now())
}
id, rev = db.save(doc)
for suffix in ["proc-stats", "proc-diskstats", "du"]:
for label in labels:
x = filename + "-" + label + "." + suffix
z = x + ".bz2"
if not os.path.exists(z):
if os.path.exists(x):
os.system("bzip2 " + x)
if os.path.exists(z):
f = open(z)
db.put_attachment(doc, f, label + "." + suffix + ".bz2")
f.close()
if __name__ == '__main__':
if len(sys.argv) < 4:
print("usage: " + sys.argv[0] + " http://HOST:5984/COUCH_DBNAME UPLOAD_TEST_NAME OUT0 [OUT1 ... OUTN]\n")
print("example: " + sys.argv[0] + " http://127.0.0.1:5984/viewperf 289-physical out-*/test-*/*.out\n")
print("Cooks the output files from runtests and uploads to couchdb.\n")
print("Try to make the UPLOAD_TEST_NAME unique across uploads.\n")
exit('ERROR: not enough parameters')
couch = sys.argv[1] # Ex: "http://localhost:5984/viewperf"
test = sys.argv[2] # Ex: "289-physical"
upload = test
print("upload: " + upload + "\n")
couch_server = '/'.join(couch.split('/')[0:-1]) # Ex: 'http://localhost:5984/'
couch_dbname = couch.split('/')[-1] # Ex: 'viewperf'
db = couchdb.Server(couch_server)[couch_dbname]
for f in sys.argv[3:]:
# Example f...
# "test-20110815090708_couchbase-2.0.0r-289-gc0dbb43/5000-0-100000-1-1-1024-b.out"
# "out/test-20110815090708_couchbase-2.0.0r-289-gc0dbb43/5000-0-100000-1-1-1024-j.out"
# "out-20110815090708/test-20110815090708_couchbase-2.0.0r-289-gc0dbb43/5000-0-100000-1-1-1024-j.out"
#
run = f.split('/')[-2] # Ex: "test-20110815090708_couchbase-2.0.0r-289-gc0dbb43"
build = run.split('_')[-1] # Ex: "couchbase-2.0.0r-289-gc0dbb43"
n = f.split('/')[-1].split('.')[0] # Ex: 5000-0-100000-1-1-1024-j
n = n.split('-') # Ex: [5000, 0, 100000, 1, 1, 1024, j]
ram_quota = int(n[0])
replica_count = int(n[1])
num_items = int(n[2])
num_nodes = int(n[3])
num_vbuckets = int(n[4])
val_size = int(n[5])
item_type = 'j'
if len(n) >= 7:
item_type = n[6]
print(run, build,
ram_quota, replica_count, num_items, num_nodes, num_vbuckets,
val_size, item_type)
process_file(db, upload, test, f, run, build,
ram_quota, replica_count, num_items, num_nodes, num_vbuckets,
val_size, item_type)
Jump to Line
Something went wrong with that request. Please try again.