mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 00:24:21 +02:00
Add 'lib/influxdb-php-sdk/' from commit '1928d59eb90bfcba40a957074987c5311afd4e3b'
git-subtree-dir: lib/influxdb-php-sdk git-subtree-mainline:15a338061dgit-subtree-split:1928d59eb9
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
namespace InfluxDB\Integration\Adapter;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use InfluxDB\Options;
|
||||
use InfluxDB\Client;
|
||||
use InfluxDB\Adapter\GuzzleAdapter;
|
||||
use GuzzleHttp\Client as GuzzleHttpClient;
|
||||
use InfluxDB\Integration\Framework\TestCase as InfluxDBTestCase;
|
||||
|
||||
class GuzzleAdapterTest extends InfluxDBTestCase
|
||||
{
|
||||
public function testAdapterWriteDataCorrectly()
|
||||
{
|
||||
$this->getClient()->createDatabase("tcp.test");
|
||||
|
||||
$options = new Options();
|
||||
$options->setPort(8086);
|
||||
$options->setDatabase("tcp.test");
|
||||
|
||||
$http = new GuzzleHttpClient();
|
||||
$adapter = new GuzzleAdapter($http, $options);
|
||||
|
||||
$adapter->send([
|
||||
"points" => [
|
||||
[
|
||||
"measurement" => "vm-serie",
|
||||
"fields" => [
|
||||
"cpu" => 18.12,
|
||||
"free" => 712423,
|
||||
],
|
||||
],
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertSerieExists("tcp.test", "vm-serie");
|
||||
$this->assertSerieCount("tcp.test", "vm-serie", 1);
|
||||
$this->assertValueExistsInSerie("tcp.test", "vm-serie", "cpu", 18.12);
|
||||
$this->assertValueExistsInSerie("tcp.test", "vm-serie", "free", 712423);
|
||||
}
|
||||
|
||||
public function testWorksWithProxies()
|
||||
{
|
||||
$this->getClient()->createDatabase("proxy.test");
|
||||
|
||||
$options = new Options();
|
||||
$options->setPort(9000);
|
||||
$options->setDatabase("proxy.test");
|
||||
$options->setPrefix("/influxdb");
|
||||
|
||||
$http = new GuzzleHttpClient();
|
||||
$adapter = new GuzzleAdapter($http, $options);
|
||||
|
||||
$adapter->send([
|
||||
"points" => [
|
||||
[
|
||||
"measurement" => "vm-serie",
|
||||
"fields" => [
|
||||
"cpu" => 18.12,
|
||||
"free" => 712423,
|
||||
],
|
||||
],
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertSerieExists("proxy.test", "vm-serie");
|
||||
$this->assertSerieCount("proxy.test", "vm-serie", 1);
|
||||
$this->assertValueExistsInSerie("proxy.test", "vm-serie", "cpu", 18.12);
|
||||
$this->assertValueExistsInSerie("proxy.test", "vm-serie", "free", 712423);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user