Bugzilla – Attachment 33760 Details for
Bug 13264
Full stack encoding tests (UTF-8)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13264: Make opac_utf8.t launch its own helper processes
Bug-13264-Make-opacutf8t-launch-its-own-helper-pro.patch (text/plain), 5.62 KB, created by
Tomás Cohen Arazi (tcohen)
on 2014-11-20 18:21:02 UTC
(
hide
)
Description:
Bug 13264: Make opac_utf8.t launch its own helper processes
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2014-11-20 18:21:02 UTC
Size:
5.62 KB
patch
obsolete
>From 0a635786a9c47cda7514ea54193e39dfea00ae3a Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@gmail.com> >Date: Thu, 20 Nov 2014 12:05:44 -0300 >Subject: [PATCH] Bug 13264: Make opac_utf8.t launch its own helper processes > >This patch makes opac_utf8.t launch its own: >- zebrasrv process >- rebuild_zebra.pl (daemon mode) > >It also takes care of killing them when finished. It sets a frecquency >of 5 seconds for the indexer, and waits 10 just in case before looking >for the indexed records. > >To test: >- Just launch the tests. > >Edit: fixes on the license text. > >Regards >Tomas >--- > t/db_dependent/www/opac_utf8.t | 105 +++++++++++++++++++++++++++++------------ > 1 file changed, 76 insertions(+), 29 deletions(-) > >diff --git a/t/db_dependent/www/opac_utf8.t b/t/db_dependent/www/opac_utf8.t >index 15c2c8e..aad38de 100644 >--- a/t/db_dependent/www/opac_utf8.t >+++ b/t/db_dependent/www/opac_utf8.t >@@ -1,22 +1,22 @@ > #!/usr/bin/perl > >-# Copyright 2012 C & P Bibliography Services >+# This file is part of Koha. > # >-# This is free software; you can redistribute it and/or modify it under the >-# terms of the GNU General Public License as published by the Free Software >-# Foundation; either version 2 of the License, or (at your option) any later >-# version. >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. > # >-# This is distributed in the hope that it will be useful, but WITHOUT ANY >-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >-# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License along with >-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, >-# Suite 330, Boston, MA 02111-1307 USA >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. > # >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >+ > use utf8; > use Test::More; > use Test::WWW::Mechanize; >@@ -24,16 +24,23 @@ use Data::Dumper; > use XML::Simple; > use JSON; > use File::Basename; >+use File::Path; > use File::Spec; >+use File::Temp qw/ tempdir /; > use POSIX; > use Encode; > >+use C4::Context; >+ > my $testdir = File::Spec->rel2abs( dirname(__FILE__) ); >+# global variables that will be used when forking >+our $zebra_pid; >+our $indexer_pid; >+our $datadir = tempdir();; > > my $koha_conf = $ENV{KOHA_CONF}; > my $xml = XMLin($koha_conf); > >-use C4::Context; > my $marcflavour = C4::Context->preference('marcflavour') || 'MARC21'; > > # For the purpose of this test, we can reasonably take MARC21 and NORMARC to be the same >@@ -47,22 +54,23 @@ my $password = $ENV{KOHA_PASS} || $xml->{config}->{pass}; > my $intranet = $ENV{KOHA_INTRANET_URL}; > my $opac = $ENV{KOHA_OPAC_URL}; > >-my $zebra_on = ProgProcesses('zebrasrv'); >-my $indexer_on = ProgProcesses('koha-index'); >- >-if ($zebra_on < 2) { >- plan skip_all => "Tests skip. You must start Zebra Server to do those tests\n"; >+# launch the zebra process >+launch_zebra( $datadir, $koha_conf ); >+if ( not defined $zebra_pid ) { >+ plan skip_all => "Tests skip. Error starting Zebra Server to do those tests\n"; > } >- >-if ($indexer_on < 2) { >- plan skip_all => "Tests skip. You must start Zebra Background indexer to do those tests\n"; >+# launch the zebra process >+launch_indexer( ); >+if ( not defined $indexer_pid ) { >+ plan skip_all => "Tests skip. Error starting the indexer daemon to do those tests\n"; > } >- >-if (not defined $intranet) { >+# test KOHA_INTRANET_URL is set >+if ( not defined $intranet ) { > plan skip_all => "Tests skip. You must set env. variable KOHA_INTRANET_URL to do tests\n"; > } >-if (not defined $opac) { >- plan skip_all => "Tests skip. You must set env. variable KOHA_INTRANET_URL to do tests\n"; >+# test KOHA_OPAC_URL is set >+if ( not defined $opac ) { >+ plan skip_all => "Tests skip. You must set env. variable KOHA_OPAC_URL to do tests\n"; > } > > $intranet =~ s#/$##; >@@ -182,8 +190,8 @@ my $webpage = $agent->{content}; > $webpage =~ /(.*<title>.*?)(\d{1,})(.*<\/title>)/sx; > my $id_batch = $2; > >-#Wait the indexer >-sleep 35; >+# wait enough time for the indexer >+sleep 10; > > # -------------------------------------------------- TEST ON OPAC > >@@ -211,8 +219,47 @@ $agent->get_ok( "$intranet/cgi-bin/koha/tools/manage-marc-import.pl", 'view and > $agent->form_name('clean_batch_'.$id_batch); > $agent->click(); > >+# clean >+cleanup(); >+ > done_testing(); > >-sub ProgProcesses { >- return scalar grep /$_[0]/, (split /\n/, `ps -aef`); >+# function that launches the zebra daemon >+sub launch_zebra { >+ >+ my ( $datadir, $koha_conf ) = @_; >+ >+ $zebra_pid = fork(); >+ if ( $zebra_pid == 0 ) { >+ exec("zebrasrv -f $koha_conf -v none,request -l $datadir/zebra.log"); >+ exit; >+ } >+ sleep( 1 ); >+} >+ >+sub launch_indexer { >+ >+ my $rootdir = dirname(__FILE__) . '/../../../'; >+ my $rebuild_zebra = "$rootdir/misc/migration_tools/rebuild_zebra.pl"; >+ >+ $indexer_pid = fork(); >+ >+ if ( $indexer_pid == 0 ) { >+ exec("$rebuild_zebra -daemon -sleep 5"); >+ exit; >+ } >+ sleep( 1 ); > } >+ >+sub cleanup { >+ >+ kill 9, $zebra_pid if defined $zebra_pid; >+ kill 9, $indexer_pid if defined $indexer_pid; >+ # Clean up the Zebra files since the child process was just shot >+ rmtree $datadir; >+ >+} >+ >+ >+ >+1; >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13264
:
33614
|
33703
|
33704
|
33705
|
33743
|
33744
|
33756
|
33757
|
33758
|
33759
|
33760
|
33777
|
33778
|
33779
|
33780
|
33781
|
33782
|
33783
|
33784
|
33785
|
33786
|
33811
|
33812
|
33813
|
33814
|
33815
|
33816
|
33817
|
34110
|
34111
|
34112
|
34113
|
34114
|
34115
|
34116
|
34117
|
34694
|
34766
|
34767
|
34768
|
34769
|
34770
|
34771
|
34772
|
34773
|
34774
|
34775
|
34776
|
34798
|
34799
|
34800
|
34801
|
34802
|
34803
|
34804
|
34805
|
34806
|
34807
|
34808
|
34809
|
34810
|
34811
|
34814
|
35068
|
35069
|
35070
|
35071
|
35072
|
35073
|
35074
|
35075
|
35076
|
35077
|
35078
|
35079
|
35080
|
35081
|
35082
|
35110
|
35111
|
35112
|
35113
|
35114
|
35115
|
35116
|
35117
|
35118
|
35119
|
35120
|
35121
|
35122
|
35123
|
35124