diff options
author | Ivan Kohler <ivan@freeside.biz> | 2014-09-15 20:44:48 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2014-09-15 20:44:48 -0700 |
commit | ed1f84b4e8f626245995ecda5afcf83092c153b2 (patch) | |
tree | 3f58bbef5fbf2502e65d29b37b5dbe537519e89d /rt/t/ticket/race.t | |
parent | fe9ea9183e8a16616d6d04a7b5c7498d28e78248 (diff) |
RT 4.0.22
Diffstat (limited to 'rt/t/ticket/race.t')
-rw-r--r-- | rt/t/ticket/race.t | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/rt/t/ticket/race.t b/rt/t/ticket/race.t new file mode 100644 index 000000000..aa1150ecb --- /dev/null +++ b/rt/t/ticket/race.t @@ -0,0 +1,51 @@ +use strict; +use warnings; + +use RT::Test tests => 2; + +use constant KIDS => 50; + +my $id; + +{ + my $t = RT::Ticket->new( RT->SystemUser ); + ($id) = $t->Create( + Queue => "General", + Subject => "Race $$", + ); +} + +diag "Created ticket $id"; +RT->DatabaseHandle->Disconnect; + +my @kids; +for (1..KIDS) { + if (my $pid = fork()) { + push @kids, $pid; + next; + } + + # In the kid, load up the ticket and correspond + RT->ConnectToDatabase; + my $t = RT::Ticket->new( RT->SystemUser ); + $t->Load( $id ); + $t->Correspond( Content => "Correspondence from PID $$" ); + undef $t; + exit 0; +} + + +diag "Forked @kids"; +waitpid $_, 0 for @kids; +diag "All kids finished corresponding"; + +RT->ConnectToDatabase; +my $t = RT::Ticket->new( RT->SystemUser ); +$t->Load($id); +my $txns = $t->Transactions; +$txns->Limit( FIELD => 'Type', VALUE => 'Status' ); +is($txns->Count, 1, "Only one transaction change recorded" ); + +$txns = $t->Transactions; +$txns->Limit( FIELD => 'Type', VALUE => 'Correspond' ); +is($txns->Count, KIDS, "But all correspondences were recorded" ); |