~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/lib/sys_mgmt/codeTree.py

  • Committer: patrick crews
  • Date: 2011-07-26 19:30:09 UTC
  • mto: (2429.2.1 dbqp_revamp)
  • mto: This revision was merged to the branch mainline in revision 2435.
  • Revision ID: gleebix@gmail.com-20110726193009-3zymdgez65m1zj65
Additional work for running MySQL servers (still not ready for prime-time / working)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
"""
30
30
# imports
31
31
import os
 
32
import sys
32
33
 
33
34
 
34
35
class codeTree:
187
188
        self.charsetdir = self.system_manager.find_path([os.path.join(self.basedir, 'mysql/charsets')
188
189
                                                       , os.path.join(self.basedir, 'sql/share/charsets')
189
190
                                                       , os.path.join(self.basedir, 'share/charsets')])
 
191
        self.langdir = self.system_manager.find_path([os.path.join(self.basedir, 'share/mysql')
 
192
                                                    , os.path.join(self.basedir, 'sql/share')
 
193
                                                    , os.path.join(self.basedir, 'share')])
 
194
 
190
195
 
191
196
        self.srcdir = self.system_manager.find_path([self.basedir])
192
197
        self.suite_paths = variables['suitepaths']
232
237
 
233
238
        self.mysqltest = self.system_manager.find_path([os.path.join(self.clientbindir,
234
239
                                                   'mysqltest')])
235
 
 
236
240
        self.server_version_string = None
237
241
        self.server_executable = None
238
242
        self.server_version = None
240
244
        self.server_platform = None
241
245
        self.server_compile_comment = None
242
246
        self.type = 'mysql'
243
 
 
244
247
        self.process_server_version()
245
248
        self.ld_lib_paths = self.get_ld_lib_paths()
 
249
        self.bootstrap_path = os.path.join( self.system_manager.workdir
 
250
                                          , 'mysql_bootstrap.sql' )
 
251
        self.generate_bootstrap()
246
252
         
247
253
        self.report()
248
254
 
289
295
                           , os.path.join(self.basedir,"lib/mysql")]
290
296
        return ld_lib_paths
291
297
 
 
298
    def generate_bootstrap(self):
 
299
        """ We do the voodoo that we need to in order to create the bootstrap
 
300
            file needed by MySQL
 
301
 
 
302
        """
 
303
        found_new_sql = False
 
304
        # determine if we have a proper area for our sql or if we
 
305
        # use the rigged method from 5.0 / 5.1
 
306
        # first we search various possible locations
 
307
        test_file = "mysql_system_tables.sql"
 
308
        for candidate_dir in [ "mysql"
 
309
                         , "sql/share"
 
310
                         , "share/mysql"
 
311
                                           , "share"
 
312
                         , "scripts"]:
 
313
            candidate_path = os.path.join(self.basedir, candidate_dir, test_file)
 
314
            if os.path.exists(candidate_path):
 
315
                bootstrap_file = open(self.bootstrap_path,'w')
 
316
                bootstrap_file.write("use mysql\n")
 
317
                for sql_file in [ 'mysql_system_tables.sql' #official mysql system tables
 
318
                                , 'mysql_system_tables_data.sql' #initial data for sys tables
 
319
                                , 'mysql_test_data_timezone.sql' # subset of full tz table data for testing
 
320
                                , 'fill_help_tables.sql' # fill help tables populated only w/ src dist(?)
 
321
                                ]:
 
322
                    sql_file_path = os.path.join(self.basedir,candidate_dir,sql_file)
 
323
                    sql_file_handle = open(sql_file_path,'r')
 
324
                    bootstrap_file.write(sql_file_handle.readlines())
 
325
                    sql_file_handle.close()
 
326
                found_new_sql = True
 
327
                break
 
328
        if not found_new_sql:
 
329
            # Install the system db's from init_db.sql
 
330
            # that is in early 5.1 and 5.0 versions of MySQL
 
331
            sql_file_path = os.path.join(self.basedir,'mysql-test/lib/init_db.sql')
 
332
            self.logging.info("Attempting to use bootstrap file - %s" %(sql_file_path))
 
333
            try:
 
334
                in_file = open(sql_file_path,'r')
 
335
                bootstrap_file = open(self.bootstrap_path,'w')
 
336
                bootstrap_file.write(in_file.readlines())
 
337
                in_file.close()
 
338
            except IOError:
 
339
                self.logging.error("Cannot find data for generating bootstrap file")
 
340
                self.logging.error("Cannot proceed without this, system exiting...")
 
341
                sys.exit(1)
 
342
        # Remove anonymous users
 
343
        bootstrap_file.write("DELETE FROM mysql.user where user= '';\n")
 
344
        # Create mtr database
 
345
        bootstrap_file.write("CREATE DATABASE mtr;\n")
 
346
        for sql_file in [ 'mtr_warnings.sql' # help tables + data for warning detection / suppression
 
347
                        , 'mtr_check.sql' # Procs for checking proper restore post-testcase
 
348
                        ]:
 
349
            sql_file_path = os.path.join(self.basedir,'mysql-test/include',sql_file)
 
350
            sql_file_handle = open(sql_file_path,'r')
 
351
            bootstrap_file.write(sql_file_handle.readlines())
 
352
            sql_file_handle.close()
 
353
        bootstrap_file.close()
 
354
        return
 
355
 
 
356
 
 
357
        
 
358
 
292
359
 
293
360