-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add probes * add tests * add tests and checks to ci
- Loading branch information
Showing
8 changed files
with
183 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,29 @@ | ||
from fastapi import APIRouter | ||
from pydantic import BaseModel | ||
import logging | ||
|
||
router = APIRouter(tags=["health"]) | ||
|
||
|
||
class ReadyResponse(BaseModel): | ||
ready: bool | ||
|
||
|
||
class AliveResponse(BaseModel): | ||
alive: bool | ||
|
||
|
||
@router.get("/ready", response_model=ReadyResponse) | ||
def ready() -> ReadyResponse: | ||
logging.debug("Health check") | ||
return ReadyResponse( | ||
ready=True, | ||
) | ||
|
||
|
||
@router.get("/alive", response_model=AliveResponse) | ||
def alive() -> AliveResponse: | ||
logging.debug("Health check") | ||
return AliveResponse( | ||
alive=True, | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,9 @@ | ||
import pytest | ||
from starlette.testclient import TestClient | ||
|
||
from app.app import app | ||
|
||
@pytest.fixture() | ||
def test_client(): | ||
with TestClient(app) as test_client: | ||
yield test_client |
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,16 @@ | ||
from fastapi.testclient import TestClient | ||
from fastapi import FastAPI | ||
|
||
def test_ready_endpoint(test_client): | ||
response = test_client.get("/ready") | ||
assert response.status_code == 200 | ||
assert response.json() == {"ready": True} | ||
|
||
def test_alive_endpoint(test_client): | ||
response = test_client.get("/alive") | ||
assert response.status_code == 200 | ||
assert response.json() == {"alive": True} | ||
|
||
def test_model_info(test_client): | ||
response = test_client.get("/v1/info", params={"model_name": "all-MiniLM-L12-v2"}) | ||
assert response.status_code == 200 |