Skip to content

Latest commit

 

History

History
297 lines (222 loc) · 5.91 KB

File metadata and controls

297 lines (222 loc) · 5.91 KB

Debug Endpoints Test Suite - Quick Start

Fast reference for running tests locally.


Prerequisites

1. Backend running:

cd /root/ai_product_visualizer
docker-compose up

2. Dependencies installed:

pip install pytest pytest-asyncio httpx

Most Common Commands

Run all debug endpoint tests

pytest tests/test_debug_endpoints.py -v

Run all tests (unit + integration)

pytest tests/test_debug_*.py -v

Run scenario-based tests with output

pytest tests/test_debug_integration.py -v -s

Specific Scenarios

Diagnose an upload failure

pytest tests/test_debug_integration.py::TestUploadDiagnostics -v -s

What it does:

  • Checks database connectivity
  • Verifies workers are running
  • Checks Gemini API availability
  • Determines where upload failed (API layer vs worker layer)

Check system health

pytest tests/test_debug_integration.py::TestSystemHealthCheck -v -s

What it does:

  • Tests database connection
  • Verifies workers & Redis
  • Checks Gemini API
  • Shows storage usage
  • Displays video processing stats

Track video processing

pytest tests/test_debug_integration.py::TestVideoProcessingTracking -v -s

What it does:

  • Lists all user's videos
  • Shows status breakdown
  • Identifies stuck/processing videos
  • Displays average processing time

Test Specific Endpoints

Database Status

pytest tests/test_debug_endpoints.py::TestSupabaseStatus -v

User Videos

pytest tests/test_debug_endpoints.py::TestUserVideos -v

User Storage

pytest tests/test_debug_endpoints.py::TestUserStorage -v

Processing Jobs

pytest tests/test_debug_endpoints.py::TestRunwareJobs -v

Gemini API

pytest tests/test_debug_endpoints.py::TestGeminiStatus -v

Workers/Redis

pytest tests/test_debug_endpoints.py::TestWorkersStatus -v

Troubleshooting Specific Issues

Issue 12: Dual upload shows [object Object],[object Object]

  1. Check if database record was created:
pytest tests/test_debug_integration.py::TestUploadDiagnostics::test_diagnose_upload_failure_workflow -v -s
  1. Verify workers can process:
pytest tests/test_debug_endpoints.py::TestWorkersStatus::test_returns_workers_status -v
  1. Verify Gemini is available:
pytest tests/test_debug_endpoints.py::TestGeminiStatus::test_returns_gemini_status -v

Issue 13: Video stuck at "processing" after 36+ minutes

  1. Check all user videos:
pytest tests/test_debug_integration.py::TestVideoProcessingTracking::test_identify_stuck_processing_videos -v -s
  1. Check overall job stats:
pytest tests/test_debug_endpoints.py::TestRunwareJobs -v
  1. Full system health check:
pytest tests/test_debug_integration.py::TestSystemHealthCheck -v -s

Understanding Output

Success ✓

tests/test_debug_endpoints.py::TestSupabaseStatus::test_returns_database_status PASSED

Failure ✗

tests/test_debug_endpoints.py::TestSupabaseStatus::test_returns_database_status FAILED
AssertionError: Expected 200, got 403

With Scenario Output (-s flag)

tests/test_debug_integration.py::TestSystemHealthCheck::test_full_system_health_check

============================================================
SYSTEM HEALTH CHECK
============================================================

[1/6] Database...
✓ Database connected
  - Users: 42
  - Videos: 187

[2/6] Workers & Redis...
✓ Workers: ✓ Running
✓ Redis: ✓ Connected
  - Pending tasks: 0

Debug Flags

Flag What it does
-v Verbose output (show test names)
-vv Very verbose (also show assertion details)
-s Show print statements (use with integration tests)
-x Stop on first failure
--tb=short Shorter traceback format
--tb=no No traceback at all
-k test_name Run only tests matching test_name
-m marker Run only tests with specific marker

Example combinations:

# See everything
pytest tests/ -vv -s --tb=short

# Stop on first failure
pytest tests/ -x

# Only slow tests
pytest tests/ -m slow -v

# Everything except slow tests
pytest tests/ -m "not slow" -v

Real-World Workflow

When upload fails:

1. Diagnose:

pytest tests/test_debug_integration.py::TestUploadDiagnostics -v -s

2. Check workers:

pytest tests/test_debug_endpoints.py::TestWorkersStatus -v

3. Check database:

pytest tests/test_debug_endpoints.py::TestSupabaseStatus -v

4. Full system check:

pytest tests/test_debug_integration.py::TestSystemHealthCheck -v -s

When video is stuck:

1. List all videos:

pytest tests/test_debug_integration.py::TestVideoProcessingTracking -v -s

2. Identify stuck videos:

pytest tests/test_debug_integration.py::TestVideoProcessingTracking::test_identify_stuck_processing_videos -v -s

3. Check worker stats:

pytest tests/test_debug_endpoints.py::TestRunwareJobs -v

For general monitoring:

pytest tests/test_debug_integration.py::TestSystemHealthCheck -v -s

Pro Tips

  1. Combine multiple scenarios:

    pytest tests/test_debug_integration.py -v -s
  2. Run with timestamps:

    pytest tests/ -v -s --tb=short 2>&1 | tee test_results_$(date +%s).log
  3. Run specific test multiple times:

    pytest tests/test_debug_endpoints.py::TestSupabaseStatus::test_returns_database_status -v --count=5
  4. Show slowest tests:

    pytest tests/ -v --durations=10

More Info

  • Full documentation: See README_DEBUG_TESTS.md
  • Test code: See test_debug_endpoints.py and test_debug_integration.py
  • Configuration: See pytest.ini

Last Updated: 2025-10-28 Status: Ready to use!