[Rt-commit] rtir branch, 3.4/upgrade-test, created. 3.3.0-139-gc4b9c54

Shawn Moore shawn at bestpractical.com
Wed May 25 17:26:32 EDT 2016


The branch, 3.4/upgrade-test has been created
        at  c4b9c54a72d7382f87f4e4371006cf091b40c1bb (commit)

- Log -----------------------------------------------------------------
commit ccb1f216eec2fa39568a3dbed597a2cff5b61fec
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed May 25 21:12:51 2016 +0000

    Implement backcompat files for RTIR test upgrades

diff --git a/lib/RT/IR/Test.pm.in b/lib/RT/IR/Test.pm.in
index 8eecb4e..d88f479 100644
--- a/lib/RT/IR/Test.pm.in
+++ b/lib/RT/IR/Test.pm.in
@@ -147,24 +147,47 @@ sub apply_upgrade {
     my @versions = @_;
 
     my $db_type = RT->Config->Get('DatabaseType');
+
+    my $upgrade = sub {
+        foreach my $n ( 0..$#versions ) {
+            my $v = $versions[$n];
+
+            my $datadir = "$base_dir/$v";
+            if ( -e "$datadir/schema.$db_type" ) {
+                my ( $ret, $msg ) = RT::Handle->InsertSchema( get_admin_dbh(), $datadir );
+                return ( $ret, $msg ) unless $ret;
+            }
+            if ( -e "$datadir/acl.$db_type" ) {
+                my ( $ret, $msg ) = RT::Handle->InsertACL( get_admin_dbh(), $datadir );
+                return ( $ret, $msg ) unless $ret;
+            }
+            if ( -e "$datadir/content" ) {
+                RT::Test::__reconnect_rt();
+                my ( $ret, $msg ) = $RT::Handle->InsertData( "$datadir/content" );
+                return ( $ret, $msg ) unless $ret;
+            }
+        }
+    };
+
     foreach my $n ( 0..$#versions ) {
         my $v = $versions[$n];
 
         my $datadir = "$base_dir/$v";
-        if ( -e "$datadir/schema.$db_type" ) {
-            my ( $ret, $msg ) = RT::Handle->InsertSchema( get_admin_dbh(), $datadir );
-            return ( $ret, $msg ) unless $ret;
-        }
-        if ( -e "$datadir/acl.$db_type" ) {
-            my ( $ret, $msg ) = RT::Handle->InsertACL( get_admin_dbh(), $datadir );
-            return ( $ret, $msg ) unless $ret;
-        }
-        if ( -e "$datadir/content" ) {
-            RT::Test::__reconnect_rt();
-            my ( $ret, $msg ) = $RT::Handle->InsertData( "$datadir/content" );
-            return ( $ret, $msg ) unless $ret;
+        my $file = "$datadir/backcompat";
+        if ( -e $file ) {
+            my $lines = do {local $/; local @ARGV = ($file); <>};
+            my $sub = eval "sub {\n# line 1 $file\n$lines\n}";
+            unless ($sub) {
+                warn "Failed to load backcompat $file: $@";
+                next;
+            }
+            my $current = $upgrade;
+            $upgrade = sub { $sub->($current) };
         }
     }
+
+    $upgrade->();
+
     RT::Test::__reconnect_rt();
 }
 

commit b0faacc030b0f18ce10cf222d16556b860729421
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed May 25 21:13:42 2016 +0000

    Run all the RTIR upgrades, not just the 2.9.0 one

diff --git a/t/upgrade/2.6.0-to-2.9.0.t b/t/upgrade/2.6.0-to-current.t
similarity index 70%
rename from t/upgrade/2.6.0-to-2.9.0.t
rename to t/upgrade/2.6.0-to-current.t
index e7ee723..afdb378 100644
--- a/t/upgrade/2.6.0-to-2.9.0.t
+++ b/t/upgrade/2.6.0-to-current.t
@@ -20,17 +20,29 @@ use Sort::Versions;
     RT::IR::Test->import_snapshot( 'rtir-2.6.after-rt-upgrade.sql' );
 
     # upgrade database for RT 4.2.0 on
-    for my $version (sort { versioncmp($a, $b) } map { m{upgrade/([\w.]+)/} && $1 } glob('../rt/etc/upgrade/4.*/')) {
-        next if versioncmp($version, '4.2.0') == -1;
-        next if versioncmp($version, $RT::VERSION) == 1;
-
-        my ($status, $msg) = RT::IR::Test->apply_upgrade( '../rt/etc/upgrade/', $version);
-        ok $status, "applied RT $version upgrade" or diag "error: $msg";
+    {
+        my @versions;
+        for my $version (sort { versioncmp($a, $b) } map { m{upgrade/([\w.]+)/} && $1 } glob('../rt/etc/upgrade/4.*/')) {
+            next if versioncmp($version, '4.2.0') == -1;
+            next if versioncmp($version, $RT::VERSION) == 1;
+            push @versions, $version;
+        }
+
+        my ($status, $msg) = RT::IR::Test->apply_upgrade( '../rt/etc/upgrade/', @versions);
+        ok $status, "applied " . scalar(@versions) . " RT version upgrades" or diag "error: $msg";
     }
 
+    # upgrade database for RTIR 2.6.0 on
     {
-        my ($status, $msg) = RT::IR::Test->apply_upgrade( 'etc/upgrade/', '2.9.0' );
-        ok $status, "applied RTIR 2.9.0 upgrade" or diag "error: $msg";
+        my @versions;
+        for my $version (sort { versioncmp($a, $b) } map { m{upgrade/([\w.]+)/} && $1 } glob('etc/upgrade/*/')) {
+            next if versioncmp($version, '2.6.0') == -1;
+
+            push @versions, $version;
+        }
+
+        my ($status, $msg) = RT::IR::Test->apply_upgrade( 'etc/upgrade/', @versions);
+        ok $status, "applied " . scalar(@versions) . " RTIR upgrades" or diag "error: $msg";
     }
 }
 
@@ -48,7 +60,7 @@ my @state_cf_ids;
     $ticket->Load(4);
 
     my $queue = $ticket->QueueObj;
-    is( $queue->Name, 'Incident Reports', 'an IR' );
+    is( $queue->Name, 'Incident Reports - EDUNET', 'an IR' );
     is( $queue->LifecycleObj->Name, 'incident_reports', 'incidents cycle' );
 
     is( $ticket->Subject, 'IR for reject' );
@@ -63,7 +75,7 @@ my @state_cf_ids;
     $ticket->Load(5);
 
     my $queue = $ticket->QueueObj;
-    is( $queue->Name, 'Incidents', 'an incident' );
+    is( $queue->Name, 'Incidents - EDUNET', 'an incident' );
     is( $queue->LifecycleObj->Name, 'incidents', 'incidents cycle' );
 
     is( $ticket->Subject, 'Inc for abandon' );

commit 8839f7112b17b8ef64e57125428fd098dd761d99
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed May 25 21:14:10 2016 +0000

    Add a backcompat file for faking a blocks lifecycle for earlier upgrades

diff --git a/etc/upgrade/3.3.0/backcompat b/etc/upgrade/3.3.0/backcompat
new file mode 100644
index 0000000..fcb8611
--- /dev/null
+++ b/etc/upgrade/3.3.0/backcompat
@@ -0,0 +1,13 @@
+my ($upgrade) = @_;
+
+$RT::Logger->debug("Temporarily adding blocks lifecycle");
+
+my $lifecycles = RT->Config->Get('Lifecycles');
+$lifecycles->{blocks} = $lifecycles->{countermeasures};
+RT::Lifecycle->FillCache;
+
+$upgrade->();
+
+delete $lifecycles->{blocks};
+RT::Lifecycle->FillCache;
+

commit 1147fd1472fd0c2428242f294cc66470ea57143c
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed May 25 21:21:35 2016 +0000

    Avoid "case sensitive search by Queues.Name" warning

diff --git a/etc/upgrade/3.3.0/content b/etc/upgrade/3.3.0/content
index c7da1e5..44084ee 100644
--- a/etc/upgrade/3.3.0/content
+++ b/etc/upgrade/3.3.0/content
@@ -16,9 +16,10 @@ our @Final = (
         {
             my $queues = RT::Queues->new(RT->SystemUser);
             $queues->Limit(
-                  FIELD    => 'Name',
-                  OPERATOR => 'STARTSWITH',
-                  VALUE    => 'Blocks',
+                  FIELD         => 'Name',
+                  OPERATOR      => 'STARTSWITH',
+                  VALUE         => 'Blocks',
+                  CASESENSITIVE => 1,
             );
 
             while (my $queue = $queues->Next) {

commit c4b9c54a72d7382f87f4e4371006cf091b40c1bb
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed May 25 21:21:46 2016 +0000

    Move upgrade subs from global to lexical
    
        Otherwise the upgrade tests fail because of redefine warnings on these
        subs

diff --git a/etc/upgrade/3.3.2/content b/etc/upgrade/3.3.2/content
index 4bae1dc..142062d 100644
--- a/etc/upgrade/3.3.2/content
+++ b/etc/upgrade/3.3.2/content
@@ -1,6 +1,36 @@
 use strict;
 use warnings;
 
+my $remove_scrip_action = sub {
+    my $module = shift;
+
+    my $actions = RT::ScripActions->new( RT->SystemUser );
+    $actions->Limit( FIELD => 'ExecModule', VALUE => $module );
+    while ( my $action = $actions->Next ) {
+        my $scrips = RT::Scrips->new( $RT::SystemUser );
+        $scrips->Limit( FIELD => 'ScripAction', VALUE => $action->id );
+        while ( my $scrip = $scrips->Next ) {
+            $scrip->Delete;
+        }
+        $action->DBIx::SearchBuilder::Record::Delete();
+    }
+};
+
+my $remove_scrip_condition = sub {
+    my $module = shift;
+
+    my $conditions = RT::ScripConditions->new( RT->SystemUser );
+    $conditions->Limit( FIELD => 'ExecModule', VALUE => $module );
+    while ( my $condition = $conditions->Next ) {
+        my $scrips = RT::Scrips->new( $RT::SystemUser );
+        $scrips->Limit( FIELD => 'ScripCondition', VALUE => $condition->id );
+        while ( my $scrip = $scrips->Next ) {
+            $scrip->Delete;
+        }
+        $condition->DBIx::SearchBuilder::Record::Delete();
+    }
+};
+
 our @CustomFields = (
     {
         Name        => 'RTIR Constituency',
@@ -45,8 +75,8 @@ our @Final = (
     sub {
         # remove old code
         {
-            remove_scrip_action( $_ ) for ( 'RTIR_SetConstituency', 'RTIR_SetConstituencyGroup' );
-            remove_scrip_condition( $_ )
+            $remove_scrip_action->( $_ ) for ( 'RTIR_SetConstituency', 'RTIR_SetConstituencyGroup' );
+            $remove_scrip_condition->( $_ )
               for ( 'RTIR_RequireConstituencyChange', 'RTIR_RequireConstituencyGroupChange' );
         }
 
@@ -171,32 +201,3 @@ our @Final = (
     },
 );
 
-sub remove_scrip_action {
-    my $module = shift;
-
-    my $actions = RT::ScripActions->new( RT->SystemUser );
-    $actions->Limit( FIELD => 'ExecModule', VALUE => $module );
-    while ( my $action = $actions->Next ) {
-        my $scrips = RT::Scrips->new( $RT::SystemUser );
-        $scrips->Limit( FIELD => 'ScripAction', VALUE => $action->id );
-        while ( my $scrip = $scrips->Next ) {
-            $scrip->Delete;
-        }
-        $action->DBIx::SearchBuilder::Record::Delete();
-    }
-}
-
-sub remove_scrip_condition {
-    my $module = shift;
-
-    my $conditions = RT::ScripConditions->new( RT->SystemUser );
-    $conditions->Limit( FIELD => 'ExecModule', VALUE => $module );
-    while ( my $condition = $conditions->Next ) {
-        my $scrips = RT::Scrips->new( $RT::SystemUser );
-        $scrips->Limit( FIELD => 'ScripCondition', VALUE => $condition->id );
-        while ( my $scrip = $scrips->Next ) {
-            $scrip->Delete;
-        }
-        $condition->DBIx::SearchBuilder::Record::Delete();
-    }
-}

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


More information about the rt-commit mailing list