Bugzilla – Attachment 102817 Details for
Bug 25109
Add execution locking to Koha::Script
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25109: Add 'wait' tests
Bug-25109-Add-wait-tests.patch (text/plain), 1.96 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-04-13 11:49:34 UTC
(
hide
)
Description:
Bug 25109: Add 'wait' tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-04-13 11:49:34 UTC
Size:
1.96 KB
patch
obsolete
>From 697bdd02d68b0b123867382b02ffcefd6d6569d7 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 13 Apr 2020 08:43:10 -0300 >Subject: [PATCH] Bug 25109: Add 'wait' tests > >This simple patch introduces a test for the lock waiting scenario. It >replicates the previous tests, but calls a script that passes the wait >=> 1 parameter to ->lock_exec. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/Koha/Script.t | 15 ++++++++++++++- > t/Koha/wait.pl | 17 +++++++++++++++++ > 2 files changed, 31 insertions(+), 1 deletion(-) > create mode 100755 t/Koha/wait.pl > >diff --git a/t/Koha/Script.t b/t/Koha/Script.t >index b5853282e8..c15432df61 100644 >--- a/t/Koha/Script.t >+++ b/t/Koha/Script.t >@@ -48,7 +48,8 @@ my $interface = C4::Context->interface; > is( $interface, 'commandline', "Context interface set correctly with no flags" ); > > subtest 'lock_exec() tests' => sub { >- plan tests => 2; >+ >+ plan tests => 3; > > # Launch the sleep script > my $pid = fork(); >@@ -63,6 +64,18 @@ subtest 'lock_exec() tests' => sub { > > like( $result, qr{Unable to acquire the lock.*}, 'Exception found' ); > >+ $pid = fork(); >+ if ( $pid == 0 ) { >+ system( dirname(__FILE__) . '/sleep.pl 2>&1' ); >+ exit; >+ } >+ >+ sleep 1; # Make sure we start after the fork >+ $command = dirname(__FILE__) . '/wait.pl'; >+ $result = `$command 2>&1`; >+ >+ is( $result, 'YAY!', 'wait.pl successfully waits for the lock' ); >+ > throws_ok > { Koha::Script->new({ lock_name => 'blah' }); } > 'Koha::Exceptions::MissingParameter', >diff --git a/t/Koha/wait.pl b/t/Koha/wait.pl >new file mode 100755 >index 0000000000..f909cb1f06 >--- /dev/null >+++ b/t/Koha/wait.pl >@@ -0,0 +1,17 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use Koha::Script; >+use Fcntl qw(:flock); >+use Try::Tiny; >+ >+# # Lock execution >+my $script = Koha::Script->new({ script => 'sleep.pl' }); >+ >+$script->lock_exec({ wait => 1 }); >+ >+print STDOUT "YAY!"; >+ >+# Normal exit >+1; >-- >2.26.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25109
:
102757
|
102758
|
102759
|
102760
|
102761
|
102762
|
102814
|
102815
|
102816
|
102817
|
102840
|
102841
|
102842
|
102843
|
102856
|
102887
|
102904
|
102905
|
102906
|
102907
|
102908
|
102909