[Rt-commit] rt branch, 4.0/web-installer-tests, created. rt-4.0.4-178-g5cb7e7f

Thomas Sibley trs at bestpractical.com
Thu Jan 5 16:15:09 EST 2012


The branch, 4.0/web-installer-tests has been created
        at  5cb7e7f17c1fc2bf86ab3ae218a32f60755a09f6 (commit)

- Log -----------------------------------------------------------------
commit e353e4fdfe09338031c88ff6d02ffd313c21421d
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Jan 5 12:27:12 2012 -0500

    Installer: respect the RT_SITE_CONFIG environment variable
    
    RT::Config respects the variable and it could lead to a weird mismatch
    to ignore it when writing the generated config.
    
    Most importantly, this lets automated testing of the installer use the
    per-testfile siteconfig we create instead of the default under
    $RT::EtcPath.

diff --git a/lib/RT/Installer.pm b/lib/RT/Installer.pm
index a1e9ea0..6a6e6bd 100644
--- a/lib/RT/Installer.pm
+++ b/lib/RT/Installer.pm
@@ -252,7 +252,7 @@ sub CurrentValues {
 
 sub ConfigFile {
     require File::Spec;
-    return File::Spec->catfile( $RT::EtcPath, 'RT_SiteConfig.pm' );
+    return $ENV{RT_SITE_CONFIG} || File::Spec->catfile( $RT::EtcPath, 'RT_SiteConfig.pm' );
 }
 
 sub SaveConfig {
diff --git a/share/html/Install/index.html b/share/html/Install/index.html
index 41610d7..abbff00 100644
--- a/share/html/Install/index.html
+++ b/share/html/Install/index.html
@@ -92,7 +92,7 @@
 my @errors;
 my $locked;
 
-my $file = File::Spec->catfile( $RT::EtcPath, 'RT_SiteConfig.pm' );
+my $file = RT::Installer->ConfigFile;
 
 if ( ! -e $file ) {
     # write a blank RT_SiteConfig.pm

commit 61dd5bed5e956b4fd7bc802d0d53d4726d06b356
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Jan 5 12:30:55 2012 -0500

    Provide a plack and inline test server variant that loads sbin/rt-server
    
    Use it in your test files with:
    
        $ENV{RT_TEST_WEB_HANDLER} = 'plack+rt-server';
    
    This is useful for testing the triggering of install mode, for example.

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 6b270be..65227e6 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -1298,8 +1298,23 @@ sub test_app {
     my $self = shift;
     my %server_opt = @_;
 
-    require RT::Interface::Web::Handler;
-    my $app = RT::Interface::Web::Handler->PSGIApp;
+    my $app;
+
+    if ($server_opt{variant} and $server_opt{variant} eq 'rt-server') {
+        $app = do {
+            my $file = "$RT::SbinPath/rt-server";
+            my $psgi = do $file;
+            unless ($psgi) {
+                die "Couldn't parse $file: $@" if $@;
+                die "Couldn't do $file: $!"    unless defined $psgi;
+                die "Couldn't run $file"       unless $psgi;
+            }
+            $psgi;
+        };
+    } else {
+        require RT::Interface::Web::Handler;
+        $app = RT::Interface::Web::Handler->PSGIApp;
+    }
 
     require Plack::Middleware::Test::StashWarnings;
     $app = Plack::Middleware::Test::StashWarnings->wrap($app);

commit b40b90eaa3b219ebd184db97df903b6f0edca53b
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Jan 5 12:33:24 2012 -0500

    Don't reconnect to the database under a plack server if the test asks for nodb
    
    The rest of RT::Test guards __reconnect_rt() similarly.  It looks like
    this was just missed.

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 65227e6..dd7f27e 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -1361,7 +1361,8 @@ sub start_plack_server {
         my $Tester = Test::Builder->new;
         $Tester->ok(1, "started plack server ok");
 
-        __reconnect_rt();
+        __reconnect_rt()
+            unless $rttest_opt{nodb};
         return ("http://localhost:$port", RT::Test::Web->new);
     }
 

commit 758f968750a10a78111b4a69198faed8437ae9cf
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Jan 5 12:35:00 2012 -0500

    Provide a way to avoid dieing if you specify nodb and start a server
    
    Most of the time specifying nodb and starting a server means you're
    doing something wrong and catching that mistake is useful.  However, if
    you know what you're doing — for example, testing the installer — you
    may want the combination.

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index dd7f27e..c3f33e3 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -1276,8 +1276,10 @@ sub started_ok {
 
     require RT::Test::Web;
 
-    if ($rttest_opt{nodb}) {
-        die "you are trying to use a test web server without db, try use noinitialdata => 1 instead";
+    if ($rttest_opt{nodb} and not $rttest_opt{server_ok}) {
+        die "You are trying to use a test web server without a database. "
+           ."You may want noinitialdata => 1 instead. "
+           ."Pass server_ok => 1 if you know what you're doing.";
     }
 
 

commit ea71403a267e65b7f5ce2364b16a1b88c636fba7
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Jan 5 14:49:35 2012 -0500

    Ensure testfiles that ask for no database don't inherit a previous database
    
    This generally isn't a problem with parallel testing, but can crop up
    when repeatedly running individual tests with prove.

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index c3f33e3..818bdf0 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -409,7 +409,11 @@ sub bootstrap_db {
         $args{$forceopt}=1;
     }
 
-    return if $args{nodb};
+    # Short-circuit the rest of ourselves if we don't want a db
+    if ($args{nodb}) {
+        __drop_database();
+        return;
+    }
 
     my $db_type = RT->Config->Get('DatabaseType');
     __create_database();

commit f855c79d598eba17185ab32383630f2ed4bcd543
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Jan 5 15:01:48 2012 -0500

    Tests for the web installer
    
    A very basic mandatory field filling, button clicking walkthrough.
    It'll catch the most egregious problems, although certainly not all.
    
    Most importantly, we now have the infrastructure for writing more
    installer tests.

diff --git a/t/web/installer.t b/t/web/installer.t
new file mode 100644
index 0000000..cde9359
--- /dev/null
+++ b/t/web/installer.t
@@ -0,0 +1,92 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+$ENV{RT_TEST_WEB_HANDLER} = 'plack+rt-server';
+use RT::Test
+    tests       => undef,
+    nodb        => 1,
+    server_ok   => 1;
+
+my ($base, $m) = RT::Test->started_ok;
+
+$m->get_ok($base);
+like $m->uri, qr/Install/, 'at installer';
+
+diag "Testing language change";
+{
+    $m->submit_form_ok(
+        {
+            with_fields => {
+                Lang => 'fr',
+            },
+            button => 'ChangeLang',
+        },
+        'change language to french'
+    );
+    $m->content_like(qr/RT\s+pour\s+example\.com/i);
+    $m->submit_form_ok(
+        {
+            with_fields => {
+                Lang => 'en',
+            },
+            button => 'ChangeLang',
+        },
+        'change language to english'
+    );
+    $m->content_like(qr/RT\s+for\s+example\.com/i);
+}
+
+diag "Walking through install screens setting defaults";
+{
+    $m->click_ok('Run');
+
+    # Database type
+    $m->content_contains('DatabaseType');
+    $m->content_contains($_, "found database $_")
+        for qw(MySQL PostgreSQL Oracle SQLite);
+    $m->submit();
+
+    # Database details
+    $m->content_contains('DatabaseName');
+    $m->submit();
+    $m->content_contains('Connection succeeded');
+    $m->submit_form_ok({ button => 'Next' });
+
+    # Basic options
+    $m->submit_form_ok({
+        with_fields => {
+            Password    => 'password',
+        }
+    }, 'set root password');
+
+    # Mail options
+    $m->submit_form_ok({
+        with_fields => {
+            OwnerEmail  => 'admin at example.com',
+        },
+    }, 'set admin email');
+
+    # Mail addresses
+    $m->submit_form_ok({
+        with_fields => {
+            CorrespondAddress   => 'rt at example.com',
+            CommentAddress      => 'rt-comment at example.com',
+        },
+    }, 'set addresses');
+
+    # Initialize database
+    $m->content_contains('database');
+    $m->submit();
+
+    # Finish
+    $m->content_contains('/RT_SiteConfig.pm');
+    $m->content_contains('Finish');
+    $m->submit();
+
+    $m->content_contains('Login');
+    ok $m->login(), 'logged in';
+}
+
+undef $m;
+done_testing;

commit 5cb7e7f17c1fc2bf86ab3ae218a32f60755a09f6
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Jan 5 16:13:41 2012 -0500

    More thoroughly ignore DROP DATABASE errors when testing
    
    This avoids useless warnings when we try to overzealously drop a
    database that doesn't exist.

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 818bdf0..59d360e 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -560,6 +560,13 @@ sub __drop_database {
         RT::Handle->SystemDSN,
         $ENV{RT_DBA_USER}, $ENV{RT_DBA_PASSWORD}
     );
+
+    # We ignore errors intentionally by not checking the return value of
+    # DropDatabase below, so let's also suppress DBI's printing of errors when
+    # we overzealously drop.
+    local $dbh->{PrintError} = 0;
+    local $dbh->{PrintWarn} = 0;
+
     RT::Handle->DropDatabase( $dbh );
     $dbh->disconnect if $my_dbh;
 }

-----------------------------------------------------------------------


More information about the Rt-commit mailing list