forked from Jimdo/prometheus_client_php
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an integration test for PushGateway
- runs BlackBox tests with docker-compose - adds a phpunit container (needed to avoid dependency cycle between php-fpm and nginx) - enables apcu on cli
- Loading branch information
Ilya Margolin
committed
Sep 21, 2016
1 parent
1cf9107
commit e3d2de8
Showing
6 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
apc.enable_cli = On |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
namespace Test; | ||
|
||
use GuzzleHttp\Client; | ||
use PHPUnit_Framework_TestCase; | ||
|
||
use Prometheus\CollectorRegistry; | ||
use Prometheus\PushGateway; | ||
use Prometheus\Storage\APC; | ||
|
||
class BlackBoxPushGatewayTest extends PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function pushGatewayShouldWork() | ||
{ | ||
$adapter = new APC(); | ||
$registry = new CollectorRegistry($adapter); | ||
|
||
$counter = $registry->registerCounter('test', 'some_counter', 'it increases', ['type']); | ||
$counter->incBy(6, ['blue']); | ||
|
||
$pushGateway = new PushGateway('pushgateway:9091'); | ||
$pushGateway->push($registry, 'my_job', array('instance' => 'foo')); | ||
|
||
$httpClient = new Client(); | ||
$metrics = $httpClient->get("http://pushgateway:9091/metrics")->getBody()->getContents(); | ||
$this->assertContains( | ||
'# HELP test_some_counter it increases | ||
# TYPE test_some_counter counter | ||
test_some_counter{instance="foo",job="my_job",type="blue"} 6', | ||
$metrics | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters