[Rt-commit] rt branch, 4.0/plugin-database-init, created. rt-3.9.7-1212-gd18f44f
Alex Vandiver
alexmv at bestpractical.com
Thu Feb 17 00:32:02 EST 2011
The branch, 4.0/plugin-database-init has been created
at d18f44f8b478172a1d2c955da15fffe123545dc5 (commit)
- Log -----------------------------------------------------------------
commit d50dc1233e464ca48718a8831fb5988ff3fe9a93
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Feb 16 22:37:33 2011 -0500
Simplify bootstrap_db() logic; this also reduces the number of reconnects
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 6b9419c..919f755 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -358,35 +358,22 @@ sub bootstrap_db {
$args{$forceopt}=1;
}
- if ($args{nodb}) {
- $args{noinitialdata} = 1;
- $args{nodata} = 1;
- }
- elsif ($args{noinitialdata}) {
- $args{nodata} = 1;
- }
-
- unless ($args{nodb}) {
- __create_database();
-
- __reconnect_rt('dba');
- $RT::Handle->InsertSchema;
+ return if $args{nodb};
- my $db_type = RT->Config->Get('DatabaseType');
- $RT::Handle->InsertACL unless $db_type eq 'Oracle';
+ my $db_type = RT->Config->Get('DatabaseType');
+ __create_database();
+ __reconnect_rt('as dba');
+ $RT::Handle->InsertSchema;
+ $RT::Handle->InsertACL unless $db_type eq 'Oracle';
- RT->InitLogging;
+ RT->InitLogging;
+ __reconnect_rt();
- unless ($args{noinitialdata}) {
- __reconnect_rt();
- $RT::Handle->InsertInitialData;
- }
+ $RT::Handle->InsertInitialData
+ unless $args{noinitialdata};
- unless ( $args{'nodata'} ) {
- __reconnect_rt();
- $RT::Handle->InsertData( $RT::EtcPath . "/initialdata" );
- }
- }
+ $RT::Handle->InsertData( $RT::EtcPath . "/initialdata" )
+ unless $args{noinitialdata} or $args{nodata};
}
sub bootstrap_plugins {
commit d308ca8606a69691f6381f3e75519fb6d8c39363
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Feb 16 23:08:55 2011 -0500
Use the RT::Test methods to handle forced disconnection and reconnection
diff --git a/t/shredder/utils.pl b/t/shredder/utils.pl
index 34e6564..b8409bf 100644
--- a/t/shredder/utils.pl
+++ b/t/shredder/utils.pl
@@ -293,15 +293,9 @@ sub restore_savepoint { return __cp_db( savepoint_name( shift ) => db_name() ) }
sub __cp_db
{
my( $orig, $dest ) = @_;
- delete $RT::System->{attributes};
- $RT::Handle->dbh->disconnect;
- # DIRTY HACK: undef Handles to force reconnect
- $RT::Handle = undef;
- %DBIx::SearchBuilder::DBIHandle = ();
- $DBIx::SearchBuilder::PrevHandle = undef;
-
+ RT::Test::__disconnect_rt();
File::Copy::copy( $orig, $dest ) or die "Couldn't copy '$orig' => '$dest': $!";
- RT::ConnectToDatabase();
+ RT::Test::__reconnect_rt();
return;
}
commit 657a54c497de93805953d2680b799329ad658b1d
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Jan 13 02:55:22 2011 +0300
bootstrap DB if we're testing a plugin that doesn't require any plugins
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 919f755..005c88f 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -380,19 +380,21 @@ sub bootstrap_plugins {
my $self = shift;
my %args = @_;
- return unless $args{'requires'};
-
- my @plugins = @{ $args{'requires'} };
+ my @plugins;
+ push @plugins, @{ $args{'requires'} }
+ if $args{'requires'};
push @plugins, $args{'testing'}
if $args{'testing'};
- require RT::Plugin;
+ return unless @plugins;
+
my $cwd;
if ( $args{'testing'} ) {
require Cwd;
$cwd = Cwd::getcwd();
}
+ require RT::Plugin;
my $old_func = \&RT::Plugin::_BasePath;
no warnings 'redefine';
*RT::Plugin::_BasePath = sub {
commit a403984c93cab9faef02964fdc84364e88c8e874
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Tue Jan 18 10:31:30 2011 +0300
create plugins element in %args out of testing and requires
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 005c88f..bd65467 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -130,6 +130,11 @@ sub import {
$class->builder->no_plan unless $class->builder->has_plan;
}
+ push @{ $args{'plugins'} ||= [] }, @{ $args{'requires'} }
+ if $args{'requires'};
+ push @{ $args{'plugins'} ||= [] }, $args{'testing'}
+ if $args{'testing'};
+
$class->bootstrap_tempdir;
$class->bootstrap_config( %args );
commit 12db13fa39ffc0f08f817d42374a52e1345344dd
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Tue Jan 18 10:32:20 2011 +0300
put plugins into @Plugins when bootstraping config
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index bd65467..c04527f 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -246,6 +246,10 @@ Set( \$RTAddressRegexp , qr/^bad_re_that_doesnt_match\$/);
print $config "Set( \$DatabaseUser , 'u${dbname}');\n";
}
+ if ( $args{'plugins'} ) {
+ print $config "Set( \@Plugins, qw(". join( ' ', @{ $args{'plugins'} } ) .") );\n";
+ }
+
if ( $INC{'Devel/Cover.pm'} ) {
print $config "Set( \$DevelMode, 0 );\n";
}
commit dbc3be4ee2b877725c516a39dc0eff435c63ac7d
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Tue Jan 18 10:34:29 2011 +0300
split bootstrap_plugins into *_paths and *_db functions
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index c04527f..b4470b6 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -385,17 +385,12 @@ sub bootstrap_db {
unless $args{noinitialdata} or $args{nodata};
}
-sub bootstrap_plugins {
+sub bootstrap_plugins_paths {
my $self = shift;
my %args = @_;
- my @plugins;
- push @plugins, @{ $args{'requires'} }
- if $args{'requires'};
- push @plugins, $args{'testing'}
- if $args{'testing'};
-
- return unless @plugins;
+ return unless $args{'plugins'};
+ my @plugins = @{ $args{'plugins'} };
my $cwd;
if ( $args{'testing'} ) {
@@ -418,9 +413,11 @@ sub bootstrap_plugins {
}
return $old_func->(@_);
};
+}
- RT->Config->Set( Plugins => @plugins );
- RT->InitPluginPaths();
+sub bootstrap_plugins_db {
+ my $self = shift;
+ my %args = @_;
my $dba_dbh;
$dba_dbh = _get_dbh(
commit fd331c5ee0895c88d2c4defbc29e1240b4eb5a86
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Tue Jan 18 10:35:47 2011 +0300
refactor bootstrap plugin_db
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index b4470b6..26ce374 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -419,13 +419,11 @@ sub bootstrap_plugins_db {
my $self = shift;
my %args = @_;
- my $dba_dbh;
- $dba_dbh = _get_dbh(
- RT::Handle->DSN,
- $ENV{RT_DBA_USER}, $ENV{RT_DBA_PASSWORD},
- ) if @plugins;
+ return unless $args{'plugins'};
require File::Spec;
+
+ my @plugins = @{ $args{'plugins'} };
foreach my $name ( @plugins ) {
my $plugin = RT::Plugin->new( name => $name );
Test::More::diag( "Initializing DB for the $name plugin" )
@@ -435,31 +433,37 @@ sub bootstrap_plugins_db {
Test::More::diag( "etc path of the plugin is '$etc_path'" )
if $ENV{'TEST_VERBOSE'};
- if ( -e $etc_path ) {
- my ($ret, $msg) = $RT::Handle->InsertSchema( $dba_dbh, $etc_path );
- Test::More::ok($ret || $msg =~ /^Couldn't find schema/, "Created schema: ".($msg||''));
-
- ($ret, $msg) = $RT::Handle->InsertACL( $dba_dbh, $etc_path );
- Test::More::ok($ret || $msg =~ /^Couldn't find ACLs/, "Created ACL: ".($msg||''));
-
- my $data_file = File::Spec->catfile( $etc_path, 'initialdata' );
- if ( -e $data_file ) {
- ($ret, $msg) = $RT::Handle->InsertData( $data_file );;
- Test::More::ok($ret, "Inserted data".($msg||''));
- } else {
- Test::More::ok(1, "There is no data file" );
- }
- }
- else {
+ unless ( -e $etc_path ) {
# we can not say if plugin has no data or we screwed with etc path
Test::More::ok(1, "There is no etc dir: no schema" );
Test::More::ok(1, "There is no etc dir: no ACLs" );
Test::More::ok(1, "There is no etc dir: no data" );
+ next;
+ }
+
+
+ { # schema
+ __reconnect_rt('dba');
+ my ($ret, $msg) = $RT::Handle->InsertSchema( undef, $etc_path );
+ Test::More::ok($ret || $msg =~ /^Couldn't find schema/, "Created schema: ".($msg||''));
}
- $RT::Handle->Connect; # XXX: strange but mysql can loose connection
+ { # ACLs
+ __reconnect_rt('dba');
+ my ($ret, $msg) = $RT::Handle->InsertACL( undef, $etc_path );
+ Test::More::ok($ret || $msg =~ /^Couldn't find ACLs/, "Created ACL: ".($msg||''));
+ }
+
+ # data
+ my $data_file = File::Spec->catfile( $etc_path, 'initialdata' );
+ if ( -e $data_file ) {
+ __reconnect_rt();
+ my ($ret, $msg) = $RT::Handle->InsertData( $data_file );;
+ Test::More::ok($ret, "Inserted data".($msg||''));
+ } else {
+ Test::More::ok(1, "There is no data file" );
+ }
}
- $dba_dbh->disconnect if $dba_dbh;
}
sub _get_dbh {
commit d8525aec55bf2ae9f5bca618f48843c1de924650
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Tue Jan 18 10:37:18 2011 +0300
reorder how we bootstrap plugins
bootstrap paths asap
set @Plugins in the config, so plugins' configs are loaded
setup plugins' DB right after setting RT's DB
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 26ce374..5b4a100 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -137,6 +137,8 @@ sub import {
$class->bootstrap_tempdir;
+ $class->bootstrap_plugins_paths( %args );
+
$class->bootstrap_config( %args );
use RT;
@@ -154,10 +156,8 @@ sub import {
RT::InitClasses();
RT::InitLogging();
- $class->bootstrap_plugins( %args );
-
RT->Plugins;
-
+
RT::I18N->Init();
RT->Config->PostLoadCheck;
@@ -383,6 +383,9 @@ sub bootstrap_db {
$RT::Handle->InsertData( $RT::EtcPath . "/initialdata" )
unless $args{noinitialdata} or $args{nodata};
+
+ $self->bootstrap_plugins_db( %args );
+ __reconnect_rt();
}
sub bootstrap_plugins_paths {
commit cfcc4e864f5950d486cc92aae3e62e8aed455c30
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Feb 10 01:47:04 2011 +0300
minor, use less reconnections
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 5b4a100..00c254e 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -444,15 +444,14 @@ sub bootstrap_plugins_db {
next;
}
+ __reconnect_rt('as dba');
{ # schema
- __reconnect_rt('dba');
my ($ret, $msg) = $RT::Handle->InsertSchema( undef, $etc_path );
Test::More::ok($ret || $msg =~ /^Couldn't find schema/, "Created schema: ".($msg||''));
}
{ # ACLs
- __reconnect_rt('dba');
my ($ret, $msg) = $RT::Handle->InsertACL( undef, $etc_path );
Test::More::ok($ret || $msg =~ /^Couldn't find ACLs/, "Created ACL: ".($msg||''));
}
commit 67d0e3383ff17dd75fcdaef223eca457afac4e44
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Feb 16 22:23:49 2011 -0500
Move reconnect for plugins to only fire if there are plugins enabled
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 00c254e..27d8ee0 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -385,7 +385,6 @@ sub bootstrap_db {
unless $args{noinitialdata} or $args{nodata};
$self->bootstrap_plugins_db( %args );
- __reconnect_rt();
}
sub bootstrap_plugins_paths {
@@ -466,6 +465,7 @@ sub bootstrap_plugins_db {
Test::More::ok(1, "There is no data file" );
}
}
+ __reconnect_rt();
}
sub _get_dbh {
commit d18f44f8b478172a1d2c955da15fffe123545dc5
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Feb 16 23:13:39 2011 -0500
Indent and reword a minor comment
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 27d8ee0..3fe6945 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -436,7 +436,7 @@ sub bootstrap_plugins_db {
if $ENV{'TEST_VERBOSE'};
unless ( -e $etc_path ) {
-# we can not say if plugin has no data or we screwed with etc path
+ # We can't tell if the plugin has no data, or we screwed up the etc/ path
Test::More::ok(1, "There is no etc dir: no schema" );
Test::More::ok(1, "There is no etc dir: no ACLs" );
Test::More::ok(1, "There is no etc dir: no data" );
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list