Koha-clms/t/db_dependent
Jonathan Druart 82f5b527d8 Bug 10611: Use mysql_auto_reconnect instead of ping
DBD::Mysql provides a mysql_auto_reconnect flag. Using it avoids
the time required to do a $dbh->ping().

Benchmarks:

use Modern::Perl;
use C4::Context;
for ( 1 .. 1000 ) {
    $dbh = C4::Context->dbh;
}

* without this patch on a local DB:
perl t.pl  0,49s user 0,02s system 98% cpu 0,525 total
* without this patch on a remote DB:
perl t.pl  0,52s user 0,05s system 1% cpu 37,358 total
* with this patch on a local DB:
perl t.pl  0,46s user 0,04s system 99% cpu 0,509 total
* with this patch on a remote DB:
perl t.pl  0,49s user 0,02s system 56% cpu 0,892 total

Testing the auto reconnect:
use Modern::Perl;
use C4::Context;
my $ping = $dbh->ping;
say $ping;
$dbh->disconnect;
$ping = $dbh->ping;
say $ping;

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Comment: Real improvement. No koha-qa errors

prove t/db_dependent/Circulation_issuingrules.t produces no error
prove t/db_dependent/Context.t produces no error

Test
1) dumped Koha DB, load it on a non-local server
2) run sample script whit and without patch, local and remote

use Modern::Perl;
use C4::Context;
for ( 1 .. 100000 ) {
    my $dbh = C4::Context->dbh;
}

Main difference I note is with remote server
a) without patch
real    0m16.357s
user    0m2.592s
sys     0m2.132s

b) with patch
real    0m0.259s
user    0m0.240s
sys     0m0.012s

I think this could be good for DBs placed on
remote servers

Bug 10611: add a "new" parameter to C4::Context->dbh

When dbh->disconnect is called and the mysql_auto_reconnect flag is set,
the dbh is not recreated: the old one is used.

Adding a new flag, we can now force the C4::Context->dbh method to
return a new dbh.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

Bug 10611: Followup: remove useless calls to dbh->disconnect

These 3 calls to disconnect are done at the end of the script, they are
useless.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 4ae3665ad8)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Conflicts:
	C4/Context.pm
2014-05-16 12:04:53 +02:00
..
Acquisition Bug 11549: Add regression test 2014-04-23 18:31:06 +02:00
Circulation Bug 11338: add unit tests for DelItemCheck 2014-01-03 10:08:08 +01:00
Koha Bug 11279: (follow-up) remove unnecessary check on number of quotes 2014-01-27 13:38:29 +01:00
LDAP
…
Labels Bug 10333: Labels/t_Batch.t needs to create its own data 2013-09-08 02:07:19 +00:00
Members Bug 10481: Unit tests for C4::Members::AddEnrolmentFeeIfNeeded 2013-08-16 15:08:41 +00:00
Record
…
Reports
…
Serials Bug 7688: (follow-up) rewrite 'for' loop in unit tests 2013-10-30 00:38:52 +00:00
data Bug 10684: add regression test 2013-11-14 18:04:39 +00:00
www
…
00-strict.t
…
Accounts.t
…
Acquisition.t Bug 11111: UT: SearchOrders returns keys basketgroupid and basketgroupname 2013-12-13 17:05:01 +01:00
Amazon.t
…
Auth.t Bug 10952: (follow-up) remove mention of KohaOpacRecentSearches cookie 2014-02-18 10:15:43 +01:00
Auth_SearchHistorySession.t Bug 10952: (follow-up) comments fixes and unit tests 2014-02-18 10:15:21 +01:00
Auth_with_cas.t
…
AuthoritiesMarc.t
…
BackgroundJob.t Bug 10601: (follow-up) unit tests for new ->set() and ->get() 2013-09-18 17:21:47 +00:00
Barcodes.t
…
Biblio.t
…
Bookseller.t Bug 11457: avoid spurious test failure in t/db_dependent/Bookseller.t 2014-02-18 09:46:21 +01:00
Borrower_Debarments.t Bug 12134: (follow-up) fix one of the IsDebarred() tests 2014-04-30 16:21:50 +02:00
Branch.t Bug 10508: (follow-up) remove Perl 5.14 construct 2013-08-28 14:24:34 +00:00
Budgets.t Bug 8037: (follow-up) improve GetBudgetByOrderNumber test 2013-10-31 14:57:18 +00:00
Circulation.t Bug 11336: (follow-up) fix typo in previous follow-up 2014-02-18 08:44:49 +01:00
Circulation_Branch.t Bug 10683: (follow-up) improvements to the unit tests 2013-10-09 03:51:55 +00:00
Circulation_Issuingrule.t Bug 10767: (follow-up) remove FIXME comments 2013-08-28 14:44:01 +00:00
Circulation_OfflineOperation.t Bug 10710: (follow-up) perltidy new code 2013-08-28 14:52:43 +00:00
Circulation_issue.t Bug 10493: (follow-up) fix test errors 2013-10-23 04:25:34 +00:00
Circulation_issuingrules.t Bug 10298: Followup: Adapt existing code 2013-08-09 16:35:43 +00:00
Circulation_transfers.t Bug 11470: fix occassional spurious test failure in Circulation_transfers.t 2014-02-18 08:50:08 +01:00
ClassSource.t Bug 10644: (follow-up) remove inadvertant dependence on Perl 5.14 2013-08-09 18:53:20 +00:00
Context.t Bug 10611: Use mysql_auto_reconnect instead of ping 2014-05-16 12:04:53 +02:00
CourseReserves.t Bug 10332: further improvements to course reserves tests 2013-06-18 16:40:43 -07:00
Csv.t Bug 10853: (follow-up) expand unit tests for C4::Csv 2013-10-11 03:25:42 +00:00
External_BakerTaylor.t
…
Heading_MARC21.t
…
Holds.t Bug 11336: update hold queue priorities correctly when deleting holds 2014-02-18 08:44:15 +01:00
HoldsQueue.t Bug 10243: (follow-up) add unit tests 2013-10-30 03:13:23 +00:00
Holidays.t Bug 11112: (follow-up) repair Koha::Calendar->add_holiday() 2013-12-24 11:52:50 +01:00
ILSDI_Services.t Bug 10667: (follow-up) fix reference to UT library in test case 2013-09-16 19:22:22 +00:00
Items.t Bug 10872: UT for GetHiddenItemnumbers and POD fix 2013-09-18 15:55:46 +00:00
KitchenSinkPlugin.kpz
…
Koha.t Bug 10078: (follow-up) add regression test 2013-10-30 05:02:45 +00:00
Koha_Authority.t Bug 5202: merge authorities from the authority file and reservoir 2013-10-10 21:32:27 +00:00
Koha_Database.t Bug 8798: moving code to Koha::Database and adding tests 2013-10-14 21:08:02 +00:00
Koha_borrower_modifications.t
…
Koha_template_plugin_Branches.t Bug 10626 - Remove doubled up TT plugins - Merge KohaBranchName and Branches 2013-12-30 10:38:24 +01:00
Koha_template_plugin_KohaDates.t
…
Linker_FirstMatch.t
…
Log.t
…
MarcModificationTemplates.t Bug 8015: Add unit tests for SimpleMARC and MarcModificationTemplates routines 2013-10-31 22:50:11 +00:00
Members.t Bug 11221: (follow-up) test for NULL rather than empty string 2013-11-19 15:35:25 +00:00
Members_columns.t Bug 7785: (follow-up) standardize POD 2013-08-13 16:15:30 +00:00
PatronLists.t Bug 10565: (follow-up) don't assume borrowernumber 1 exists in unit test 2013-10-14 21:30:34 +00:00
Plugins.t
…
Ratings.t
…
Record.t bug 6201: (follow-up) update unit tests 2013-10-09 05:26:27 +00:00
RecordProcessor_EmbedSeeFromHeadings.t
…
Reports.t
…
ReportsGuided.t
…
Reports_Guided.t Bug 10761: (follow-up) remove inadvertant dependence on Perl 5.14 2013-08-21 16:29:18 +00:00
Reserves.t Bug 9788: (follow-up) Unit tests for changed routine GetReservesFromItemnumber 2014-03-18 09:27:31 +01:00
RotatingCollections.t Bug 10653: (follow-up) minor tweaks to RotatingCollections tests 2013-08-16 16:09:13 +00:00
SIP_ILS.t
…
SQLHelper.t
…
Search.t Bug 11533: fix authority searching with no sorting when QueryParser is enabled 2014-04-23 18:23:21 +02:00
Search_SearchHistory.t Bug 10361: (follow-up) add tests for search history functions 2013-09-04 14:22:50 +00:00
Serials.t Bug 7688: (follow-up) have Serials.t create its test subscription 2013-10-31 05:07:44 +00:00
Serials_2.t Bug 8435: (follow-up) handle lack of userenv gracefully 2013-10-31 15:29:42 +00:00
Service.t
…
ShelfBrowser.t Bug 10856: Improve the previous and next items on the shelf browser 2013-10-04 15:56:35 +00:00
SuggestionEngine_ExplodedTerms.t
…
Suggestions.t
…
Tags.t
…
UploadedFile.t
…
VirtualShelves.t Bug 10499: VirtualShelves.t - wrap tests in a database transaction 2013-07-16 14:17:27 +00:00
VirtualShelves_Page.t
…
XISBN.t Bug 11439: (follow-up) adjust for change in list returned by OCLC XISBN 2014-02-08 09:37:32 +01:00
check_sysprefs.t
…
rollingloans.t
…
sysprefs.t Bug 10325: (follow-up) add test for overriding system preferences 2013-09-08 02:28:45 +00:00
zebra_config.pl Bug 11499: UT: Make zebra_setup.pl correctly set indexing mode 2014-02-18 09:55:22 +01:00