Test Execution System
Tests run against endpoints through executors selected by test type, coordinated by an async batch engine. This page covers the executor architecture; for single-turn vs. multi-turn tests see Test Types, and for parallel vs. sequential runs see Execution Modes.
Architecture
A factory routes each test to an executor based on its type:
Key Components
-
Test Execution Entry Point (
test_execution.py)- Main
execute_test()function - Routes to appropriate executor via factory pattern
- Maintains backward compatibility
- Main
-
Executors (
executors/)BaseTestExecutor- Abstract base classSingleTurnTestExecutor- Traditional request/response testsMultiTurnTestExecutor- Agentic multi-turn tests using Penelopefactory.py- Routing logic based on test type
-
Shared Utilities (
executors/shared.py)- Common helper functions
- Data retrieval and validation
- Result storage
Test Flow
Standard Execution Flow
Parallel vs Sequential
Test configurations can execute multiple tests in two modes:
- Parallel (default): one Celery task runs an internal async batch engine
- Sequential: tests run one after another
See Execution Modes for details.
Executor Pattern
Creating an Executor
All executors must implement the BaseTestExecutor interface:
Return Format
All executors must return a dictionary with:
test_id(str): The test identifierexecution_time(float): Execution time in millisecondsmetrics(Dict[str, Any]): Metric evaluation results
Usage Examples
Running a Test
Using Executors Directly
Extending the System
Adding a New Test Type
- Create the Executor
- Update the Factory
- Add Test Type Enum
Async Batch Engine
The parallel path uses an internal async batch runner rather than Celery chord fan-out:
execute_test_configurationcreates a single worker task per test runexecute_tests_as_batchprefetches execution context and runsrun_batch(...)run_batchruns each test as anasynciotask with semaphore-limited concurrency- cancellation is cooperative via Celery revoke checks and task cancellation
- per-test timeout defaults to
1800seconds (30 minutes); batch concurrency defaults to10
Module Location
The test execution code is located in the backend repository but is primarily executed by workers:
Related Documentation
- Test Types - Single-turn vs Multi-turn tests
- Execution Modes - Sequential vs Parallel
- Background Tasks - Celery task system
- Architecture - Worker system overview