Elasticsearch::TestServer - A helper class to launch Elasticsearch nodes
version 1.05
use Elasticsearch; use Elasticsearch::TestServer; my $server = Elasticsearch::TestServer->new( es_home => '/path/to/elasticsearch', ); my $nodes = $server->start; my $es = Elasticsearch->new( nodes => $nodes ); # run tests $server->shutdown;
The Elasticsearch::TestServer class can be used to launch one or more instances of Elasticsearch for testing purposes. The nodes will be shutdown automatically.
new()
my $server = Elasticsearch::TestServer->new( es_home => '/path/to/elasticsearch', instances => 1, http_port => 9600, es_port => 9700, );
Params:
es_home
Required. Must point to the Elasticsearch home directory, which contains ./bin/elasticsearch.
./bin/elasticsearch
instances
The number of nodes to start. Defaults to 1
http_port
The port to use for HTTP. If multiple instances are started, the http_port will be incremented for each subsequent instance. Defaults to 9600.
es_port
The port to use for Elasticsearch's internal transport. If multiple instances are started, the es_port will be incremented for each subsequent instance. Defaults to 9700
start()
$nodes = $server->start;
Starts the required instances and returns an array ref containing the IP and port of each node, suitable for passing to "new()" in Elasticsearch:
$es = Elasticsearch->new( nodes => $nodes );
shutdown()
$server->shutdown;
Kills the running instances. This will be called automatically when $server goes out of scope or if the program receives a SIGINT.
$server
SIGINT
Clinton Gormley <drtech@cpan.org>
This software is Copyright (c) 2014 by Elasticsearch BV.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
To install Elasticsearch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Elasticsearch
CPAN shell
perl -MCPAN -e shell install Elasticsearch
For more information on module installation, please visit the detailed CPAN module installation guide.