Bug 34843

Summary: Koha/Database/Commenter.t is failing if the DB has been upgraded
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Test SuiteAssignee: Marcel de Rooy <m.de.rooy>
Status: Pushed to oldstable --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: fridolin.somers
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.11.00,23.05.04,22.11.11
Bug Depends on: 29093, 32334    
Bug Blocks: 34841    
Attachments: Bug 34843: Fix database comment inconsistency on toc_request
Bug 34843: Fix database comment inconsistency on toc_request

Description Jonathan Druart 2023-09-20 12:27:04 UTC
To recreate:
root@kohadevbox:koha$ perl /kohadevbox/misc4dev/run_tests.pl --run-db-upgrade-only

kohadev-koha@kohadevbox:koha$ prove t/db_dependent/Koha/Database/Commenter.t

t/db_dependent/Koha/Database/Commenter.t .. 
    #   Failed test 'No comment for toc_request'
    #   at t/db_dependent/Koha/Database/Commenter.t line 40.
    #          got: '0'
    #     expected: '1'

    #   Failed test 'Reset for one-columned article_requests'
    #   at t/db_dependent/Koha/Database/Commenter.t line 55.
    #                   'ALTER TABLE koha_kohadev.article_requests MODIFY COLUMN `cancellation_reason` varchar(80) COLLATE utf8mb4_unicode_ci DEFAULT NULL;
    # ALTER TABLE koha_kohadev.article_requests MODIFY COLUMN `debit_id` int(11) DEFAULT NULL;
    # ALTER TABLE koha_kohadev.article_requests MODIFY COLUMN `toc_request` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'borrower requested table of contents';'
    #     doesn't match '(?^um:ALTER.*toc_request.*DEFAULT 0;(.*\n)+ALTER.*toc_request.*COMMENT.*$)'
    # Looks like you failed 2 tests of 9.
t/db_dependent/Koha/Database/Commenter.t .. 1/2 
#   Failed test '->new, dry_run'
#   at t/db_dependent/Koha/Database/Commenter.t line 58.
# Looks like you failed 1 test of 2.
t/db_dependent/Koha/Database/Commenter.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests
Comment 1 Marcel de Rooy 2023-09-20 13:04:33 UTC
Will have a look
Comment 2 Marcel de Rooy 2023-09-20 13:50:23 UTC
(In reply to Jonathan Druart from comment #0)
> To recreate:
> root@kohadevbox:koha$ perl /kohadevbox/misc4dev/run_tests.pl
> --run-db-upgrade-only
> 

Cant reproduce this right away in Koha. Did new install on current master too.
This may need some specific context?
SQL version ?
Other specifics ?
Comment 3 Marcel de Rooy 2023-09-20 13:53:33 UTC
Note that Commenter.t also passes with me if I completely remove all data by drop / create db / run kohastructure.sql
Comment 4 Jonathan Druart 2023-09-20 14:27:15 UTC
(In reply to Marcel de Rooy from comment #2)
> (In reply to Jonathan Druart from comment #0)
> > To recreate:
> > root@kohadevbox:koha$ perl /kohadevbox/misc4dev/run_tests.pl
> > --run-db-upgrade-only
> > 
> 
> Cant reproduce this right away in Koha. Did new install on current master
> too.
> This may need some specific context?
> SQL version ?
> Other specifics ?

This is in the context of bug 34841.

The --run-db-upgrade-only will reset the DB to 19.11.00 (using a dump that is present in the misc4dev repo), then run the DB upgrade process, twice.

And the test suite will eventually run on top of that.

Here Commenter.t is failing when it's run after the 19.11.00 DB reset+upgrade x 2
Comment 5 Jonathan Druart 2023-09-20 14:28:04 UTC
I guess this is coming from COMMENTs missing from atomic updates, when we added the columns.
Comment 6 Marcel de Rooy 2023-09-22 07:34:38 UTC
Caused by bug 29093 (from a certain Marcel)
Comment 7 Marcel de Rooy 2023-09-22 07:39:56 UTC
Created attachment 156030 [details] [review]
Bug 34843: Fix database comment inconsistency on toc_request

Bug 29093 had a dbrev without comment, but added comment to
kohastructure.

Test plan:
Check (or remove) comment on article_requests.toc_request.
Run dbrev.
Check if comment was added (if you removed).
Run t/db/Koha/Database/Commenter.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 8 Jonathan Druart 2023-09-22 08:02:18 UTC
Created attachment 156033 [details] [review]
Bug 34843: Fix database comment inconsistency on toc_request

Bug 29093 had a dbrev without comment, but added comment to
kohastructure.

Test plan:
Check (or remove) comment on article_requests.toc_request.
Run dbrev.
Check if comment was added (if you removed).
Run t/db/Koha/Database/Commenter.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 9 Tomás Cohen Arazi 2023-09-22 14:35:18 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 10 Fridolin Somers 2023-09-22 19:56:33 UTC
Pushed to 23.05.x for 23.05.04
Comment 11 Jacob O'Mara 2023-10-17 11:21:12 UTC
Nice work everyone!

Pushed to oldstable for 22.11.x