mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Versional testing support
This commit is contained in:
@ -188,8 +188,6 @@ my $exe_ndbd;
|
||||
my $exe_ndb_mgmd;
|
||||
my $exe_ndb_waiter;
|
||||
|
||||
our $path_sql_dir;
|
||||
|
||||
our $debug_compiled_binaries;
|
||||
|
||||
our %mysqld_variables;
|
||||
@ -651,7 +649,6 @@ sub run_worker ($) {
|
||||
|
||||
setup_vardir();
|
||||
check_running_as_root();
|
||||
mysql_install_db($thread_num);
|
||||
|
||||
if ( using_extern() ) {
|
||||
create_config_file_for_extern(%opts_extern);
|
||||
@ -894,21 +891,10 @@ sub command_line_setup {
|
||||
"$basedir/sql/share",
|
||||
"$basedir/share");
|
||||
|
||||
|
||||
$path_language= mtr_path_exists("$path_share/english");
|
||||
$path_charsetsdir= mtr_path_exists("$path_share/charsets");
|
||||
|
||||
# Look for SQL scripts directory
|
||||
if ( mtr_file_exists("$path_share/mysql_system_tables.sql") ne "")
|
||||
{
|
||||
# The SQL scripts are in path_share
|
||||
$path_sql_dir= $path_share;
|
||||
}
|
||||
else
|
||||
{
|
||||
$path_sql_dir= mtr_path_exists("$basedir/share",
|
||||
"$basedir/scripts");
|
||||
}
|
||||
|
||||
if (using_extern())
|
||||
{
|
||||
# Connect to the running mysqld and find out what it supports
|
||||
@ -2419,7 +2405,7 @@ sub initialize_servers {
|
||||
remove_stale_vardir();
|
||||
setup_vardir();
|
||||
|
||||
mysql_install_db(0);
|
||||
mysql_install_db(default_mysqld(), "$opt_vardir/install.db");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2474,9 +2460,33 @@ sub sql_to_bootstrap {
|
||||
}
|
||||
|
||||
|
||||
sub default_mysqld {
|
||||
# Generate new config file from template
|
||||
my $config= My::ConfigFactory->new_config
|
||||
( {
|
||||
basedir => $basedir,
|
||||
template_path => "include/default_my.cnf",
|
||||
vardir => $opt_vardir,
|
||||
tmpdir => $opt_tmpdir,
|
||||
baseport => 0,
|
||||
user => $opt_user,
|
||||
password => '',
|
||||
}
|
||||
);
|
||||
|
||||
my $mysqld= $config->group('mysqld.1')
|
||||
or mtr_error("Couldn't find mysqld.1 in default config");
|
||||
return $mysqld;
|
||||
}
|
||||
|
||||
|
||||
sub mysql_install_db {
|
||||
my ($thread_num)= @_;
|
||||
my $data_dir= "$opt_vardir/install.db";
|
||||
my ($mysqld, $datadir)= @_;
|
||||
|
||||
my $install_datadir= $datadir || $mysqld->value('datadir');
|
||||
my $install_basedir= $mysqld->value('basedir');
|
||||
my $install_lang= $mysqld->value('language');
|
||||
my $install_chsdir= $mysqld->value('character-sets-dir');
|
||||
|
||||
mtr_report("Installing system database...");
|
||||
|
||||
@ -2484,8 +2494,8 @@ sub mysql_install_db {
|
||||
mtr_init_args(\$args);
|
||||
mtr_add_arg($args, "--no-defaults");
|
||||
mtr_add_arg($args, "--bootstrap");
|
||||
mtr_add_arg($args, "--basedir=%s", $basedir);
|
||||
mtr_add_arg($args, "--datadir=%s", $data_dir);
|
||||
mtr_add_arg($args, "--basedir=%s", $install_basedir);
|
||||
mtr_add_arg($args, "--datadir=%s", $install_datadir);
|
||||
mtr_add_arg($args, "--loose-skip-innodb");
|
||||
mtr_add_arg($args, "--loose-skip-ndbcluster");
|
||||
mtr_add_arg($args, "--tmpdir=%s", "$opt_vardir/tmp/");
|
||||
@ -2497,47 +2507,60 @@ sub mysql_install_db {
|
||||
$path_vardir_trace);
|
||||
}
|
||||
|
||||
mtr_add_arg($args, "--language=%s", $path_language);
|
||||
mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
|
||||
mtr_add_arg($args, "--language=%s", $install_lang);
|
||||
mtr_add_arg($args, "--character-sets-dir=%s", $install_chsdir);
|
||||
|
||||
# If DISABLE_GRANT_OPTIONS is defined when the server is compiled (e.g.,
|
||||
# configure --disable-grant-options), mysqld will not recognize the
|
||||
# --bootstrap or --skip-grant-tables options. The user can set
|
||||
# MYSQLD_BOOTSTRAP to the full path to a mysqld which does accept
|
||||
# --bootstrap, to accommodate this.
|
||||
my $exe_mysqld_bootstrap = $ENV{'MYSQLD_BOOTSTRAP'} || find_mysqld($basedir);
|
||||
my $exe_mysqld_bootstrap =
|
||||
$ENV{'MYSQLD_BOOTSTRAP'} || find_mysqld($install_basedir);
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# export MYSQLD_BOOTSTRAP_CMD variable containing <path>/mysqld <args>
|
||||
# ----------------------------------------------------------------------
|
||||
$ENV{'MYSQLD_BOOTSTRAP_CMD'}= "$exe_mysqld_bootstrap " . join(" ", @$args);
|
||||
|
||||
return if $thread_num > 0; # Only generate MYSQLD_BOOTSTRAP_CMD in workers
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Create the bootstrap.sql file
|
||||
# ----------------------------------------------------------------------
|
||||
my $bootstrap_sql_file= "$opt_vardir/tmp/bootstrap.sql";
|
||||
|
||||
if (-f "$path_sql_dir/mysql_system_tables.sql")
|
||||
my $path_sql= my_find_file($install_basedir,
|
||||
["mysql", "sql/share", "share", "scripts"],
|
||||
"mysql_system_tables.sql",
|
||||
NOT_REQUIRED);
|
||||
|
||||
if (-f $path_sql )
|
||||
{
|
||||
my $sql_dir= dirname($path_sql);
|
||||
# Use the mysql database for system tables
|
||||
mtr_tofile($bootstrap_sql_file, "use mysql\n");
|
||||
|
||||
# Add the offical mysql system tables
|
||||
# for a production system
|
||||
mtr_appendfile_to_file("$path_sql_dir/mysql_system_tables.sql",
|
||||
mtr_appendfile_to_file("$sql_dir/mysql_system_tables.sql",
|
||||
$bootstrap_sql_file);
|
||||
|
||||
# Add the mysql system tables initial data
|
||||
# for a production system
|
||||
mtr_appendfile_to_file("$path_sql_dir/mysql_system_tables_data.sql",
|
||||
mtr_appendfile_to_file("$sql_dir/mysql_system_tables_data.sql",
|
||||
$bootstrap_sql_file);
|
||||
|
||||
# Add test data for timezone - this is just a subset, on a real
|
||||
# system these tables will be populated either by mysql_tzinfo_to_sql
|
||||
# or by downloading the timezone table package from our website
|
||||
mtr_appendfile_to_file("$path_sql_dir/mysql_test_data_timezone.sql",
|
||||
mtr_appendfile_to_file("$sql_dir/mysql_test_data_timezone.sql",
|
||||
$bootstrap_sql_file);
|
||||
|
||||
# Fill help tables, just an empty file when running from bk repo
|
||||
# but will be replaced by a real fill_help_tables.sql when
|
||||
# building the source dist
|
||||
mtr_appendfile_to_file("$sql_dir/fill_help_tables.sql",
|
||||
$bootstrap_sql_file);
|
||||
|
||||
}
|
||||
@ -2545,7 +2568,7 @@ sub mysql_install_db {
|
||||
{
|
||||
# Install db from init_db.sql that exist in early 5.1 and 5.0
|
||||
# versions of MySQL
|
||||
my $init_file= "$basedir/mysql-test/lib/init_db.sql";
|
||||
my $init_file= "$install_basedir/mysql-test/lib/init_db.sql";
|
||||
mtr_report(" - from '$init_file'");
|
||||
my $text= mtr_grab_file($init_file) or
|
||||
mtr_error("Can't open '$init_file': $!");
|
||||
@ -2554,12 +2577,6 @@ sub mysql_install_db {
|
||||
sql_to_bootstrap($text));
|
||||
}
|
||||
|
||||
# Fill help tables, just an empty file when running from bk repo
|
||||
# but will be replaced by a real fill_help_tables.sql when
|
||||
# building the source dist
|
||||
mtr_appendfile_to_file("$path_sql_dir/fill_help_tables.sql",
|
||||
$bootstrap_sql_file);
|
||||
|
||||
# Remove anonymous users
|
||||
mtr_tofile($bootstrap_sql_file,
|
||||
"DELETE FROM mysql.user where user= '';\n");
|
||||
@ -2582,8 +2599,8 @@ sub mysql_install_db {
|
||||
"$exe_mysqld_bootstrap " . join(" ", @$args) . "\n");
|
||||
|
||||
# Create directories mysql and test
|
||||
mkpath("$data_dir/mysql");
|
||||
mkpath("$data_dir/test");
|
||||
mkpath("$install_datadir/mysql");
|
||||
mkpath("$install_datadir/test");
|
||||
|
||||
if ( My::SafeProcess->run
|
||||
(
|
||||
@ -4087,14 +4104,26 @@ sub start_servers($) {
|
||||
}
|
||||
}
|
||||
|
||||
# Copy datadir from installed system db
|
||||
for my $path ( "$opt_vardir", "$opt_vardir/..") {
|
||||
my $install_db= "$path/install.db";
|
||||
copytree($install_db, $datadir)
|
||||
if -d $install_db;
|
||||
my $mysqld_basedir= $mysqld->value('basedir');
|
||||
if ( $basedir eq $mysqld_basedir )
|
||||
{
|
||||
# Copy datadir from installed system db
|
||||
for my $path ( "$opt_vardir", "$opt_vardir/..") {
|
||||
my $install_db= "$path/install.db";
|
||||
copytree($install_db, $datadir)
|
||||
if -d $install_db;
|
||||
}
|
||||
mtr_error("Failed to copy system db to '$datadir'")
|
||||
unless -d $datadir;
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql_install_db($mysqld);
|
||||
|
||||
mtr_error("Failed to install system db to '$datadir'")
|
||||
unless -d $datadir;
|
||||
|
||||
}
|
||||
mtr_error("Failed to copy system db to '$datadir'")
|
||||
unless -d $datadir;
|
||||
|
||||
# Create the servers tmpdir
|
||||
my $tmpdir= $mysqld->value('tmpdir');
|
||||
|
Reference in New Issue
Block a user