mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
Test also multiple measurement with UDP/IP
This commit is contained in:
@@ -58,7 +58,37 @@ class UdpAdapterTest extends \PHPUnit_Framework_TestCase
|
||||
],
|
||||
],
|
||||
"cpu,region=us-west,host=serverA,env=prod,target=servers,zone=1c cpu=18.12,free=712432 1257894000"
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
"tags" => [
|
||||
"region" => "us-west",
|
||||
"host" => "serverA",
|
||||
"env" => "prod",
|
||||
"target" => "servers",
|
||||
"zone" => "1c",
|
||||
],
|
||||
"time" => "2009-11-10T23:00:00Z",
|
||||
"points" => [
|
||||
[
|
||||
"measurement" => "cpu",
|
||||
"fields" => [
|
||||
"cpu" => 18.12,
|
||||
],
|
||||
],
|
||||
[
|
||||
"measurement" => "mem",
|
||||
"fields" => [
|
||||
"free" => 712432,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
<<<EOF
|
||||
cpu,region=us-west,host=serverA,env=prod,target=servers,zone=1c cpu=18.12 1257894000
|
||||
mem,region=us-west,host=serverA,env=prod,target=servers,zone=1c free=712432 1257894000
|
||||
EOF
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,6 +191,56 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertCount(4, $body["results"][0]["series"][0]["values"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group udp
|
||||
*/
|
||||
public function testSendMultipleMeasurementWithUdpIp()
|
||||
{
|
||||
$rawOptions = $this->rawOptions;
|
||||
$options = new Options();
|
||||
$options->setHost($rawOptions["udp"]["host"]);
|
||||
$options->setUsername($rawOptions["udp"]["username"]);
|
||||
$options->setPassword($rawOptions["udp"]["password"]);
|
||||
$options->setPort($rawOptions["udp"]["port"]);
|
||||
$options->setDatabase($rawOptions["udp"]["database"]);
|
||||
|
||||
$adapter = new UdpAdapter($options);
|
||||
$object = new Client();
|
||||
$object->setAdapter($adapter);
|
||||
|
||||
$object->mark([
|
||||
"points" => [
|
||||
[
|
||||
"measurement" => "mem",
|
||||
"fields" => [
|
||||
"free" => 712423,
|
||||
],
|
||||
],
|
||||
[
|
||||
"measurement" => "cpu",
|
||||
"fields" => [
|
||||
"cpu" => 18.12,
|
||||
],
|
||||
],
|
||||
]
|
||||
]);
|
||||
|
||||
sleep(2);
|
||||
|
||||
$this->options->setDatabase("udp.test");
|
||||
$body = $this->object->query("select * from \"cpu\"");
|
||||
|
||||
$this->assertCount(1, $body["results"][0]["series"][0]["values"]);
|
||||
$this->assertEquals("cpu", $body["results"][0]["series"][0]["columns"][1]);
|
||||
$this->assertEquals(18.12, $body["results"][0]["series"][0]["values"][0][1]);
|
||||
|
||||
$body = $this->object->query("select * from \"mem\"");
|
||||
|
||||
$this->assertCount(1, $body["results"][0]["series"][0]["values"]);
|
||||
$this->assertEquals("free", $body["results"][0]["series"][0]["columns"][1]);
|
||||
$this->assertEquals(712423, $body["results"][0]["series"][0]["values"][0][1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group udp
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user