From af6b02c5f17243af7c3db8a564be201252eb8f6f Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 9 Dec 2016 11:26:33 +0100 Subject: [PATCH] Bug 15108: [QA Follow-up] Remove the sleep Content-Type: text/plain; charset=utf-8 Ordering by timestamp, biblionumber in ListBase.pm c/would be a performance killer. In order to speed up the test, we manipulate the timestamp. Signed-off-by: Marcel de Rooy --- t/db_dependent/OAI/Server.t | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/OAI/Server.t b/t/db_dependent/OAI/Server.t index 508efc5..1a3b155 100644 --- a/t/db_dependent/OAI/Server.t +++ b/t/db_dependent/OAI/Server.t @@ -47,6 +47,8 @@ BEGIN { use_ok('Koha::OAI::Server::ResumptionToken'); } +use constant NUMBER_OF_MARC_RECORDS => 10; + # Mocked CGI module in order to be able to send CGI parameters to OAI Server my %param; my $module = Test::MockModule->new('CGI'); @@ -64,14 +66,15 @@ 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=?'); -# Add 10 biblio records -foreach my $index ( 0..9 ) { +# Add biblio records +foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { my $record = MARC::Record->new(); $record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $index" ) ); my ($biblionumber) = AddBiblio($record, ''); $sth->execute($biblionumber); my $timestamp = $sth->fetchrow_array . 'Z'; $timestamp =~ s/ /T/; + $timestamp = manipulate_timestamp( $index, $biblionumber, $timestamp ); $record = GetMarcBiblio($biblionumber); $record = XMLin($record->as_xml_record); push @header, { datestamp => $timestamp, identifier => "TEST:$biblionumber" }; @@ -109,7 +112,6 @@ foreach my $index ( 0..9 ) { }, }, }; - sleep 2; # FIXME Why do we need this sleep? } my $syspref = { @@ -340,3 +342,16 @@ test_query( }); $schema->storage->txn_rollback; + +sub manipulate_timestamp { +# This eliminates waiting a few seconds in order to get a higher timestamp + my ( $index, $bibno, $timestamp ) = @_; + my ( $year ) = $timestamp =~ /(\d{4})/; + return $timestamp if !$year; # bad luck + $year += $index - NUMBER_OF_MARC_RECORDS; + $timestamp =~ s/\d{4}/$year/; + $timestamp =~ s/02-29T/02-28T/; # paranoid programmer + $dbh->do("UPDATE biblioitems SET timestamp=? WHERE biblionumber=?", undef, + ( $timestamp, $bibno )); + return $timestamp; +} -- 2.1.4