Bug 30596 - api/v1/acquisitions_baskets.t is failing randomly
Summary: api/v1/acquisitions_baskets.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)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on: 30055
Blocks:
  Show dependency treegraph
 
Reported: 2022-04-22 09:55 UTC by Jonathan Druart
Modified: 2022-05-06 15:00 UTC (History)
5 users (show)

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


Attachments
Bug 30596: Prevent api/v1/acquisitions_baskets.t to fail randomly (1.48 KB, patch)
2022-04-22 09:56 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 30596: Prevent api/v1/acquisitions_baskets.t to fail randomly (936 bytes, patch)
2022-04-22 11:25 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 30596: Prevent api/v1/acquisitions_baskets.t and api/v1/acquisitions_funds.t to fail randomly (1.67 KB, patch)
2022-04-22 11:28 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 30596: Prevent api/v1/acquisitions_baskets.t and api/v1/acquisitions_funds.t to fail randomly (1.73 KB, patch)
2022-04-22 19:14 UTC, Fridolin Somers
Details | Diff | Splinter Review
Bug 30596: Prevent api/v1/acquisitions_baskets.t and api/v1/acquisitions_funds.t to fail randomly (1.78 KB, patch)
2022-04-25 22:06 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2022-04-22 09:55:22 UTC
Because of date comparison

03:57:34 koha_1       |     #   Failed test 'exact match for JSON Pointer ""'
03:57:34 koha_1       |     #   at t/db_dependent/api/v1/acquisitions_baskets.t line 59.
03:57:34 koha_1       |     #     Structures begin differing at:
03:57:34 koha_1       |     #          $got->[1]{updated_on} = '2022-04-22T01:54:35+00:00'
03:57:34 koha_1       |     #     $expected->[1]{updated_on} = '2022-04-22T01:54:34+00:00'
03:57:34 koha_1       |     # Looks like you failed 1 test of 3.
03:57:34 koha_1       | 
03:57:34 koha_1       | #   Failed test 'list_managers() tests'
03:57:34 koha_1       | #   at t/db_dependent/api/v1/acquisitions_baskets.t line 63.
03:57:34 koha_1       | # Looks like you failed 1 test of 1.
Comment 1 Jonathan Druart 2022-04-22 09:56:48 UTC
Created attachment 133656 [details] [review]
Bug 30596: Prevent api/v1/acquisitions_baskets.t to fail randomly
Comment 2 Jonathan Druart 2022-04-22 09:58:19 UTC
This is a bit ugly, and we will need to reuse it in (at least) api/v1/acquisitions_funds.t

See 
commit 9bbbed2a4024311cbbd9b828eba0512f63069735
Bug 30055: API unit tests

Tomas, did you deal with that already in other REST api tests?
Comment 3 Tomás Cohen Arazi 2022-04-22 11:09:20 UTC
(In reply to Jonathan Druart from comment #2)
> This is a bit ugly, and we will need to reuse it in (at least)
> api/v1/acquisitions_funds.t
> 
> See 
> commit 9bbbed2a4024311cbbd9b828eba0512f63069735
> Bug 30055: API unit tests
> 
> Tomas, did you deal with that already in other REST api tests?

Maybe we need a new is_deeply, that accepts a list of things to exclude in the comparisson?
Comment 4 Nick Clemens 2022-04-22 11:10:32 UTC
(In reply to Jonathan Druart from comment #2)
> This is a bit ugly, and we will need to reuse it in (at least)
> api/v1/acquisitions_funds.t
> 
> See 
> commit 9bbbed2a4024311cbbd9b828eba0512f63069735
> Bug 30055: API unit tests
> 
> Tomas, did you deal with that already in other REST api tests?

Why not:
+    $superlibrarian->discard_changes;
+    $patron_with_permission->discard_changes;
Comment 5 Tomás Cohen Arazi 2022-04-22 11:24:26 UTC
(In reply to Nick Clemens from comment #4)
> (In reply to Jonathan Druart from comment #2)
> > This is a bit ugly, and we will need to reuse it in (at least)
> > api/v1/acquisitions_funds.t
> > 
> > See 
> > commit 9bbbed2a4024311cbbd9b828eba0512f63069735
> > Bug 30055: API unit tests
> > 
> > Tomas, did you deal with that already in other REST api tests?
> 
> Why not:
> +    $superlibrarian->discard_changes;
> +    $patron_with_permission->discard_changes;

+1
Comment 6 Jonathan Druart 2022-04-22 11:25:43 UTC
Created attachment 133668 [details] [review]
Bug 30596: Prevent api/v1/acquisitions_baskets.t to fail randomly
Comment 7 Jonathan Druart 2022-04-22 11:26:17 UTC
(In reply to Nick Clemens from comment #4)
> (In reply to Jonathan Druart from comment #2)
> > This is a bit ugly, and we will need to reuse it in (at least)
> > api/v1/acquisitions_funds.t
> > 
> > See 
> > commit 9bbbed2a4024311cbbd9b828eba0512f63069735
> > Bug 30055: API unit tests
> > 
> > Tomas, did you deal with that already in other REST api tests?
> 
> Why not:
> +    $superlibrarian->discard_changes;
> +    $patron_with_permission->discard_changes;

Yes, I think I actually focused on the wrong thing. updated_on is modified because of the set_password call. Having an up-to-date object should fix the problem. Thanks, Nick!
Comment 8 Jonathan Druart 2022-04-22 11:28:33 UTC
Created attachment 133669 [details] [review]
Bug 30596: Prevent api/v1/acquisitions_baskets.t and api/v1/acquisitions_funds.t to fail randomly

because of updated_on
Comment 9 Fridolin Somers 2022-04-22 19:14:57 UTC
Created attachment 133693 [details] [review]
Bug 30596: Prevent api/v1/acquisitions_baskets.t and api/v1/acquisitions_funds.t to fail randomly

because of updated_on

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Comment 10 Victor Grousset/tuxayo 2022-04-25 22:06:11 UTC
Created attachment 133845 [details] [review]
Bug 30596: Prevent api/v1/acquisitions_baskets.t and api/v1/acquisitions_funds.t to fail randomly

because of updated_on

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 11 Victor Grousset/tuxayo 2022-04-25 22:06:26 UTC
Works, qa script happy, code looks good, passing QA :)
Comment 12 Fridolin Somers 2022-04-26 06:54:14 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄