1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
import os
from autotest_lib.client.bin import test, autotest_utils
from autotest_lib.client.common_lib import utils
# Dbt-2 is a fair-use implementation of the TPC-C benchmark. The test is
# currently hardcoded to use PostgreSQL but the kit also supports MySQL.
class dbt2(test.test):
version = 2
# http://osdn.dl.sourceforge.net/sourceforge/osdldbt/dbt2-0.39.tar.gz
def setup(self, tarball = 'dbt2-0.39.tar.bz2'):
tarball = utils.unmap_url(self.bindir, tarball,
self.tmpdir)
autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
self.job.setup_dep(['pgsql', 'pgpool', 'mysql'])
#
# Extract one copy of the kit for MySQL.
#
utils.system('cp -pR ' + self.srcdir + ' ' + self.srcdir + '.mysql')
os.chdir(self.srcdir + '.mysql')
utils.system('./configure --with-mysql=%s/deps/mysql/mysql' \
% self.autodir)
utils.system('make')
#
# Extract one copy of the kit for PostgreSQL.
#
utils.system('cp -pR ' + self.srcdir + ' ' + self.srcdir + '.pgsql')
os.chdir(self.srcdir + '.pgsql')
utils.system('./configure --with-postgresql=%s/deps/pgsql/pgsql' \
% self.autodir)
utils.system('make')
# Create symlinks to autotest's results directory from dbt-2's
# preferred results directory to self.resultsdir
utils.system('ln -s %s %s' % (self.resultsdir, \
self.srcdir + '.mysql/scripts/output'))
utils.system('ln -s %s %s' % (self.resultsdir, \
self.srcdir + '.pgsql/scripts/output'))
def execute(self, db_type, args = ''):
logfile = self.resultsdir + '/dbt2.log'
if (db_type == "mysql"):
self.execute_mysql(args)
elif (db_type == "pgpool"):
self.execute_pgpool(args)
elif (db_type == "pgsql"):
self.execute_pgsql(args)
def execute_mysql(self, args = ''):
args = args
utils.system(self.srcdir + '.mysql/scripts/mysql/build_db.sh -g -w 1')
utils.system(self.srcdir + '.mysql/scripts/run_workload.sh ' + args)
def execute_pgpool(self, args = ''):
utils.system('%s/deps/pgpool/pgpool/bin/pgpool -f %s/../pgpool.conf' \
% (self.autodir, self.srcdir))
self.execute_pgsql(args)
utils.system('%s/deps/pgpool/pgpool/bin/pgpool stop' % self.autodir)
def execute_pgsql(self, args = ''):
utils.system(self.srcdir + '.pgsql/scripts/pgsql/build_db.sh -g -w 1')
utils.system(self.srcdir + '.pgsql/scripts/run_workload.sh ' + args)
#
# Clean up by dropping the database after the test.
#
utils.system(self.srcdir + '.pgsql/scripts/pgsql/start_db.sh')
utils.system(self.srcdir + '.pgsql/scripts/pgsql/drop_db.sh')
utils.system(self.srcdir + '.pgsql/scripts/pgsql/stop_db.sh')
|