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);
 }
 public function testDirectMessagesMarkPublicSignature()
 {
     $options = new Options();
     $options->setDatabase("tcp.test");
     $guzzleHttp = new GuzzleHttpClient();
     $adapter = new InfluxHttpAdapter($guzzleHttp, $options);
     $client = new Client($adapter);
     $client->mark(["database" => "tcp.test", "retentionPolicy" => "default", "points" => [["measurement" => "tt", "fields" => ["cpu" => 1, "mem" => 2]]]]);
     $this->assertSerieExists("tcp.test", "tt");
     $this->assertSerieCount("tcp.test", "tt", 1);
     $this->assertValueExistsInSerie("tcp.test", "tt", "cpu", 1);
     $this->assertValueExistsInSerie("tcp.test", "tt", "mem", 2);
 }
 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);
 }
 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;
 }
 /**
  * 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 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"]]]]);
 }