Skip to content

Commit

Permalink
add health probes
Browse files Browse the repository at this point in the history
  • Loading branch information
salimkanoun committed Jun 20, 2023
1 parent e487c79 commit 77e8acb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
15 changes: 15 additions & 0 deletions GaelO2/routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use App\Http\Controllers\VisitGroupController;
use App\Http\Controllers\VisitTypeController;
use App\Http\Requests\SignedEmailVerificationRequest;
use App\Models\Country;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -232,3 +234,16 @@

//Magic link route
Route::get('magic-link/{id}', [AuthController::class, 'getMagicLink'])->name('magic-link');

//Public probs
Route::get('liveness', function () {
return 'ok';
});

Route::get('readiness', function () {
$check = Country::count();
if ($check > 0) {
return 'ok';
}
return response('', 500);
});
28 changes: 28 additions & 0 deletions GaelO2/tests/Feature/ProbeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class ProbeTest extends TestCase
{
use RefreshDatabase;

protected function setUp() : void {
parent::setUp();
$this->artisan('db:seed');
}

public function testLiveness()
{
$response = $this->get('api/liveness');
$response->assertStatus(200);
}

public function testReadiness()
{
$response = $this->get('api/readiness');
$response->assertStatus(200);
}

}

0 comments on commit 77e8acb

Please sign in to comment.