Mysql tests
diff --git a/wally/run_test.py b/wally/run_test.py
index 6606d04..5412be3 100755
--- a/wally/run_test.py
+++ b/wally/run_test.py
@@ -20,7 +20,7 @@
from wally.timeseries import SensorDatastore
from wally.discover import discover, Node, undiscover
from wally import utils, report, ssh_utils, start_vms
-from wally.suits.itest import IOPerfTest, PgBenchTest
+from wally.suits.itest import IOPerfTest, PgBenchTest, MysqlTest
from wally.sensors_utils import deploy_sensors_stage
from wally.config import cfg_dict, load_config, setup_loggers
@@ -117,6 +117,7 @@
tool_type_mapper = {
"io": IOPerfTest,
"pgbench": PgBenchTest,
+ "mysql": MysqlTest,
}
test_nodes = [node for node in nodes
@@ -455,6 +456,10 @@
print("\n")
print(IOPerfTest.format_for_console(data))
print("\n")
+ if 'mysql' == tp and data is not None:
+ print("\n")
+ print(MysqlTest.format_for_console(data))
+ print("\n")
def html_report_stage(cfg, ctx):
diff --git a/wally/suits/itest.py b/wally/suits/itest.py
index bd98dee..c3848a7 100644
--- a/wally/suits/itest.py
+++ b/wally/suits/itest.py
@@ -7,6 +7,7 @@
import datetime
from paramiko import SSHException, SFTPError
+import texttable
from wally.utils import (ssize_to_b, open_for_append_or_create,
sec_to_str, StopTestError)
@@ -17,6 +18,7 @@
connect, read_from_remote, Local)
from . import postgres
+from . import mysql
from .io import agent as io_agent
from .io import formatter as io_formatter
from .io.results_loader import parse_output
@@ -78,30 +80,26 @@
def __init__(self, *dt, **mp):
IPerfTest.__init__(self, *dt, **mp)
- if 'run_script' in self.options:
+ if 'scripts_path' in self.options:
+ self.root = self.options['scripts_path']
self.run_script = self.options['run_script']
- self.prepare_script = self.options['prepare_script']
+ self.prerun_script = self.options['prerun_script']
def get_remote_for_script(self, script):
- return os.path.join(self.tmp_dir, script.rpartition('/')[2])
+ return os.path.join(self.remote_dir, script.rpartition('/')[2])
- def copy_script(self, src):
- remote_path = self.get_remote_for_script(src)
- copy_paths(self.node.connection, {src: remote_path})
- return remote_path
def pre_run(self):
- remote_script = self.copy_script(self.node.connection,
- self.pre_run_script)
- cmd = remote_script
- self.run_over_ssh(cmd)
+ copy_paths(self.node.connection, {self.root: self.remote_dir})
+ cmd = self.get_remote_for_script(self.pre_run_script)
+ self.run_over_ssh(cmd, timeout=2000)
def run(self, barrier):
- remote_script = self.copy_script(self.node.connection, self.run_script)
+ remote_script = self.get_remote_for_script(self.run_script)
cmd_opts = ' '.join(["%s %s" % (key, val) for key, val
in self.options.items()])
cmd = remote_script + ' ' + cmd_opts
- out_err = self.run_over_ssh(cmd)
+ out_err = self.run_over_ssh(cmd, timeout=6000)
self.on_result(out_err, cmd)
def parse_results(self, out):
@@ -117,13 +115,31 @@
msg_templ = "Error during postprocessing results: {0!s}. {1}"
raise RuntimeError(msg_templ.format(exc, out_err))
+ def merge_results(self, results):
+ tpcm = sum([val[1] for val in results])
+ return {"res": {"TpmC": tpcm}}
+
class PgBenchTest(TwoScriptTest):
root = os.path.dirname(postgres.__file__)
- prepare_script = os.path.join(root, "prepare.sh")
+ pre_run_script = os.path.join(root, "prepare.sh")
run_script = os.path.join(root, "run.sh")
+class MysqlTest(TwoScriptTest):
+ root = os.path.dirname(mysql.__file__)
+ pre_run_script = os.path.join(root, "prepare.sh")
+ run_script = os.path.join(root, "run.sh")
+
+ @classmethod
+ def format_for_console(cls, data):
+ tab = texttable.Texttable(max_width=120)
+ tab.set_deco(tab.HEADER | tab.VLINES | tab.BORDER)
+ tab.header(["TpmC"])
+ tab.add_row([data['res']['TpmC']])
+ return tab.draw()
+
+
class IOPerfTest(IPerfTest):
tcp_conn_timeout = 30
max_pig_timeout = 5
diff --git a/wally/suits/mysql/tpcc/prepare.sh b/wally/suits/mysql/prepare.sh
old mode 100644
new mode 100755
similarity index 84%
rename from wally/suits/mysql/tpcc/prepare.sh
rename to wally/suits/mysql/prepare.sh
index c5043ad..13804d3
--- a/wally/suits/mysql/tpcc/prepare.sh
+++ b/wally/suits/mysql/prepare.sh
@@ -1,5 +1,8 @@
#!/bin/bash
# install and configure mysql
+set -e
+set -x
+
DATABASE_PASSWORD=wally
DATBASE_USER=root
DB_NAME=tpcc
@@ -16,8 +19,8 @@
apt-get install -y make
# disable mysql profile in apparmor
-sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
-sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
+#sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
+#sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
# allows us not to access mysql without specifying password
cat <<EOF >$HOME/.my.cnf
@@ -28,7 +31,7 @@
EOF
cd ~
-apt-get install bzr
+apt-get -y install bzr
bzr branch lp:~percona-dev/perconatools/tpcc-mysql
cd tpcc-mysql/src
make
diff --git a/wally/suits/mysql/run.sh b/wally/suits/mysql/run.sh
new file mode 100755
index 0000000..284bc1e
--- /dev/null
+++ b/wally/suits/mysql/run.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+set -e
+set -x
+
+DATABASE_PASSWORD=wally
+DATBASE_USER=root
+DB_NAME=tpcc
+
+cd ~/tpcc-mysql
+./tpcc_start -h127.0.0.1 "-d$DB_NAME" "-u$DATBASE_USER" "-p$DATABASE_PASSWORD" -w20 -c16 -r10 -l1200 > ~/tpcc-output.log
+echo "TpmC:" `cat ~/tpcc-output.log | grep TpmC | grep -o '[0-9,.]\+'`
\ No newline at end of file
diff --git a/wally/suits/mysql/tpcc/run.sh b/wally/suits/mysql/tpcc/run.sh
deleted file mode 100644
index 3d0f6f7..0000000
--- a/wally/suits/mysql/tpcc/run.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-cd ~/tpcc-mysql
-./tpcc_start -h127.0.0.1 -dtpcc1000 -uroot -p -w20 -c16 -r10 -l1200 > ~/tpcc-output.log
-cat ~/tpcc-output.log | grep TpmC | grep -o '[0-9,.]\+'
\ No newline at end of file