summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/benchmarks/pgbench.py12
-rw-r--r--client/benchmarks/runner.py35
-rw-r--r--client/collectors/collectd.conf.in2
-rw-r--r--client/collectors/collectd.py3
-rw-r--r--client/perffarm-client.py5
-rw-r--r--client/settings.py3
-rw-r--r--client/utils/git.py31
7 files changed, 73 insertions, 18 deletions
diff --git a/client/benchmarks/pgbench.py b/client/benchmarks/pgbench.py
index ab4238f..01f681f 100644
--- a/client/benchmarks/pgbench.py
+++ b/client/benchmarks/pgbench.py
@@ -249,12 +249,12 @@ class PgBench(object):
r.update({'run': i})
results[tag][scale][clients]['results'].append(r)
- tps = []
- for result in results[tag][scale][clients]['results']:
- tps.append(float(result['tps']))
- results[tag][scale][clients]['metric'] = mean(tps)
- results[tag][scale][clients]['median'] = median(tps)
- results[tag][scale][clients]['std'] = std(tps)
+ tps = []
+ for result in results[tag][scale][clients]['results']:
+ tps.append(float(result['tps']))
+ results[tag][scale][clients]['metric'] = mean(tps)
+ results[tag][scale][clients]['median'] = median(tps)
+ results[tag][scale][clients]['std'] = std(tps)
self._results['pgbench'] = results
return self._results
diff --git a/client/benchmarks/runner.py b/client/benchmarks/runner.py
index 4d56187..05bbe57 100644
--- a/client/benchmarks/runner.py
+++ b/client/benchmarks/runner.py
@@ -1,5 +1,7 @@
import json
import os
+import codecs
+import urllib2
from multiprocessing import Process, Queue
from time import gmtime, strftime
@@ -11,7 +13,7 @@ from utils.logging import log
class BenchmarkRunner(object):
'manages runs of all the benchmarks, including cluster restarts etc.'
- def __init__(self, out_dir, cluster, collector):
+ def __init__(self, out_dir, url, secret, cluster, collector):
''
self._output = out_dir # where to store output files
@@ -19,6 +21,8 @@ class BenchmarkRunner(object):
self._configs = {} # config name => (bench name, config)
self._cluster = cluster
self._collector = collector
+ self._url = url
+ self._secret = secret
def register_benchmark(self, benchmark_name, benchmark_class):
''
@@ -26,15 +30,17 @@ class BenchmarkRunner(object):
# FIXME check if a mapping for the same name already exists
self._benchmarks.update({benchmark_name: benchmark_class})
- def register_config(self, config_name, benchmark_name, postgres_config,
- **kwargs):
+ def register_config(self, config_name, benchmark_name, branch, commit,
+ postgres_config, **kwargs):
''
# FIXME check if a mapping for the same name already exists
# FIXME check that the benchmark mapping already exists
self._configs.update({config_name: {'benchmark': benchmark_name,
'config': kwargs,
- 'postgres': postgres_config}})
+ 'postgres': postgres_config,
+ 'branch': branch,
+ 'commit': commit}})
def _check_config(self, config_name):
''
@@ -114,9 +120,30 @@ class BenchmarkRunner(object):
'uname': uname,
}
+ r['postgres'] = {
+ 'branch': config['branch'],
+ 'commit': config['commit'],
+ 'settings': config['postgres'],
+ }
+
with open('%s/results.json' % self._output, 'w') as f:
f.write(json.dumps(r, indent=4))
+ try:
+ self._upload_results(r)
+ except Exception as e:
+ print e
+
+ def _upload_results(self, results):
+ postdata = results
+ post = []
+ post.append(postdata)
+ req = urllib2.Request(self._url, json.dumps(post))
+ req.add_header('Authorization', self._secret) # add token in header
+ req.add_header('Content-Type', 'application/json')
+ response = urllib2.urlopen(req)
+
+
def run(self):
'run all the configured benchmarks'
diff --git a/client/collectors/collectd.conf.in b/client/collectors/collectd.conf.in
index 20291d2..404c0ae 100644
--- a/client/collectors/collectd.conf.in
+++ b/client/collectors/collectd.conf.in
@@ -404,7 +404,7 @@ FROM pg_stat_bgwriter;"
</Query>
<Database %(database)s>
Host "localhost"
- User "postgres"
+ User "%(pguser)s"
Query db_stats
Query table_stats
Query index_stats
diff --git a/client/collectors/collectd.py b/client/collectors/collectd.py
index 57a2ce0..4d3df1d 100644
--- a/client/collectors/collectd.py
+++ b/client/collectors/collectd.py
@@ -49,7 +49,8 @@ class CollectdCollector(object):
config = open(COLLECTD_CONFIG, 'w')
config.write(config_template.read() % {'database': dbname,
'datadir': outdir,
- 'modules': modules})
+ 'modules': modules,
+ 'pguser': self._env['USER']})
config.close()
config_template.close()
diff --git a/client/perffarm-client.py b/client/perffarm-client.py
index 0b0c0d3..e258bb4 100644
--- a/client/perffarm-client.py
+++ b/client/perffarm-client.py
@@ -54,7 +54,8 @@ if __name__ == '__main__':
bin_path=('%s/bin' % (BUILD_PATH)))
collectors.register('postgres', pg_collector)
- runner = BenchmarkRunner(OUTPUT_DIR, cluster, collectors)
+ runner = BenchmarkRunner(OUTPUT_DIR, PERFFARM_URL, SECRET,
+ cluster, collectors)
# register the three tests we currently have
@@ -66,6 +67,8 @@ if __name__ == '__main__':
PGBENCH_CONFIG['results_dir'] = OUTPUT_DIR
runner.register_config('pgbench-basic',
'pgbench',
+ repository.current_branch(),
+ repository.current_commit(),
dbname=DATABASE_NAME,
bin_path=('%s/bin' % (BUILD_PATH,)),
postgres_config=POSTGRES_CONFIG,
diff --git a/client/settings.py b/client/settings.py
index 1afdfc2..16279db 100644
--- a/client/settings.py
+++ b/client/settings.py
@@ -2,6 +2,9 @@ import os
import sys
# global configuration
+PERFFARM_URL = 'http://140.211.168.111:8000/upload/'
+SECRET='CHANGEME'
+
GIT_URL = 'https://github.com/postgres/postgres.git'
REPOSITORY_PATH = '/tmp/git-postgres'
BUILD_PATH = '/tmp/bin-postgres'
diff --git a/client/utils/git.py b/client/utils/git.py
index d380d7f..137e80d 100644
--- a/client/utils/git.py
+++ b/client/utils/git.py
@@ -40,6 +40,15 @@ class GitRepository(object):
with TemporaryFile() as strout:
call(['git', 'pull'], cwd=self._path, stdout=strout, stderr=STDOUT)
+ def current_branch(self):
+ 'returns current branch'
+
+ with TemporaryFile() as strout:
+ call(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], cwd=self._path,
+ stdout=strout, stderr=STDOUT)
+ strout.seek(0)
+ return strout.read().strip()
+
def current_commit(self):
'returns current commit hash'
@@ -57,6 +66,7 @@ class GitRepository(object):
else:
self._clone()
+ log("current branch '%s'" % (self.current_branch(),))
log("current commit '%s'" % (self.current_commit(),))
def build_and_install(self, path, remove=True):
@@ -81,8 +91,19 @@ class GitRepository(object):
call(['make', '-s', '-j', str(cpu_count()), 'install'],
cwd=self._path, stdout=strout, stderr=STDOUT)
- # Install pgbench from contrib in the older versions
- oldpgbenchdir = ''.join([self._path, '/', 'contrib/pgbench'])
- if os.path.isdir(oldpgbenchdir):
- call(['make', '-s', '-j', str(cpu_count()), 'install'],
- cwd=oldpgbenchdir, stdout=strout, stderr=STDOUT)
+ # Various things needs to be installed because of various changes
+ # changes between releases. Take a systematic approach and check
+ # if the directory exist, then try to install it.
+ items = [
+ 'src/bin/initdb',
+ 'src/bin/pg_ctl',
+ 'src/bin/scripts',
+ 'src/bin/psql',
+ 'src/bin/pgbench',
+ 'contrib/pgbench',
+ ]
+ for item in items:
+ srcdir = ''.join([self._path, '/', item])
+ if os.path.isdir(srcdir):
+ call(['make', '-s', '-j', str(cpu_count()), 'install'],
+ cwd=srcdir, stdout=strout, stderr=STDOUT)