Skip to content

Feature/add smoke tests api db#30

Merged
fearnworks merged 12 commits intoOpen-Model-Initiative:mainfrom
PrateekKumar1709:feature/add-smoke-tests-api-db
Aug 29, 2024
Merged

Feature/add smoke tests api db#30
fearnworks merged 12 commits intoOpen-Model-Initiative:mainfrom
PrateekKumar1709:feature/add-smoke-tests-api-db

Conversation

@PrateekKumar1709
Copy link
Copy Markdown
Contributor

Problem Statement

We need to implement smoke tests to verify that our core API and database services are up and running after deployment. This will help ensure the reliability of our deployments and quickly identify any issues.

Related Issue

Fixes #3 - Add smoke tests for services

Proposed Changes

API Smoke Test

  1. Create a new health check endpoint in modules/odr_api/odr_api/api/endpoints/health.py
  2. Update modules/odr_api/odr_api/api/main.py to include the health check router
  3. Implement a test in modules/odr_api/tests/integration/models/test_health.py
  4. Update modules/odr_api/Taskfile.yml to include a smoke test task

Database Smoke Test

  1. Implement a database connection test in modules/odr_database/tests/test_db_connection.py
  2. Update modules/odr_database/Taskfile.yml to include a smoke test task

Combined Smoke Tests

  1. Update the root Taskfile.yml to include a task that runs both API and database smoke tests

Signed-off-by: Prateek Kumar <85689959+PrateekKumar1709@users.noreply.github.com>
Signed-off-by: Prateek Kumar <85689959+PrateekKumar1709@users.noreply.github.com>
Signed-off-by: Prateek Kumar <85689959+PrateekKumar1709@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@fearnworks fearnworks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some issues that need to be addressed for the api test before merging. But looks mostly good.

- cmd: python -m debugpy --listen 0.0.0.0:5678 --wait-for-client ./modules/odr_api/odr_api/main.py
platforms: [windows, linux, darwin]

test_api:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be included in the api-test taskfile https://github.com/Open-Model-Initiative/OMI-Data-Pipeline/blob/main/modules/odr_api/tests/Taskfile.yml .

To keep naming in alignment across tasks use - and not _ in task names, (change to test-api). I would also just rename this one to health-check and add it as the first command ran in the test-all command in the odr_api/test/Taskfile.yml

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like something is a bit off when running this command when in the root directory:

PS C:\OMI-Data-Pipeline> task api:test_api
task: [api:test_api] pytest -s modules/odr_api/tests/integration/models/test_health.py
========================================= test session starts ==========================================
platform win32 -- Python 3.12.0, pytest-8.3.2, pluggy-1.5.0
rootdir: C:\OMI-Data-Pipeline\modules\odr_api
configfile: pyproject.toml
plugins: anyio-4.4.0
collected 0 items / 1 error

================================================ ERRORS ================================================ 
_______________________ ERROR collecting tests/integration/models/test_health.py _______________________ 
ImportError while importing test module 'C:\OMI-Data-Pipeline\modules\odr_api\tests\integration\models\test_health.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
modules\odr_api\tests\integration\models\__init__.py:1: in <module>
    from models.test_users import TestUserLifecycle
E   ModuleNotFoundError: No module named 'models'
======================================= short test summary info ======================================== 
ERROR modules\odr_api\tests\integration\models\test_health.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
=========================================== 1 error in 0.08s =========================================== 
task: Failed to run task "api:test_api": exit status 2
PS C:\OMI-Data-Pipeline>

app.include_router(annotation_router, prefix=settings.API_V1_STR)
app.include_router(auth_router, prefix=settings.API_V1_STR)
app.include_router(embedding_router, prefix=settings.API_V1_STR)
app.include_router(health.router)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try and match to the existing routes. Should have a prefix and same naming style

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test seems fine!

Signed-off-by: Prateek Kumar <85689959+PrateekKumar1709@users.noreply.github.com>
…l task

Signed-off-by: Prateek Kumar <85689959+PrateekKumar1709@users.noreply.github.com>
Signed-off-by: Prateek Kumar <85689959+PrateekKumar1709@users.noreply.github.com>
Signed-off-by: Prateek Kumar <85689959+PrateekKumar1709@users.noreply.github.com>
Signed-off-by: Prateek Kumar <85689959+PrateekKumar1709@users.noreply.github.com>
Signed-off-by: Prateek Kumar <85689959+PrateekKumar1709@users.noreply.github.com>
@PrateekKumar1709
Copy link
Copy Markdown
Contributor Author

Thank you for the review @fearnworks. I've addressed all the points raised and made the necessary changes. Please let me know if anything else needs attention

@fearnworks
Copy link
Copy Markdown
Collaborator

Hitting what looks like some pytest config issues. Are you able to run task smoke_tests and get all green? . Trying to resolve and will push a fix.

Signed-off-by: jphillips <josh.phillips@fearnworks.com>
Signed-off-by: jphillips <josh.phillips@fearnworks.com>
@fearnworks
Copy link
Copy Markdown
Collaborator

Had to make the changes from the last two commits to get running : https://github.com/Open-Model-Initiative/OMI-Data-Pipeline/tree/feature/add-smoke-tests-api-db

@fearnworks
Copy link
Copy Markdown
Collaborator

If you can get those integrated into your PR I think we are good to merge this in.

Signed-off-by: jphillips <120260158+fearnworks@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@fearnworks fearnworks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed, tests performed and merged into PR by author. Merging

@fearnworks fearnworks merged commit 78e0b22 into Open-Model-Initiative:main Aug 29, 2024
@PrateekKumar1709 PrateekKumar1709 deleted the feature/add-smoke-tests-api-db branch August 29, 2024 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add smoke tests for services

2 participants