or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

administration.mdindex.mdtest-execution.md

index.mddocs/

0

# Azure Developer LoadTesting

1

2

Microsoft 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.

3

4

## Package Information

5

6

- **Package Name**: azure-developer-loadtesting

7

- **Package Type**: pypi

8

- **Language**: Python

9

- **Installation**: `pip install azure-developer-loadtesting`

10

- **Supported Python Versions**: 3.7+

11

12

## Core Imports

13

14

```python

15

from azure.developer.loadtesting import LoadTestAdministrationClient, LoadTestRunClient

16

```

17

18

For asynchronous operations:

19

20

```python

21

from azure.developer.loadtesting.aio import LoadTestAdministrationClient, LoadTestRunClient

22

```

23

24

## Basic Usage

25

26

```python

27

from azure.core.credentials import DefaultAzureCredential

28

from azure.developer.loadtesting import LoadTestAdministrationClient, LoadTestRunClient

29

30

# Initialize credentials

31

credential = DefaultAzureCredential()

32

endpoint = "https://your-loadtest-resource.loadtest.azure.com"

33

34

# Create clients

35

admin_client = LoadTestAdministrationClient(endpoint=endpoint, credential=credential)

36

run_client = LoadTestRunClient(endpoint=endpoint, credential=credential)

37

38

# Create a load test

39

test_definition = {

40

"displayName": "My Load Test",

41

"description": "Load test for my application"

42

}

43

44

with admin_client:

45

# Create the test

46

test = admin_client.create_or_update_test("my-test-id", test_definition)

47

print(f"Created test: {test['displayName']}")

48

49

# Upload a test script (JMeter .jmx file)

50

with open("test-script.jmx", "rb") as f:

51

upload_result = admin_client.begin_upload_test_file(

52

test_id="my-test-id",

53

file_name="test-script.jmx",

54

body=f,

55

file_type="JMX_FILE"

56

)

57

58

# Execute the test

59

test_run_definition = {

60

"testId": "my-test-id",

61

"displayName": "My Test Run"

62

}

63

64

with run_client:

65

# Start the test run

66

run_poller = run_client.begin_test_run("my-test-run-id", test_run_definition)

67

test_run = run_poller.result()

68

print(f"Test run status: {test_run['status']}")

69

70

# Monitor test run progress

71

test_run = run_client.get_test_run("my-test-run-id")

72

print(f"Current status: {test_run['status']}")

73

```

74

75

## Architecture

76

77

The library provides two primary client interfaces:

78

79

- **LoadTestAdministrationClient**: Manages test definitions, test scripts, application components, and server metrics configuration

80

- **LoadTestRunClient**: Handles test execution, monitoring, metrics collection, and result analysis

81

82

Both clients support:

83

- **Context management** for automatic resource cleanup

84

- **Long Running Operations (LRO)** with polling for file uploads and test execution

85

- **Pagination** for listing operations

86

- **Custom request support** through `send_request()` method

87

- **Synchronous and asynchronous** programming models

88

89

## Capabilities

90

91

### Test Administration

92

93

Complete 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.

94

95

```python { .api }

96

def create_or_update_test(test_id: str, body: Union[JSON, IO], **kwargs) -> JSON: ...

97

def delete_test(test_id: str, **kwargs) -> None: ...

98

def get_test(test_id: str, **kwargs) -> JSON: ...

99

def list_tests(*, orderby: Optional[str] = None, search: Optional[str] = None, **kwargs) -> Iterable[JSON]: ...

100

def begin_upload_test_file(test_id: str, file_name: str, body: IO, **kwargs) -> JSON: ...

101

```

102

103

[Test Administration](./administration.md)

104

105

### Test Execution and Monitoring

106

107

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.

108

109

```python { .api }

110

def begin_test_run(test_run_id: str, body: Union[JSON, IO], *, old_test_run_id: Optional[str] = None, **kwargs) -> LROPoller[JSON]: ...

111

def get_test_run(test_run_id: str, **kwargs) -> JSON: ...

112

def stop_test_run(test_run_id: str, **kwargs) -> JSON: ...

113

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]: ...

114

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]: ...

115

```

116

117

[Test Execution and Monitoring](./test-execution.md)

118

119

## Types

120

121

```python { .api }

122

# Type aliases for API responses and requests

123

JSON = MutableMapping[str, Any]

124

125

# Long Running Operation types

126

from azure.core.polling import LROPoller

127

LROPoller[JSON] # For test run operations

128

129

# Async equivalents

130

from azure.core.polling import AsyncLROPoller

131

AsyncLROPoller[JSON] # For async test run operations

132

133

# Pagination types

134

from typing import Iterable, AsyncIterable

135

Iterable[JSON] # For sync list operations

136

AsyncIterable[JSON] # For async list operations

137

138

# Credential types

139

from azure.core.credentials import TokenCredential

140

from azure.core.credentials_async import AsyncTokenCredential

141

142

# HTTP types for custom requests

143

from azure.core.rest import HttpRequest, HttpResponse, AsyncHttpResponse

144

145

# Time handling

146

from datetime import datetime

147

```