-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Service Description
Current State & Problem
The TGB-MicroSuite project currently lacks a systematic, automated testing strategy. Code quality is primarily verified through manual checks and occasional ad-hoc scripting, which is slow, error-prone, and not scalable. This absence of a "test safety net" makes refactoring existing code extremely risky, slows down the development of new features, and critically, prevents the project from achieving the reliability required for production deployment.
Without a robust test suite, we cannot confidently deploy changes, leading to a high risk of introducing regressions (breaking existing functionality) and a prolonged, inefficient development cycle.
Goals & Objectives
This epic aims to establish a comprehensive, multi-layered testing framework across the entire TGB-MicroSuite project, focusing on the a-rag and tg-gateway services. The primary goal is to build a robust safety net that guarantees code quality, prevents regressions, and enables confident, rapid development and CI/CD integration. We will adopt a structured approach based on the Testing Pyramid philosophy.
1. Establish Core Testing Infrastructure
- Description: Configure the project to fully support
pytest, including dependency management, test discovery, and code coverage analysis. - Tasks:
- Integrate
pytestand key plugins (pytest-cov,pytest-asyncio) as development dependencies in thepyproject.tomlfor each service. - Create a standard
tests/directory structure (tests/unit,tests/integration) within botha-ragandtg-gatewayservices. - Configure
pytestviapyproject.tomlto correctly handle thesrclayout (pythonpath = ["src"]) and define test paths.
- Integrate
2. Implement Unit Test Coverage (The Foundation)
- Description: Cover all critical, isolated business logic with fast and reliable unit tests. This forms the base of our testing pyramid.
- Tasks:
- Identify and write unit tests for all "pure" functions and classes that have no external dependencies (e.g.,
core/config.py,core/profiling.py, pipeline processors). - Write comprehensive unit tests for modules containing critical business logic, using mocking (
monkeypatch) to isolate them from external systems (database, external APIs). - Achieve a target of >95% unit test coverage for all modules in the
core,agent, andpipelinesdirectories of thea-ragservice.
- Identify and write unit tests for all "pure" functions and classes that have no external dependencies (e.g.,
3. Implement Integration Test Coverage (Service Interactions)
- Description: Write tests to verify the interaction between different components within a service, and between the service and external infrastructure like databases.
- Tasks:
- Develop integration tests for all FastAPI API endpoints in the
a-ragservice usingTestClient. - Verify request/response schemas, status codes, and authentication/authorization logic for all routers (
auth_router,llm_router, etc.). - Write tests that validate the interaction with the relational database (PostgreSQL/SQLite) by using a dedicated test database.
- Write tests to confirm correct interaction with the vector database (Qdrant) and Redis.
- Develop integration tests for all FastAPI API endpoints in the
4. Automate Testing with Continuous Integration (CI)
- Description: Create a CI pipeline that automatically runs the entire test suite on every code change, providing immediate feedback and preventing faulty code from being merged.
- Tasks:
- Create a GitHub Actions workflow file (
.github/workflows/ci.yml). - Configure the workflow to trigger on every
pushto feature branches and on everypull_requesttomain/develop. - The CI job must:
- Install project dependencies using
uv. - Run the complete
pytestsuite for all services. - Calculate and report code coverage using
pytest-cov.
- Install project dependencies using
- Implement a branch protection rule that requires the CI checks to pass before a Pull Request can be merged.
- Create a GitHub Actions workflow file (
Definition of Done
- The core testing infrastructure is fully configured and documented.
- Overall project test coverage exceeds 85%.
- All critical business logic modules are covered by unit tests at >95%.
- All API endpoints are covered by integration tests.
- A green CI pipeline is successfully running and required for all Pull Requests.
- The README is updated with instructions on how to run the test suite locally.
Metadata
Metadata
Assignees
Labels
Projects
Status