There should be a set of tests that use Test::WWW::Mechanize to automatically test the functionality of Koha.
Created attachment 10445 [details] [review] Bug 8300: Add mechanized unit test for batch import This new unit test confirms that importing records via the Stage MARC import tool still works by connecting to a Koha instance and importing a record then reverting the import, checking at each step of the way that everything is as it should be. To test: 1. Install Test::WWW::Mechanize > sudo apt-get install libtest-www-mechanize-perl 2. Set environment variables to reflect your Koha instance: > export KOHA_USER=kohaadmin > export KOHA_PASS=katikoan > export KOHA_INTRANET_URL=http://localhost:8080 > export KOHA_OPAC_URL=http://localhost 3. Run the test: > prove t/db_dependent/www/batch.t
I got an error when I launch tests: % prove t/db_dependent/www/batch.t t/db_dependent/www/batch.t .. 14/19 # Failed test 'found book' # at t/db_dependent/www/batch.t line 111. # searched: "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Trans"... # can't find: "Data structures : Esakov, Jeffrey" # LCSS: "cture" # LCSS context: " \x{0a} \x{0a}\x{09}<li><a href="/cgi-bin/koha/tools/picture-" Test::WWW::Mechanize seems to be a new dependency.
(In reply to comment #2) > I got an error when I launch tests: > > % prove t/db_dependent/www/batch.t > t/db_dependent/www/batch.t .. 14/19 > # Failed test 'found book' > # at t/db_dependent/www/batch.t line 111. > # searched: "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Trans"... > # can't find: "Data structures : Esakov, Jeffrey" > # LCSS: "cture" > # LCSS context: " \x{0a} \x{0a}\x{09}<li><a > href="/cgi-bin/koha/tools/picture-" > > > Test::WWW::Mechanize seems to be a new dependency. I've been struggling to figure out the problem, and I finally realized- my sample record is MARC21. I'll update the test to have both UNIMARC and MARC21.
Created attachment 12103 [details] [review] Bug 8300: Add mechanized unit test for batch import This new unit test confirms that importing records via the Stage MARC import tool still works by connecting to a Koha instance and importing a record then reverting the import, checking at each step of the way that everything is as it should be. To test: 1. Install Test::WWW::Mechanize > sudo apt-get install libtest-www-mechanize-perl 2. Set environment variables to reflect your Koha instance: > export KOHA_USER=kohaadmin > export KOHA_PASS=katikoan > export KOHA_INTRANET_URL=http://localhost:8080 > export KOHA_OPAC_URL=http://localhost 3. Run the test: > prove t/db_dependent/www/batch.t This updated patch now handles both MARC21 and UNIMARC installations.
After applying the patch I get this: $ prove -v t/db_dependent/www/batch.t t/db_dependent/www/batch.t .. 1..20 ok 1 - connect to intranet ok 2 - login to staff client ok 3 - load main page Link not found at t/db_dependent/www/batch.t line 63. # Looks like you planned 20 tests but ran 3. # Looks like your test exited with 255 just after 3. Dubious, test returned 255 (wstat 65280, 0xff00) Failed 17/20 subtests Test Summary Report ------------------- t/db_dependent/www/batch.t (Wstat: 65280 Tests: 3 Failed: 0) Non-zero exit status: 255 Parse errors: Bad plan. You planned 20 tests but ran 3. Files=1, Tests=3, 4 wallclock secs ( 0.04 usr 0.00 sys + 0.38 cusr 0.04 csys = 0.46 CPU) Result: FAIL I think the problem is that after the new look of the staff client was introduced, the link to tools no longer contains the text "Tools". Changing line 63 of t/db_dependent/www/batch.t to this: $agent->follow_link_ok( { url_regex => qr/tools-home/i }, 'open tools module' ); makes the test succeed.
The environment variables that need to be set should probably be documented somewhere too? Not sure where though. A README in t/db_dependent/www/ perhaps?
This would be more of an enhancement request, but I imagine lots of tests could require lots of different env variables, to point the scripts to users, records etc that could be used for testing. I can also imagine wanting to run the tests against a number of different installations, both on and off localhost. Would it make sense to have these tests read config files that contain all the different settings required to test a given installation, and then point the tests to the right config with a single env var?
Created attachment 12222 [details] [review] Bug 8300: Add mechanized unit test for batch import This new unit test confirms that importing records via the Stage MARC import tool still works by connecting to a Koha instance and importing a record then reverting the import, checking at each step of the way that everything is as it should be. To test: 1. Install Test::WWW::Mechanize > sudo apt-get install libtest-www-mechanize-perl 2. Set environment variables to reflect your Koha instance: > export KOHA_USER=kohaadmin > export KOHA_PASS=katikoan > export KOHA_INTRANET_URL=http://localhost:8080 > export KOHA_OPAC_URL=http://localhost 3. Run the test: > prove t/db_dependent/www/batch.t This updated patch now handles both MARC21 and UNIMARC installations.
Created attachment 12226 [details] [review] Bug 8300: Add mechanized unit test for batch import This new unit test confirms that importing records via the Stage MARC import tool still works by connecting to a Koha instance and importing a record then reverting the import, checking at each step of the way that everything is as it should be. To test: 1. Install Test::WWW::Mechanize > sudo apt-get install libtest-www-mechanize-perl 2. Set environment variables to reflect your Koha instance: > export KOHA_USER=kohaadmin > export KOHA_PASS=katikoan > export KOHA_INTRANET_URL=http://localhost:8080 > export KOHA_OPAC_URL=http://localhost 3. Run the test: > prove t/db_dependent/www/batch.t This updated patch now handles both MARC21 and UNIMARC installations. Signed-off-by: Magnus Enger <magnus@enger.priv.no> All tests pass with marcflavour = MARC21 and NORMARC. Test #15 fails when marcflavour = UNIMARC, but from what I can see, that is because I'm testing on a MARC21 setup, missing the UNIMARC frameworks etc. I'm signing off - QA folks, please ask for a proper UNIMARC signoff if you feel it is needed.
Not tested on a UNIMARC setup, but still signing off. It's not as if this will break anything if there really is an error for UNIMARC.
> > To test: > 1. Install Test::WWW::Mechanize > > sudo apt-get install libtest-www-mechanize-perl can we get a follow-up patch to add www-mech as a dependancy package?
Created attachment 12780 [details] [review] Patch for new dependency Marked as optional dependency, since it is only needed in the context of testing suite.
My test (on current master) results in: t/db_dependent/www/batch.t .. 14/20 # Failed test 'found book' # at t/db_dependent/www/batch.t line 165. # searched: "\x{0a}\x{0a}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tra"... # can't find: "Data structures" # LCSS: "Data str" # LCSS context: "" rel="gb_page_center[600,500]">Englewood Data str" t/db_dependent/www/batch.t .. 19/20 # Looks like you failed 1 test of 20. t/db_dependent/www/batch.t .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/20 subtests Test Summary Report ------------------- t/db_dependent/www/batch.t (Wstat: 256 Tests: 20 Failed: 1) Failed test: 15 Non-zero exit status: 1 Files=1, Tests=20, 14 wallclock secs ( 0.02 usr 0.01 sys + 0.51 cusr 0.02 csys = 0.56 CPU) Result: FAIL
Just looking at the previous comment, I wonder why it should find the title Data structures. On Manage staged MARC records, I can see the file name, but not this title. Please explain. Changing status to reflect need of clarification. Thank you.
I have started to collect some ideas here: http://wiki.koha-community.org/wiki/Mechanized_testing_suite_RFC
(In reply to comment #13) > t/db_dependent/www/batch.t .. 14/20 > # Failed test 'found book' > # at t/db_dependent/www/batch.t line 165. > # searched: "\x{0a}\x{0a}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 > Tra"... > # can't find: "Data structures" > # LCSS: "Data str" > # LCSS context: "" rel="gb_page_center[600,500]">Englewood Data str" > t/db_dependent/www/batch.t .. 19/20 # Looks like you failed 1 test of 20. > t/db_dependent/www/batch.t .. Dubious, test returned 1 (wstat 256, 0x100) > Failed 1/20 subtests What MARC-flavour did you test with, Marcel? I just ran the tests on current master without any problems: $ prove -v t/db_dependent/www/batch.t t/db_dependent/www/batch.t .. 1..20 ok 1 - connect to intranet ok 2 - login to staff client ok 3 - load main page ok 4 - open tools module ok 5 - go to stage MARC ok 6 - uploaded file ok 7 - upload succeeded ok 8 - reopen stage MARC page ok 9 - stage MARC ok 10 - have job ID ok 11 - job was completed ok 12 - reopen stage MARC page at end of upload ok 13 - stage MARC ok 14 - view batch ok 15 - found book ok 16 - imported records into catalog ok 17 - successfully imported record ok 18 - revert import ok 19 - getting reverted bib ok 20 - bib is gone ok All tests successful. Files=1, Tests=20, 25 wallclock secs ( 0.04 usr 0.00 sys + 0.56 cusr 0.04 csys = 0.64 CPU) Result: PASS
(In reply to comment #16) > What MARC-flavour did you test with, Marcel? I just ran the tests on current > master without any problems: MARC21
Created attachment 12899 [details] Screenshot showing the link followed by the test script on line 157
(In reply to comment #14) > Just looking at the previous comment, I wonder why it should find the title > Data structures. On Manage staged MARC records, I can see the file name, but > not this title. > Please explain. Changing status to reflect need of clarification. > Thank you. I think I found an axplanation for this: After the file is uploaded you get a list of information as shown in the screenshot I just uploaded. This list has a link labelled "Manage staged records" which takes you directly to the records you just uploaded. This is the link the test follows on line 157: $agent->follow_link_ok( { text => 'Manage staged records' }, 'view batch' ); And this page should display the titles of the uploaded/staged records. From the test output it looks like your title might have been truncated to ">Englewood Data str"? If you want to spend more time on this you might try and put an __END__ below line 165, like so: $agent->content_contains( $bookdescription, 'found book' ); __END__ $agent->form_number(5); This will let you visit "Staged MARC record management" and see what the results of the staging looks like (before it is removed further down in the test). (I just tested the patch on another installation and it still works for me :-)
I still do not get this working. Manually importing the data file, I have the impression that this file is the actual problem. When importing, I see under Citation: Englewood Data str This probably should have been Data structures. Is this marc datafile really in good shape? I do not think so.
That *is* weird. For me, both the test itself and staging and importing t/db_dependent/www/data/marc21record.mrc manually works as expected. But the format of the marc file definitely seems to be the problem then.
The floor routine is provided by the POSIX module which is not loaded.
I just had a go at this again. - The first patch still applies, and for me all the tests pass (on a NORMARC setup). POSIX not being loaded does not seem to be an issue. - The second patch does not apply because new dependencies have been added since the path was made. Making a new patch for this should be easy. How do we move this bug forwards? It seems to work well for me but not for Marcel...
Created attachment 16516 [details] [review] Bug 8300 - Add Test::WWW::Mechanize as an optional dependency This patch replaces an earlier patch by Marcel de Rooy, which had become outdated because lots of new dependencies were added since the patch was made.
I just staged and imported the record in the marc21record.mrc file successfully into Koha, and the results look good to me. Not sure that file is the cause of Marcel's problems... I'm resetting this to "Needs signoff" so we can hopefully get another set of eyes on it and rule out any weirdness in either my setup or that of Marcel.
Created attachment 17394 [details] [review] Bug 8300: Add mechanized unit test for batch import This new unit test confirms that importing records via the Stage MARC import tool still works by connecting to a Koha instance and importing a record then reverting the import, checking at each step of the way that everything is as it should be. To test: 1. Install Test::WWW::Mechanize > sudo apt-get install libtest-www-mechanize-perl 2. Set environment variables to reflect your Koha instance: > export KOHA_USER=kohaadmin > export KOHA_PASS=katikoan > export KOHA_INTRANET_URL=http://localhost:8080 > export KOHA_OPAC_URL=http://localhost 3. Run the test: > prove t/db_dependent/www/batch.t This updated patch now handles both MARC21 and UNIMARC installations. Signed-off-by: Magnus Enger <magnus@enger.priv.no> All tests pass with marcflavour = MARC21 and NORMARC. Test #15 fails when marcflavour = UNIMARC, but from what I can see, that is because I'm testing on a MARC21 setup, missing the UNIMARC frameworks etc. I'm signing off - QA folks, please ask for a proper UNIMARC signoff if you feel it is needed. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 17395 [details] [review] Bug 8300 - Add Test::WWW::Mechanize as an optional dependency This patch replaces an earlier patch by Marcel de Rooy, which had become outdated because lots of new dependencies were added since the patch was made. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
QA comment: Nice unit test. Tests pass here (UNIMARC install), so I mark these patches as Passed QA. ps: I maintain my previous remark: we should load the POSIX module for the floor routine. My SO patch will contain this modification.
Created attachment 17437 [details] [review] Bug 8300: Add mechanized unit test for batch import This new unit test confirms that importing records via the Stage MARC import tool still works by connecting to a Koha instance and importing a record then reverting the import, checking at each step of the way that everything is as it should be. To test: 1. Install Test::WWW::Mechanize > sudo apt-get install libtest-www-mechanize-perl 2. Set environment variables to reflect your Koha instance: > export KOHA_USER=kohaadmin > export KOHA_PASS=katikoan > export KOHA_INTRANET_URL=http://localhost:8080 > export KOHA_OPAC_URL=http://localhost 3. Run the test: > prove t/db_dependent/www/batch.t This updated patch now handles both MARC21 and UNIMARC installations. Signed-off-by: Magnus Enger <magnus@enger.priv.no> All tests pass with marcflavour = MARC21 and NORMARC. Test #15 fails when marcflavour = UNIMARC, but from what I can see, that is because I'm testing on a MARC21 setup, missing the UNIMARC frameworks etc. I'm signing off - QA folks, please ask for a proper UNIMARC signoff if you feel it is needed. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> Amended patch: Load the POSIX module (for the floor routine).
Created attachment 17438 [details] [review] Bug 8300 - Add Test::WWW::Mechanize as an optional dependency This patch replaces an earlier patch by Marcel de Rooy, which had become outdated because lots of new dependencies were added since the patch was made. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
This does not work with Plack, of course, since importing records doesn't work under Plack, but I am pushing the patch anyway as it could be useful for people who use Apache.
This patch has been pushed to master and 3.12.x.