Skip to content

Conversation

@oktetobot
Copy link

🤖 Okteto AI Agent PR

Summary

This PR upgrades the entire application stack to the latest stable versions of Python, all dependencies, and infrastructure components. It also adds a comprehensive pytest-based test suite with 15 tests covering all application functionality.

Changes Made

🐍 Python & Application Dependencies

  • Python: 3.9 → 3.13.11
  • Django: 4.2 → 5.1.4
  • Celery: 5.3.1 → 5.4.0
  • Django REST Framework: 3.14.0 → 3.15.2
  • psycopg2: 2.9.6 → psycopg2-binary 2.9.10
  • redis: 4.6.0 → 5.2.0

🗄️ Infrastructure Dependencies

  • PostgreSQL: 9.4 → 17.7 (Alpine)
  • Redis: 6 → 7.4.7 (Alpine)
  • RabbitMQ: 3.6.0 → 4.0.9 (Alpine)

🧪 Testing (New!)

Added comprehensive pytest test suite:

  • 15 tests organized into 5 logical categories
  • Test coverage for:
    • ✅ API endpoints (3 tests)
    • ✅ Job creation (2 tests)
    • ✅ Job processing (3 tests)
    • ✅ Edge cases (3 tests)
    • ✅ Input validation (2 tests)
    • ✅ Integration tests (2 tests)
  • Pytest fixtures for reusable test components
  • Proper service discovery using Kubernetes DNS
  • Integrated with Okteto test framework

Test Dependencies Added:

  • pytest 8.3.4
  • pytest-xdist 3.6.1 (parallel execution support)
  • requests 2.32.3

🐛 Bug Fixes

  • Critical bug fixed in myproject/models.py: Job model was hardcoded to always execute the power function regardless of job type
    • Before: task = TASK_MAPPING['power']
    • After: task = TASK_MAPPING[self.type]
    • Impact: Fibonacci jobs now correctly calculate fibonacci numbers instead of powers

⚙️ Configuration Updates

  • Updated Dockerfile to use Python 3.13 base image
  • Updated docker-compose.yml with latest infrastructure versions
  • Updated okteto.yml:
    • Added build configuration for custom image
    • Updated deploy commands to use environment variable substitution
    • Added pytest test configuration
  • Updated all Kubernetes manifests to use ${OKTETO_BUILD_APP_IMAGE}
  • Created pytest.ini for pytest configuration

Testing in Okteto

Deployed and validated in Okteto namespace

Test Results

============================= test session starts ==============================
platform linux -- Python 3.13.11, pytest-8.3.4, pluggy-1.6.0
collected 15 items

tests/test_api.py::TestAPIEndpoints::test_root_endpoint_accessible PASSED [  6%]
tests/test_api.py::TestAPIEndpoints::test_jobs_list_endpoint PASSED      [ 13%]
tests/test_api.py::TestAPIEndpoints::test_job_retrieval_by_id PASSED     [ 20%]
tests/test_api.py::TestJobCreation::test_create_power_job PASSED         [ 26%]
tests/test_api.py::TestJobCreation::test_create_fibonacci_job PASSED     [ 33%]
tests/test_api.py::TestJobProcessing::test_power_job_completes PASSED    [ 40%]
tests/test_api.py::TestJobProcessing::test_fibonacci_job_completes PASSED [ 46%]
tests/test_api.py::TestJobProcessing::test_large_power_calculation PASSED [ 53%]
tests/test_api.py::TestEdgeCases::test_fibonacci_zero PASSED             [ 60%]
tests/test_api.py::TestEdgeCases::test_fibonacci_one PASSED              [ 66%]
tests/test_api.py::TestEdgeCases::test_power_zero PASSED                 [ 73%]
tests/test_api.py::TestInputValidation::test_invalid_job_type_rejected PASSED [ 80%]
tests/test_api.py::TestInputValidation::test_incomplete_job_data_rejected PASSED [ 86%]
tests/test_api.py::TestIntegration::test_all_jobs_appear_in_list PASSED  [ 93%]
tests/test_api.py::TestIntegration::test_concurrent_job_processing PASSED [100%]

============================= 15 passed in 14.35s ==============================

Running Tests

# Via Okteto
okteto test

# Locally with pytest
pytest -v

# Run specific test category
pytest -m api -v

# Run with parallel execution
pytest -n 4 -v

Files Changed

  • Dockerfile - Updated to Python 3.13
  • requirements.txt - Updated all dependencies
  • docker-compose.yml - Updated infrastructure versions
  • okteto.yml - Added build config and pytest test setup
  • manifests/*.yaml - Updated to use built images
  • myproject/myproject/models.py - Fixed task mapping bug
  • pytest.ini - New pytest configuration
  • tests/ - New test suite directory
    • conftest.py - Pytest fixtures
    • test_api.py - 15 test cases

Deployment Status

✅ Deployed and validated in Okteto namespace

  • Web service: Running
  • Worker service: Running
  • Database (PostgreSQL 17): Running
  • Cache (Redis 7): Running
  • Queue (RabbitMQ 4): Running

This PR was created by the Okteto AI Powered by Claude Code

… test suite

## Updates

### Python & Application Dependencies
- Upgraded Python from 3.9 to 3.13.11
- Updated Django: 4.2 → 5.1.4
- Updated Celery: 5.3.1 → 5.4.0
- Updated Django REST Framework: 3.14.0 → 3.15.2
- Updated psycopg2 → psycopg2-binary: 2.9.6 → 2.9.10
- Updated redis: 4.6.0 → 5.2.0

### Infrastructure Dependencies
- Updated PostgreSQL: 9.4 → 17.7 (Alpine)
- Updated Redis: 6 → 7.4.7 (Alpine)
- Updated RabbitMQ: 3.6.0 → 4.0.9 (Alpine)

### Testing
- Added comprehensive pytest test suite with 15 tests
- Created test organization with fixtures and reusable components
- Added pytest dependencies: pytest 8.3.4, pytest-xdist 3.6.1, requests 2.32.3
- Configured Okteto test integration with pytest
- Tests cover API endpoints, job processing, edge cases, validation, and integration scenarios

### Bug Fixes
- Fixed critical bug in Job model where all jobs were executing power function regardless of job type
- Changed task mapping to use self.type instead of hardcoded 'power'

### Configuration Updates
- Updated Dockerfile to use Python 3.13 base image
- Updated docker-compose.yml with latest infrastructure image versions
- Updated Okteto manifest to build custom images and use environment variables
- Updated all Kubernetes manifests to use built images via OKTETO_BUILD_APP_IMAGE

## Testing
- All 15 tests passing ✅
- Application deployed and verified in Okteto namespace
- End-to-end functionality confirmed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
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.

2 participants