แก้ไข

แชร์ผ่าน


Quickstart: Automate an existing load test with CI/CD

In this article, you learn how to automate an existing load test by creating a CI/CD pipeline in Azure Pipelines. Select your test in Azure Load Testing, and directly configure a pipeline in Azure DevOps that triggers your load test with every source code commit. Automate load tests with CI/CD to continuously validate your application performance and stability under load.

If you want to automate your load test with GitHub Actions, learn how to manually configure a CI/CD pipeline for Azure Load Testing.

Prerequisites

Configure a CI/CD pipeline

In this section, you'll create a CI/CD pipeline in Azure Pipelines to run an existing load test. The test files like JMeter script and test configuration YAML will be committed to your repository.

  1. In the Azure portal, go to your Azure load testing resource.

  2. On the left pane, select Tests to view the list of tests.

  3. Select a test from the list by selecting the checkbox, and then select Set up CI/CD.

    Screenshot that shows the list of tests in Azure portal.

  4. Enter the following details for creating a CI/CD pipeline definition:

    Setting Value
    Organization Select the Azure DevOps organization where you want to run the pipeline from.
    Project Select the project from the organization selected above.
    Repository Select the source code repository to store and run the Azure pipeline from.
    Branch Select the branch in the selected repository.
    Repository branch folder (Optional) Enter the repository branch folder name in which you'd like to commit. If empty, the root folder is used.
    Override existing files Check this setting.
    Service connection Select Create new to create a new service connection to allow Azure Pipelines to connect to the load testing resource.

    If you already have a service connection with the Load Test Contributor role on the resource, choose Select existing and select the service connection from the dropdown list.

    Screenshot that shows the settings to be configured to set up a CI/CD pipeline.

    Important

    If you're getting an error creating a PAT token, or you don't see any repositories, make sure to connect your Azure DevOps organization to Microsoft Entra ID. Make sure the directory in Azure DevOps matches the directory you're using for Azure Load Testing. After connecting to Microsoft Entra ID, close and reopen your browser window.

  5. Select Create Pipeline to start creating the pipeline definition.

    Azure Load Testing performs the following steps to configure the CI/CD pipeline:

    • Create a new service connection of type Azure Resource Manager in the Azure DevOps project. The service principal is automatically assigned the Load Test Contributor role on the Azure load testing resource.

    • Commit the JMeter script and test configuration YAML to the source code repository.

    • Create a pipeline definition that invokes the Azure load testing resource and runs the load test.

  6. When the pipeline creation finishes, you receive a notification in the Azure portal with a link to the pipeline.

  7. Optionally, you can open the pipeline definition and modify the pipeline steps or change when the pipeline is triggered.

You now have a CI/CD pipeline in Azure Pipelines that invokes your load test when the pipeline is triggered. By default, the pipeline is triggered whenever you push an update to the selected branch.

Screenshot that shows the Azure pipeline in Azure DevOps that was generated by Azure Load Testing.

Grant permission to service connection

When you run the CI/CD pipeline for the first time, you need to grant permission to the pipeline to access the service connection and start the load test.

  1. Sign in to your Azure DevOps organization (https://dev.azure.com/<your-organization>), and select your project.

    Replace the <your-organization> text placeholder with your project identifier.

  2. Select Pipelines in the left navigation, and then select your pipeline.

    Notice that the pipeline run status is Pending.

  3. Select the pending pipeline run, and then select View.

    An alert message is shown that the pipeline needs permission to access the load test resource.

    Screenshot that shows the alert message that the Azure pipeline run needs permission to access a resource.

  4. Select Permit, and then select Permit again in the confirmation window.

    Screenshot that shows the grant permission window in Azure Pipelines to grant access to the service connection for running a load test.

The CI/CD pipeline run now starts and accesses the Azure load testing resource to run the test.

View load test results in CI/CD

You can view the load test summary results directly in the CI/CD output log.

Screenshot that shows the Azure Pipelines output log information, highlighting the load testing results.

The generated CI/CD pipeline publishes the load test results as a pipeline artifact. You can download these results as a CSV file for further reporting.

Screenshot that shows the artifacts page for pipeline run in Azure Pipelines, highlighting the load test results zip file.

Next steps

You've configured a CI/CD pipeline in Azure Pipelines for an existing load test.