Exemplo n.º 1
0
 /**
  * Test that we handle socket problems correctly in the UDP
  * adapter, and that they don't inturrupt the user's application.
  *
  * @group udp
  */
 public function testReplicateIssue27()
 {
     $options = new \InfluxDB\Options();
     // Configure options
     $options->setHost('172.16.1.182');
     $options->setPort(4444);
     $options->setDatabase('...');
     $options->setUsername('root');
     $options->setPassword('root');
     $httpAdapter = new \InfluxDB\Adapter\UdpAdapter($options);
     $client = new \InfluxDB\Client($httpAdapter);
     $client->mark("udp.test", ["mark" => "element"]);
 }
 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);
 }
Exemplo n.º 3
0
 public function setUp()
 {
     $options = new Options();
     $options->setHost("localhost");
     $options->setPort(8086);
     $options->setUsername("root");
     $options->setPassword("root");
     $options->setDatabase("tcp.test");
     $client = new Client(new GuzzleAdapter(new HttpClient(), $options));
     $client->createDatabase("tcp.test");
     $client->createDatabase("udp.test");
     $this->httpClient = $client;
     $opts = new Options();
     $opts->setPort(4444);
     $client = new Client(new UdpAdapter($opts));
     $this->udpClient = $client;
 }
Exemplo n.º 4
0
 public function __construct(array $params, $username, $password, array $driverOptions = array())
 {
     $http = new \GuzzleHttp\Client();
     $options = new Options();
     $options->setHost($params["host"]);
     $options->setDatabase($params["dbname"]);
     $options->setUsername($username);
     $options->setPassword($password);
     $options->setPort($params["port"]);
     $adapter = new GuzzleAdapter($http, $options);
     $this->client = new Client($adapter);
 }
Exemplo n.º 5
0
 /**
  * @group udp
  */
 public function testWriteUDPPackagesToInvalidHostname()
 {
     $options = new Options();
     $options->setHost("www.test-invalid.this-is-not-a-tld");
     $options->setUsername("nothing");
     $options->setPassword("nothing");
     $options->setPort(15984);
     $adapter = new UdpAdapter($options);
     $object = new Client($adapter);
     $object->mark("udp.test", ["mark" => "element"]);
 }
 public function testTagsFieldIsMergedWithGlobalTags()
 {
     $options = new Options();
     $options->setDatabase("db");
     $options->setTags(["dc" => "us-west"]);
     $httpClient = $this->prophesize("GuzzleHttp\\Client");
     $httpClient->post(Argument::Any(), ["auth" => ["root", "root"], "query" => ["db" => "db", "retentionPolicy" => "default"], "body" => 'tcp.test,dc=us-west,region=us mark="element" 1257894000000000000'])->shouldBeCalledTimes(1);
     $adapter = new InfluxHttpAdapter($httpClient->reveal(), $options);
     $adapter->send(["time" => "2009-11-10T23:00:00Z", "tags" => ["region" => "us"], "points" => [["measurement" => "tcp.test", "fields" => ["mark" => "element"]]]]);
 }