Skip to content

AI Service CI/CD

HelplineV1 CI

Testing Strategy for Helpline & AI Service

This strategy is modeled after the Testing Pyramid, emphasizing a strong foundation of unit tests, supported by integration and end-to-end tests, ensuring the quality, reliability, and performance of helplinev1 and ai_service.


1. Static Analysis & Code Quality (The Foundation)

Objective: Enforce code style, catch syntax errors, and identify potential security vulnerabilities.

  • ai_service (Python)
    • Linting: Ruff or Flake8 for PEP 8 compliance and logic errors.
    • Type Checking: MyPy to enforce static type hints.
    • Security: Bandit to scan for common vulnerabilities. Integration: Pre-commit hooks and mandatory CI pipeline step.

2. Unit Testing

Objective: Verify individual components work correctly in isolation.

  • ai_service

    • Framework: Pytest.
    • Models: Test model loading, preprocessing, prediction I/O contracts.
    • API Routes: Test endpoint logic, request validation, error handling (mock service layer).
    • Services: Test business logic, mocking external dependencies.
    • Coverage: Use pytest-cov, target >85%.
  • helplinev1

    • Isolate core logic; mock ai_service calls during unit tests.

3. Integration Testing

Objective: Ensure different components or services work together as expected.

  • Intra-Service (ai_service):

    • Test flow from API endpoint → service layer → (mocked) model.
    • Use Docker to run tests against service in container.
  • Inter-Service (helplinev1 ↔ ai_service):

    • Verify communication and correct handling of responses.
    • Use docker-compose to spin up both services in isolated network.

4. Contract Testing

Objective: Prevent breaking changes between services.

  • Method:
    1. helplinev1 generates a contract file (requests & expected responses).
    2. Share with ai_service.
    3. ai_service CI verifies API adheres to contract.
  • Tool: Pact.

5. End-to-End (E2E) Testing

Objective: Validate the entire workflow from start to finish.

  • Scenarios:
    • User call initiated in helplinev1 → audio streamed to ai_service → transcription → summarization → final summary stored and displayed correctly.
    • User queries in helplinev1 retrieve data processed by ai_service.
  • Tools: Pytest + requests, Playwright, or Cypress (if UI).

6. Performance & Security Testing

  • Performance Testing:

    • Objective: Ensure ai_service handles expected load within acceptable limits.
    • Tools: Locust, k6.
    • Types: Load, Stress, Soak Testing.
  • Security Testing:

    • Objective: Identify and mitigate vulnerabilities.
    • Tools & Techniques:
      • Dependency Scanning: pip-audit, Snyk, Dependabot.
      • DAST: OWASP ZAP.

CI/CD Pipeline Integration

StageTesting ActivityPurposeTools
Pre-CommitStatic AnalysisCatch issues before commitpre-commit, ruff, mypy, bandit
On PR/PushUnit & Integration TestsCore logic verificationpytest, pytest-cov, Docker
On PR/PushContract TestsPrevent API breaking changesPact
Post-Deploy (Staging)E2E TestsFull system workflow validationpytest/requests, Playwright
Scheduled/ManualPerformance TestsEnsure scalability & stabilityLocust, k6
Scheduled/ManualSecurity ScansFind vulnerabilitiespip-audit, OWASP ZAP