2016-02-06 02:44:16 +00:00
|
|
|
use strict;
|
2021-08-19 20:36:43 +00:00
|
|
|
use warnings;
|
2016-02-06 02:44:16 +00:00
|
|
|
use Setup;
|
2022-02-10 02:06:28 +00:00
|
|
|
use Hydra::Config;
|
2016-02-06 02:44:16 +00:00
|
|
|
|
|
|
|
my %ctx = test_init(hydra_config => q|
|
|
|
|
<statsd>
|
|
|
|
host = foo.bar
|
|
|
|
port = 18125
|
|
|
|
</statsd>
|
|
|
|
|);
|
|
|
|
|
|
|
|
require Hydra::Helper::Nix;
|
|
|
|
use Test2::V0;
|
|
|
|
|
2022-02-10 02:06:28 +00:00
|
|
|
is(Hydra::Helper::Nix::getStatsdConfig(getHydraConfig()), {
|
2016-02-06 02:44:16 +00:00
|
|
|
'host' => "foo.bar",
|
|
|
|
'port' => 18125
|
|
|
|
}, "Reading specific configuration from the hydra.conf works");
|
|
|
|
|
|
|
|
is(Hydra::Helper::Nix::getStatsdConfig(), {
|
|
|
|
'host' => "localhost",
|
|
|
|
'port' => 8125
|
|
|
|
}, "A totally empty configuration yields default options");
|
|
|
|
|
|
|
|
is(Hydra::Helper::Nix::getStatsdConfig({
|
|
|
|
"statsd" => {
|
|
|
|
|
|
|
|
}
|
|
|
|
}), {
|
|
|
|
'host' => "localhost",
|
|
|
|
'port' => 8125
|
|
|
|
}, "A empty statsd block yields default options");
|
|
|
|
|
|
|
|
is(Hydra::Helper::Nix::getStatsdConfig({
|
|
|
|
"statsd" => {
|
|
|
|
'host' => "statsdhost"
|
|
|
|
}
|
|
|
|
}), {
|
|
|
|
'host' => "statsdhost",
|
|
|
|
'port' => 8125
|
|
|
|
}, "An overridden statsd host propogates, but the other defaults are returned");
|
|
|
|
|
|
|
|
is(Hydra::Helper::Nix::getStatsdConfig({
|
|
|
|
"statsd" => {
|
|
|
|
'port' => 5218
|
|
|
|
}
|
|
|
|
}), {
|
|
|
|
'host' => "localhost",
|
|
|
|
'port' => 5218
|
|
|
|
}, "An overridden statsd port propogates, but the other defaults are returned");
|
|
|
|
|
|
|
|
is(Hydra::Helper::Nix::getStatsdConfig({
|
|
|
|
"statsd" => {
|
|
|
|
'host' => 'my.statsd.host',
|
|
|
|
'port' => 5218
|
|
|
|
}
|
|
|
|
}), {
|
|
|
|
'host' => "my.statsd.host",
|
|
|
|
'port' => 5218
|
|
|
|
}, "An overridden statsd port and host propogate");
|
|
|
|
|
|
|
|
done_testing;
|