Bug 29368

Summary: Zebra index not correctly mocked from tests
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Test SuiteAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: kyle, tomascohen
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.11.00
Attachments: Bug 29368: Correctly mock Zebra index from tests
Bug 29368: Don't crash if search engine returns a deleted record
Bug 29368: Fix remove_from_cart
Bug 29368: Correctly mock Zebra index from tests
Bug 29368: Fix remove_from_cart

Description Jonathan Druart 2021-10-29 10:35:45 UTC

    
Comment 1 Jonathan Druart 2021-10-29 10:37:48 UTC
Created attachment 127087 [details] [review]
Bug 29368: Correctly mock Zebra index from tests

This is just reusing what is done in Search.t (and that is correct).
But search_utf8.t and remove_from_cart.t are wrong
Comment 2 Jonathan Druart 2021-10-29 10:37:52 UTC
Created attachment 127088 [details] [review]
Bug 29368: Don't crash if search engine returns a deleted record

Needs to be moved to its own bug report
Comment 3 Jonathan Druart 2021-10-29 10:37:56 UTC
Created attachment 127089 [details] [review]
Bug 29368: Fix remove_from_cart

Reusing what has been done previously
Comment 4 Jonathan Druart 2021-10-29 12:16:50 UTC
(In reply to Jonathan Druart from comment #3)
> Created attachment 127089 [details] [review] [review]
> Bug 29368: Fix remove_from_cart
> 
> Reusing what has been done previously

This does not actually work.
Comment 5 Jonathan Druart 2021-10-29 12:25:43 UTC
I think the trick may have worked before (no plack), but now I really don't see how we could find a fix for mocking correctly the koha-conf (and so zebra config/index).
The only solution I see would be to introduce a fixed path for an alternate koha-conf file. Koha::Config->guess_koha_conf would pick it first if exists (only for dev_install). I don't even know if that would work (as we are loading it very early).
Comment 6 Jonathan Druart 2021-10-29 12:26:40 UTC
And we cannot know it's a dev_install before we load koha-conf...
Comment 7 Jonathan Druart 2021-10-29 12:30:11 UTC
We could mess with the usual koha-conf file (replace the zebra paths before and after the tests) but that feels so bad and wrong.
Comment 8 Jonathan Druart 2021-10-29 12:56:04 UTC
I've tried with a ALT_KOHA_CONF to pick before KOHA_CONF (in Koha::Config->guess_koha_conf but it does not work either). Plack is loaded already and the context is kept in a module var.
Comment 9 Jonathan Druart 2021-10-29 13:46:47 UTC
Created attachment 127097 [details] [review]
Bug 29368: Correctly mock Zebra index from tests

This is just reusing what is done in Search.t (and that is correct).
But search_utf8.t and remove_from_cart.t are wrong as we want to use the
UI (and we cannot mock the zebra index, ie. koha-conf, from tests for
plack).

This still needs some work but improve a bit the existing code and make
tests pass (hopefully!)
Comment 10 Jonathan Druart 2021-10-29 13:47:07 UTC
Created attachment 127099 [details] [review]
Bug 29368: Fix remove_from_cart

Reusing what has been done previously.
Comment 11 Jonathan Druart 2021-10-29 13:48:55 UTC
Pushed to master for 21.11, thanks to everybody involved!
Comment 12 Jonathan Druart 2021-10-29 13:50:21 UTC
So basically this is not perfect as we are not really mocking zebra index for UI tests, but tests may be passing and jenkins will be happy for 21.11.00