From bcfe79fcfd9ff951a44852d3baab1cbc0c7d8a30 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 | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/OAI/Server.t b/t/db_dependent/OAI/Server.t index cd643b7..76a142f 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'); @@ -67,14 +69,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" }; @@ -112,7 +115,6 @@ foreach my $index ( 0..9 ) { }, }, }; - sleep 2; # FIXME Why do we need this sleep? } my $syspref = { @@ -343,3 +345,15 @@ test_query( }); $schema->storage->txn_rollback; + +sub manipulate_timestamp { +# This eliminates waiting a few seconds in order to get a higher timestamp +# Works only for 60 records.. + my ( $index, $bibno, $timestamp ) = @_; + return $timestamp if $timestamp !~ /\d{2}Z/; + my $secs = sprintf( "%02d", $index ); + $timestamp =~ s/\d{2}Z/${secs}Z/; + $dbh->do("UPDATE biblioitems SET timestamp=? WHERE biblionumber=?", undef, + ( $timestamp, $bibno )); + return $timestamp; +} -- 2.1.4