Add new option --mem to mysql-test-run.pl. It will automatically setup a symlink

from var/ to a tmpfs area and thereby speed up the execution of the testsuite
 significantly
parent 1fb0862f
...@@ -209,6 +209,7 @@ our $opt_fast; ...@@ -209,6 +209,7 @@ our $opt_fast;
our $opt_force; our $opt_force;
our $opt_reorder= 0; our $opt_reorder= 0;
our $opt_enable_disabled; our $opt_enable_disabled;
our $opt_mem;
our $opt_gcov; our $opt_gcov;
our $opt_gcov_err; our $opt_gcov_err;
...@@ -643,6 +644,7 @@ sub command_line_setup () { ...@@ -643,6 +644,7 @@ sub command_line_setup () {
'tmpdir=s' => \$opt_tmpdir, 'tmpdir=s' => \$opt_tmpdir,
'vardir=s' => \$opt_vardir, 'vardir=s' => \$opt_vardir,
'benchdir=s' => \$glob_mysql_bench_dir, 'benchdir=s' => \$glob_mysql_bench_dir,
'mem' => \$opt_mem,
# Misc # Misc
'comment=s' => \$opt_comment, 'comment=s' => \$opt_comment,
...@@ -715,6 +717,32 @@ sub command_line_setup () { ...@@ -715,6 +717,32 @@ sub command_line_setup () {
} }
mtr_report("Using binlog format '$used_binlog_format'"); mtr_report("Using binlog format '$used_binlog_format'");
# --------------------------------------------------------------------------
# Check if we should speed up tests by trying to run on tmpfs
# --------------------------------------------------------------------------
if ( $opt_mem )
{
mtr_error("Can't use --mem and --vardir at the same time ")
if $opt_vardir;
mtr_error("Can't use --mem and --tmpdir at the same time ")
if $opt_tmpdir;
# Use /dev/shm as the preferred location for vardir and
# thus implicitly also tmpdir. Add other locations to list
my @tmpfs_locations= ("/dev/shm");
# One could maybe use "mount" to find tmpfs location(s)
foreach my $fs (@tmpfs_locations)
{
if ( -d $fs )
{
mtr_report("Using tmpfs in $fs");
$opt_mem= "$fs/var";
$opt_mem .= $ENV{'MTR_BUILD_THREAD'} if $ENV{'MTR_BUILD_THREAD'};
last;
}
}
}
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# Set the "var/" directory, as it is the base for everything else # Set the "var/" directory, as it is the base for everything else
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
...@@ -1771,6 +1799,8 @@ sub kill_running_server () { ...@@ -1771,6 +1799,8 @@ sub kill_running_server () {
sub cleanup_stale_files () { sub cleanup_stale_files () {
my $created_by_mem_file= "$glob_mysql_test_dir/var/created_by_mem";
mtr_report("Removing Stale Files"); mtr_report("Removing Stale Files");
if ( $opt_vardir eq "$glob_mysql_test_dir/var" ) if ( $opt_vardir eq "$glob_mysql_test_dir/var" )
...@@ -1778,7 +1808,17 @@ sub cleanup_stale_files () { ...@@ -1778,7 +1808,17 @@ sub cleanup_stale_files () {
# #
# Running with "var" in mysql-test dir # Running with "var" in mysql-test dir
# #
if ( -l "$glob_mysql_test_dir/var" ) if ( -l $opt_vardir)
{
# var is a symlink
if (-f $created_by_mem_file)
{
# Remove the directory which the link points at
rmtree(readlink($opt_vardir));
# Remove the entire "var" dir
rmtree("$opt_vardir/");
}
else
{ {
# Some users creates a soft link in mysql-test/var to another area # Some users creates a soft link in mysql-test/var to another area
# - allow it # - allow it
...@@ -1788,6 +1828,7 @@ sub cleanup_stale_files () { ...@@ -1788,6 +1828,7 @@ sub cleanup_stale_files () {
rmtree("$opt_vardir/run"); rmtree("$opt_vardir/run");
rmtree("$opt_vardir/tmp"); rmtree("$opt_vardir/tmp");
} }
}
else else
{ {
# Remove the entire "var" dir # Remove the entire "var" dir
...@@ -1808,6 +1849,17 @@ sub cleanup_stale_files () { ...@@ -1808,6 +1849,17 @@ sub cleanup_stale_files () {
rmtree("$opt_vardir/"); rmtree("$opt_vardir/");
} }
if ( $opt_mem )
{
# Runinng with var as a link to some "memory" location, normally tmpfs
rmtree($opt_mem);
mkpath($opt_mem);
mtr_verbose("Creating symlink from $opt_vardir to $opt_mem");
symlink($opt_mem, $opt_vardir);
# Put a small file to recognize this dir was created by --mem
mtr_tofile($created_by_mem_file, $opt_mem);
}
mkpath("$opt_vardir/log"); mkpath("$opt_vardir/log");
mkpath("$opt_vardir/run"); mkpath("$opt_vardir/run");
mkpath("$opt_vardir/tmp"); mkpath("$opt_vardir/tmp");
...@@ -4326,6 +4378,9 @@ Options to control directories to use ...@@ -4326,6 +4378,9 @@ Options to control directories to use
vardir=DIR The directory where files generated from the test run vardir=DIR The directory where files generated from the test run
is stored (default: ./var). Specifying a ramdisk or is stored (default: ./var). Specifying a ramdisk or
tmpfs will speed up tests. tmpfs will speed up tests.
mem=DIR Run testsuite in "memory" using tmpfs if
available(default: /dev/shm)
Options to control what test suites or cases to run Options to control what test suites or cases to run
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment