Bug 26250 - Test suite does not pass if Elastic is used as search engine
Summary: Test suite does not pass if Elastic is used as search engine
Status: Pushed to master
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low major (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-19 06:45 UTC by Jonathan Druart
Modified: 2020-11-09 11:22 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Text to go in the release notes:
Version(s) released in:
20.11.00


Attachments
Bug 26250: Fix tests when SearchEngine=Elastic (228.58 KB, patch)
2020-08-19 12:06 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 26250: StockRotationItems.t - wip (9.57 KB, patch)
2020-08-19 12:06 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 26250: StockRotationItems.t and StockRotationStages.t (13.28 KB, patch)
2020-08-19 13:01 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 26250: StockRotationItems.t and StockRotationStages.t (13.35 KB, patch)
2020-08-19 13:15 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 26250: Fix tests when SearchEngine=Elastic (228.91 KB, patch)
2020-08-20 11:27 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 26250: StockRotationItems.t and StockRotationStages.t (13.42 KB, patch)
2020-08-20 11:27 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 26250: Fix tests when SearchEngine=Elastic (228.97 KB, patch)
2020-08-26 22:17 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 26250: StockRotationItems.t and StockRotationStages.t (13.47 KB, patch)
2020-08-26 22:17 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 26250: Fix regressions.t when SearchEngine=ES (1.09 KB, patch)
2020-09-10 08:42 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2020-08-19 06:45:10 UTC
This is a long standing issue we really need to address.

Who is willing to help me with this one?
Comment 1 Jonathan Druart 2020-08-19 12:06:35 UTC
Created attachment 108590 [details] [review]
Bug 26250: Fix tests when SearchEngine=Elastic

Most of the time the tests are failing because the item is not created
correctly (missing biblio and/or biblioitem).
The usual error is:
 t/db_dependent/selenium/regressions.t ..... 5/5 Can't call method "leader" on an undefined value at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch.pm line 534.

In this patch we are making sure $builder->build({ source => 'Item' })
is replace with $builder->build_sample_item

Test plan:
Turn on Elastic and confirm that all the tests pass!
Comment 2 Jonathan Druart 2020-08-19 12:06:38 UTC
Created attachment 108591 [details] [review]
Bug 26250: StockRotationItems.t - wip

StockRotationItems.t and StockRotationStages.t need to be fixed
Comment 3 Jonathan Druart 2020-08-19 12:07:36 UTC
We are very close here, only 2 test files are still failing.
Can I get some help to fix them and have this awesome patch pushed to master ASAP?
It will be a nightmare to rebase, we need it now!
Comment 4 Martin Renvoize 2020-08-19 13:01:11 UTC
Created attachment 108623 [details] [review]
Bug 26250: StockRotationItems.t and StockRotationStages.t
Comment 5 Jonathan Druart 2020-08-19 13:14:30 UTC
Thanks Martin!
Comment 6 Jonathan Druart 2020-08-19 13:15:11 UTC
Created attachment 108627 [details] [review]
Bug 26250: StockRotationItems.t and StockRotationStages.t

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 7 Nick Clemens 2020-08-20 11:27:33 UTC
Created attachment 108730 [details] [review]
Bug 26250: Fix tests when SearchEngine=Elastic

Most of the time the tests are failing because the item is not created
correctly (missing biblio and/or biblioitem).
The usual error is:
 t/db_dependent/selenium/regressions.t ..... 5/5 Can't call method "leader" on an undefined value at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch.pm line 534.

In this patch we are making sure $builder->build({ source => 'Item' })
is replace with $builder->build_sample_item

Test plan:
Turn on Elastic and confirm that all the tests pass!

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 8 Nick Clemens 2020-08-20 11:27:36 UTC
Created attachment 108731 [details] [review]
Bug 26250: StockRotationItems.t and StockRotationStages.t

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 9 Katrin Fischer 2020-08-20 22:38:31 UTC
We have a QA script fail here:

 FAIL	t/db_dependent/Koha/Patrons.t
   OK	  critic
   FAIL	  forbidden patterns
		forbidden pattern: Use of DateTime->now should certainly be replaced with dt_from_string (bug 24840) (line 612)
		forbidden pattern: Use of DateTime->now should certainly be replaced with dt_from_string (bug 24840) (line 613)
		forbidden pattern: Use of DateTime->now should certainly be replaced with dt_from_string (bug 24840) (line 1427)
		forbidden pattern: Use of DateTime->now should certainly be replaced with dt_from_string (bug 24840) (line 1428)

Hm, and some tests are failing?
t/db_dependent/CourseReserves/CourseItems.t
Test Summary Report
-------------------
t/db_dependent/CourseReserves/CourseItems.t (Wstat: 1536 Tests: 35 Failed: 6)
  Failed tests:  2, 7, 12, 17, 22, 34
  Non-zero exit status: 6
Comment 10 Jonathan Druart 2020-08-21 06:54:00 UTC
(In reply to Katrin Fischer from comment #9)
> We have a QA script fail here:
> 
>  FAIL	t/db_dependent/Koha/Patrons.t
>    OK	  critic
>    FAIL	  forbidden patterns
> 		forbidden pattern: Use of DateTime->now should certainly be replaced with
> dt_from_string (bug 24840) (line 612)
> 		forbidden pattern: Use of DateTime->now should certainly be replaced with
> dt_from_string (bug 24840) (line 613)
> 		forbidden pattern: Use of DateTime->now should certainly be replaced with
> dt_from_string (bug 24840) (line 1427)
> 		forbidden pattern: Use of DateTime->now should certainly be replaced with
> dt_from_string (bug 24840) (line 1428)

That's not valid, the diff is:
-    AddIssue( $patron, $item_1->{barcode}, DateTime->now->subtract( days => 1 ) );
-    AddIssue( $patron, $item_2->{barcode}, DateTime->now->subtract( days => 5 ) );
-    AddIssue( $patron, $item_3->{barcode} );
+    AddIssue( $patron, $item_1->barcode, DateTime->now->subtract( days => 1 ) );
+    AddIssue( $patron, $item_2->barcode, DateTime->now->subtract( days => 5 ) );
+    AddIssue( $patron, $item_3->barcode );


> Hm, and some tests are failing?
> t/db_dependent/CourseReserves/CourseItems.t
> Test Summary Report
> -------------------
> t/db_dependent/CourseReserves/CourseItems.t (Wstat: 1536 Tests: 35 Failed: 6)
>   Failed tests:  2, 7, 12, 17, 22, 34
>   Non-zero exit status: 6

It passes for me :-/
Comment 11 Katrin Fischer 2020-08-26 22:16:33 UTC
I have rerun the tests on a fresh setup and it looks much better now. I have an issue with the selenium tests in general sadly, so I am passing QA, but ask you to double check this one.

Maybe you can also see what's going wrong, so posting my error too:

prove t/db_dependent/selenium/regressions.t
t/db_dependent/selenium/regressions.t .. Could not create new session: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
null,"translators":null,"contributors":null,"locales":["sk"]},{"name":"Википедија (sr)","description":"Претрага Википедије на српском језику","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["sr"]},{"name":"Wikipedia (af)","description":"Wikipedia, die vrye ensiklopedie","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["af"]},{"name":"ویکی‌پدیا (fa)","description":"ویکی‌پدیا، دانشنامهٔ آزاد","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["fa"]},{"name":"വിക്കിപീഡിയ (ml)","description":"വിക്കിപീഡിയ, സ്വതന്ത്ര സര്‍വ്വവിജ്ഞാനകോശം ","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["ml"]},{"name":"Wikipedia (ms)","description":"Wikipedia, ensiklopedia bebas","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["ms"]},{"name":"Wikipedia (ia)","description":"Wikipedia, le encyclopedia libere","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["ia"]},{"name":"Wikipedia (no)","description":"Wikipedia, den frie encyklopedi","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["NO"]},{"name":"Википедия (ru)","description":"Википедия, свободная энциклопедия","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["ru"]},{"name":"Wikipedia (br)","description":"Wikipedia, an holloueziadur digor","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["br"]},{"name":"Wikipedia (pl)","description":"Wikipedia, wolna encyklopedia","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["pl"]},{"name":"Вікіпэдыя (be-tarask)","description":"Вікіпэдыя, вольная энцыкляпэдыя","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["be-tarask"]},{"name":"ວິກິພີເດຍ (lo)","description":"ວິກິພີເດຍ, ສາລານຸກົມເສລີ","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["lo"]},{"name":"Wikipedia (sv)","description":"Wikipedia, den fria encyklopedin","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["sv-SE"]},{"name":"Vikipēdija","description":"Vikipēdija, brīvā enciklopēdija","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["lv"]},{"name":"Wikipedija (sl)","description":"Wikipedija, prosta enciklopedija","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["sl"]},{"name":"Biquipedia (an)","description":"A enciclopedia Libre","creator":null,"developers":null,"translators":null,"contributors":null,"locales":["an"]}],"targetApplications":[{"id":"toolkit@mozilla.org","minVersion":null,"maxVersion":null}],"targetPlatforms":[],"seen":true,"dependencies":[],"incognito":"spanning","userPermissions":{"permissions":[],"origins":[]},"icons":{"16":"favicon.ico"},"iconURL":null,"blocklistState":0,"blocklistURL":null,"startupData":null,"hidden":true,"installTelemetryInfo":null,"recommendationState":null,"rootURI":"resource://search-extensions/wikipedia/","location":"app-builtin"}
1598362999817	addons.xpi	DEBUG	Loading bootstrap scope from resource://search-extensions/wikipedia/
1598362999817	addons.xpi	DEBUG	Calling bootstrap method install on wikipedia@search.mozilla.org version 1.0
1598362999817	addons.xpi	DEBUG	Calling bootstrap method startup on wikipedia@search.mozilla.org version 1.0
1598363019143	addons.productaddons	INFO	sending request to: https://aus5.mozilla.org/update/3/GMP/68.11.0/20200720181548/Linux_x86_64-gcc3/null/esr/Linux%204.9.0-13-amd64%20(GTK%203.22.11%2Clibpulse%20not-available)/default/default/update.xml
1598363019578	addons.productaddons	INFO	Completed downloading document
 at /home/vagrant/kohaclone/t/lib/Selenium.pm line 58.
Use of uninitialized value $value in string eq at /home/vagrant/kohaclone/C4/Context.pm line 529.
# Looks like your test exited with 255 before it could output anything.
t/db_dependent/selenium/regressions.t .. Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 5/5 subtests 

Test Summary Report
-------------------
t/db_dependent/selenium/regressions.t (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 5 tests but ran 0.
Comment 12 Katrin Fischer 2020-08-26 22:17:23 UTC
Created attachment 109208 [details] [review]
Bug 26250: Fix tests when SearchEngine=Elastic

Most of the time the tests are failing because the item is not created
correctly (missing biblio and/or biblioitem).
The usual error is:
 t/db_dependent/selenium/regressions.t ..... 5/5 Can't call method "leader" on an undefined value at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch.pm line 534.

In this patch we are making sure $builder->build({ source => 'Item' })
is replace with $builder->build_sample_item

Test plan:
Turn on Elastic and confirm that all the tests pass!

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 13 Katrin Fischer 2020-08-26 22:17:27 UTC
Created attachment 109209 [details] [review]
Bug 26250: StockRotationItems.t and StockRotationStages.t

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 14 Jonathan Druart 2020-08-27 07:33:15 UTC
(In reply to Katrin Fischer from comment #11)
> I have rerun the tests on a fresh setup and it looks much better now. I have
> an issue with the selenium tests in general sadly, so I am passing QA, but
> ask you to double check this one.
> 
> Maybe you can also see what's going wrong, so posting my error too:

I guess you are not using ktd but kohadevbox. It is one of the reason I moved to ktd, it was getting tricky to make the selenium tests pass.
You should double check the selenium version, most of the time the problems come from there (you need 2.53.1)
Comment 15 Katrin Fischer 2020-08-27 07:46:45 UTC
Yes, the last one on kohadevbox it appears... but thx for the hint, I will check!
Comment 16 Jonathan Druart 2020-08-31 14:21:09 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 17 Lucas Gass 2020-09-04 21:10:08 UTC
doesnt apply clean to 20.05.x, no backport

please rebase if needed
Comment 18 Jonathan Druart 2020-09-10 08:42:19 UTC
Created attachment 109838 [details] [review]
Bug 26250: Fix regressions.t when SearchEngine=ES

Prior to this patch it failed with:
t/db_dependent/selenium/regressions.t .. 5/5 Can't call method "leader" on an undefined value at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch.pm line 548.
Comment 19 Jonathan Druart 2020-09-10 08:42:48 UTC
Last patch pushed to master.