~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/lib/test_run_options.py

* Completes the blueprint for splitting the XA Resource Manager
  API from the storage engine API:

We add a new plugin::XaResourceManager abstract interface class
which exposes the X/Open XA distributed transaction protocol for
resource managers.

We add a new plugin::MonitoredInTransaction base class from
which all plugins that need monitored by Drizzle's transaction
manager (drizzled::TransactionServices component) derive.

All plugin::StorageEngine's now derive from plugin::MonitoredInTransaction
since all storage engines a monitored by the transaction manager
and the Session keeps a "slot" available for keeping the engine's
per-session data state.  In a future patch, the transaction log's
XaApplier plugin will also derive from MonitoredInTransaction, as
the transaction log, in XA mode, is also monitored by Drizzle's
transaction manager and automatically enlisted in XA transactions.

* Updates all documentation in /drizzled/transaction_services.cc
  to accurately reflect Drizzle's new transaction management
  process and explicit transaction and statement boundaries.

* Kills off dead code:

  binlog_format_names
  ha_init()
  total_ha, total_ha_2pc (no longer necessary, as the above-mentioned
  abstract base classes provide all of this functionality)
  StorageEngine::slot (now plugin::MonitoredInTransaction::getId())
  TransactionalStorageEngine::two_phase_commit (same as above)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /usr/bin/env python
2
 
# -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
3
 
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
 
#
5
 
# Copyright (C) 2010 Patrick Crews
6
 
#
7
 
# This program is free software; you can redistribute it and/or modify
8
 
# it under the terms of the GNU General Public License as published by
9
 
# the Free Software Foundation; either version 2 of the License, or
10
 
# (at your option) any later version.
11
 
#
12
 
# This program is distributed in the hope that it will be useful,
13
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
# GNU General Public License for more details.
16
 
#
17
 
# You should have received a copy of the GNU General Public License
18
 
# along with this program; if not, write to the Free Software
19
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
 
 
21
 
 
22
 
 
23
 
"""Processes command line options for Drizzle test-runner"""
24
 
 
25
 
import sys
26
 
import os
27
 
import exceptions
28
 
import optparse
29
 
 
30
 
# functions
31
 
def comma_list_split(option, opt, value, parser):
32
 
    """Callback for splitting input expected in list form"""
33
 
    cur_list = getattr(parser.values, option.dest,[])
34
 
    input_list = value.split(',')
35
 
    # this is a hack to work with make target - we
36
 
    # don't deal with a dangling ',' in our list
37
 
    if '' in input_list:
38
 
        input_list.remove('')
39
 
    if cur_list:
40
 
        value_list = cur_list + input_list 
41
 
    else:
42
 
        value_list = input_list 
43
 
    setattr(parser.values, option.dest, value_list)
44
 
 
45
 
def organize_options(args, test_cases):
46
 
    """Put our arguments in a nice dictionary
47
 
       We use option.dest as dictionary key
48
 
       item = supplied input
49
 
 
50
 
    """
51
 
    variables = {}
52
 
    variables = vars(args)
53
 
    variables['test_cases']= test_cases
54
 
    # This code should become a function once
55
 
    # enough thought has been given to it
56
 
    if variables['manualgdb']:
57
 
        variables['gdb']=True
58
 
    if variables['repeat'] <= 0:
59
 
        print "Setting --repeat=1.  You chose a silly value that I will ignore :P"
60
 
        variables['repeat'] = 1
61
 
    return variables
62
 
 
63
 
# Create the CLI option parser
64
 
parser= optparse.OptionParser()
65
 
 
66
 
# find some default values
67
 
# assume we are in-tree testing in general and operating from root/test(?)
68
 
testdir_default = os.path.abspath(os.getcwd())
69
 
 
70
 
server_default = os.path.abspath(os.path.join(testdir_default,
71
 
                                       '../drizzled/drizzled'))
72
 
 
73
 
workdir_default = os.path.join(testdir_default,'dbqp_work')
74
 
 
75
 
clientbindir_default = os.path.abspath(os.path.join(testdir_default,
76
 
                                       '../client'))
77
 
 
78
 
basedir_default = os.path.split(testdir_default)[0]
79
 
 
80
 
 
81
 
# system_control_group - things like verbose, debug, etc
82
 
# test-runner affecting options
83
 
system_control_group = optparse.OptionGroup(parser, 
84
 
                         "Options for the test-runner itself")
85
 
 
86
 
system_control_group.add_option(
87
 
   "--force"
88
 
 , dest="force"
89
 
 , action="store_true"
90
 
 , default=False
91
 
 , help="Set this to continue test execution beyond the first failed test"
92
 
 )
93
 
 
94
 
system_control_group.add_option(
95
 
    "--start-and-exit"
96
 
  , dest="startandexit"
97
 
  , action="store_true"
98
 
  , default=False
99
 
  , help="Spin up the server(s) for the first specified test then exit (will leave servers running)"
100
 
  )
101
 
 
102
 
system_control_group.add_option(
103
 
    "--verbose"
104
 
   , dest="verbose"
105
 
   , action="store_true"
106
 
   , default = False
107
 
   , help="Produces extensive output about test-runner state.  Distinct from --debug"
108
 
   )
109
 
 
110
 
system_control_group.add_option(
111
 
    "--debug"
112
 
   , dest="debug"
113
 
   , action="store_true"
114
 
   , default = False
115
 
   , help="Provide internal-level debugging output.  Distinct from --verbose"
116
 
   )
117
 
 
118
 
system_control_group.add_option(
119
 
    "--mode"
120
 
  , dest="mode"
121
 
  , default="dtr"
122
 
  , help="Testing mode.  We only support dtr...for now >;) [%default]"
123
 
  )
124
 
 
125
 
system_control_group.add_option(
126
 
    "--record"
127
 
  , dest="record"
128
 
  , action="store_true"
129
 
  , default=False
130
 
  , help="Record a testcase result (if the testing mode supports it) [%default]"
131
 
  )
132
 
 
133
 
system_control_group.add_option(
134
 
    "--fast"
135
 
  , dest="fast"
136
 
  , action="store_true"
137
 
  , default=False
138
 
  , help="Don't try to cleanup from earlier runs (currently just a placeholder) [%default]"
139
 
  )
140
 
 
141
 
parser.add_option_group(system_control_group)
142
 
 
143
 
# end system_control_group
144
 
 
145
 
# test_control_group - things like suite, do-test, skip-test
146
 
# Affect which tests are run
147
 
test_control_group = optparse.OptionGroup(parser, 
148
 
                         "Options for controlling which tests are executed")
149
 
 
150
 
 
151
 
test_control_group.add_option(
152
 
    "--suite"
153
 
  , dest="suitelist"
154
 
  , type='string'
155
 
  , action="callback"
156
 
  , callback=comma_list_split
157
 
  , help="The name of the suite containing tests we want. Can accept comma-separated list (with no spaces).  Additional --suite args are appended to existing list [autosearch]"
158
 
  )
159
 
 
160
 
test_control_group.add_option(
161
 
    "--suitepath"
162
 
  , dest="suitepaths"
163
 
  , type='string'
164
 
  , action="append"
165
 
  , default = []
166
 
  , help="The path containing the suite(s) you wish to execute.  Use on --suitepath for each suite you want to use."
167
 
  )
168
 
test_control_group.add_option(
169
 
    "--do-test"
170
 
  , dest="dotest"
171
 
  , type='string'
172
 
  , default = None
173
 
  , help="input can either be a prefix or a regex. Will only execute tests that match the provided pattern"
174
 
  )
175
 
 
176
 
test_control_group.add_option(
177
 
    "--skip-test"
178
 
  , dest="skiptest"
179
 
  , type='string'
180
 
  , default = None
181
 
  , help = "input can either be a prefix or a regex.  Will exclude tests that match the provided pattern"
182
 
  )
183
 
 
184
 
test_control_group.add_option(
185
 
    "--reorder"
186
 
  , dest="reorder"
187
 
  , action="store_true"
188
 
  , default=False
189
 
  , help = "sort the testcases so that they are executed optimally for the given mode [%default]"
190
 
  )
191
 
 
192
 
test_control_group.add_option(
193
 
    "--repeat"
194
 
  , dest="repeat"
195
 
  , type='int'
196
 
  , action="store"
197
 
  , default=1
198
 
  , help = "Run each test case the specified number of times.  For a given sequence, the first test will be run n times, then the second, etc [%default]"
199
 
  )
200
 
 
201
 
parser.add_option_group(test_control_group)
202
 
# end test_control_group
203
 
 
204
 
# test subject control group
205
 
# terrible name for options tht define the server / code
206
 
# that is under test
207
 
test_subject_control_group = optparse.OptionGroup(parser,
208
 
                                 "Options for defining the code that will be under test")
209
 
 
210
 
test_subject_control_group.add_option(
211
 
    "--basedir"
212
 
  , dest="basedir"
213
 
  , type='string'
214
 
  , default = basedir_default
215
 
  , help = "Pass this argument to signal to the test-runner that this is an in-tree test.  We automatically set a number of variables relative to the argument (client-bindir, serverdir, testdir) [%default]"
216
 
  )
217
 
 
218
 
test_subject_control_group.add_option(
219
 
    "--serverdir"
220
 
  , dest="serverpath"
221
 
  , type='string'
222
 
  , default = "auto-search"
223
 
  , help = "Path to the server executable.  [%default]"
224
 
  )
225
 
 
226
 
test_subject_control_group.add_option(
227
 
    "--client-bindir"
228
 
  , dest="clientbindir"
229
 
  , type = 'string'
230
 
  , default = "auto-search"
231
 
  , help = "Path to the directory containing client program binaries for use in testing [%default]"
232
 
  )
233
 
 
234
 
 
235
 
test_subject_control_group.add_option(
236
 
    "--default-storage-engine"
237
 
   , dest="defaultengine"
238
 
   , default = 'innodb'
239
 
   , help="Start drizzled using the specified engine [%default]"
240
 
   )    
241
 
 
242
 
 
243
 
parser.add_option_group(test_subject_control_group)
244
 
# end test subject control group
245
 
 
246
 
 
247
 
# environment options
248
 
# define where to find our testsets, working dirs, etc
249
 
environment_control_group = optparse.OptionGroup(parser, 
250
 
                            "Options for defining the testing environment")
251
 
 
252
 
environment_control_group.add_option(
253
 
    "--testdir"
254
 
  , dest="testdir"
255
 
  , type = 'string'
256
 
  , default = testdir_default
257
 
  , help = "Path to the test dir, containing additional files for test execution. [%default]"
258
 
  )
259
 
 
260
 
environment_control_group.add_option(
261
 
    "--workdir"
262
 
  , dest="workdir"
263
 
  , type='string'
264
 
  , default = workdir_default
265
 
  , help = "Path to the directory test-run will use to store generated files and directories. [%default]"
266
 
  )
267
 
 
268
 
environment_control_group.add_option(
269
 
    "--top-srcdir"
270
 
  , dest="topsrcdir"
271
 
  , type='string'
272
 
  , default = basedir_default
273
 
  , help = "build option [%default]"
274
 
  )
275
 
 
276
 
environment_control_group.add_option(
277
 
    "--top-builddir"
278
 
  , dest="topbuilddir"
279
 
  , type='string'
280
 
  , default = basedir_default
281
 
  , help = "build option [%default]"
282
 
  )
283
 
 
284
 
environment_control_group.add_option(
285
 
    "--no-shm"
286
 
  , dest="noshm"
287
 
  , action='store_true'
288
 
  , default=False
289
 
  , help = "By default, we symlink workdir to a location in shm.  Use this flag to not symlink [%default]"
290
 
  )
291
 
 
292
 
environment_control_group.add_option(
293
 
    "--start-dirty"
294
 
  , dest="startdirty"
295
 
  , action='store_true'
296
 
  , default=False
297
 
  , help = "Don't try to clean up working directories before test execution [%default]"
298
 
  )
299
 
 
300
 
environment_control_group.add_option(
301
 
    "--no-secure-file-priv"
302
 
  , dest = "nosecurefilepriv"
303
 
  , action='store_true'
304
 
  , default=False
305
 
  , help = "Turn off the use of --secure-file-priv=vardir for started servers"
306
 
  )
307
 
 
308
 
parser.add_option_group(environment_control_group)
309
 
# end environment control group
310
 
 
311
 
option_passing_group = optparse.OptionGroup(parser,
312
 
                          "Options to pass options on to the server")
313
 
 
314
 
option_passing_group.add_option(
315
 
    "--drizzled"
316
 
  , dest="drizzledoptions"
317
 
  , type='string'
318
 
  , action='append' 
319
 
  , default = []
320
 
  , help = "Pass additional options to the server.  Will be passed to all servers for all tests (mostly for --start-and-exit)"
321
 
  )
322
 
 
323
 
parser.add_option_group(option_passing_group)
324
 
# end option passing group
325
 
 
326
 
 
327
 
analysis_control_group = optparse.OptionGroup(parser, 
328
 
                            "Options for defining the tools we use for code analysis (valgrind, gprof, gcov, etc)")
329
 
 
330
 
analysis_control_group.add_option(
331
 
    "--valgrind"
332
 
  , dest="valgrind"
333
 
  , action='store_true'
334
 
  , default = False
335
 
  , help = "Run drizzletest and drizzled executables using valgrind with default options [%default]"
336
 
  )
337
 
analysis_control_group.add_option(
338
 
    "--valgrind-option"
339
 
  , dest="valgrindarglist"
340
 
  , type='string'
341
 
  , action="append"
342
 
  , help = "Pass an option to valgrind (overrides/removes default valgrind options)"
343
 
  )
344
 
 
345
 
parser.add_option_group(analysis_control_group)
346
 
 
347
 
debugger_control_group = optparse.OptionGroup(parser,
348
 
                           "Options for controlling the use of debuggers with test execution")
349
 
 
350
 
debugger_control_group.add_option(
351
 
    "--gdb"
352
 
  , dest="gdb"
353
 
  , action='store_true'
354
 
  , default=False
355
 
  , help="Start the drizzled server(s) in gdb"
356
 
  )
357
 
 
358
 
debugger_control_group.add_option(
359
 
    "--manual-gdb"
360
 
  , dest="manualgdb"
361
 
  , action='store_true'
362
 
  , default=False
363
 
  , help="Allows you to start the drizzled server(s) in gdb manually (in another window, etc)"
364
 
  )
365
 
 
366
 
parser.add_option_group(debugger_control_group)
367
 
 
368
 
 
369
 
# supplied will be those arguments matching an option, 
370
 
# and test_cases will be everything else
371
 
(args, test_cases)= parser.parse_args()
372
 
 
373
 
variables = {}
374
 
variables = organize_options(args, test_cases)
375