loadero_python.resources.run module
Loadero run resource.
- Run resources is seperated into three parts
RunParams class that describes runs attributes
RunAPI class implements run resources API operations
Runs class that in combination with RunParams and RunAPI allows to manage a single run resources instance.
- class loadero_python.resources.run.Run(run_id: int | None = None, test_id: int | None = None, params: RunParams | None = None)[source]
Bases:
LoaderoResourceRun class allows to create, read and stop runs.
APIClient must be previously initialized with a valid Loadero access token.
The target Loadero run resource is determined by RunParams.
- create() Run[source]
Creates new run with given data.
Required attributes of params field that need to be populated, otherwise the method will raise an exception:
test_id
- Raises:
ValueError: If resource params do not sufficiently identify parent resource.
APIException: If API call fails.
- Returns:
Run: Created run resource.
- participants(query_params: QueryParams | None = None) tuple[list[RunParticipant], PaginationParams, dict[any, any]][source]
Read all participants in run.
Required attributes of params field that need to be populated, otherwise the method will raise an exception:
run_id
- Args:
query_params (QueryParams, optional): Describes query parameters
- Raises:
ValueError: Run.params.run_id must be a valid int.
APIException: If API call fails.
- Returns:
list[RunParticipant]: List of run participants in test.
PaginationParams: Pagination parameters of request.
dict[any, any]: Filters applied to in request.
- poll(interval: float = 15.0, timeout: float = 43200) Run[source]
Polls run status until it is finished.
Required attributes of params field that need to be populated, otherwise the method will raise an exception:
run_id
- Args:
interval (float, optional): Poll interval in seconds. Defaults to 15.0.
timeout (float, optional): Poll timeout in seconds. Defaults to 12*60*60 (12h).
- Raises:
ValueError: If resource params do not sufficiently identify resource.
APIException: If API call fails.
TimeoutError: Run poll timeout exceeded
- Returns:
Run: Finished run resource.
- read() Run[source]
Read an existing run resource.
Required attributes of params field that need to be populated, otherwise the method will raise an exception:
run_id
- Raises:
ValueError: If resource params do not sufficiently identify resource.
APIException: If API call fails.
- Returns:
Run: Read run resource.
- results(query_params: QueryParams | None = None) tuple[list[Result], PaginationParams, dict[any, any]][source]
Get all results of the run.
Required attributes of params field that need to be populated, otherwise the method will raise an exception:
run_id
- Args:
query_params (QueryParams, optional): Describes query parameters
- Raises:
APIException: If API call fails.
ValueError: Run.params.run_id must be a valid int
- Returns:
list[Result]: List of all results of the run.
PaginationParams: Pagination parameters of request.
dict[any, any]: Filters applied to in request.
- stop() Run[source]
Stop an active run. To stop a run need only to specify the test_id and run_id in resource params.
Required attributes of params field that need to be populated, otherwise the method will raise an exception:
run_id
- Raises:
ValueError: If resource params do not sufficiently identify resource.
APIException: If API call fails.
- Returns:
Run: Stopped run resource.
- class loadero_python.resources.run.RunAPI[source]
Bases:
objectRunAPI defines Loadero API operations for run resources.
- static create(params: RunParams) RunParams[source]
Creates and launches a new test run.
- Args:
params (RunParams): Describes the run resource to be created. Only the RunParams.test_id field is required.
- Raises:
ValueError: If resource params do not sufficiently identify parent resource.
APIException: If API call fails.
- Returns:
RunParams: Created run resource.
- static read(params: RunParams) RunParams[source]
Read an existing run resource.
- Args:
params (RunParams): Describes the run resource to read.
- Raises:
ValueError: If resource params do not sufficiently identify resource.
APIException: If API call fails.
- Returns:
RunParams: Read run resource.
- static read_all(test_id: int | None = None, query_params: QueryParams | None = None) PagedResponse[source]
Read all run resources.
- Args:
test_id (int, optional): Parent test resource id. Defaults to None. If omitted all runs in project will be read.
query_params (QueryParams, optional): Describes query parameters.
- Raises:
ValueError: If resource params do not sufficiently identify parent resource.
APIException: If API call fails.
- Returns:
PagedResponse: Paged response of run resources.
- static route(test_id: int | None = None, run_id: int | None = None) str[source]
Build run resource url route.
- Args:
test_id (int, optional): Test resource id. Defaults to None. If omitted route will point to all runs in project.
run_id (int, optional): Run resource id. Defaults to None. If omitted the route will point to all run resources that belong to parent resource, either test or project.
- Returns:
str: Route to run resource/s.
- class loadero_python.resources.run.RunFilterKey(value)[source]
Bases:
FilterKeyRunFilterKey is an enum of all filter keys for run read all API operation.
- EXECUTION_FINISHED_FROM = 'filter_execution_finished_from'
- EXECUTION_FINISHED_TO = 'filter_execution_finished_to'
- EXECUTION_STARTED_FROM = 'filter_execution_started_from'
- EXECUTION_STARTED_TO = 'filter_execution_started_to'
- FINISHED = 'filter_finished'
- FINISHED_FROM = 'filter_finished_from'
- FINISHED_TO = 'filter_finished_to'
- INCREMENT_STRATEGY = 'filter_increment_strategy'
- METRIC_STATUS = 'filter_metric_status'
- MOS_STATUS = 'filter_mos_status'
- MOS_TEST = 'filter_mos_test'
- NAME = 'filter_test_name'
- PARTICIPANT_TIMEOUT_FROM = 'filter_participant_timeout_from'
- PARTICIPANT_TIMEOUT_TO = 'filter_participant_timeout_to'
- STARTED = 'filter_started'
- STARTED_FROM = 'filter_started_from'
- STARTED_TO = 'filter_started_to'
- START_INTERVAL_FROM = 'filter_start_interval_from'
- START_INTERVAL_TO = 'filter_start_interval_to'
- STATUS = 'filter_status'
- TEST_MODE = 'filter_test_mode'
- class loadero_python.resources.run.RunParams(run_id: int | None = None, test_id: int | None = None)[source]
Bases:
LoaderoResourceParamsRunParams describes single Loadero run resources attributes.
RunParams has a builder pattern for writeable attributes.
- property created: datetime
Time when run was created.
- Returns:
datetime: Time when run was created.
- property execution_finished: datetime
Time when test script execution of the run finished.
- Returns:
datetime: Time when test script execution of the run finished.
- property execution_started: datetime
Time when test script execution of the run started.
- Returns:
datetime: Time when test script execution of the run started.
- property group_count: int
Number of groups in the test.
- Returns:
int: Number of groups in the test.
- in_test(test_id: int) RunParams[source]
Set the ID of the test.
- Args:
test_id (int): ID of the test.
- Returns:
RunParams: Run params with set test id.
- property increment_strategy: IncrementStrategy
Increment strategy of the run.
- Returns:
IncrementStrategy: Increment strategy of the run.
- property launching_account_id: int
ID of the account that launched the test.
- Returns:
int: ID of the account that launched the test.
- property metric_status: MetricStatus
Status of metric calculation for the run.
- Returns:
MetricStatus: Status of metric calculation for the run.
- property mos_status: MetricStatus
Status of mean opinion score calculation for the run.
- Returns:
MetricStatus: Status of mean opinion score calculation for the run.
- property mos_test: bool
Whether the test run is a MOS test run.
- Returns:
bool: Whether the test run is a MOS test run.
- property participant_count: int
Number of participants in the test.
- Returns:
int: Number of participants in the test.
- property participant_timeout: int
Timeout for participants in the test.
- Returns:
int: Timeout for participants in the test.
- property processing_finished: datetime
Time when processing of the run finished.
- Returns:
datetime: Time when processing of the run finished.
- property processing_started: datetime
Time when processing of the run started.
- Returns:
datetime: Time when processing of the run started.
- property script_file_id: int
ID of the script file used for the run.
- Returns:
int: ID of the script file used for the run.
- property start_interval: int
Start interval of the test.
- Returns:
int: Start interval of the test.
- property success_rate: float
Fraction of participants that finished the test successfully over the total number of participants.
- Returns:
float: Success rate of the test run.
- property test_name: str
Name of the test being run.
- Returns:
str: Name of the test being run.
- property total_cu_count: float
Total compute units used by the test run.
- Returns:
float: Total compute units used by the test run.
- property updated: datetime
Time when run was last updated.
- Returns:
datetime: Time when run was last updated.