Option to start a custom mysql for ./Build test

Mantis: 3435#c23805
agranig/peering-route
Gerhard Jungwirth 12 years ago
parent 5c5e41cf9c
commit 563adfddf3

@ -82,6 +82,7 @@ my $builder = Local::Module::Build->new(
# actually, the `plackup` external bin. this will break if the Plack distro is split into pieces
'Sipwise::Base' => 0,
'Test::More' => 0,
'Test::mysqld' => 0,
'Test::WebDriver' => 0,
'strict' => 0,
'Sys::Sig' => 0,
@ -125,6 +126,8 @@ Build.PL - NGCP-Panel build system including test fixtures
--wd-server HOST:PORT of an external webdriver to connect to
--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
--help brief help message
--man full documentation
@ -151,6 +154,18 @@ If the NGCP::Schema is not installed to a known path to perl, this
option can specify the base directory of its development location.
It will then be included via blib, so we have access to its lib and share.
=head2 C<--mysqld-port>
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>
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>.
=head2 C<--help>
Print a brief help message and exits.

@ -7,7 +7,7 @@ use TryCatch;
use MooseX::Method::Signatures;
extends 'Module::Build';
our ($plackup, $webdriver, @cover_opt);
our ($plackup, $webdriver, @cover_opt, $mysqld);
method wait_socket($host, $port) {
require IO::Socket::IP;
@ -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')
Getopt::Long::GetOptions(\%opt, 'webdriver=s', 'server:s', 'help|?', 'man', 'wd-server=s', 'schema-base-dir=s', 'mysqld-port=s', 'mysqld-dir=s')
or die 'could not process command-line options';
require Pod::Usage;
@ -54,6 +54,22 @@ sub _test_preconditions {
$ENV{TWD_PORT} = $wd_port;
}
if ($opt{'schema-base-dir'}) {
require blib;
blib->import($opt{'schema-base-dir'})
}
if ($opt{'mysqld-port'} && $opt{'mysqld-dir'}) {
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;
}
unless ($opt{webdriver} eq "external") {
$webdriver = child { exec $opt{webdriver} };
$self->wait_socket(qw(localhost 4444));
@ -77,10 +93,6 @@ sub _test_preconditions {
} stdout => $debug_fh;
};
if ($opt{'schema-base-dir'}) {
require blib;
blib->import($opt{'schema-base-dir'})
}
$self->wait_socket($uri->host, $uri->port);
$ENV{CATALYST_SERVER} = $opt{server};
}

@ -17,6 +17,11 @@ sub setup {
use_module('NGCP::Schema::Config')->instance
->config_file($config_location);
}
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}};
}
}
__PACKAGE__->config(

Loading…
Cancel
Save