-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add isDaprHealthy function to client (#100)
* Add healthz endpoint support * Add doc string * Add tests
- Loading branch information
1 parent
debcd71
commit f87e3d3
Showing
3 changed files
with
68 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
use GuzzleHttp\Exception\RequestException; | ||
use GuzzleHttp\Psr7\Request; | ||
use GuzzleHttp\Psr7\Response; | ||
|
||
/** | ||
* Class HealthTest | ||
*/ | ||
class HealthTest extends DaprTests | ||
{ | ||
public function testIsHealthy() | ||
{ | ||
$container = $this->get_http_client_stack( | ||
[ | ||
new Response(200) | ||
] | ||
); | ||
$client = $this->get_new_client_with_http($container->client); | ||
$this->assertTrue($client->isDaprHealthy()); | ||
$request = $container->history[0]['request']; | ||
$this->assertRequestUri('/v1.0/healthz', $request); | ||
} | ||
|
||
public function testIsNotHealthy() { | ||
$container = $this->get_http_client_stack( | ||
[ | ||
new Response(500) | ||
] | ||
); | ||
$client = $this->get_new_client_with_http($container->client); | ||
$this->assertFalse($client->isDaprHealthy()); | ||
$request = $container->history[0]['request']; | ||
$this->assertRequestUri('/v1.0/healthz', $request); | ||
} | ||
|
||
public function testTimeout() { | ||
$container = $this->get_http_client_stack( | ||
[ | ||
new RequestException('timed out', new Request('GET', 'test')) | ||
] | ||
); | ||
$client = $this->get_new_client_with_http($container->client); | ||
$this->assertFalse($client->isDaprHealthy()); | ||
$request = $container->history[0]['request']; | ||
$this->assertRequestUri('/v1.0/healthz', $request); | ||
} | ||
} |