79
79
self.logging.debug_class(self)
81
def execute(self, start_and_exit):
82
""" Execute a test case. The details are *very* mode specific """
83
self.status = 1 # we are running
86
self.logging.verbose("Executor: %s beginning test execution..." %(self.name))
87
while self.test_manager.has_tests() and keep_running == 1:
89
for i in range(self.testcase_repeat_count):
90
self.handle_system_reqs()
91
self.handle_server_reqs()
92
self.handle_utility_reqs()
93
self.handle_start_and_exit(start_and_exit)
94
if self.current_test_status != 'fail':
95
self.execute_testCase()
96
self.record_test_result()
97
if self.current_test_status == 'fail' and not self.execution_manager.force:
98
self.logging.error("Failed test. Use --force to execute beyond the first test failure")
81
102
def get_testCase(self):
82
103
""" Ask our execution_manager for a testCase to work on """
86
107
#self.test_manager.mutex.release()
89
def handle_server_reqs(self, start_and_exit):
110
def handle_server_reqs(self):
90
111
""" Get the servers required to execute the testCase
91
112
and ensure that we have servers and they were started
92
113
as expected. We take necessary steps if not
93
114
We also handle --start-and-exit here
97
master_count, slave_count, server_options = self.process_server_reqs()
118
server_requirements = self.current_testcase.server_requirements
98
119
(self.current_servers,bad_start) = self.server_manager.request_servers( self.name
121
, server_requirements
103
122
, self.working_environment)
104
123
if self.current_servers == 0 or bad_start:
105
124
# error allocating servers, test is a failure
107
126
self.current_test_status = 'fail'
108
127
self.set_server_status(self.current_test_status)
112
# TODO: Report out all started servers via server_manager/server objects?
113
self.current_servers[0].report()
114
self.logging.info("User specified --start-and-exit. dbqp.py exiting and leaving servers running...")
131
self.current_servers[0].report()
132
self.master_server = self.current_servers[0]
135
def handle_start_and_exit(self, start_and_exit):
136
""" Do what needs to be done if we have the
137
--start-and-exit flag
115
141
# We blow away any port_management files for our ports
116
142
# Technically this won't let us 'lock' any ports that
117
143
# we aren't explicitly using (visible to netstat scan)
119
145
# We shouldn't hog it ; )
120
146
# We might need to do this better later
121
147
for server in self.current_servers:
148
if server != self.master_server:
122
150
server.cleanup() # this only removes any port files
151
self.logging.info("User specified --start-and-exit. dbqp.py exiting and leaving servers running...")
126
self.current_servers[0].report()
127
self.master_server = self.current_servers[0]
130
def process_server_reqs(self):
131
""" Check out our current_testcase to see what kinds of servers
132
we need up and running. The executionManager sees to
154
def handle_utility_reqs(self):
155
""" Call any utilities we want to use before starting a test
156
At present this is envisioned for use with datagen
157
but there may be other things we wish to use
158
At that point, we may need to explore other ways of
159
defining our testing environment, such as with
160
nice config files / modules
137
master_count = self.current_testcase.master_count
138
slave_count = self.current_testcase.slave_count
139
server_options = self.current_testcase.server_options
141
return(master_count, slave_count, server_options)
143
def execute(self, start_and_exit):
144
""" Execute a test case. The details are *very* mode specific """
145
self.status = 1 # we are running
148
self.logging.verbose("Executor: %s beginning test execution..." %(self.name))
149
while self.test_manager.has_tests() and keep_running == 1:
151
self.handle_system_reqs()
152
self.handle_server_reqs(start_and_exit)
153
for i in range(self.testcase_repeat_count):
154
self.execute_testCase()
155
self.record_test_result()
156
if self.current_test_status == 'fail' and not self.execution_manager.force:
157
self.logging.error("Failed test. Use --force to execute beyond the first test failure")
164
# We call gendata against the server(s) with the
166
if self.execution_manager.gendata_file:
167
dsn = "--dsn=dbi:drizzle:host=localhost:port=%d:user=root:password="":database=test" %(self.master_server.master_port)
168
gendata_cmd = "./gendata.pl %s --spec=%s" %( dsn
169
, self.execution_manager.gendata_file
171
#self.system_manager.execute_cmd(gendata_cmd)
172
gendata_subproc = subprocess.Popen( gendata_cmd
174
, cwd=self.system_manager.randgen_path
178
gendata_subproc.wait()
179
gendata_retcode = gendata_subproc.returncode
181
self.logging.error("gendata command: %s failed with retcode: %d" %(gendata_cmd
161
184
def execute_testCase(self):
162
185
""" Do whatever evil voodoo we must do to execute a testCase """