summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Vondra2016-08-11 00:00:32 +0000
committerTomas Vondra2017-02-27 00:25:34 +0000
commitafafb8549915da7b1dddb3e355efef70586a26aa (patch)
tree98754b07e6d813670444021ce1781b4112921d68
parentacb9f222d3a6242b0286b08e92648a1124100d9e (diff)
Check configuration before running any benchmarks
Before doing any heavy-lifting, check existence of directories, binaries and some other sanity checks.
-rw-r--r--client/benchmarks/pgbench.py30
-rw-r--r--client/benchmarks/runner.py33
-rwxr-xr-xclient/perffarm-client.py11
3 files changed, 72 insertions, 2 deletions
diff --git a/client/benchmarks/pgbench.py b/client/benchmarks/pgbench.py
index eaa8402..2ec38d5 100644
--- a/client/benchmarks/pgbench.py
+++ b/client/benchmarks/pgbench.py
@@ -1,5 +1,6 @@
import math
import os
+import os.path
import re
import time
@@ -155,6 +156,35 @@ class PgBench(object):
return '\n'.join(o)
+ def check_config(self):
+ 'check pgbench configuration (existence of binaries etc.)'
+
+ issues = []
+
+ if not os.path.isdir(self._bin):
+ issues.append("bin_dir='%s' does not exist" % (self._bin,))
+ elif not os.path.exists('%s/pgbench' % (self._bin,)):
+ issues.append("pgbench not found in bin_dir='%s'" % (self._bin,))
+ elif not os.path.exists('%s/createdb' % (self._bin,)):
+ issues.append("createdb not found in bin_dir='%s'" % (self._bin,))
+ elif not os.path.exists('%s/dropdb' % (self._bin,)):
+ issues.append("dropdb not found in bin_dir='%s'" % (self._bin,))
+ elif not os.path.exists('%s/psql' % (self._bin,)):
+ issues.append("psql not found in bin_dir='%s'" % (self._bin,))
+
+ if type(self._duration) is not int:
+ issues.append("duration (%s) needs to be an integer" % (self._duration,))
+ elif not self._duration >= 1:
+ issues.append("duration (%s) needs to be >= 1" % (self._duration,))
+
+ if type(self._runs) is not int:
+ issues.append("runs (%s) needs to be an integer" % (self._duration,))
+ elif not self._runs >= 1:
+ issues.append("runs (%s) needs to be >= 1" % (self._runs,))
+
+ return issues
+
+
def _run(self, duration, nclients=1, njobs=1, read_only=False, aggregate=True):
'run pgbench on the database (either a warmup or actual benchmark run)'
diff --git a/client/benchmarks/runner.py b/client/benchmarks/runner.py
index 3a891dc..b6ef293 100644
--- a/client/benchmarks/runner.py
+++ b/client/benchmarks/runner.py
@@ -32,6 +32,38 @@ class BenchmarkRunner(object):
self._configs.update({config_name : {'benchmark' : benchmark_name, 'config' : kwargs, 'postgres' : postgres_config}})
+ def _check_config(self, config_name):
+ ''
+
+ log("checking benchmark configuration '%s'" % (config_name,))
+
+ # construct the benchmark class for the given config name
+ config = self._configs[config_name]
+ bench = self._benchmarks[config['benchmark']]
+
+ # expand the attribute names
+ bench = bench(**config['config'])
+
+ # run the tests
+ return bench.check_config()
+
+
+ def check(self):
+ 'check configurations for all benchmarks'
+
+ issues = {}
+
+ if os.path.exists(self._output):
+ issues['global'] = ["output directory '%s' already exists" % (self._output,)]
+
+ for config_name in self._configs:
+ t = self._check_config(config_name)
+ if t:
+ issues[config_name] = t
+
+ return issues
+
+
def _run_config(self, config_name):
''
@@ -75,7 +107,6 @@ class BenchmarkRunner(object):
def run(self):
'run all the configured benchmarks'
- # FIXME check that the directory does not exist
os.mkdir(self._output)
for config_name in self._configs:
diff --git a/client/perffarm-client.py b/client/perffarm-client.py
index 1d75a10..5826d33 100755
--- a/client/perffarm-client.py
+++ b/client/perffarm-client.py
@@ -51,4 +51,13 @@ if __name__ == '__main__':
postgres_config = POSTGRES_CONFIG,
**PGBENCH_CONFIG)
- runner.run()
+ # check configuration and report all issues
+ issues = runner.check()
+
+ if issues:
+ # print the issues
+ for k in issues:
+ for v in issues[k]:
+ print k, ':', v
+ else:
+ runner.run()