From a86c08c6a2a3ee916eb9b7afc73fd33e01273d68 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 27 Aug 2020 15:24:58 +0000 Subject: [PATCH] Bug 26310: Allow setting trace_to parameter in Elaasticsearch config For debugging purposes we may wish to see the requests and responses made to Elasticsearch To test: 1 - prove -v t/Koha/SearchEngine/Elasticsearch.t 2 - Set Stderr in koha-conf 3 - Restart all 4 - perl misc/search_tools/rebuild_elasticsearch.pl 5 - Note requests are shown 6 - Set File /var/log/koha/kohadev/plack-error.log in koha-conf 7 - Restart all 8 - perl misc/search_tools/rebuild_elasticsearch.pl 9 - Check the plack log and see the ES requests Signed-off-by: Bob Bennhoff --- Koha/SearchEngine/Elasticsearch.pm | 2 ++ etc/koha-conf.xml | 2 ++ t/db_dependent/Koha/SearchEngine/Elasticsearch.t | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm index e7a8964ba1..182551f4af 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -1282,6 +1282,8 @@ sub _read_configuration { $configuration->{cxn_pool} = $conf->{cxn_pool} // 'Static'; + $configuration->{trace_to} = $conf->{trace_to} if defined $conf->{trace_to}; + return $configuration; } diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml index eff50d2bcd..bb28962a3a 100644 --- a/etc/koha-conf.xml +++ b/etc/koha-conf.xml @@ -178,6 +178,8 @@ __PAZPAR2_TOGGLE_XML_POST__ Static + + diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t index 79c198c3f2..c4fe589aa3 100755 --- a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t +++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t @@ -37,7 +37,7 @@ $schema->storage->txn_begin; subtest '_read_configuration() tests' => sub { - plan tests => 13; + plan tests => 15; my $configuration; t::lib::Mocks::mock_config( 'elasticsearch', undef ); @@ -100,10 +100,15 @@ subtest '_read_configuration() tests' => sub { $configuration = Koha::SearchEngine::Elasticsearch::_read_configuration; is( $configuration->{cxn_pool}, 'Fluid', 'cxn_pool configuration parsed correctly' ); + isnt( defined $configuration->{trace_to}, 'trace_to is not defined if not set' ); my $params = Koha::SearchEngine::Elasticsearch::get_elasticsearch_params; is_deeply( $configuration->{nodes}, \@servers , 'get_elasticsearch_params is just a wrapper for _read_configuration' ); + t::lib::Mocks::mock_config( 'elasticsearch', { server => \@servers, index_name => 'index', cxn_pool => 'Fluid', trace_to => 'Stderr' } ); + + $configuration = Koha::SearchEngine::Elasticsearch::_read_configuration; + is( $configuration->{trace_to}, 'Stderr', 'trace_to configuration parsed correctly' ); }; subtest 'get_elasticsearch_settings() tests' => sub { -- 2.11.0