Browse Source

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 <trace_to>Stderr</trace_to> in koha-conf
3 - Restart all
4 - perl misc/search_tools/rebuild_elasticsearch.pl
5 - Note requests are shown
6 - Set
    <trace_to>File</trace_to>
    <trace_to>/var/log/koha/kohadev/plack-error.log</trace_to>
    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 <bbennhoff@clicweb.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Nick Clemens 1 year ago
committed by Jonathan Druart
parent
commit
55f2279314
  1. 2
      Koha/SearchEngine/Elasticsearch.pm
  2. 2
      etc/koha-conf.xml
  3. 7
      t/db_dependent/Koha/SearchEngine/Elasticsearch.t

2
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;
}

2
etc/koha-conf.xml

@ -178,6 +178,8 @@ __PAZPAR2_TOGGLE_XML_POST__
<!-- See https://metacpan.org/pod/Search::Elasticsearch#cxn_pool -->
<cxn_pool>Static</cxn_pool>
<!-- See https://metacpan.org/pod/Search::Elasticsearch#trace_to -->
<!-- <trace_to>Stderr</trace_to> -->
</elasticsearch>
<!-- Uncomment the following line if you want to override the Elasticsearch default index settings -->
<!-- <elasticsearch_index_config>__KOHA_CONF_DIR__/searchengine/elasticsearch/index_config.yaml</elasticsearch_index_config> -->

7
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 {

Loading…
Cancel
Save