2
# -*- mode: python; indent-tabs-mode: nil; -*-
3
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5
# Copyright (C) 2011 Patrick Crews
8
# This program is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 2 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program; if not, write to the Free Software
20
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
from lib.util.sysbench_methods import prepare_sysbench
27
from lib.util.sysbench_methods import execute_sysbench
28
from lib.util.sysbench_methods import process_sysbench_output
29
from lib.util.mysqlBaseTestCase import mysqlBaseTestCase
31
# TODO: make server_options vary depending on the type of server being used here
33
#server_requirements = [['innodb.buffer-pool-size=256M innodb.log-file-size=64M innodb.log-buffer-size=8M innodb.thread-concurrency=0 innodb.additional-mem-pool-size=16M table-open-cache=4096 table-definition-cache=4096 mysql-protocol.max-connections=2048']]
35
#server_requirements = [['innodb_buffer_pool_size=256M innodb_log_file_size=64M innodb_log_buffer_size=8M innodb_thread_concurrency=0 innodb_additional_mem_pool_size=16M table_open_cache=4096 table_definition_cache=4096 max_connections=2048']]
36
server_requirements = [[]]
41
class basicTest(mysqlBaseTestCase):
43
def test_sysbench_readonly(self):
44
self.logging = test_executor.logging
45
master_server = servers[0]
46
# our base test command
47
test_cmd = [ "sysbench"
51
, "--db-ps-mode=disable"
52
, "--%s-table-engine=innodb" %master_server.type
53
, "--oltp-read-only=on"
54
, "--oltp-table-size=1000000"
55
, "--%s-user=root" %master_server.type
56
, "--%s-db=test" %master_server.type
57
, "--%s-port=%d" %(master_server.type, master_server.master_port)
58
, "--%s-host=localhost" %master_server.type
59
, "--db-driver=%s" %master_server.type
62
if master_server.type == 'drizzle':
63
test_cmd.append("--drizzle-mysql=on")
64
if master_server.type == 'mysql':
65
test_cmd.append("--mysql-socket=%s" %master_server.socket_file)
67
# We sleep for a minute to wait
69
# how many times to run sysbench at each concurrency
72
# various concurrencies to use with sysbench
73
#concurrencies = [16, 32, 64, 128, 256, 512, 1024]
74
concurrencies = [1, 4, 8 ]
77
for concurrency in concurrencies:
78
self.logging.info("Resetting test server...")
79
for query in ["DROP SCHEMA IF EXISTS test"
82
retcode, result = self.execute_query(query, master_server, schema="INFORMATION_SCHEMA")
83
test_cmd.append("--num-threads=%d" %concurrency)
84
# we setup once per concurrency, copying drizzle-automation
85
# this should likely change and if not for readonly, then definitely
88
exec_cmd = " ".join(test_cmd)
89
retcode, output = prepare_sysbench(test_executor, exec_cmd)
90
err_msg = ("sysbench 'prepare' phase failed.\n"
92
"output: %s" %(retcode,output))
93
self.assertEqual(retcode, 0, msg = err_msg)
95
for test_iteration in range(iterations):
96
retcode, output = execute_sysbench(test_executor, exec_cmd)
97
self.assertEqual(retcode, 0, msg = output)
98
parsed_output = process_sysbench_output(output)
99
self.logging.info(parsed_output)
102
server_manager.reset_servers(test_executor.name)