- How to set up a pipeline in Azure DevOps to run your Artillery tests
- How to generate and view Artillery test reports from Azure Pipelines
- How to schedule your Artillery tests to run at a specific time
- How to use Artillery Pro in Azure Pipelines
Integrating Artillery with Azure DevOps allows you to continuously track your service’s performance while developing your applications. The following guide will show you how to load-test your services using the Azure Pipelines functionality that’s a part of the family of Azure DevOps Services.
You can find the complete source code used in this guide in the Artillery CI/CD Examples GitHub repo.
In this guide, we’ll use the following Artillery test script to run a load test on a running Socket.IO service, sending 50 virtual users per second for 10 minutes and ensuring the aggregate maximum latency for the test is under 500 milliseconds:
In an existing Azure DevOps project, go to the Pipelines section and create a new pipeline. This brings up the New Pipeline creation wizard. First, you need to point Azure to the code repository containing your Artillery test scripts to use for continuous integration. Azure DevOps supports the most popular code hosting services, but you can use any accessible Git or Subversion code repository:
For this guide, we’ll use a GitHub code repository as an example. After granting permissions to GitHub, select the code repository containing your tests.
Next, Azure DevOps offers a few options to help configure your pipeline, depending on your code repository. In this guide, we’ll select the Starter pipeline that provides the basics of an Azure Pipelines setup.
In the last step of the setup wizard, you can modify the starter configuration file to suit your needs. The configuration file for the pipeline is defined through a file usually named
azure-pipelines.yml at the root of your code repository. The configuration files use YAML syntax to determine the events that will trigger your workflow and the jobs and steps to execute.
You can modify the configuration file directly in the setup wizard. For this guide, the Artillery load test for the Socket.IO service will run after pushing new code to the
main branch of your repository. The pipeline will install the Node.js version 12 and install Artillery before executing the test script as part of the CI setup.
Update the configuration with the following contents:
After updating the configuration file, click the Save and run button. You’ll get a prompt to commit the
azure-pipelines.yml file into your code repository. Once you commit the file into your repository’s
main branch, Azure DevOps will execute the load test:
Artillery can output a JSON file with additional details from the load test and use it to generate a self-contained HTML report.
First, your workflow needs to create a directory to place the test reports. Next, you can generate a JSON report when executing the Artillery load test. You can then use the
report command to generate the HTML report from the JSON file. Finally, you’ll need to store the files as artifacts to access the reports upon completion of the workflow.
The configuration to accomplish these steps is the following:
After successfully executing the load test, Azure DevOps will store the files inside the reports directory created as part of the workflow. You can find the published artifacts under the “Related” section of the test run results:
For more details on accessing the artifacts in Azure Pipelines, read the “Artifacts in Azure Pipelines overview” section in the Azure DevOps documentation.
You can also trigger an Azure Pipelines run on a recurring schedule which is helpful if you want to execute your Artillery load tests at a specific time. For instance, you may wish to load-test your production applications outside of peak hours.
schedules trigger can be configured using the POSIX cron syntax, with the times in UTC. The following configuration will automatically trigger Azure Pipelines to run every day at midnight UTC:
For more details about scheduling test runs in Azure DevOps, read the “Configure schedules for pipelines” section in the Azure DevOps documentation.
You can scale your load tests by using Artillery Pro to execute your tests. Artillery Pro allows you to run your Artillery tests from different geographic regions within your AWS infrastructure.
To use Artillery Pro with Azure DevOps, you must have previously deployed the Artillery Pro backend to your AWS account. You also must set up the following environment variables as secret variables in your pipeline:
AWS_ACCESS_KEY_ID- The access key ID of an IAM user with permissions to access the Artillery Pro backend resources.
AWS_SECRET_ACCESS_KEY- The secret access key of the IAM user.
The following configuration will execute your Artillery test script on an Artillery Pro backend deployed in the
us-east-1 region using the
AWS_SECRET_ACCESS_KEY values set as environment variables using the secret variables set above:
For more options on executing your tests using Artillery Pro, check the Pro Commands section in the Command Line guide.