Bug 21155 - SwitchOnSiteCheckouts.t is failing randomly
Summary: SwitchOnSiteCheckouts.t is failing randomly
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal (vote)
Target Milestone: ---
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-03 14:17 UTC by Jonathan Druart
Modified: 2018-11-28 15:32 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 21155: Prevent SwitchOnSiteCheckouts.t to fail randomly (1.84 KB, patch)
2018-10-16 13:33 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 21155: Prevent SwitchOnSiteCheckouts.t to fail randomly (1.91 KB, patch)
2018-10-16 13:42 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2018-08-03 14:17:00 UTC
https://jenkins.koha-community.org/job/Koha_18.05_D9/lastCompletedBuild/consoleFull

koha_1       | #   Failed test 'The date_due should have been set depending on the circ rules when the on-site checkout has been switched'
koha_1       | #   at t/db_dependent/Circulation/SwitchOnSiteCheckouts.t line 122.
koha_1       | #          got: '2018-08-03T23:59:00'
koha_1       | #     expected: '2018-08-08T23:59:00'
koha_1       | # Looks like you failed 1 test of 10.
koha_1       | [13:48:23] t/db_dependent/Circulation/SwitchOnSiteCheckouts.t
koha_1       | Dubious, test returned 1 (wstat 256, 0x100)
koha_1       | Failed 1/10 subtests
Comment 1 Jonathan Druart 2018-10-16 12:43:18 UTC
https://jenkins.koha-community.org/job/Koha_18.05_D8/lastCompletedBuild/consoleFull

koha_1       | #   Failed test 'The date_due should have been set depending on the circ rules when the on-site checkout has been switched'
koha_1       | #   at t/db_dependent/Circulation/SwitchOnSiteCheckouts.t line 122.
koha_1       | #          got: '2018-10-16T23:59:00'
koha_1       | #     expected: '2018-10-21T23:59:00'
koha_1       | # Looks like you failed 1 test of 10.
koha_1       | [12:17:48] t/db_dependent/Circulation/SwitchOnSiteCheckouts.t
Comment 2 Jonathan Druart 2018-10-16 13:33:38 UTC
Created attachment 80652 [details] [review]
Bug 21155: Prevent SwitchOnSiteCheckouts.t to fail randomly

#   Failed test 'The date_due should have been set depending on the circ
 rules when the on-site checkout has been switched'
 #   at t/db_dependent/Circulation/SwitchOnSiteCheckouts.t line 126.
 #          got: '2018-10-16T23:59:00'
 #     expected: '2018-10-21T23:59:00'

TestBuilder set date to today, so issuingrules.harduedate will be set to
today.
issuingrules.hardduedatecompare will be set to an integer.
If set to 0, $datedue will be reset to the hard due date

The call stack is: AddIssue > CalcDateDue > GetHardDueDate

In GetHardDueDate:
3509         if ( $hardduedatecompare == 0 || $hardduedatecompare == $cmp ) {
3510             $datedue = $hardduedate->clone;
3511         }

To fix this random failure we need to set issuingrules.harduedate to undef.

Test plan:
0. Do not apply this patch
1. Modify the test to set hardduedatecompare to 0 (search 'my $issuingrule = ')
2. Execute the test and confirm the failure
3. Apply this patch
4. Execute the test and confirm the it is no longer failing
Comment 3 Martin Renvoize 2018-10-16 13:42:18 UTC
Created attachment 80653 [details] [review]
Bug 21155: Prevent SwitchOnSiteCheckouts.t to fail randomly

 #   Failed test 'The date_due should have been set depending on the circ
 rules when the on-site checkout has been switched'
 #   at t/db_dependent/Circulation/SwitchOnSiteCheckouts.t line 126.
 #          got: '2018-10-16T23:59:00'
 #     expected: '2018-10-21T23:59:00'

TestBuilder set date to today, so issuingrules.harduedate will be set to
today.
issuingrules.hardduedatecompare will be set to an integer.
If set to 0, $datedue will be reset to the hard due date

The call stack is: AddIssue > CalcDateDue > GetHardDueDate

In GetHardDueDate:
3509         if ( $hardduedatecompare == 0 || $hardduedatecompare == $cmp ) {
3510             $datedue = $hardduedate->clone;
3511         }

To fix this random failure we need to set issuingrules.harduedate to undef.

Test plan:
0. Do not apply this patch
1. Modify the test to set hardduedatecompare to 0 (search 'my $issuingrule = ')
2. Execute the test and confirm the failure
3. Apply this patch
4. Execute the test and confirm the it is no longer failing

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2018-10-16 13:43:37 UTC
Well sleuthed Jonathan.

Going straight to Passed QA for this; Works as expected and keeps Jenkins happy.. it's always good to appease the mighty Jenkins!
Comment 5 Nick Clemens 2018-10-17 19:22:51 UTC
Awesome work all!

Pushed to master for 18.11
Comment 6 Martin Renvoize 2018-10-26 11:46:41 UTC
Pushed to 18.05.x for 18.05.06
Comment 7 Fridolin SOMERS 2018-11-09 11:58:12 UTC
Pushed to 17.11.x for 17.11.12