Bugzilla – Attachment 142729 Details for
Bug 31969
Options for cleanup_database.pl to remove finished jobs from the background job queue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31969: (follow-up) Unit tests for Koha::BackgroundJobs->purge
Bug-31969-follow-up-Unit-tests-for-KohaBackgroundJ.patch (text/plain), 3.63 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-10-27 18:00:46 UTC
(
hide
)
Description:
Bug 31969: (follow-up) Unit tests for Koha::BackgroundJobs->purge
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-10-27 18:00:46 UTC
Size:
3.63 KB
patch
obsolete
>From a385ecee859ae5b855da0f177015d1ca8afe0a8f Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Bj=C3=B6rn=20Nyl=C3=A9n?= <bjorn.nylen@ub.lu.se> >Date: Thu, 27 Oct 2022 10:47:56 +0200 >Subject: [PATCH] Bug 31969: (follow-up) Unit tests for > Koha::BackgroundJobs->purge > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Koha/BackgroundJobs.t | 67 +++++++++++++++++++++++++++- > 1 file changed, 66 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/BackgroundJobs.t b/t/db_dependent/Koha/BackgroundJobs.t >index cfb9c28cc7..ed4fd8d9fb 100755 >--- a/t/db_dependent/Koha/BackgroundJobs.t >+++ b/t/db_dependent/Koha/BackgroundJobs.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 14; >+use Test::More tests => 15; > use Test::MockModule; > > use List::MoreUtils qw(any); >@@ -140,3 +140,68 @@ subtest 'search_limited' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'purge' => sub { >+ plan tests => 9; >+ $schema->storage->txn_begin; >+ >+ my $recent_date = dt_from_string; >+ my $old_date = dt_from_string->subtract({ days => 3 }); >+ my $job_recent_t1_new = $builder->build_object( { class => 'Koha::BackgroundJobs', value => { status => 'new', ended_on => $old_date, type => 'type1' } } ); >+ my $job_recent_t2_fin = $builder->build_object( { class => 'Koha::BackgroundJobs', value => { status => 'finished', ended_on => $recent_date, type => 'type2' } } ); >+ my $job_old_t1_fin = $builder->build_object( { class => 'Koha::BackgroundJobs', value => { status => 'finished', ended_on => $old_date, type => 'type1' } } ); >+ my $job_old_t2_fin = $builder->build_object( { class => 'Koha::BackgroundJobs', value => { status => 'finished', ended_on => $old_date, type => 'type2' } } ); >+ >+ my $params = { job_types => ['type1'] , # Arrayref of jobtypes to be purged >+ days => 1, # Age in days of jobs to be purged >+ confirm => 0, # Confirm deletion >+ }; >+ is( Koha::BackgroundJobs->purge($params), 1, 'Only the old finished type1 job would be purged' ); >+ >+ $params->{'job_types'} = ['all']; >+ is( Koha::BackgroundJobs->purge($params), 2, 'All finished old jobs would be purged with job_types = all' ); >+ >+ my $rs = Koha::BackgroundJobs->search( >+ { >+ id => [ $job_recent_t1_new->id, $job_recent_t2_fin->id, $job_old_t1_fin->id, $job_old_t2_fin->id ] >+ } >+ ); >+ is( $rs->count, 4, 'All jobs still left in queue'); >+ >+ $params->{'job_types'} = ['type1']; >+ $params->{'confirm'} = 1; >+ is( Koha::BackgroundJobs->purge($params), 1, 'Only the old finished type1 job is purged' ); >+ >+ $rs = Koha::BackgroundJobs->search( >+ { >+ id => [ $job_recent_t1_new->id, $job_recent_t2_fin->id, $job_old_t1_fin->id, $job_old_t2_fin->id ] >+ } >+ ); >+ is( $rs->count, 3, '3 jobs still left in queue'); >+ >+ $params->{'job_types'} = ['all']; >+ is( Koha::BackgroundJobs->purge($params), 1, 'The remaining old finished jobs is purged' ); >+ $rs = Koha::BackgroundJobs->search( >+ { >+ id => [ $job_recent_t1_new->id, $job_recent_t2_fin->id, $job_old_t1_fin->id, $job_old_t2_fin->id ] >+ } >+ ); >+ is( $rs->count, 2, '2 jobs still left in queue'); >+ >+ $rs = Koha::BackgroundJobs->search( >+ { >+ id => [ $job_recent_t1_new->id ] >+ } >+ ); >+ is( $rs->count, 1, 'Unfinished job still left in queue'); >+ >+ $rs = Koha::BackgroundJobs->search( >+ { >+ id => [ $job_recent_t2_fin->id ] >+ } >+ ); >+ is( $rs->count, 1, 'Recent finished job still left in queue'); >+ >+ $schema->storage->txn_rollback; >+ >+}; >-- >2.34.1
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 31969
:
142603
|
142668
|
142699
|
142700
|
142727
|
142728
| 142729 |
144189
|
144190