Search...tServer(3pm)
π Search::Elasticsearch::TestServer β the manual page, but make it cute π
Search::Elasticsearch::TestServer(3pm) β from the User Contributed Perl Documentation, bestie. This is the one that spins up whole Elasticsearch nodes for you like it's nothing. β¨
πΈ NAME πΈ
Search::Elasticsearch::TestServer</purl> β a lil helper class whose entire job is launching Elasticsearch nodes for you. That's it. That's the girlboss. π
β VERSION β
version 8.12
π¦ SYNOPSIS π¦
okay so here's the whole vibe in one go:
use Search::Elasticsearch;
use Search::Elasticsearch::TestServer;
my $server = Search::Elasticsearch::TestServer->new(
es_home => '/path/to/elasticsearch', # defaults to $ENV{ES_HOME}
es_version => '6_0' # defaults to $ENV{ES_VERSION}
);
my $nodes = $server->start;
my $es = Search::Elasticsearch->new( nodes => $nodes );
# run tests
$server->shutdown;
like. it starts the servers, you point your client at them, you run your tests, you shut it down. effortless. π₯
π DESCRIPTION π
The Search::Elasticsearch::TestServer class is here to launch one or more instances of Elasticsearch purely for testing purposes. Yes, multiple. Yes, whenever you want. And the nodes? They get shut down automatically, so you don't have to chase after them. no cap. π«Ά
π METHODS π
π new()
my $server = Search::Elasticsearch::TestServer->new(
es_home => '/path/to/elasticsearch',
es_version => '6_0',
instances => 1,
http_port => 9600,
es_port => 9700,
conf => ['attr.foo=bar'],
);
Params, bestie:
es_homeβ Required, no skipping. It has to point at the Elasticsearch home directory, the one that contains./bin/elasticsearch. Defaults to$ENV{ES_HOME}.es_versionβ also Required. Takes a version of the client, eg6_0,5_0,2_0,1_0,0_90. Defaults to$ENV{ES_VERSION}.instancesβ how many nodes to start. Defaults to1.http_portβ the port used for HTTP. If you start multiple instances, thehttp_portgets incremented for each subsequent instance. Defaults to9600.es_portβ the port used for Elasticsearch's internal transport. Same deal: multiple instances means thees_portgets incremented for each subsequent instance. Defaults to9700.confβ an array holding any extra startup options you want passed straight to Elasticsearch.
β¨ start()
$nodes = $server->start;
Starts up all the instances you asked for and hands you back an array ref with the IP and port of each node β formatted exactly so you can pass it straight to new() in Search::Elasticsearch:
$es = Search::Elasticsearch->new( nodes => $nodes );
it's giving plug-and-play honestly. π
π§ shutdown()
$server->shutdown;
Kills the running instances. periodt. π
And the best part? This gets called automatically when $server goes out of scope, or if the program catches a SIGINT. so you literally cannot forget. iconic behaviour fr fr.
π AUTHOR π
Enrico Zimuel <enrico.zimuel@elastic.co>
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2024 by Elasticsearch BV.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
and that's the whole page, bestie π₯° this was Search...tServer(3pm) β shipped as part of perl v5.38.2, dated 2024-02-04. go forth and spin up nodes. slay. π
β¨
π¦ where this page comes from
- debian trixie: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- ubuntu noble: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- ubuntu resolute: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- ubuntu stonking: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms