Added k8s health checks and metrics scraping
parent
e4247cd0bd
commit
a3f7942d0d
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Engelsystem\Controllers;
|
||||
|
||||
use Engelsystem\Http\Response;
|
||||
|
||||
class HealthController extends BaseController
|
||||
{
|
||||
/** @var Response */
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* @param Response $response
|
||||
*/
|
||||
public function __construct(Response $response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Response
|
||||
*/
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->response->withContent('Ok');
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Engelsystem\Test\Unit\Controllers;
|
||||
|
||||
use Engelsystem\Controllers\HealthController;
|
||||
use Engelsystem\Http\Response;
|
||||
use Engelsystem\Test\Unit\TestCase;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class HealthControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \Engelsystem\Controllers\HealthController::__construct
|
||||
* @covers \Engelsystem\Controllers\HealthController::index
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
/** @var Response|MockObject $response */
|
||||
$response = $this->createMock(Response::class);
|
||||
$this->setExpects($response, 'withContent', ['Ok'], $response);
|
||||
|
||||
$controller = new HealthController($response);
|
||||
$controller->index();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue