How httprunner/httprunnermanager works
Project Type and Purpose
• This is a full-stack web application (Django “MTV” / MVC pattern) that provides an interface for managing, executing, scheduling, and reporting on HTTP API tests based on HttpRunner.
• Core purpose: allow users to create projects, modules, test cases and configurations; run tests synchronously or asynchronously (via Celery+RabbitMQ); view and persist reports; schedule periodic tasks; integrate with CI (e.g., Jenkins); send email notifications.
File Structure
• Top-level:
– HttpRunnerManager/*: Django project settings, URL routing, WSGI entry point, Celery config
– ApiManager/*: Django app implementing models, views, admin, custom managers, Celery tasks, utilities, template tags
– static/ & templates/: front-end assets (CSS/JS/images), HTML templates
– logs/: application logs
– uwsgi.ini, manage.py, requirements.txt
• Architectural patterns:
– Django’s MTV (Models in ApiManager/models.py, Views in views.py + templates, URL routes in HttpRunnerManager/urls.py)
– Asynchronous task queue (DJCelery + RabbitMQ broker)
– Modular separation: API management logic in ApiManager app, project-wide settings and bootstrapping in HttpRunnerManager project
Extract Key Architecture from README
• DB: MySQL (persistent storage of projects, modules, tests, reports, schedules, users)
• Broker: RabbitMQ (task queue)
• Workers: Celery workers + Celery-beat scheduler (execute tests, send emails)
• Runner: HttpRunner instances invoked by Celery tasks to run tests
• Frontend: jQuery-based pages, served by Django’s staticfiles via Nginx/uWSGI or Django dev server
• External integrations: SMTP mail server (for notifications), Jenkins (CI hook), RabbitMQ management UI (e.g., Celery Flower)
Main Components and Their Interactions
1. Browser / UI (HTML templates + static JS/CSS)
2. Web Server Layer
• Nginx (or dev server)
• uWSGI (WSGI app server)
3. Django Application
• HttpRunnerManager (settings, URL router)
• ApiManager app (models, views, admin, utils, Celery tasks)
4. Relational Database (MySQL)
5. Message Broker (RabbitMQ)
6. Celery Workers & Scheduler (celery worker + celery beat)
7. HttpRunner Core (invoked by workers)
8. Email / SMTP Service
9. CI/CD System (Jenkins)
10. Logging (log files in logs/)
1. User → Browser → HTTP request → Nginx → uWSGI → Django views
2. Django view (synchronous operations) ↔ MySQL (ORM in ApiManager/models.py)
3. Django view triggers Celery task → RabbitMQ → Celery worker
4. Celery worker executes HttpRunner test, writes results → MySQL; optionally sends email via SMTP
5. Celery-beat reads periodic task entries from MySQL → enqueues tasks on RabbitMQ
6. Browser polls/requests report pages → Django views → MySQL → renders report_template.html
7. Jenkins (external) triggers HTTP API endpoints on Django to kick off test runs
c. Architectural Patterns & Principles:
• MTV (Model-Template-View) separation of concerns
• Asynchronous task queue for long-running test executions
• Pluggable modular design: ApiManager encapsulates all test management logic
• Externalization of configuration: Django settings.py for DB / broker credentials
• Scheduled tasks via Celery-beat (crontab expressions stored in Django DB)
d. Key Technologies / Libraries:
• Framework: Django
• Task Queue: Celery + djcelery
• Broker: RabbitMQ
• Test Runner: HttpRunner
• Database: MySQL
• Web Server: uWSGI + (optional) Nginx
• Front-end: HTML templates + jQuery, custom CSS
• Reporting: ExtentReports (via templates in templates/extent_report_template.html)
• Email: Django’s email utilities configured in settings.py