Bug 25665 - test t/db_dependent/Circulation.t fails on a specific date
Summary: test t/db_dependent/Circulation.t fails on a specific date
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: 19.05
Hardware: All All
: P5 - low minor
Assignee: Victor Grousset/tuxayo
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-03 17:35 UTC by Victor Grousset/tuxayo
Modified: 2021-06-14 21:31 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
19.05.17
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Victor Grousset/tuxayo 2020-06-03 17:35:44 UTC
2020-06-02

== Test plan ==
Warning: changing the system time to something too far in the past will disrupt HTTPS & TLS so you will have errors if you try to browse the web in parallel. And other software(like email clients) might pop errors.
Nothing to worry about.

1. Set system date to 2020-06-01 (time: somewhere during that day)
2. prove t/db_dependent/Circulation.t
3. "All tests successful."
4. Set system date to 2020-06-02 (time: somewhere during that day)
5. prove t/db_dependent/Circulation.t
6. Fail
7. Set system date to 2020-06-03 (time: somewhere during that day)
8. "All tests successful."


master : doesn't happen
19.11.x: doesn't happen
19.05.x: happens (v19.05.11)
Comment 1 Victor Grousset/tuxayo 2020-06-03 17:35:52 UTC
I tried very quickly to find if the test suite mentioned mocking time (to have a clean way to test) but I haven't found such thing. (will continue searching)
Comment 2 Victor Grousset/tuxayo 2020-06-03 17:36:51 UTC
Severity: minor but it will also depend of the underlying cause.
Comment 3 Victor Grousset/tuxayo 2020-06-03 17:39:40 UTC
failure message:

kohadev-koha@04fc7d250165:/kohadevbox/koha$ prove t/db_dependent/Circulation.t
t/db_dependent/Circulation.t .. 43/46 
    #   Failed test 'Hourly rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays (168h - 24h * 0.25u)'
    #   at t/db_dependent/Circulation.t line 3245.
    #          got: '30'
    #     expected: '36'
    # Looks like you failed 1 test of 20.
t/db_dependent/Circulation.t .. 44/46 
#   Failed test 'Incremented fee tests'
#   at t/db_dependent/Circulation.t line 3270.
t/db_dependent/Circulation.t .. 45/46 # Looks like you failed 1 test of 46.
t/db_dependent/Circulation.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/46 subtests 

Test Summary Report
-------------------
t/db_dependent/Circulation.t (Wstat: 256 Tests: 46 Failed: 1)
  Failed test:  44
  Non-zero exit status: 1
Files=1, Tests=46, 30 wallclock secs ( 0.10 usr  0.02 sys + 22.21 cusr  4.17 csys = 26.50 CPU)
Result: FAIL
kohadev-koha@04fc7d250165:/kohadevbox/koha$
Comment 4 Victor Grousset/tuxayo 2020-06-03 17:44:15 UTC
Patch of bug 24881 comment 1 is still in 19.05.x and isn't not the cause of this bug. A revert doesn't make the test output change.
Comment 5 Victor Grousset/tuxayo 2020-06-03 17:52:15 UTC
TODO use Time::Fake to reproduce instead of changing date.
Comment 6 Jonathan Druart 2020-06-04 09:46:59 UTC
When you managed to make it fail, share the patch to make sure it fails for someone else as well.
Comment 8 Victor Grousset/tuxayo 2020-06-30 21:34:33 UTC
I don't manage to use Time::Fake ...

IIUC I should just replace this line:
https://gitlab.com/koha-community/Koha/-/blob/19.05.x/t/db_dependent/Circulation.t#L3100

By one of the following to decide the outcome of the test:
    my $dt = dt_from_string("2020-06-02 19:05"); # should fail
    my $dt = dt_from_string("2020-06-03 19:05"); # should work

But it has no effect, I can still only decide the outcome of the test using system's time.
Comment 9 Jonathan Druart 2020-07-28 08:06:56 UTC
Victor, I recreate this error today.

I have applied the 2 last patches from bug 23382 and the failure is fixed.

You may want to backport them using this bug id to have things clear in the release note. So prefix the patch's title with "Bug 25665: (bug 23382 follow-up)"

Let me know if you need help.
Comment 10 Victor Grousset/tuxayo 2020-10-28 16:38:08 UTC
I works! thanks a lot and sorry for the delay.
Comment 11 Victor Grousset/tuxayo 2020-10-28 16:38:58 UTC
Backported to 19.05.x branch for 19.05.17