[Bug 18286] New: Test::DBIx::Class connection/ schema is shadowed by a cached connection/schema
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Bug ID: 18286 Summary: Test::DBIx::Class connection/schema is shadowed by a cached connection/schema Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Test Suite Assignee: chris@bigballofwax.co.nz Reporter: olli-antti.kivilahti@jns.fi QA Contact: gmcharlt@gmail.com If Koha::Database->schema gets called before use Test::DBIx::Class The DB connection from $KOHA_CONF is cached. This happens most of the time because when C4::Context and friends are loaded (in compile-time?), they already access the DB. After Test::DBIx::Class is instantiated and hooks put in place to overload Koha::Schema connection, those hooks are never called due to getting the old connection from cache. This feature introduces a test case to replicate the behaviour and shows how flushing the connection cache solves the problem. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 --- Comment #1 from Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> --- Created attachment 61186 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=61186&action=edit Bug 18286 - Test::DBIx::Class connection/schema is shadowed by a cached connection/schema If Koha::Database->schema gets called before use Test::DBIx::Class The DB connection from $KOHA_CONF is cached. This happens most of the time because when C4::Context and friends are loaded (in compile-time?), they already access the DB. After Test::DBIx::Class is instantiated and hooks put in place to overload Koha::Schema connection, those hooks are never called due to getting the old connection from cache. This feature introduces a test case to replicate the behaviour and shows how flushing the connection cache solves the problem. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |18285 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18285 [Bug 18285] Koha::Database schema cache accessors -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|chris@bigballofwax.co.nz |olli-antti.kivilahti@jns.fi -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 --- Comment #2 from Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> --- Prior to this patch, for example t/Koha.t fails due to this caching issue. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |18226 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18226 [Bug 18226] Remove "use Test::DBIx::Class" instantiations' dangerous code duplication -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Josef Moravec <josef.moravec@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA CC| |josef.moravec@gmail.com --- Comment #3 from Josef Moravec <josef.moravec@gmail.com> --- comment from qa tools: FAIL t/db_dependent/01-test_dbic.t FAIL critic Code before strictures are enabled at line 4, column 1. See page 429 of PBP. "$schema" is declared but not used at line 18, column 3. Unused variables clutter code and make it harder to read. Expression form of "eval" at line 77, column 3. See page 161 of PBP. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |m.de.rooy@rijksmuseum.nl --- Comment #4 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Do we need a t/etc/schema file here? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #61186|0 |1 is obsolete| | --- Comment #5 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 62963 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=62963&action=edit Bug 18286: Test::DBIx::Class connection/schema is shadowed by a cached connection/schema If Koha::Database->schema gets called before use Test::DBIx::Class The DB connection from $KOHA_CONF is cached. This happens most of the time because when C4::Context and friends are loaded (in compile-time?), they already access the DB. After Test::DBIx::Class is instantiated and hooks put in place to overload Koha::Schema connection, those hooks are never called due to getting the old connection from cache. This feature introduces a test case to replicate the behaviour and shows how flushing the connection cache solves the problem. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 --- Comment #6 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 62964 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=62964&action=edit Bug 18286: [Follow-up] Add t/etc/schema.pl We need this file here already. Copied from bug 18226 and adjusted in order to keep qa tools quiet. Test plan: Run t/db_dependent/01-test_dbic.t again. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 --- Comment #7 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 62965 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=62965&action=edit Bug 18286: [QA Follow-up] Fix some warnings from qa tools [1] Resolve warning on variable assignment before use strict. [2] Remove unused $schema variable. [3] Remove eval expression construction. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 --- Comment #8 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 62966 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=62966&action=edit Bug 18286: [Follow-up] Remove assumption on branch count A test in db_dependent should not make assumptions on the number of branches in the database. If you need one, create one. Removing the assumption of a non-zero count. Removing the library count statement outside the subtest. Replacing C4::Context by Koha::Database. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Mason James <mtj@kohaaloha.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mtj@kohaaloha.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #62963|0 |1 is obsolete| | Attachment #62964|0 |1 is obsolete| | Attachment #62965|0 |1 is obsolete| | Attachment #62966|0 |1 is obsolete| | --- Comment #9 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 64004 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=64004&action=edit Bug 18286: Test::DBIx::Class connection/schema is shadowed by a cached connection/schema If Koha::Database->schema gets called before use Test::DBIx::Class The DB connection from $KOHA_CONF is cached. This happens most of the time because when C4::Context and friends are loaded (in compile-time?), they already access the DB. After Test::DBIx::Class is instantiated and hooks put in place to overload Koha::Schema connection, those hooks are never called due to getting the old connection from cache. This feature introduces a test case to replicate the behaviour and shows how flushing the connection cache solves the problem. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 --- Comment #10 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 64005 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=64005&action=edit Bug 18286: [Follow-up] Add t/etc/schema.pl We need this file here already. Copied from bug 18226 and adjusted in order to keep qa tools quiet. Test plan: Run t/db_dependent/01-test_dbic.t again. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 --- Comment #11 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 64006 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=64006&action=edit Bug 18286: [QA Follow-up] Fix some warnings from qa tools [1] Resolve warning on variable assignment before use strict. [2] Remove unused $schema variable. [3] Remove eval expression construction. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 --- Comment #12 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Created attachment 64007 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=64007&action=edit Bug 18286: [Follow-up] Remove assumption on branch count A test in db_dependent should not make assumptions on the number of branches in the database. If you need one, create one. Removing the assumption of a non-zero count. Removing the library count statement outside the subtest. Replacing C4::Context by Koha::Database. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master --- Comment #13 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Pushed to master for 17.11, thanks to everybody involved! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Bug 18286 depends on bug 18285, which changed state. Bug 18285 Summary: Koha::Database schema cache accessors https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18285 What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to Master |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18286 Fridolin SOMERS <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to Master |RESOLVED CC| |fridolin.somers@biblibre.co | |m Resolution|--- |FIXED --- Comment #14 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- Enhancement not pushed to 17.05.x -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org