67
68
self.logging.debug_class(self)
69
def request_servers( self, requester, workdir, server_requirements
70
def request_servers( self, requester, workdir, cnf_path, server_requirements
70
71
, working_environ, expect_fail = 0):
71
72
""" We produce the server objects / start the server processes
72
73
as requested. We report errors and whatnot if we can't
88
89
, workdir, server_requirements)
90
91
# Make sure we are running with the correct options
91
self.evaluate_existing_servers(requester, server_requirements)
92
self.evaluate_existing_servers(requester, cnf_path, server_requirements)
93
94
# Fire our servers up
94
95
bad_start = self.start_servers( requester, working_environ
316
317
def log_server(self, new_server, requester):
317
318
self.servers[requester].append(new_server)
319
def evaluate_existing_servers( self, requester, server_requirements):
320
def evaluate_existing_servers( self, requester, cnf_path, server_requirements):
320
321
""" See if the requester has any servers and if they
321
322
are suitable for the current test
326
327
current_servers = self.servers[requester]
329
# We have a config reader so we can do
330
# special per-server magic for setting up more
331
# complex scenario-based testing (eg we use a certain datadir)
333
config_reader = RawConfigParser()
334
config_reader.read(cnf_path)
337
# A list that holds tuples of src,tgt pairs
338
# for using a pre-loaded-datadirs on a test server
339
datadir_requests = []
328
341
for index,server in enumerate(current_servers):
329
server_options = server_requirements[index]
343
desired_server_options = server_requirements[index]
330
344
# We add in any user-supplied options here
331
server_options = server_options + self.user_server_opts
345
desired_server_options = desired_server_options + self.user_server_opts
347
# Do our checking for config-specific madness we need to do
348
if config_reader and config_reader.has_section(server.name):
349
# mark server for restart in case it hasn't yet
350
if '--restart' not in desired_server_options:
351
desired_server_options.append('--restart')
352
# We handle various scenarios
353
server_config_data = config_reader.items(server.name)
354
for cnf_option, data in server_config_data:
355
if cnf_option == 'load-datadir':
357
datadir_requests.append((datadir_path,server))
332
359
if self.compare_options( server.server_options
360
, desired_server_options):
336
363
# We need to reset what is running and change the server
338
server_options = self.filter_server_options(server_options)
365
desired_server_options = self.filter_server_options(desired_server_options)
339
366
self.reset_server(server)
340
self.update_server_options(server, server_options)
367
self.update_server_options(server, desired_server_options)
368
self.load_datadirs(datadir_requests)
375
403
for server in self.servers[requester]:
376
404
self.reset_server(server)
406
def load_datadirs(self, datadir_requests):
407
""" We load source_dir to the server's datadir """
408
for source_dir, server in datadir_requests:
409
source_dir_path = os.path.join(server.vardir,'std_data_ln',source_dir)
410
self.system_manager.remove_dir(server.datadir)
411
self.system_manager.copy_dir(source_dir_path, server.datadir)
379
414
def process_server_count(self, requester, desired_count, workdir, server_reqs):
380
415
""" We see how many servers we have. We shrink / grow