From 574becb11a867db7375159be266e9716704c29f8 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 16 Aug 2012 14:38:32 -0400 Subject: [PATCH] bug 8649: create a temp directory for Zebra for C4::Search tests The Zebra test uses Unix-domain sockets, which won't work if Koha is being installed or tested from an NFS- or SSHFS-mounted clone. Therefore, create (and clenaup) a temporary directory on (hopefully) a normal filesytem to run the test. Signed-off-by: Galen Charlton Signed-off-by: wajasu Signed-off-by: Kyle M Hall --- t/db_dependent/Search.t | 14 +++++++------- .../data/var/lib/zebradb/authorities/key/README | 1 - .../var/lib/zebradb/authorities/register/README | 1 - .../data/var/lib/zebradb/authorities/shadow/README | 1 - .../data/var/lib/zebradb/authorities/tmp/README | 1 - .../data/var/lib/zebradb/biblios/key/README | 1 - .../data/var/lib/zebradb/biblios/register/README | 1 - .../data/var/lib/zebradb/biblios/shadow/README | 1 - .../data/var/lib/zebradb/biblios/tmp/README | 1 - .../data/var/lock/zebradb/authorities/README | 1 - .../data/var/lock/zebradb/biblios/README | 1 - t/db_dependent/data/var/log/README | 1 - t/db_dependent/data/var/run/zebradb/README | 1 - t/db_dependent/zebra_config.pl | 14 +++++++++++++- 14 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 t/db_dependent/data/var/lib/zebradb/authorities/key/README delete mode 100644 t/db_dependent/data/var/lib/zebradb/authorities/register/README delete mode 100644 t/db_dependent/data/var/lib/zebradb/authorities/shadow/README delete mode 100644 t/db_dependent/data/var/lib/zebradb/authorities/tmp/README delete mode 100644 t/db_dependent/data/var/lib/zebradb/biblios/key/README delete mode 100644 t/db_dependent/data/var/lib/zebradb/biblios/register/README delete mode 100644 t/db_dependent/data/var/lib/zebradb/biblios/shadow/README delete mode 100644 t/db_dependent/data/var/lib/zebradb/biblios/tmp/README delete mode 100644 t/db_dependent/data/var/lock/zebradb/authorities/README delete mode 100644 t/db_dependent/data/var/lock/zebradb/biblios/README delete mode 100644 t/db_dependent/data/var/log/README delete mode 100644 t/db_dependent/data/var/run/zebradb/README diff --git a/t/db_dependent/Search.t b/t/db_dependent/Search.t index e949050f6e..3e7abad2cb 100644 --- a/t/db_dependent/Search.t +++ b/t/db_dependent/Search.t @@ -19,9 +19,12 @@ use File::Spec; use File::Basename; use File::Find; use Test::Warn; +use File::Temp qw/ tempdir /; +use File::Path; -system(dirname(__FILE__) . "/zebra_config.pl"); -my $datadir = dirname(__FILE__) . "/data"; +my $datadir = tempdir(); +system(dirname(__FILE__) . "/zebra_config.pl $datadir"); +my $sourcedir = dirname(__FILE__) . "/data"; my $QueryStemming = 0; my $QueryAutoTruncate = 0; @@ -197,7 +200,7 @@ my %itemtypes = ( unlink("$datadir/zebra.log"); system("zebraidx -c $datadir/etc/koha/zebradb/zebra-biblios.cfg -v none,fatal,warn -g iso2709 -d biblios init"); -system("zebraidx -c $datadir/etc/koha/zebradb/zebra-biblios.cfg -v none,fatal,warn -g iso2709 -d biblios update $datadir/zebraexport/biblio"); +system("zebraidx -c $datadir/etc/koha/zebradb/zebra-biblios.cfg -v none,fatal,warn -g iso2709 -d biblios update $sourcedir/zebraexport/biblio"); system("zebraidx -c $datadir/etc/koha/zebradb/zebra-biblios.cfg -v none,fatal,warn -g iso2709 -d biblios commit"); my $child = fork(); @@ -507,10 +510,7 @@ END { kill 9, $child; # Clean up the Zebra files since the child process was just shot - - find(sub { unlink($_) if ( -f $_ && m/\.(mf|pid|LCK)$/ ); }, "$datadir"); - unlink("$datadir/var/run/zebradb/authoritysocket"); - unlink("$datadir/var/run/zebradb/bibliosocket"); + rmtree $datadir; } } diff --git a/t/db_dependent/data/var/lib/zebradb/authorities/key/README b/t/db_dependent/data/var/lib/zebradb/authorities/key/README deleted file mode 100644 index 519851e604..0000000000 --- a/t/db_dependent/data/var/lib/zebradb/authorities/key/README +++ /dev/null @@ -1 +0,0 @@ -Zebra authorities key dir diff --git a/t/db_dependent/data/var/lib/zebradb/authorities/register/README b/t/db_dependent/data/var/lib/zebradb/authorities/register/README deleted file mode 100644 index b93dac8eed..0000000000 --- a/t/db_dependent/data/var/lib/zebradb/authorities/register/README +++ /dev/null @@ -1 +0,0 @@ -Zebra authorities register dir diff --git a/t/db_dependent/data/var/lib/zebradb/authorities/shadow/README b/t/db_dependent/data/var/lib/zebradb/authorities/shadow/README deleted file mode 100644 index 5286b79b5c..0000000000 --- a/t/db_dependent/data/var/lib/zebradb/authorities/shadow/README +++ /dev/null @@ -1 +0,0 @@ -Zebra authorities shadow dir diff --git a/t/db_dependent/data/var/lib/zebradb/authorities/tmp/README b/t/db_dependent/data/var/lib/zebradb/authorities/tmp/README deleted file mode 100644 index a0b0e2d1a9..0000000000 --- a/t/db_dependent/data/var/lib/zebradb/authorities/tmp/README +++ /dev/null @@ -1 +0,0 @@ -Zebra authorities tmp dir diff --git a/t/db_dependent/data/var/lib/zebradb/biblios/key/README b/t/db_dependent/data/var/lib/zebradb/biblios/key/README deleted file mode 100644 index 2829ae0f24..0000000000 --- a/t/db_dependent/data/var/lib/zebradb/biblios/key/README +++ /dev/null @@ -1 +0,0 @@ -Zebra biblios key dir diff --git a/t/db_dependent/data/var/lib/zebradb/biblios/register/README b/t/db_dependent/data/var/lib/zebradb/biblios/register/README deleted file mode 100644 index 678109abd7..0000000000 --- a/t/db_dependent/data/var/lib/zebradb/biblios/register/README +++ /dev/null @@ -1 +0,0 @@ -Zebra biblios register dir diff --git a/t/db_dependent/data/var/lib/zebradb/biblios/shadow/README b/t/db_dependent/data/var/lib/zebradb/biblios/shadow/README deleted file mode 100644 index 6898112412..0000000000 --- a/t/db_dependent/data/var/lib/zebradb/biblios/shadow/README +++ /dev/null @@ -1 +0,0 @@ -Zebra biblios shadow dir diff --git a/t/db_dependent/data/var/lib/zebradb/biblios/tmp/README b/t/db_dependent/data/var/lib/zebradb/biblios/tmp/README deleted file mode 100644 index eb282b1264..0000000000 --- a/t/db_dependent/data/var/lib/zebradb/biblios/tmp/README +++ /dev/null @@ -1 +0,0 @@ -Zebra biblios tmp dir diff --git a/t/db_dependent/data/var/lock/zebradb/authorities/README b/t/db_dependent/data/var/lock/zebradb/authorities/README deleted file mode 100644 index ef9cad1e43..0000000000 --- a/t/db_dependent/data/var/lock/zebradb/authorities/README +++ /dev/null @@ -1 +0,0 @@ -Zebra authorities lock dir diff --git a/t/db_dependent/data/var/lock/zebradb/biblios/README b/t/db_dependent/data/var/lock/zebradb/biblios/README deleted file mode 100644 index 22ac627241..0000000000 --- a/t/db_dependent/data/var/lock/zebradb/biblios/README +++ /dev/null @@ -1 +0,0 @@ -Zebra biblios lock dir diff --git a/t/db_dependent/data/var/log/README b/t/db_dependent/data/var/log/README deleted file mode 100644 index bc4d73ef75..0000000000 --- a/t/db_dependent/data/var/log/README +++ /dev/null @@ -1 +0,0 @@ -Koha Apache logs diff --git a/t/db_dependent/data/var/run/zebradb/README b/t/db_dependent/data/var/run/zebradb/README deleted file mode 100644 index 1582989fea..0000000000 --- a/t/db_dependent/data/var/run/zebradb/README +++ /dev/null @@ -1 +0,0 @@ -Zebra Unix-domain sockets diff --git a/t/db_dependent/zebra_config.pl b/t/db_dependent/zebra_config.pl index d98230f1fb..581a70265e 100755 --- a/t/db_dependent/zebra_config.pl +++ b/t/db_dependent/zebra_config.pl @@ -8,10 +8,22 @@ use File::Basename; use File::Spec; my $source = File::Spec->rel2abs('.'); -my $destination = File::Spec->rel2abs('.') . "/t/db_dependent/data"; +my $destination = $ARGV[0]; make_path("$destination/var/lock/zebradb"); +make_path("$destination/var/lock/zebradb/biblios"); +make_path("$destination/var/lock/zebradb/authorities"); make_path("$destination/var/lib/zebradb"); +make_path("$destination/var/lib/zebradb/biblios"); +make_path("$destination/var/lib/zebradb/biblios/key"); +make_path("$destination/var/lib/zebradb/biblios/register"); +make_path("$destination/var/lib/zebradb/biblios/shadow"); +make_path("$destination/var/lib/zebradb/biblios/tmp"); +make_path("$destination/var/lib/zebradb/authorities"); +make_path("$destination/var/lib/zebradb/authorities/key"); +make_path("$destination/var/lib/zebradb/authorities/register"); +make_path("$destination/var/lib/zebradb/authorities/shadow"); +make_path("$destination/var/lib/zebradb/authorities/tmp"); make_path("$destination/var/run/zebradb"); $ENV{'INSTALL_BASE'} = $destination; -- 2.39.5