You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/load-testing/how-to-configure-load-test-cicd.md
+114-8Lines changed: 114 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,22 @@
1
1
---
2
2
title: 'Manually configure CI/CD for load tests'
3
3
titleSuffix: Azure Load Testing
4
-
description: 'This article shows how to run your load tests with Azure Load Testing in CI/CD. Learn how to add a load test to GitHub Actions or Azure Pipelines.'
4
+
description: 'This article shows how to run your load tests with Azure Load Testing in CI/CD. Learn how to add a load test to GitHub Actions, Azure Pipelines or other CI tools.'
5
5
author: ntrogh
6
6
ms.author: nicktrog
7
7
ms.service: load-testing
8
8
ms.topic: how-to
9
9
ms.date: 06/05/2023
10
10
---
11
11
12
-
# Manually configure CI/CD for load tests in GitHub Actions or Azure Pipelines
12
+
# Manually configure your CI/CD workflow for running load tests
13
13
14
-
You can automate a load test in Azure Load Testing by creating a CI/CD pipeline. In this article, you learn how to manually configure GitHub Actions or Azure Pipelines to invoke an existing test in Azure Load Testing. Automate a load test to continuously validate your application performance and stability under load.
14
+
You can automate a load test in Azure Load Testing by creating a CI/CD pipeline. In this article, you learn how to manually configure GitHub Actions, Azure Pipelines, or other CI tools to invoke an existing test in Azure Load Testing. Automate a load test to continuously validate your application performance and stability under load.
15
15
16
16
To add an existing load test to a CI/CD pipeline:
17
17
18
-
- Configure service authentication to allow GitHub Actions or Azure Pipelines to connect to your Azure load testing resource.
19
-
-Export the load test configuration files, such as the JMeter file and load test YAML configuration.
18
+
- Configure service authentication to allow the CI tool to connect to your Azure load testing resource.
19
+
-Add load test input files to your repository, such as the JMeter test script and the load test YAML configuration.
20
20
- Update the CI/CD pipeline definition to invoke Azure Load Testing.
21
21
22
22
## Prerequisites
@@ -31,6 +31,10 @@ To add an existing load test to a CI/CD pipeline:
31
31
- A GitHub account. If you don't have a GitHub account, you can [create one for free](https://github.com/).
32
32
- A GitHub repository to store the load test input files and create a GitHub Actions workflow. To create one, see [Creating a new repository](https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-new-repository).
33
33
34
+
# [Other](#tab/otherci)
35
+
- Permission to create or modify a CI pipeline.
36
+
- A source code repository to store the load test input files.
37
+
34
38
---
35
39
36
40
## Configure service authentication
@@ -106,9 +110,11 @@ Create a service principal in the Azure subscription and assign the Load Test Co
106
110
1. Create a service principal and assign the `Load Test Contributor` role:
107
111
108
112
```azurecli-interactive
113
+
# Get the resource ID for the load testing resource - replace the text place holders.
# Create a service principal and assign the Load Test Contributor role - the scope is limited to the load testing resource.
112
118
az ad sp create-for-rbac --name "my-load-test-cicd" --role "Load Test Contributor" \
113
119
--scopes $loadtest \
114
120
--json-auth
@@ -161,13 +167,67 @@ To create a GitHub Actions secret:
161
167
162
168
You can now access your Azure subscription and load testing resource from your GitHub Actions workflow by using the stored credentials.
163
169
170
+
# [Other](#tab/otherci)
171
+
172
+
If you're using another CI/CD tool, you use the Azure CLI to interact with your Azure resources. Perform the following steps to authorize the CI tool access to your load testing resource:
173
+
174
+
1. Create a Microsoft Entra [service principal](/azure/active-directory/develop/app-objects-and-service-principals#service-principal-object) to connect to your Azure subscription and access your Azure load testing resource.
175
+
1. Grant the service principal permissions to create and run a load test by assigning the Load Test Contributor role.
176
+
1. Store the Azure credentials securely in the CI tool.
177
+
178
+
Perform the following steps to configure the service authorization for your CI tool:
179
+
180
+
1. Create a service principal and assign the Load Test Contributor role:
181
+
182
+
Replace the `<resource-group-name>` and `<load-testing-resource-name>` text placeholders.
183
+
184
+
```azurecli-interactive
185
+
# Get the resource ID for the load testing resource - replace the text place holders.
1. Copy the `clientId`, `clientSecret`, and `tenantId` values and securely store them as secrets in your CI tool.
214
+
215
+
You use these values to sign into your Azure subscription with the Azure CLI `az login` command.
216
+
164
217
---
165
218
166
-
## Export load test input files
219
+
## Add load test files in your repository
220
+
221
+
To run a load test with Azure Load Testing in a CI/CD workflow, you need to add all load test input files in your source control repository.
167
222
168
-
To run a load test with Azure Load Testing in a CI/CD workflow, you need to add the load test configuration settings and any input files in your source control repository. If you have an existing load test, you can download the configuration settings and all input files from the Azure portal.
223
+
If you don't have an existing load test, add the following files to your source code repository:
169
224
170
-
Perform the following steps to download the input files for an existing load testing in the Azure portal:
225
+
- Load test configuration YAML file. Learn how you can create a [load test configuration YAML file](./reference-test-config-yaml.md).
226
+
- Test plan file. For JMeter-based tests, add a JMeter test script (`JMX` file). For URL-based tests, add a [requests JSON file](./reference-test-config-yaml.md#requests-json-file).
227
+
- Any [JMeter user properties files](./how-to-configure-user-properties.md).
228
+
- Any input data files that your test plan uses. For example, CSV data files.
229
+
230
+
If you have an existing load test, you can download the configuration settings and all input files directly from the Azure portal. Perform the following steps to download the input files for an existing load testing in the Azure portal:
171
231
172
232
1. In the [Azure portal](https://portal.azure.com/), go to your Azure Load Testing resource.
173
233
@@ -298,6 +358,42 @@ Update your GitHub Actions workflow to run a load test for your Azure load testi
298
358
path: ${{ github.workspace }}/loadTest
299
359
```
300
360
361
+
# [Other](#tab/otherci)
362
+
363
+
Update your CI workflow to run a load test for your Azure load testing resource by using the Azure CLI. Use the specifics of your CI tool to add the following commands to your CI workflow:
364
+
365
+
1. Sign into the Azure subscription by using the service principal.
366
+
367
+
Use the `clientId`, `clientSecret`, and `tenandId` values you stored previously.
368
+
369
+
```azurecli-interactive
370
+
az login --service-principal -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET -t $AZURE_TENANT_ID
371
+
az account set -s $AZURE_SUBSCRIPTION_ID
372
+
```
373
+
374
+
1. Create a load test by using the load test configuration YAML file.
375
+
376
+
Replace the *`<load-testing-resource>`*, *`<load-testing-resource-group>`*, and *`<load-test-config-yaml>`* text placeholders with the name of the load testing resource, the resource group name, and the file name of the load test configuration YAML file you added to the repository previously.
377
+
378
+
```azurecli-interactive
379
+
az load test create --load-test-resource <load-testing-resource> --resource-group <load-testing-resource-group> --test-id sample-test-id --load-test-config-file <load-test-config-yaml>
380
+
```
381
+
382
+
1. Run the load test.
383
+
384
+
```azurecli-interactive
385
+
testRunId="run_"`date +"%Y%m%d%_H%M%S"`
386
+
displayName="Run"`date +"%Y/%m/%d_%H:%M:%S"`
387
+
388
+
az load test-run create --load-test-resource <load-testing-resource> --test-id sample-test-id --test-run-id $testRunId --display-name $displayName --description "Test run from CLI"
389
+
```
390
+
391
+
1. Retrieve and display the client-side metrics for the load test run.
392
+
393
+
```azurecli-interactive
394
+
az load test-run metrics list --load-test-resource <load-testing-resource> --test-run-id $testRunId --metric-namespace LoadTestRunMetrics
395
+
```
396
+
301
397
---
302
398
303
399
## View load test results
@@ -338,6 +434,16 @@ If you don't plan to use any of the resources that you created, delete them so y
338
434
1. If you created a new workflow definition, delete the workflow YAML file in the `.github/workflows` folder.
339
435
1. If you modified an existing workflow definition, undo the modifications for running the load test, and save the workflow.
340
436
437
+
1. Remove the service principal:
438
+
439
+
```azurecli-interactive
440
+
az ad sp delete --id $(az ad sp show --display-name "my-load-test-cicd" -o tsv)
0 commit comments