Bugzilla – Attachment 90865 Details for
Bug 20576
t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t fails if Elasticsearch is configured but not running
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20576: Skip gracefully with a meaningful message
Bug-20576-Skip-gracefully-with-a-meaningful-messag.patch (text/plain), 4.02 KB, created by
Mark Tompsett
on 2019-06-20 18:45:15 UTC
(
hide
)
Description:
Bug 20576: Skip gracefully with a meaningful message
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2019-06-20 18:45:15 UTC
Size:
4.02 KB
patch
obsolete
>From fc95cd26b9035a6cb74d723b2d0c1d5588c770fe Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Thu, 20 Jun 2019 18:44:19 +0000 >Subject: [PATCH] Bug 20576: Skip gracefully with a meaningful message > >--- > .../Koha/SearchEngine/Elasticsearch/Search.t | 69 ++++++++++++++-------- > 1 file changed, 46 insertions(+), 23 deletions(-) > >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t >index 8d73f14058..94e5e5e649 100644 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t >@@ -1,3 +1,5 @@ >+#!/usr/bin/perl >+ > # Copyright 2015 Catalyst IT > # > # This file is part of Koha. >@@ -17,12 +19,39 @@ > > use Modern::Perl; > >-use Test::More tests => 11; >+use Test::More; > use t::lib::Mocks; >+use English qw( -no-match-vars ); > > use Koha::SearchEngine::Elasticsearch::QueryBuilder; >-use Koha::SearchEngine::Elasticsearch::Indexer; > >+BEGIN { >+ my $check; >+ my $msg; >+ if ( !defined C4::Context->config('elasticsearch') ) { >+ $msg = '**** ELASTICSEARCH CONFIGURATION NOT AVAILABLE ****'; >+ } >+ if ( !$msg ) { >+ my $ses = Search::Elasticsearch->new( >+ { 'nodes' => ['localhost:9200'], 'index' => 'mydb' } ); >+ $check = eval { my $node_check = $ses->nodes->info; }; >+ $msg = $EVAL_ERROR; >+ } >+ >+ if ( !$check && !$msg ) { >+ $msg = '**** UNABLE TO CHECK ELASTICSEARCH NODE INFO ****'; >+ } >+ elsif ( $msg =~ /NoNode/xsm ) { >+ $msg = '**** ELASTICsEARCH LACKS NODES ****'; >+ } >+ >+ if ($msg) { >+ plan skip_all => $msg; >+ } >+ >+} >+ >+use Koha::SearchEngine::Elasticsearch::Indexer; > > my $se = Test::MockModule->new( 'Koha::SearchEngine::Elasticsearch' ); > $se->mock( 'get_elasticsearch_mappings', sub { >@@ -84,31 +113,25 @@ is( $searcher->index, 'mydb', 'Testing basic accessor' ); > > ok( my $query = $builder->build_query('easy'), 'Build a search query'); > >-SKIP: { >- >- eval { $builder->get_elasticsearch_params; }; >- >- skip 'Elasticsearch configuration not available', 8 >- if $@; >+Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'mydb' })->drop_index; >+Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'mydb' })->create_index; > >- Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'mydb' })->drop_index; >- Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'mydb' })->create_index; >+ok( my $results = $searcher->search( $query) , 'Do a search ' ); > >- ok( my $results = $searcher->search( $query) , 'Do a search ' ); >+is (my $count = $searcher->count( $query ), 0 , 'Get a count of the results, without returning results '); > >- is (my $count = $searcher->count( $query ), 0 , 'Get a count of the results, without returning results '); >+ok ($results = $searcher->search_compat( $query ), 'Test search_compat' ); > >- ok ($results = $searcher->search_compat( $query ), 'Test search_compat' ); >+ok (($results,$count) = $searcher->search_auth_compat ( $query ), 'Test search_auth_compat' ); > >- ok (($results,$count) = $searcher->search_auth_compat ( $query ), 'Test search_auth_compat' ); >+is ( $count = $searcher->count_auth_use($searcher,1), 0, 'Testing count_auth_use'); > >- is ( $count = $searcher->count_auth_use($searcher,1), 0, 'Testing count_auth_use'); >+is ($searcher->max_result_window, 10000, 'By default, max_result_window is 10000'); >+$searcher->store->es->indices->put_settings(index => $searcher->store->index_name, body => { >+ 'index' => { >+ 'max_result_window' => 12000, >+ }, >+}); >+is ($searcher->max_result_window, 12000, 'max_result_window returns the correct value'); > >- is ($searcher->max_result_window, 10000, 'By default, max_result_window is 10000'); >- $searcher->store->es->indices->put_settings(index => $searcher->store->index_name, body => { >- 'index' => { >- 'max_result_window' => 12000, >- }, >- }); >- is ($searcher->max_result_window, 12000, 'max_result_window returns the correct value'); >-} >+done_testing(); >-- >2.11.0
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 20576
:
74120
| 90865