mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge branch 'release/0.3.1'
This commit is contained in:
@@ -19,7 +19,7 @@ class ColumnsPointsFilterSpec extends ObjectBehavior
|
||||
|
||||
function it_should_map_columns_with_points()
|
||||
{
|
||||
$response = json_decode('[{"name":"hd_used","columns":["time","sequence_number","value","host","mount","time_precision"],"points":[[1410591684,11820001,23.2,"serverA","/mnt","s"]]}]');
|
||||
$response = json_decode('[{"name":"hd_used","columns":["time","sequence_number","value","host","mount","time_precision"],"points":[[1410591684,11820001,23.2,"serverA","/mnt","s"]]}]', true);
|
||||
|
||||
$this->filter($response)->shouldBeEqualTo([
|
||||
"hd_used" => [
|
||||
@@ -37,7 +37,7 @@ class ColumnsPointsFilterSpec extends ObjectBehavior
|
||||
|
||||
function it_should_map_also_a_series_list()
|
||||
{
|
||||
$response = json_decode('[{"name":"list_series_result","columns":["time","name"],"points":[[0,"hd_used"]]}]');
|
||||
$response = json_decode('[{"name":"list_series_result","columns":["time","name"],"points":[[0,"hd_used"]]}]', true);
|
||||
|
||||
$this->filter($response)->shouldBeEqualTo([
|
||||
"list_series_result" => [
|
||||
@@ -51,7 +51,7 @@ class ColumnsPointsFilterSpec extends ObjectBehavior
|
||||
|
||||
function it_should_reply_to_an_empty_set()
|
||||
{
|
||||
$response = json_decode('[]');
|
||||
$response = json_decode('[]', true);
|
||||
|
||||
$this->filter($response)->shouldBeEqualTo([]);
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ class ColumnsPointsFilter implements FilterInterface
|
||||
$response = [];
|
||||
|
||||
foreach ($metrics as $metric) {
|
||||
$columns = $metric->columns;
|
||||
$response[$metric->name] = [];
|
||||
$columns = $metric["columns"];
|
||||
$response[$metric["name"]] = [];
|
||||
|
||||
foreach ($metric->points as $point) {
|
||||
$response[$metric->name][] = array_combine($columns, $point);
|
||||
foreach ($metric["points"] as $point) {
|
||||
$response[$metric["name"]][] = array_combine($columns, $point);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ use InfluxDB\Adapter\GuzzleAdapter as InfluxHttpAdapter;
|
||||
use InfluxDB\Options;
|
||||
use InfluxDB\Adapter\UdpAdapter;
|
||||
use GuzzleHttp\Client as GuzzleHttpClient;
|
||||
use InfluxDB\Filter\ColumnsPointsFilter;
|
||||
|
||||
class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -146,6 +147,21 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals("udp.test", $body[0]["name"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group filter
|
||||
*/
|
||||
public function testColumnsPointsFilterWorksCorrectly()
|
||||
{
|
||||
$this->object->setFilter(new ColumnsPointsFilter());
|
||||
$this->object->mark("tcp.test", ["time" => 1410591552, "mark" => "element"], "s");
|
||||
|
||||
$body = $this->object->query("select mark from tcp.test", "ms");
|
||||
|
||||
$this->assertCount(1, $body);
|
||||
$this->assertEquals("element", $body["tcp.test"][0]["mark"]);
|
||||
$this->assertSame(1410591552000, $body["tcp.test"][0]["time"]);
|
||||
}
|
||||
|
||||
public function testListActiveDatabses()
|
||||
{
|
||||
$databases = $this->object->getDatabases();
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace InfluxDB;
|
||||
|
||||
use InfluxDB\Adapter\HttpAdapter;
|
||||
use InfluxDB\Adapter\UdpAdapter;
|
||||
use InfluxDB\Filter\ColumnsPointsFilter;
|
||||
|
||||
class HttpAdapterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -109,6 +110,21 @@ class HttpAdapterTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals("1410591552000", $body[0]["points"][0][0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group filter
|
||||
*/
|
||||
public function testColumnsPointsFilterWorksCorrectly()
|
||||
{
|
||||
$this->object->setFilter(new ColumnsPointsFilter());
|
||||
$this->object->mark("tcp.test", ["time" => 1410591552, "mark" => "element"], "s");
|
||||
|
||||
$body = $this->object->query("select mark from tcp.test", "ms");
|
||||
|
||||
$this->assertCount(1, $body);
|
||||
$this->assertEquals("element", $body["tcp.test"][0]["mark"]);
|
||||
$this->assertSame(1410591552000, $body["tcp.test"][0]["time"]);
|
||||
}
|
||||
|
||||
public function testListActiveDatabses()
|
||||
{
|
||||
$databases = $this->object->getDatabases();
|
||||
|
||||
Reference in New Issue
Block a user