View | Details | Raw Unified | Return to bug 29856
Collapse All | Expand All

(-)a/Koha/SearchEngine/Elasticsearch.pm (-16 / +15 lines)
Lines 1308-1340 sub _read_configuration { Link Here
1308
        );
1308
        );
1309
    }
1309
    }
1310
1310
1311
    if ( $conf && $conf->{server} ) {
1311
    unless ( exists $conf->{server} ) {
1312
        my $nodes = $conf->{server};
1313
        if ( ref($nodes) eq 'ARRAY' ) {
1314
            $configuration->{nodes} = $nodes;
1315
        }
1316
        else {
1317
            $configuration->{nodes} = [$nodes];
1318
        }
1319
    }
1320
    else {
1321
        Koha::Exceptions::Config::MissingEntry->throw(
1312
        Koha::Exceptions::Config::MissingEntry->throw(
1322
            "Missing <elasticsearch>/<server> entry in koha-conf.xml"
1313
            "Missing <elasticsearch>/<server> entry in koha-conf.xml"
1323
        );
1314
        );
1324
    }
1315
    }
1325
1316
1326
    if ( defined $conf->{index_name} ) {
1317
    unless ( exists $conf->{index_name} ) {
1327
        $configuration->{index_name} = $conf->{index_name};
1328
    }
1329
    else {
1330
        Koha::Exceptions::Config::MissingEntry->throw(
1318
        Koha::Exceptions::Config::MissingEntry->throw(
1331
            "Missing <elasticsearch>/<index_name> entry in koha-conf.xml",
1319
            "Missing <elasticsearch>/<index_name> entry in koha-conf.xml",
1332
        );
1320
        );
1333
    }
1321
    }
1334
1322
1335
    $configuration->{cxn_pool} = $conf->{cxn_pool} // 'Static';
1323
    while ( my ( $var, $val ) = each %$conf ) {
1324
        if ( $var eq 'server' ) {
1325
            if ( ref($val) eq 'ARRAY' ) {
1326
                $configuration->{nodes} = $val;
1327
            }
1328
            else {
1329
                $configuration->{nodes} = [$val];
1330
            }
1331
        } else {
1332
            $configuration->{$var} = $val;
1333
        }
1334
    }
1336
1335
1337
    $configuration->{trace_to} = $conf->{trace_to} if defined $conf->{trace_to};
1336
    $configuration->{cxn_pool} //= 'Static';
1338
1337
1339
    return $configuration;
1338
    return $configuration;
1340
}
1339
}
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t (-3 / +3 lines)
Lines 39-45 $schema->storage->txn_begin; Link Here
39
39
40
subtest '_read_configuration() tests' => sub {
40
subtest '_read_configuration() tests' => sub {
41
41
42
    plan tests => 15;
42
    plan tests => 16;
43
43
44
    my $configuration;
44
    my $configuration;
45
    t::lib::Mocks::mock_config( 'elasticsearch', undef );
45
    t::lib::Mocks::mock_config( 'elasticsearch', undef );
Lines 107-116 subtest '_read_configuration() tests' => sub { Link Here
107
    my $params = Koha::SearchEngine::Elasticsearch::get_elasticsearch_params;
107
    my $params = Koha::SearchEngine::Elasticsearch::get_elasticsearch_params;
108
    is_deeply( $configuration->{nodes}, \@servers , 'get_elasticsearch_params is just a wrapper for _read_configuration' );
108
    is_deeply( $configuration->{nodes}, \@servers , 'get_elasticsearch_params is just a wrapper for _read_configuration' );
109
109
110
    t::lib::Mocks::mock_config( 'elasticsearch', { server => \@servers, index_name => 'index', cxn_pool => 'Sniff', trace_to => 'Stderr' } );
110
    t::lib::Mocks::mock_config( 'elasticsearch', { server => \@servers, index_name => 'index', cxn_pool => 'Sniff', trace_to => 'Stderr', request_timeout => 42 } );
111
111
112
    $configuration = Koha::SearchEngine::Elasticsearch::_read_configuration;
112
    $configuration = Koha::SearchEngine::Elasticsearch::_read_configuration;
113
    is( $configuration->{trace_to}, 'Stderr', 'trace_to configuration parsed correctly' );
113
    is( $configuration->{trace_to}, 'Stderr', 'trace_to configuration parsed correctly' );
114
    is( $configuration->{request_timeout}, '42', 'additional configuration (request_timeout) parsed correctly' );
114
};
115
};
115
116
116
subtest 'get_elasticsearch_settings() tests' => sub {
117
subtest 'get_elasticsearch_settings() tests' => sub {
117
- 

Return to bug 29856