Bug 39286 - BackgroundJob.t should mock_config
Summary: BackgroundJob.t should mock_config
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal
Assignee: Jonathan Druart
QA Contact: Tomás Cohen Arazi (tcohen)
URL:
Keywords:
Depends on: 35655
Blocks: 34070
  Show dependency treegraph
 
Reported: 2025-03-10 10:14 UTC by Jonathan Druart
Modified: 2025-03-17 07:28 UTC (History)
2 users (show)

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


Attachments
Bug 39286: Use mock_config instead of env vars (2.96 KB, patch)
2025-03-10 10:17 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 39286: Use mock_config instead of env vars (3.07 KB, patch)
2025-03-11 09:23 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 39286: Use mock_config instead of env vars (3.13 KB, patch)
2025-03-11 12:21 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2025-03-10 10:14:03 UTC
Bug 35655 needed to mock the config, but instead introduced new env variables.
Comment 1 Jonathan Druart 2025-03-10 10:17:01 UTC Comment hidden (obsolete)
Comment 2 Magnus Enger 2025-03-11 09:23:47 UTC
Created attachment 179148 [details] [review]
Bug 39286: Use mock_config instead of env vars

Bug 35655 needed to mock the config, but instead introduced new env variables.

Test plan:
  prove t/db_dependent/Koha/BackgroundJob.t
should still return green

Bonus 1: no more warning
t/db_dependent/Koha/BackgroundJob.t .. 1/6 Cannot connect to broker Failed to connect: Error connecting to not_localhost:99999: Invalid argument at /usr/share/perl5/Net/Stomp.pm line 27.; giving up at /usr/share/perl5/Net/Stomp.pm line 27.

Bonus 2: tests are passing even if you have 'message_broker' in the
config
To test this, add the following entry to $KOHA_CONf then prove again
 <message_broker>
    <hostname>localhost</hostname>
    <port>61613</port>
    <username>guest</username>
    <password>guest</password>
    <vhost></vhost>
 </message_broker>
=> Without this patch the tests fail because the config will overwrite
the env vars.

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Warning goes away and prove works even with the message_broker config.
Comment 3 Tomás Cohen Arazi (tcohen) 2025-03-11 12:21:47 UTC
Created attachment 179161 [details] [review]
Bug 39286: Use mock_config instead of env vars

Bug 35655 needed to mock the config, but instead introduced new env variables.

Test plan:
  prove t/db_dependent/Koha/BackgroundJob.t
should still return green

Bonus 1: no more warning
t/db_dependent/Koha/BackgroundJob.t .. 1/6 Cannot connect to broker Failed to connect: Error connecting to not_localhost:99999: Invalid argument at /usr/share/perl5/Net/Stomp.pm line 27.; giving up at /usr/share/perl5/Net/Stomp.pm line 27.

Bonus 2: tests are passing even if you have 'message_broker' in the
config
To test this, add the following entry to $KOHA_CONf then prove again
 <message_broker>
    <hostname>localhost</hostname>
    <port>61613</port>
    <username>guest</username>
    <password>guest</password>
    <vhost></vhost>
 </message_broker>
=> Without this patch the tests fail because the config will overwrite
the env vars.

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Warning goes away and prove works even with the message_broker config.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 4 Katrin Fischer 2025-03-17 07:28:46 UTC
Pushed for 25.05!

Well done everyone, thank you!