Skip to main content

Testing

Tests are located in the tests/ directory and run against a live backend instance.

Test Files

FileDescription
test_e2e_api.pyEnd-to-end HTTP API tests for all backend endpoints
test_issues_sanity.pyIssues page sanity and performance tests

End-to-End API Tests (test_e2e_api.py)

Tests all backend API endpoints over HTTP. Generates a JWT token locally and calls each endpoint with auth headers.

What It Covers

  1. Authentication -- Generates a test JWT for kiran.kamreddy@celerdata.com with superadmin role
  2. Issues KPIs -- GET /api/issues/kpis?days=0
  3. Issues List -- GET /api/issues?days=0&severities=Critical,Warning,Info with pagination
  4. Issue Detail -- GET /api/issues/<id> for the first issue, verifies alerts and performance (< 5s)
  5. Additional endpoint coverage for all API routes

Running

# On bastion
cd ~/byocusage-app
source ~/app.env
PYTHONPATH=. ~/.venv/bin/python3 tests/test_e2e_api.py

Issues Sanity Tests (test_issues_sanity.py)

Tests database connectivity and data integrity for the issues pipeline.

What It Covers

  1. StarRocks connectivity -- Verifies the DB connection works
  2. Data presence -- Checks alerts.issues table has rows
  3. Performance -- Ensures queries complete within acceptable time

Running

# On bastion
cd ~/byocusage-app
~/.venv/bin/python3 tests/test_issues_sanity.py

Notes

  • Tests require a running backend (default: http://localhost:8501)
  • Tests require a working StarRocks connection (SSH tunnel must be active)
  • The JWT secret defaults to byoc-ops-secret-key (from JWT_SECRET env var)
  • Output uses colored PASS/FAIL markers in the terminal