Bugzilla – Attachment 73684 Details for
Bug 20191
OAI/Server.t still fails on slow servers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20191: Use Test::MockTime to hold time still
Bug-20191-Use-TestMockTime-to-hold-time-still.patch (text/plain), 3.14 KB, created by
Tomás Cohen Arazi (tcohen)
on 2018-04-05 13:07:32 UTC
(
hide
)
Description:
Bug 20191: Use Test::MockTime to hold time still
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2018-04-05 13:07:32 UTC
Size:
3.14 KB
patch
obsolete
>From 3e2509c0698b24133b6db639826bcd79fb355c2c Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Thu, 5 Apr 2018 01:31:38 +0000 >Subject: [PATCH] Bug 20191: Use Test::MockTime to hold time still > >The problem is the calls to HTTP::OAI::Header, etc. >may reference gmtime which is continually changing by >the second. By forcing time to lock for all the tests, >except the last one, we can be assured things should >not fail. > >TEST PLAN >--------- >install libtest-mocktime-perl >apply the patch >restart_all >in kshell, prove t/db_dependent/OAI/Server.t >run koha qa test tools > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > C4/Installer/PerlDependencies.pm | 5 +++++ > t/db_dependent/OAI/Server.t | 17 +++++++++++++---- > 2 files changed, 18 insertions(+), 4 deletions(-) > >diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm >index 234865ed3a..55db081e82 100644 >--- a/C4/Installer/PerlDependencies.pm >+++ b/C4/Installer/PerlDependencies.pm >@@ -883,6 +883,11 @@ our $PERL_DEPS = { > required => 0, > min_ver => '0.52', > }, >+ 'Test::MockTime' => { >+ usage => 'Testing suite', >+ required => 0, >+ min_ver => '0.17', >+ }, > }; > > 1; >diff --git a/t/db_dependent/OAI/Server.t b/t/db_dependent/OAI/Server.t >index 87d5c8b557..7309c4a3ab 100644 >--- a/t/db_dependent/OAI/Server.t >+++ b/t/db_dependent/OAI/Server.t >@@ -18,6 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >+use Test::MockTime qw/set_fixed_time restore_time/; > > use Test::More tests => 29; > use DateTime; >@@ -69,10 +70,14 @@ $dbh->do('DELETE FROM deletedbiblioitems'); > $dbh->do('DELETE FROM deleteditems'); > $dbh->do('DELETE FROM oai_sets'); > >-my $date_added = DateTime->now() . 'Z'; >+set_fixed_time(CORE::time()); >+ >+my $base_datetime = DateTime->now(); >+my $date_added = $base_datetime->ymd . ' ' .$base_datetime->hms . 'Z'; > my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z'; > my (@header, @marcxml, @oaidc); >-my $sth = $dbh->prepare('SELECT timestamp FROM biblioitems WHERE biblionumber=?'); >+my $sth = $dbh->prepare('UPDATE biblioitems SET timestamp=? WHERE biblionumber=?'); >+my $sth2 = $dbh->prepare('UPDATE biblio_metadata SET timestamp=? WHERE biblionumber=?'); > > # Add biblio records > foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { >@@ -85,8 +90,10 @@ foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { > $record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $index" ) ); > } > my ($biblionumber) = AddBiblio($record, ''); >- $sth->execute($biblionumber); >- my $timestamp = $sth->fetchrow_array . 'Z'; >+ my $timestamp = $base_datetime->ymd . ' ' .$base_datetime->hms; >+ $sth->execute($timestamp,$biblionumber); >+ $sth2->execute($timestamp,$biblionumber); >+ $timestamp .= 'Z'; > $timestamp =~ s/ /T/; > $record = GetMarcBiblio({ biblionumber => $biblionumber }); > $record = XMLin($record->as_xml_record); >@@ -341,6 +348,8 @@ test_query( > }, > }); > >+restore_time(); >+ > subtest 'Bug 19725: OAI-PMH ListRecords and ListIdentifiers should use biblio_metadata.timestamp' => sub { > plan tests => 1; > >-- >2.17.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 20191
:
71673
|
71816
|
72009
|
73669
| 73684 |
73685