Use a mysql dump instead of a mysql data directory for tests

Mantis 3435#c23805 (still)
agranig/peering-route
Gerhard Jungwirth 12 years ago
parent 563adfddf3
commit 373185c563

@ -127,7 +127,7 @@ Build.PL - NGCP-Panel build system including test fixtures
--server URI for socket test server
--schema-base-dir directory of NGCP::Schema if its not yet installed
--mysqld-port port where the mysqld should be started
--mysqld-dir data directory for the temporary mysqld
--mysql-dump one or more mysql dumps to be imported to our mysqld
--help brief help message
--man full documentation
@ -160,11 +160,12 @@ If this option and C<--mysqld-dir> are supplied, a mysqld will be started
at the specified port and be used for the tests. mysqld will be stopped
and the temporary data deleted when this script finishes.
=head2 C<--mysqld-dir>
=head2 C<--mysql-dump>
If this option and C<--mysqld-port> are supplied, a mysqld will be started and be used for the tests. It will use a copy of the specified directory as
the data directory of MySQL.
For more information see L<Test::mysqld>.
If this option and C<--mysqld-port> are supplied, a mysqld will be started
and be used for the tests. It will import all dumps supplied with this option.
This option can be set multiple times. In this case all specified files will
be dumped into the database.
=head2 C<--help>

@ -40,7 +40,7 @@ sub _test_preconditions {
require Getopt::Long;
my %opt = (server => 'http://localhost:5000');
Getopt::Long::GetOptions(\%opt, 'webdriver=s', 'server:s', 'help|?', 'man', 'wd-server=s', 'schema-base-dir=s', 'mysqld-port=s', 'mysqld-dir=s')
Getopt::Long::GetOptions(\%opt, 'webdriver=s', 'server:s', 'help|?', 'man', 'wd-server=s', 'schema-base-dir=s', 'mysqld-port=s', 'mysql-dump=s@')
or die 'could not process command-line options';
require Pod::Usage;
@ -59,15 +59,16 @@ sub _test_preconditions {
blib->import($opt{'schema-base-dir'})
}
if ($opt{'mysqld-port'} && $opt{'mysqld-dir'}) {
if ($opt{'mysqld-port'} && $opt{'mysql-dump'}) {
require Test::mysqld;
$mysqld = Test::mysqld->new(
my_cnf => {
'port' => $opt{'mysqld-port'},
},
copy_data_from => $opt{'mysqld-dir'},
) or die "couldnt start mysqld";
$ENV{NGCP_PANEL_CUSTOM_DSN} = $mysqld->dsn;
$ENV{NGCP_PANEL_CUSTOM_DSN} = $mysqld->dsn(host => 'localhost');
my $dump_files = join(' ', @{ $opt{'mysql-dump'} });
system("cat $dump_files | mysql -uroot --port=$opt{'mysqld-port'}");
}
unless ($opt{webdriver} eq "external") {
@ -141,4 +142,11 @@ method ACTION_test_tap {
$self->generic_test(type => 'default');
}
method ACTION_test_servers {
$self->depends_on('code');
$self->_test_preconditions;
print "All servers ready for you!\nPress [Enter] to exit.";
<STDIN>;
}
END { shutdown_servers }

@ -20,7 +20,7 @@ sub setup {
if($ENV{NGCP_PANEL_CUSTOM_DSN}) {
use_module('NGCP::Schema::Config')->instance->as_hash;
use_module('NGCP::Schema::Config')->instance->as_hash
->{ngcp_connect_info} = {dsn => $ENV{NGCP_PANEL_CUSTOM_DSN}};
->{ngcp_connect_info}{dsn} = $ENV{NGCP_PANEL_CUSTOM_DSN};
}
}

Loading…
Cancel
Save