import math
import os
+import os.path
import re
import time
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)'
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):
''
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: