2
# -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
3
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5
# Copyright (C) 2010 Patrick Crews
8
code related to the execution of est cases
10
We are provided access to a testManager with
11
mode-specific testCases. We contact the executionManager
12
to produce the system and server configurations we need
21
""" class for handling the execution of testCase
22
objects. Mode-specific executors inherit
27
def __init__(self, execution_manager, name, verbose, debug):
28
self.skip_keys = [ 'execution_manager'
33
self.verbose = verbose
35
self.status = 0 # not running
36
self.execution_manager = execution_manager
37
self.system_manager = self.execution_manager.system_manager
38
self.logging = self.system_manager.logging
39
self.test_manager = self.execution_manager.test_manager
40
self.server_manager = self.execution_manager.server_manager
42
self.master_server = None
43
self.record_flag=self.execution_manager.record_flag
44
self.environment_vars = {}
45
self.current_servers = []
46
self.current_testcase = None
47
self.current_test_status = None
48
self.dirset = { self.name : { 'log': None } }
49
self.workdir = self.system_manager.create_dirset( self.system_manager.workdir
51
self.logdir = os.path.join(self.workdir,'log')
54
self.logging.debug_class(self)
56
def get_testCase(self):
57
""" Ask our execution_manager for a testCase to work on """
59
#self.test_manager.mutex.acquire()
60
self.current_testcase = self.test_manager.get_testCase(self.name)
61
#self.test_manager.mutex.release()
63
self.logging.debug("Executor: %s, assigned test: %s" %(self.name
64
, self.current_testcase.fullname))
66
def handle_server_reqs(self):
67
""" Get the servers required to execute the testCase """
69
master_count, slave_count, server_options = self.process_server_reqs()
70
self.current_servers = self.server_manager.request_servers( self.name
75
if self.current_servers == 0:
76
# error allocating servers, test is a failure
80
self.current_servers[0].report()
81
self.master_server = self.current_servers[0]
84
def process_server_reqs(self):
85
""" Check out our current_testcase to see what kinds of servers
86
we need up and running. The executionManager sees to
91
master_count = self.current_testcase.master_count
92
slave_count = self.current_testcase.slave_count
93
server_options = self.current_testcase.server_options
95
return(master_count, slave_count, server_options)
98
""" Execute a test case. The details are *very* mode specific """
99
self.status = 1 # we are running
102
self.logging.verbose("Executor: %s beginning test execution..." %(self.name))
103
while self.test_manager.has_tests() and keep_running == 1:
105
self.handle_server_reqs()
106
test_status = self.execute_testCase()
107
if test_status == 'fail' and not self.execution_manager.force:
108
self.logging.error("Failed test. Use --force to execute beyond the first test failure")
112
def execute_testCase(self):
113
""" Do whatever evil voodoo we must do to execute a testCase """
115
self.logging.verbose("Executor: %s executing test: %s" %(self.name, self.current_testcase.fullname))