@@ -, +, @@ --------- -- nasty -- ugly -- unique skips --- t/db_dependent/Koha_Elasticsearch_Indexer.t | 31 ++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) --- a/t/db_dependent/Koha_Elasticsearch_Indexer.t +++ a/t/db_dependent/Koha_Elasticsearch_Indexer.t @@ -1,3 +1,5 @@ +#!/usr/bin/perl + # Copyright 2015 Catalyst IT # # This file is part of Koha. @@ -19,6 +21,8 @@ use Modern::Perl; use Test::More tests => 6; use Test::MockModule; +use Try::Tiny; +use English qw( -no_match_vars ); use t::lib::Mocks; use MARC::Record; @@ -49,11 +53,28 @@ ok( my $converted = $indexer->_convert_marc_to_json($records), is( $converted->count, 1, 'One converted record' ); SKIP: { - - eval { $indexer->get_elasticsearch_params; }; - - skip 'ElasticSeatch configuration not available', 1 - if $@; + my $check; + my $msg; + try { + my $ses = Search::Elasticsearch->new( + $indexer->get_elasticsearch_params ); + $check = eval { + my $node_check = $ses->nodes->info; + }; + $msg = $EVAL_ERROR; + } catch { + $msg = 'ElasticSearch configuration not available'; + }; + + if (! $check && ! $msg) { + $msg = 'Unable to check ElasticSearch node info'; + } elsif ( $msg =~ /NoNode/xsm ) { + $msg = 'ElasticSearch lacks nodes'; + } + + if ($msg) { + skip $msg, 1; + } ok( $indexer->update_index(undef,$records), 'Update Index' ); } --