Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Request Tracker: Commit

rt branch, 4.0/stop-shredder-dataloss, created. rt-4.0.5-138-gceb9394

 

 

Request Tracker commit RSS feed   Index | Next | Previous | View Threaded


jbrandt at bestpractical

May 9, 2012, 12:36 PM

Post #1 of 1 (183 views)
Permalink
rt branch, 4.0/stop-shredder-dataloss, created. rt-4.0.5-138-gceb9394

The branch, 4.0/stop-shredder-dataloss has been created
at ceb93948422c54d21a6d9e434db8046c45d53664 (commit)

- Log -----------------------------------------------------------------
commit da3fc87812215963908023bb909d6c58f8383118
Author: Bradley Bell <bradleyb [at] uw>
Date: Tue May 8 14:35:24 2012 -0700

make replace_relations work properly

diff --git a/lib/RT/Shredder.pm b/lib/RT/Shredder.pm
index 10d3536..26bd9ee 100644
--- a/lib/RT/Shredder.pm
+++ b/lib/RT/Shredder.pm
@@ -537,9 +537,9 @@ sub WipeoutAll
{
my $self = $_[0];

- while ( my ($k, $v) = each %{ $self->{'cache'} } ) {
- next if $v->{'State'} & (WIPED | IN_WIPING);
- $self->Wipeout( Object => $v->{'Object'} );
+ foreach ( values %{ $self->{'cache'} } ) {
+ next if $_->{'State'} & (WIPED | IN_WIPING);
+ $self->Wipeout( Object => $_->{'Object'} );
}
}


commit 27b8a617e40785660cd8fa9ca4b790a79a6b5c5b
Author: Bradley Bell <bradleyb [at] uw>
Date: Tue May 8 19:48:10 2012 -0700

result set is always empty unless schema arg is set

diff --git a/t/shredder/utils.pl b/t/shredder/utils.pl
index 5f5c182..9b848c6 100644
--- a/t/shredder/utils.pl
+++ b/t/shredder/utils.pl
@@ -283,7 +283,7 @@ sub dump_sqlite
my $old_fhkn = $dbh->{'FetchHashKeyName'};
$dbh->{'FetchHashKeyName'} = 'NAME_lc';

- my $sth = $dbh->table_info( '', '', '%', 'TABLE' ) || die $DBI::err;
+ my $sth = $dbh->table_info( '', '%', '%', 'TABLE' ) || die $DBI::err;
my @tables = keys %{$sth->fetchall_hashref( 'table_name' )};

my $res = {};

commit 1282c41a83211bb1f14fa2c97b3da56217cb73b0
Author: Bradley Bell <bradleyb [at] uw>
Date: Wed May 9 06:40:17 2012 -0700

test for replace_relations

diff --git a/t/shredder/03plugin_users.t b/t/shredder/03plugin_users.t
index 4f4ecc8..1f4cb49 100644
--- a/t/shredder/03plugin_users.t
+++ b/t/shredder/03plugin_users.t
@@ -5,8 +5,8 @@ use warnings;

use Test::Deep;
use File::Spec;
-use Test::More tests => 9;
-use RT::Test nodb => 1;
+use Test::More tests => 21;
+use RT::Test ();
BEGIN {
my $shredder_utils = RT::Test::get_relocatable_file('utils.pl',
File::Spec->curdir());
@@ -38,3 +38,61 @@ use_ok('RT::Shredder::Plugin::Users');
ok(!$status, "bad 'status' arg value");
}

+init_db();
+
+RT::Test->set_rights(
+ { Principal => 'Everyone', Right => [qw(CreateTicket)] },
+);
+
+create_savepoint('clean');
+
+{ # Create two users and a ticket. Shred second user and replace relations with first user
+ my ($uidA, $uidB, $msg);
+ my $userA = RT::User->new( RT->SystemUser );
+ ($uidA, $msg) = $userA->Create( Name => 'userA', Privileged => 1, Disabled => 0 );
+ ok( $uidA, "created user A" ) or diag "error: $msg";
+
+ my $userB = RT::User->new( RT->SystemUser );
+ ($uidB, $msg) = $userB->Create( Name => 'userB', Privileged => 1, Disabled => 0 );
+ ok( $uidB, "created user B" ) or diag "error: $msg";
+
+ my ($tid, $trid);
+ my $ticket = RT::Ticket->new( RT::CurrentUser->new($userB) );
+ ($tid, $trid, $msg) = $ticket->Create( Subject => 'UserB Ticket', Queue => 1 );
+ ok( $tid, "created new ticket") or diag "error: $msg";
+
+ my $transaction = RT::Transaction->new( RT->SystemUser );
+ $transaction->Load($trid);
+ is ( $transaction->Creator, $uidB, "ticket creator is user B" );
+
+ my $plugin = RT::Shredder::Plugin::Users->new;
+ isa_ok($plugin, 'RT::Shredder::Plugin::Users');
+
+ my $status;
+ ($status, $msg) = $plugin->TestArgs( status => 'any', name => 'userB', replace_relations => $uidA );
+ ok($status, "plugin arguments are ok") or diag "error: $msg";
+
+ my @objs;
+ ($status, @objs) = $plugin->Run;
+ ok($status, "executed plugin successfully") or diag "error: @objs";
+ @objs = RT::Shredder->CastObjectsToRecords( Objects => \@objs );
+ is(scalar @objs, 1, "one object in the result set");
+
+ my $shredder = shredder_new();
+
+ ($status, $msg) = $plugin->SetResolvers( Shredder => $shredder );
+ ok($status, "set conflicts resolver") or diag "error: $msg";
+
+ $shredder->PutObjects( Objects => \@objs );
+ $shredder->WipeoutAll;
+
+ $ticket->Load( $tid );
+ is($ticket->id, $tid, 'loaded ticket');
+
+ $transaction->Load($trid);
+ is ( $transaction->Creator, $uidA, "ticket creator is now user A" );
+
+ $shredder->Wipeout( Object => $ticket );
+ $shredder->Wipeout( Object => $userA );
+}
+cmp_deeply( dump_current_and_savepoint('clean'), "current DB equal to savepoint");

commit ceb93948422c54d21a6d9e434db8046c45d53664
Author: Jim Brandt <jbrandt [at] bestpractical>
Date: Wed May 9 15:25:19 2012 -0400

Modify DB check in ticket test to reflect conditions after WipeoutAll.

The commit modifying the table_info call in utils
(27b8a617) revealed the DBs in shredder tests appeared to be empty
and one test in 01ticket.t started failing. This commit removes
a link and a transaction for the parent that are still
in the DB after a child ticket is wiped. Need to confirm this
is the expected behavior. These are successfully removed by
shredder when the parent is wiped.

diff --git a/t/shredder/01ticket.t b/t/shredder/01ticket.t
index 7dff16d..4fae182 100644
--- a/t/shredder/01ticket.t
+++ b/t/shredder/01ticket.t
@@ -64,21 +64,30 @@ cmp_deeply( dump_current_and_savepoint('clean'), "current DB equal to savepoint"
{
my $parent = RT::Ticket->new( RT->SystemUser );
my ($pid) = $parent->Create( Subject => 'test', Queue => 1 );
- ok( $pid, "created new ticket" );
+ ok( $pid, "Created new parent ticket $pid" );
my ($status, $msg) = $parent->Delete;
- ok( $status, 'deleted parent ticket');
+ ok( $status, "Deleted parent ticket $pid - $msg ");
create_savepoint('parent_ticket');

my $child = RT::Ticket->new( RT->SystemUser );
my ($cid) = $child->Create( Subject => 'test', Queue => 1 );
- ok( $cid, "created new ticket" );
+ ok( $cid, "Created new child ticket $cid" );

($status, $msg) = $parent->AddLink( Type => 'DependsOn', Target => $cid );
- ok( $status, "Added link between tickets") or diag("error: $msg");
+ ok( $status, "Added link between tickets - $msg");
my $shredder = shredder_new();
$shredder->PutObjects( Objects => $child );
$shredder->WipeoutAll;
- cmp_deeply( dump_current_and_savepoint('parent_ticket'), "current DB equal to savepoint");
+
+ my ($current, $parent_save) = dump_current_and_savepoint('parent_ticket');
+
+ # The the link and a transaction that are still
+ # there after the child object is wiped.
+ # Is this the correct behavior?
+ delete $current->{'Transactions'}{'31'};
+ delete $current->{'Links'}{'1'};
+
+ cmp_deeply( $current, $parent_save , "current DB minus link and transaction equal to savepoint");

$shredder->PutObjects( Objects => $parent );
$shredder->WipeoutAll;

-----------------------------------------------------------------------
_______________________________________________
Rt-commit mailing list
Rt-commit [at] lists
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit

Request Tracker commit RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.