60
51
self.initial_run = 1
61
52
self.owner = requester
62
53
self.server_options = server_options
63
self.default_storage_engine = default_storage_engine
64
54
self.server_manager = server_manager
65
55
# We register with server_manager asap
66
56
self.server_manager.log_server(self, requester)
68
58
self.system_manager = self.server_manager.system_manager
69
59
self.valgrind = self.system_manager.valgrind
70
self.gdb = self.system_manager.gdb
72
61
self.valgrind_time_buffer = 10
74
self.valgrind_time_buffer = 1
63
self.valgrind_time_buffer = 0
75
64
self.cmd_prefix = self.system_manager.cmd_prefix
76
65
self.logging = self.system_manager.logging
77
66
self.no_secure_file_priv = self.server_manager.no_secure_file_priv
159
148
value = vars(self)[key]
160
149
self.logging.info("%s: %s" %(key.upper(), value))
162
def get_start_cmd(self):
163
""" Return the command string that will start up the server
164
as desired / intended
151
def start(self, expect_fail):
152
""" Start the server, using the options in option_list
153
as well as self.standard_options
155
if expect_fail = 1, we know the server shouldn't
168
server_args = [ self.process_server_options()
169
, "--mysql-protocol.port=%d" %(self.master_port)
170
, "--mysql-protocol.connect-timeout=60"
171
, "--innodb.data-file-path=ibdata1:20M:autoextend"
172
, "--sort-buffer-size=256K"
173
, "--max-heap-table-size=1M"
174
, "--mysql-unix-socket-protocol.path=%s" %(self.socket_file)
175
, "--pid-file=%s" %(self.pid_file)
176
, "--drizzle-protocol.port=%d" %(self.drizzle_tcp_port)
177
, "--default-storage-engine=%s" %(self.default_storage_engine)
178
, "--datadir=%s" %(self.datadir)
179
, "--tmpdir=%s" %(self.tmpdir)
180
, self.secure_file_string
185
server_args.append('--gdb')
186
return self.system_manager.handle_gdb_reqs(self, server_args)
160
self.logging.verbose("Starting server: %s.%s" %(self.owner, self.name))
161
start_cmd = "%s %s %s --mysql-protocol.port=%d --mysql-protocol.connect-timeout=60 --mysql-unix-socket-protocol.path=%s --pid-file=%s --drizzle-protocol.port=%d --datadir=%s --tmpdir=%s --innodb.data-file-path=ibdata1:20M:autoextend --sort-buffer-size=256K --max-heap-table-size=1M %s %s > %s 2>&1 & " % ( self.cmd_prefix
163
, self.process_server_options()
167
, self.drizzle_tcp_port
170
, self.secure_file_string
175
self.logging.debug("Starting server with:")
176
self.logging.debug("%s" %(start_cmd))
177
# we signal we tried to start as an attempt
178
# to catch the case where a server is just
179
# starting up and the user ctrl-c's
180
# we don't know the server is running (still starting up)
181
# so we give it a few minutes
183
server_retcode = os.system(start_cmd)
186
timeout = self.server_start_timeout
187
while not self.ping(quiet= True) and timer != timeout:
190
# We make sure the server is running and return False if not
191
if timer == timeout and not self.ping(quiet= True):
192
self.logging.error(( "Server failed to start within %d seconds. This could be a problem with the test machine or the server itself" %(timeout)))
195
if server_retcode == 0:
196
self.status = 1 # we are running
198
if server_retcode != 0 and not expect_fail and self.debug:
199
self.logging.debug("Server startup command: %s failed with error code %d" %( start_cmd
201
elif server_retcode == 0 and expect_fail:
202
# catch a startup that should have failed and report
203
self.logging.error("Server startup command :%s expected to fail, but succeeded" %(start_cmd))
205
return server_retcode ^ expect_fail
208
""" Stop the server """
210
self.logging.verbose("Stopping server %s.%s" %(self.owner, self.name))
211
stop_cmd = "%s --user=root --port=%d --shutdown " %(self.drizzle_client_path, self.master_port)
213
self.logging.debug("%s" %(stop_cmd))
214
retcode, output = self.system_manager.execute_cmd(stop_cmd)
216
self.logging.error("Problem shutting down server:")
217
self.logging.error("%s : %s" %(retcode, output))
188
return "%s %s %s & " % ( self.cmd_prefix
190
, " ".join(server_args)
194
def get_stop_cmd(self):
195
""" Return the command that will shut us down """
197
return "%s --user=root --port=%d --shutdown " %(self.drizzle_client_path, self.master_port)
219
self.status = 0 # indicate we are shutdown
200
def get_ping_cmd(self):
201
"""Return the command string that will
202
ping / check if the server is alive
206
return "%s --ping --port=%d --user=root" % (self.drizzle_client_path, self.master_port)
222
def ping(self, quiet= False):
223
"""Pings the server. Returns True if server is up and running, False otherwise."""
224
ping_cmd= "%s --ping --port=%d --user=root" % (self.drizzle_client_path, self.master_port)
226
self.logging.info("Pinging Drizzled server on port %d" % self.master_port)
227
(retcode, output)= self.system_manager.execute_cmd(ping_cmd, must_pass = 0)
208
230
def process_server_options(self):
209
231
"""Consume the list of options we have been passed.