~zisis00/drizzle/ldap_policy

« back to all changes in this revision

Viewing changes to tests/qp_tests/sysbench/sysbench_readonly_test.py

  • Committer: Zisis Sialveras
  • Date: 2012-08-09 18:18:22 UTC
  • mfrom: (2553.1.25 workspace)
  • Revision ID: zisis00@gmail.com-20120809181822-9wobhdfdx411tu5w
Some changes in ldap_policy

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
# -*- mode: python; indent-tabs-mode: nil; -*-
 
3
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
4
#
 
5
# Copyright (C) 2011 Patrick Crews
 
6
#
 
7
#
 
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.
 
12
#
 
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.
 
17
#
 
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
 
21
 
 
22
import unittest
 
23
import subprocess
 
24
import time
 
25
 
 
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
 
30
 
 
31
# TODO:  make server_options vary depending on the type of server being used here
 
32
# drizzle options
 
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']]
 
34
# mysql options
 
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 = [[]]
 
37
servers = []
 
38
server_manager = None
 
39
test_executor = None
 
40
 
 
41
class basicTest(mysqlBaseTestCase):
 
42
        
 
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"
 
48
                   , "--max-time=240"
 
49
                   , "--max-requests=0"
 
50
                   , "--test=oltp"
 
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
 
60
                   ]
 
61
 
 
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)
 
66
       
 
67
        # We sleep for a minute to wait
 
68
        time.sleep(10) 
 
69
        # how many times to run sysbench at each concurrency
 
70
        iterations = 1
 
71
        
 
72
        # various concurrencies to use with sysbench
 
73
        #concurrencies = [16, 32, 64, 128, 256, 512, 1024]
 
74
        concurrencies = [1, 4, 8 ]
 
75
 
 
76
        # start the test!
 
77
        for concurrency in concurrencies:
 
78
            self.logging.info("Resetting test server...")
 
79
            for query in ["DROP SCHEMA IF EXISTS test"
 
80
                         ,"CREATE SCHEMA test"
 
81
                         ]:
 
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
 
86
            # for readwrite
 
87
 
 
88
            exec_cmd = " ".join(test_cmd)
 
89
            retcode, output = prepare_sysbench(test_executor, exec_cmd)
 
90
            err_msg = ("sysbench 'prepare' phase failed.\n"
 
91
                       "retcode:  %d"
 
92
                       "output:  %s" %(retcode,output))
 
93
            self.assertEqual(retcode, 0, msg = err_msg) 
 
94
 
 
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)
 
100
 
 
101
    def tearDown(self):
 
102
            server_manager.reset_servers(test_executor.name)
 
103