Skip to content

Commit 0ab41d3

Browse files
Merge pull request #261230 from ntrogh/alt-cicd-other
[Azure Load Testing] Add instructions for other CI tools
2 parents 1f6b60e + 8915e35 commit 0ab41d3

File tree

1 file changed

+114
-8
lines changed

1 file changed

+114
-8
lines changed

articles/load-testing/how-to-configure-load-test-cicd.md

Lines changed: 114 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
---
22
title: 'Manually configure CI/CD for load tests'
33
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.'
55
author: ntrogh
66
ms.author: nicktrog
77
ms.service: load-testing
88
ms.topic: how-to
99
ms.date: 06/05/2023
1010
---
1111

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
1313

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

1616
To add an existing load test to a CI/CD pipeline:
1717

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.
2020
- Update the CI/CD pipeline definition to invoke Azure Load Testing.
2121

2222
## Prerequisites
@@ -31,6 +31,10 @@ To add an existing load test to a CI/CD pipeline:
3131
- A GitHub account. If you don't have a GitHub account, you can [create one for free](https://github.com/).
3232
- 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).
3333

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+
3438
---
3539

3640
## Configure service authentication
@@ -106,9 +110,11 @@ Create a service principal in the Azure subscription and assign the Load Test Co
106110
1. Create a service principal and assign the `Load Test Contributor` role:
107111

108112
```azurecli-interactive
113+
# Get the resource ID for the load testing resource - replace the text place holders.
109114
loadtest=$(az resource show -g <resource-group-name> -n <load-testing-resource-name> --resource-type "Microsoft.LoadTestService/loadtests" --query "id" -o tsv)
110115
echo $loadtest
111116
117+
# Create a service principal and assign the Load Test Contributor role - the scope is limited to the load testing resource.
112118
az ad sp create-for-rbac --name "my-load-test-cicd" --role "Load Test Contributor" \
113119
--scopes $loadtest \
114120
--json-auth
@@ -161,13 +167,67 @@ To create a GitHub Actions secret:
161167
162168
You can now access your Azure subscription and load testing resource from your GitHub Actions workflow by using the stored credentials.
163169
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.
186+
loadtest=$(az resource show -g <resource-group-name> -n <load-testing-resource-name> --resource-type "Microsoft.LoadTestService/loadtests" --query "id" -o tsv)
187+
echo $loadtest
188+
189+
# Create a service principal and assign the Load Test Contributor role - the scope is limited to the load testing resource.
190+
az ad sp create-for-rbac --name "my-load-test-cicd" --role "Load Test Contributor" \
191+
--scopes $loadtest \
192+
--json-auth
193+
```
194+
195+
The output is a JSON object that represents the service principal.
196+
197+
```output
198+
Creating 'Load Test Contributor' role assignment under scope
199+
{
200+
"clientId": "00000000-0000-0000-0000-000000000000",
201+
"clientSecret": "00000000-0000-0000-0000-000000000000",
202+
"subscriptionId": "00000000-0000-0000-0000-000000000000",
203+
"tenantId": "00000000-0000-0000-0000-000000000000",
204+
"activeDirectoryEndpointUrl": "https://login.microsoftonline.com",
205+
"resourceManagerEndpointUrl": "https://management.azure.com/",
206+
"activeDirectoryGraphResourceId": "https://graph.windows.net/",
207+
"sqlManagementEndpointUrl": "https://management.core.windows.net:8443/",
208+
"galleryEndpointUrl": "https://gallery.azure.com/",
209+
"managementEndpointUrl": "https://management.core.windows.net/"
210+
}
211+
```
212+
213+
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+
164217
---
165218
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.
167222
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:
169224
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:
171231
172232
1. In the [Azure portal](https://portal.azure.com/), go to your Azure Load Testing resource.
173233
@@ -298,6 +358,42 @@ Update your GitHub Actions workflow to run a load test for your Azure load testi
298358
path: ${{ github.workspace }}/loadTest
299359
```
300360
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+
301397
---
302398
303399
## 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
338434
1. If you created a new workflow definition, delete the workflow YAML file in the `.github/workflows` folder.
339435
1. If you modified an existing workflow definition, undo the modifications for running the load test, and save the workflow.
340436
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)
441+
```
442+
443+
# [Other](#tab/otherci)
444+
445+
1. Undo the changes in your CI workflow.
446+
341447
1. Remove the service principal:
342448
343449
```azurecli-interactive

0 commit comments

Comments
 (0)