Bug 21155

Summary: SwitchOnSiteCheckouts.t is failing randomly
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Test SuiteAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: fridolin.somers, martin.renvoize, nick
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:
Bug Depends on:    
Bug Blocks: 25551    
Attachments: Bug 21155: Prevent SwitchOnSiteCheckouts.t to fail randomly
Bug 21155: Prevent SwitchOnSiteCheckouts.t to fail randomly

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