Microsoft Azure Developer LoadTesting Client Library for Python providing programmatic access to Azure's load testing platform.
npx @tessl/cli install tessl/pypi-azure-developer-loadtesting@1.0.0Microsoft Azure Developer LoadTesting Client Library for Python provides programmatic access to Azure's fully managed load testing platform. The library enables developers to create, configure, and execute load tests, monitor performance metrics, and integrate load testing into CI/CD pipelines through comprehensive Python APIs.
pip install azure-developer-loadtestingfrom azure.developer.loadtesting import LoadTestAdministrationClient, LoadTestRunClientFor asynchronous operations:
from azure.developer.loadtesting.aio import LoadTestAdministrationClient, LoadTestRunClientfrom azure.core.credentials import DefaultAzureCredential
from azure.developer.loadtesting import LoadTestAdministrationClient, LoadTestRunClient
# Initialize credentials
credential = DefaultAzureCredential()
endpoint = "https://your-loadtest-resource.loadtest.azure.com"
# Create clients
admin_client = LoadTestAdministrationClient(endpoint=endpoint, credential=credential)
run_client = LoadTestRunClient(endpoint=endpoint, credential=credential)
# Create a load test
test_definition = {
"displayName": "My Load Test",
"description": "Load test for my application"
}
with admin_client:
# Create the test
test = admin_client.create_or_update_test("my-test-id", test_definition)
print(f"Created test: {test['displayName']}")
# Upload a test script (JMeter .jmx file)
with open("test-script.jmx", "rb") as f:
upload_result = admin_client.begin_upload_test_file(
test_id="my-test-id",
file_name="test-script.jmx",
body=f,
file_type="JMX_FILE"
)
# Execute the test
test_run_definition = {
"testId": "my-test-id",
"displayName": "My Test Run"
}
with run_client:
# Start the test run
run_poller = run_client.begin_test_run("my-test-run-id", test_run_definition)
test_run = run_poller.result()
print(f"Test run status: {test_run['status']}")
# Monitor test run progress
test_run = run_client.get_test_run("my-test-run-id")
print(f"Current status: {test_run['status']}")The library provides two primary client interfaces:
Both clients support:
send_request() methodComplete management of load test definitions, test scripts, and configuration. Includes creating and updating tests, uploading JMeter scripts and supporting files, configuring application components for monitoring, and setting up server-side metrics collection.
def create_or_update_test(test_id: str, body: Union[JSON, IO], **kwargs) -> JSON: ...
def delete_test(test_id: str, **kwargs) -> None: ...
def get_test(test_id: str, **kwargs) -> JSON: ...
def list_tests(*, orderby: Optional[str] = None, search: Optional[str] = None, **kwargs) -> Iterable[JSON]: ...
def begin_upload_test_file(test_id: str, file_name: str, body: IO, **kwargs) -> JSON: ...Execution of load tests with real-time monitoring and comprehensive metrics collection. Includes starting and stopping test runs, monitoring execution progress, collecting performance metrics, and accessing detailed results and logs.
def begin_test_run(test_run_id: str, body: Union[JSON, IO], *, old_test_run_id: Optional[str] = None, **kwargs) -> LROPoller[JSON]: ...
def get_test_run(test_run_id: str, **kwargs) -> JSON: ...
def stop_test_run(test_run_id: str, **kwargs) -> JSON: ...
def list_test_runs(*, orderby: Optional[str] = None, search: Optional[str] = None, test_id: Optional[str] = None, execution_from: Optional[datetime] = None, execution_to: Optional[datetime] = None, status: Optional[str] = None, **kwargs) -> Iterable[JSON]: ...
def list_metrics(test_run_id: str, body: Optional[Union[JSON, IO]] = None, *, metric_name: str, metric_namespace: str, time_interval: str, aggregation: Optional[str] = None, interval: Optional[str] = None, **kwargs) -> Iterable[JSON]: ...# Type aliases for API responses and requests
JSON = MutableMapping[str, Any]
# Long Running Operation types
from azure.core.polling import LROPoller
LROPoller[JSON] # For test run operations
# Async equivalents
from azure.core.polling import AsyncLROPoller
AsyncLROPoller[JSON] # For async test run operations
# Pagination types
from typing import Iterable, AsyncIterable
Iterable[JSON] # For sync list operations
AsyncIterable[JSON] # For async list operations
# Credential types
from azure.core.credentials import TokenCredential
from azure.core.credentials_async import AsyncTokenCredential
# HTTP types for custom requests
from azure.core.rest import HttpRequest, HttpResponse, AsyncHttpResponse
# Time handling
from datetime import datetime