[Bug 14334] New: DBI fighting DBIx over Autocommit in tests
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 Bug ID: 14334 Summary: DBI fighting DBIx over Autocommit in tests Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Test Suite Assignee: chris@bigballofwax.co.nz Reporter: mtompset@hotmail.com QA Contact: gmcharlt@gmail.com As per an email on the KohaDev list, tcohen pointed out the problem. gmcharlt pointed out a solution here: http://paste.lisp.org/display/149194 --- BEGIN PASTE --- diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t index f53e75b..8599c3f 100644 --- a/t/db_dependent/Letters.t +++ b/t/db_dependent/Letters.t @@ -45,11 +45,15 @@ use t::lib::Mocks; use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Acquisition::Order; use Koha::Acquisition::Bookseller; +use Koha::Database; my $dbh = C4::Context->dbh; +my $database = Koha::Database->new(); +my $schema = $database->schema(); +$schema->storage->txn_begin(); + # Start transaction -$dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; $dbh->do(q|DELETE FROM letter|); @@ -341,4 +345,4 @@ is($err, 1, "Successfully sent claim"); is($mail{'To'}, 'testemail@mydomain.com', "mailto correct in sent claim"); is($mail{'Message'}, 'my vendor|John Smith|Ordernumber ' . $ordernumber . ' (Silence in the library) (1 ordered)', 'Claim notice text constructed successfully'); -$dbh->rollback; +$schema->storage->txn_rollback(); --- END PASTE --- And I have volunteered to do it. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 M. Tompsett <mtompset@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Medium patch Status|NEW |ASSIGNED Assignee|chris@bigballofwax.co.nz |mtompset@hotmail.com --- Comment #1 from M. Tompsett <mtompset@hotmail.com> --- Shoot! Those things which are NOT tests scare me, particularly rebuild_zebra.pl -- going to investigate further. $ git grep -i -l autocommit installer/data/mysql/updatedatabase.pl misc/batchRebuildItemsTables.pl misc/commit_file.pl misc/cronjobs/create_koc_db.pl misc/cronjobs/delete_patrons.pl misc/cronjobs/update_totalissues.pl misc/link_bibs_to_authorities.pl misc/maintenance/borrowers-force-messaging-defaults misc/maintenance/fix_accountlines_date.pl misc/migration_tools/bulkmarcimport.pl misc/migration_tools/create_analytical_rel.pl misc/migration_tools/rebuild_zebra.pl misc/stage_file.pl test/progressbar.pl tools/batch_delete_records.pl tools/manage-marc-import.pl tools/stage-marc-import.pl t/db_dependent/Accounts.t t/db_dependent/Acquisition/FillWithDefaultValues.t t/db_dependent/Auth.t t/db_dependent/Auth_with_cas.t t/db_dependent/Auth_with_ldap.t t/db_dependent/AuthoritiesMarc.t t/db_dependent/BackgroundJob.t t/db_dependent/Biblio.t t/db_dependent/Bookseller.t t/db_dependent/Borrower.t t/db_dependent/Borrower_Debarments.t t/db_dependent/Borrower_Discharge.t t/db_dependent/Borrower_Files.t t/db_dependent/Borrowers.t t/db_dependent/Branch.t t/db_dependent/Budgets.t t/db_dependent/Charset.t t/db_dependent/Circulation.t t/db_dependent/Circulation/CheckIfIssuedToPatron.t t/db_dependent/Circulation/CheckValidBarcode.t t/db_dependent/Circulation/GetIssues.t t/db_dependent/Circulation/IsItemIssued.t t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t t/db_dependent/Circulation/Returns.t t/db_dependent/Circulation_Branch.t t/db_dependent/Circulation_Issuingrule.t t/db_dependent/Circulation_OfflineOperation.t t/db_dependent/Circulation_issue.t t/db_dependent/Circulation_transfers.t t/db_dependent/ClassSource.t t/db_dependent/ColumnsSettings.t t/db_dependent/Contract.t t/db_dependent/CourseReserves.t t/db_dependent/Creators/Lib.t t/db_dependent/Csv.t t/db_dependent/FrameworkPlugin.t t/db_dependent/Holds.t t/db_dependent/Holds/LocalHoldsPriority.t t/db_dependent/Holds/RevertWaitingStatus.t t/db_dependent/HoldsQueue.t t/db_dependent/Holidays.t t/db_dependent/ILSDI_Services.t t/db_dependent/ImportBatch.t t/db_dependent/Items.t t/db_dependent/Items/GetItemsForInventory.t t/db_dependent/Items_DelItem.t t/db_dependent/Koha.t t/db_dependent/Koha/GetDailyQuote.t t/db_dependent/Koha/IsKohaFieldLinked.t t/db_dependent/Koha/Item/Search/Field.t t/db_dependent/Koha_Misc_Files.t t/db_dependent/Koha_borrower_modifications.t t/db_dependent/Labels/t_Batch.t t/db_dependent/Languages.t t/db_dependent/Letters.t t/db_dependent/Letters/GetLetterTemplates.t t/db_dependent/Letters/GetLettersAvailableForALibrary.t t/db_dependent/Log.t t/db_dependent/MarcModificationTemplates.t t/db_dependent/Members.t t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t t/db_dependent/Members/GetAllIssues.t t/db_dependent/Members/GetPendingIssues.t t/db_dependent/Members/IssueSlip.t t/db_dependent/Members_Attributes.t t/db_dependent/MungeMarcPrice.t t/db_dependent/NewsChannels.t t/db_dependent/OAI/Sets.t t/db_dependent/Overdues.t t/db_dependent/Ratings.t t/db_dependent/Record/marcrecord2csv.t t/db_dependent/Reports_Guided.t t/db_dependent/Reserves.t t/db_dependent/Review.t t/db_dependent/RotatingCollections.t t/db_dependent/Search/History.t t/db_dependent/Search_SearchHistory.t t/db_dependent/Serials.t t/db_dependent/Serials/Claims.t t/db_dependent/Serials/Frequency.t t/db_dependent/Serials/GetNextDate.t t/db_dependent/Serials/GetNextSeq.t t/db_dependent/Serials/Numberpattern.t t/db_dependent/Serials_2.t t/db_dependent/ShelfBrowser.t t/db_dependent/Stats.t t/db_dependent/Suggestions.t t/db_dependent/Template/Plugin/Branches.t t/db_dependent/Template/Plugin/Categories.t t/db_dependent/Utils/Datatables_Members.t t/db_dependent/Utils/Datatables_Virtualshelves.t t/db_dependent/VirtualShelves.t t/db_dependent/XISBN.t t/db_dependent/sysprefs.t -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 M. Tompsett <mtompset@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tomascohen@gmail.com -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 M. Tompsett <mtompset@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #2 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 39871 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=39871&action=edit Bug 14334: t/db_dependent/Bookseller.t AutoCommit fix TEST PLAN ---------- 1) git reset --hard origin/master 2) prove t/db_dependent/Bookseller.t -- horrible failure about transaction 3) apply this patch 4) prove t/db_dependent/Bookseller.t -- no issues 5) koha qa test tools. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #3 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 39872 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=39872&action=edit Bug 14334: t/db_dependent/Budgets.t AutoCommit fix TEST PLAN ---------- 1) git reset --hard origin/master 2) prove t/db_dependent/Budgets.t -- horrible failure about transaction 3) apply this patch 4) prove t/db_dependent/Budgets.t -- no issues 5) koha qa test tools. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #4 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 39873 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=39873&action=edit Bug 14334: t/db_dependent/Letters.t AutoCommit fix TEST PLAN ---------- 1) git reset --hard origin/master 2) prove t/db_dependent/Letters.t -- horrible failure about transaction 3) apply this patch 4) prove t/db_dependent/Letters.t -- no issues 5) koha qa test tools. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #5 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 39874 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=39874&action=edit Bug 14334: t/db_dependent/Accounts.t AutoCommit fix There is no easy way to trigger an obvious problem, as this test uses Koha::Borrowers and other DBIx things, which may or may not be causing it to not blow up. TEST PLAN --------- 1) apply patch 2) git diff origin/master -- Are the additions/subtractions similar to http://paste.lisp.org/display/149194? 3) run koha qa test tools -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #6 from M. Tompsett <mtompset@hotmail.com> --- t/db_dependent/Acquisition/FillWithDefaultValues.t seems to only read from the DB. I think the removal of the dbh code in the test file is the correct solution, and add a comment about how to do AutoCommit = 0 stuff if a test needs to write. Thoughts? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #7 from M. Tompsett <mtompset@hotmail.com> --- t/db_dependent/Auth.t seems to only read from the DB. I think the removal of the dbh code in the test file is the correct solution, and add a comment about how to do AutoCommit = 0 stuff if a test needs to write. Thoughts? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #8 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 39875 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=39875&action=edit Bug 14334: t/db_dependent/Auth_with_cas.t AutoCommit fix There is no easy way to trigger an obvious problem. TEST PLAN --------- 1) apply patch 2) git diff origin/master -- Are the additions/subtractions similar to http://paste.lisp.org/display/149194? 3) run koha qa test tools -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #9 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 39876 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=39876&action=edit Bug 14334: t/db_dependent/Auth_with_ldap.t AutoCommit fix There is no easy way to trigger an obvious problem. TEST PLAN --------- 1) apply patch 2) git diff origin/master -- Are the additions/subtractions similar to http://paste.lisp.org/display/149194? 3) run koha qa test tools -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #10 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 39877 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=39877&action=edit Bug 14334: t/db_dependent/AuthoritiesMarc.t AutoCommit fix There is no easy way to trigger an obvious problem. TEST PLAN --------- 1) apply patch 2) git diff origin/master -- Are the additions/subtractions similar to http://paste.lisp.org/display/149194? 3) run koha qa test tools -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 Indranil Das Gupta <indradg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |indradg@gmail.com -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #11 from M. Tompsett <mtompset@hotmail.com> --- I was not expecting to see: $dbh->{AutoCommit} = 1; in t/db_dependent/BackgroundJob.t at all. Is this correct? Why even include it then? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #12 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 39879 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=39879&action=edit Bug 14334: t/db_dependent/Biblio.t AutoCommit fix There is no easy way to trigger an obvious problem. TEST PLAN --------- 1) apply patch 2) git diff origin/master -- Are the additions/subtractions similar to http://paste.lisp.org/display/149194? -- this is a special case, in that the transaction rollbacks seem to terminate the transaction in DBIx. So there needs to be a transaction for each subtest. 3) run koha qa test tools -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #13 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 39880 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=39880&action=edit Bug 14334: t/db_dependent/Borrower.t AutoCommit fix There is no easy way to trigger an obvious problem. TEST PLAN --------- 1) apply patch 2) git diff origin/master -- Are the additions/subtractions similar to http://paste.lisp.org/display/149194? -- I added explicit rollback, since I do not know the default behaviour of DBIx. 3) run koha qa test tools -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #14 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 39881 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=39881&action=edit Bug 14334: t/db_dependent/Borrower_Debarments.t AutoCommit fix There is no easy way to trigger an obvious problem. TEST PLAN --------- 1) apply patch 2) git diff origin/master -- Are the additions/subtractions similar to http://paste.lisp.org/display/149194? 3) run koha qa test tools -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 M. Tompsett <mtompset@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yohann.dufour@biblibre.com -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #15 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 39882 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=39882&action=edit Bug 14334: t/db_dependent/Borrower_Discharge.t AutoCommit fix There is no easy way to trigger an obvious problem. TEST PLAN --------- 1) apply patch 2) git diff origin/master -- Are the additions/subtractions similar to http://paste.lisp.org/display/149194? 3) run koha qa test tools NOTE: I am uncertain of what yohann.dufour@biblibre.com means in his FIXME comments. No problems experienced under Debian Jessie. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #16 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 39883 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=39883&action=edit Bug 14334: t/db_dependent/Borrower_Files.t AutoCommit fix There is no easy way to trigger an obvious problem. TEST PLAN --------- 1) apply patch 2) git diff origin/master -- Are the additions/subtractions similar to http://paste.lisp.org/display/149194? 3) run koha qa test tools -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #17 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 39884 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=39884&action=edit Bug 14334: t/db_dependent/Borrowers.t AutoCommit fix There is no easy way to trigger an obvious problem. TEST PLAN --------- 1) apply patch 2) git diff origin/master -- Are the additions/subtractions similar to http://paste.lisp.org/display/149194? 3) run koha qa test tools -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #18 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 39885 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=39885&action=edit Bug 14334: t/db_dependent/Branch.t AutoCommit fix There is no easy way to trigger an obvious problem. TEST PLAN --------- 1) apply patch 2) git diff origin/master -- Are the additions/subtractions similar to http://paste.lisp.org/display/149194? 3) run koha qa test tools -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 M. Tompsett <mtompset@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |ASSIGNED -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #19 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Borrowed some of this patches so we can rely on jenkins. Will be back to this once finished. Thanks Mark! -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #39871|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #39872|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #39873|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #20 from M. Tompsett <mtompset@hotmail.com> --- Okay. Sorry it may take longer. Just was in a car accident. If anyone wishes to continue. What you see is what you get. I haven't made it further yet. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #21 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 40080 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=40080&action=edit Bug 14334: t/db_dependent/Charset.t AutoCommit fix There is no easy way to trigger an obvious problem. TEST PLAN --------- 1) apply patch 2) git diff origin/master -- Are the additions/subtractions similar to http://paste.lisp.org/display/149194? 3) run koha qa test tools -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #22 from M. Tompsett <mtompset@hotmail.com> --- Created attachment 40086 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=40086&action=edit Bug 14334: t/db_dependent/Circulation.t AutoCommit fix There is no easy way to trigger an obvious problem. Confirmed with khall that tweaking those two other lines to ensure the autocommit fix will be correct. (http://irc.koha-community.org/koha/2015-06-10#i_1686796) TEST PLAN --------- 1) apply patch 2) git diff origin/master -- Are the additions/subtractions similar to http://paste.lisp.org/display/149194? 3) run koha qa test tools -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #23 from Jonathan Druart <jonathan.druart@biblibre.com> --- Created attachment 40184 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=40184&action=edit [ FOR DISCUSSION ] Bug 14334: Add a Database module for db dependent tests What about something like that to avoid c/p? -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14334 --- Comment #24 from M. Tompsett <mtompset@hotmail.com> --- (In reply to Jonathan Druart from comment #23)
Created attachment 40184 [details] [review] [ FOR DISCUSSION ] Bug 14334: Add a Database module for db dependent tests
What about something like that to avoid c/p?
So, what are you thinking exactly, because I still see all the files needing modification if we make some db_dependent test module(s)? Plus, this isn't completely C&P. There was a correction or two as well. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org