Bug 18976

Summary: Fix t/db_dependent/Auth.t cleanup
Product: Koha Reporter: Lari Taskula <lari.taskula>
Component: Test SuiteAssignee: Lari Taskula <lari.taskula>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, katrin.fischer, mtj
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17427
Change sponsored?: --- Patch complexity: ---
Who signed the patch off: Text to go in the release notes:
Version(s) released in:
Attachments: Bug 18976: Fix t/db_dependent/Auth.t cleanup
Bug 18976: (follow-up) Fix t/db_dependent/Search/History.t cleanup
Bug 18976: Fix t/db_dependent/Auth.t cleanup
Bug 18976: (follow-up) Fix t/db_dependent/Search/History.t cleanup
Bug 18976: [16.11] Add missing use statement

Description Lari Taskula 2017-07-24 13:42:53 UTC
Test t/db_dependent/Auth.t seems to have an ineffective test data cleanup.
Data generated by TestBuilder is left in borrowers, branches, categories,
sms_providers and sessions tables after the test.

To replicate:
1. Check the row count of borrowers, branches and categories tables
2. prove t/db_dependent/Auth.t
3. Repeat step 1
4. Observe borrowers the following tables have increased in row count:
   - borrowers
   - branches
   - categories
   - sessions
   - sms_providers
Comment 1 Lari Taskula 2017-07-24 13:47:47 UTC
Created attachment 65195 [details] [review]
Bug 18976: Fix t/db_dependent/Auth.t cleanup

Test t/db_dependent/Auth.t seems to have an ineffective test data cleanup.
Data generated by TestBuilder is left in borrowers, branches, categories,
sms_providers and sessions tables after the test.

To replicate:
1. Check the row count of borrowers, branches and categories tables
2. prove t/db_dependent/Auth.t
3. Repeat step 1
4. Observe borrowers the following tables have increased in row count:
   - borrowers
   - branches
   - categories
   - sessions
   - sms_providers

To test:
1. Before applying the patch, go through steps at "To replicate" plan
2. Apply patch
3. Go through steps at "To replicate" plan
4. Observe step 4 no longer applies and those tables have the same number of
   rows as before executing the test.

This issue has been happening in REST tests as well, and this solution is
directly copy-pasted from t/db_dependent/api/v1/cities.t
Comment 2 Lari Taskula 2017-07-24 15:20:30 UTC
Created attachment 65197 [details] [review]
Bug 18976: (follow-up) Fix t/db_dependent/Search/History.t cleanup

Same problem in t/db_dependent/Search/History.t.

To replicate:
1. Check the row count of borrowers, branches, categories, sessions, sms_providers
   tables
2. prove t/db_dependent/Search/History.t
3. Repeat step 1
4. Observe borrowers the following tables have increased in row count:
   - borrowers
   - branches
   - categories
   - sessions
   - sms_providers

To test:
1. Before applying the patch, go through steps at "To replicate" plan
2. Apply patch
3. Go through steps at "To replicate" plan
4. Observe step 4 no longer applies and those tables have the same number of
   rows as before executing the test.
Comment 3 Jonathan Druart 2017-07-26 17:34:40 UTC
Caused by CGI::Session, see bug 17427.
Comment 4 Jonathan Druart 2017-07-26 17:38:07 UTC
Created attachment 65284 [details] [review]
Bug 18976: Fix t/db_dependent/Auth.t cleanup

Test t/db_dependent/Auth.t seems to have an ineffective test data cleanup.
Data generated by TestBuilder is left in borrowers, branches, categories,
sms_providers and sessions tables after the test.

To replicate:
1. Check the row count of borrowers, branches and categories tables
2. prove t/db_dependent/Auth.t
3. Repeat step 1
4. Observe borrowers the following tables have increased in row count:
   - borrowers
   - branches
   - categories
   - sessions
   - sms_providers

To test:
1. Before applying the patch, go through steps at "To replicate" plan
2. Apply patch
3. Go through steps at "To replicate" plan
4. Observe step 4 no longer applies and those tables have the same number of
   rows as before executing the test.

This issue has been happening in REST tests as well, and this solution is
directly copy-pasted from t/db_dependent/api/v1/cities.t

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 5 Jonathan Druart 2017-07-26 17:38:11 UTC
Created attachment 65285 [details] [review]
Bug 18976: (follow-up) Fix t/db_dependent/Search/History.t cleanup

Same problem in t/db_dependent/Search/History.t.

To replicate:
1. Check the row count of borrowers, branches, categories, sessions, sms_providers
   tables
2. prove t/db_dependent/Search/History.t
3. Repeat step 1
4. Observe borrowers the following tables have increased in row count:
   - borrowers
   - branches
   - categories
   - sessions
   - sms_providers

To test:
1. Before applying the patch, go through steps at "To replicate" plan
2. Apply patch
3. Go through steps at "To replicate" plan
4. Observe step 4 no longer applies and those tables have the same number of
   rows as before executing the test.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 6 Jonathan Druart 2017-07-26 17:38:48 UTC
Skipping QA, it will fixes selenium tests.
Comment 7 Jonathan Druart 2017-07-26 17:39:46 UTC
Pushed to master for 17.11, thanks Lari!
Comment 8 Fridolin SOMERS 2017-07-31 07:25:37 UTC
Pushed to 17.05.x, will be in 17.05.03.

In order to correct selenium test failures.
Comment 9 Katrin Fischer 2017-08-01 05:39:45 UTC
Patches apply, but don't work on 16.11.x:

kohadev-koha@kohadevbox:/home/vagrant/kohaclone$ perl t/db_dependent/Search/History.t 
1..26
Undefined subroutine &t::lib::Mocks::mock_preference called at t/db_dependent/Search/History.t line 19.
# Looks like your test exited with 255 before it could output anything.
Comment 10 Jonathan Druart 2017-08-01 11:32:06 UTC
Created attachment 65390 [details] [review]
Bug 18976: [16.11] Add missing use statement

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 11 Katrin Fischer 2017-08-16 21:55:23 UTC
All good this time - thx for the follow-up!

These patches have been pushed to 16.11.x and will be in 16.11.11.
Comment 12 Mason James 2017-08-24 14:07:16 UTC
Pushed to 16.05.x, for 16.05.16 release