Hands-on demo – Identify performance regressions with Azure Load Testing and GitHub Actions
To identify performance regressions with Azure Load Testing and GitHub Actions, you can integrate load testing into your CI/CD pipeline. This ensures performance metrics are evaluated with every change in code, helping catch regressions early.
Here goes a step-by-step guide to setup the performance regression testing in Azure Load Testing and GitHub Actions.
1. Prerequisites
Azure Load Testing resource in your Azure subscription.
JMeter script (
.jmx) for your load test.GitHub repository integrated with your application.
Azure service principal with required permissions to interact with the Azure Load Testing resource.
2. Create an Azure Load Testing Resource
In the Azure Portal, navigate to Create a Resource > Load Testing.
Configure the resource and note the resource's details:
Resource Name
Resource Group
Region
3. Prepare Your JMeter Script
The script should define the test scenarios, such as endpoint requests, user load, and response time thresholds.
Example of a simple JMeter test plan:
xxxxxxxxxx101<ThreadGroup>2 <num_threads>10</num_threads>3 <ramp_time>30</ramp_time>4 <loop_count>1</loop_count>5 <HTTPSamplerProxy>6 <HTTPSamplerDomain>example.com</HTTPSamplerDomain>7 <HTTPSamplerPath>/api/endpoint</HTTPSamplerPath>8 <HTTPSamplerMethod>GET</HTTPSamplerMethod>9 </HTTPSamplerProxy>10</ThreadGroup>Save this as load-test.jmx.
4. Set Up GitHub Actions for Azure Load Testing
4.1 Add Azure Service Principal Credentials
In your GitHub repository, go to Settings > Secrets and Variables > Actions.
Add the following secrets:
AZURE_CLIENT_ID(Service principal’s app ID)AZURE_TENANT_ID(Azure AD tenant ID)AZURE_CLIENT_SECRET(Service principal password)AZURE_SUBSCRIPTION_ID(Subscription ID)LOAD_TEST_RESOURCE(Name of your Azure Load Testing resource)LOAD_TEST_RESOURCE_GROUP(Resource group name)
4.2 Create a GitHub Actions Workflow
Add a .github/workflows/load-testing.yml file in your repository.
xxxxxxxxxx391nameAzure Load Testing2on3 push4 branches5main6 pull_request7jobs8 load-test9 runs-onubuntu-latest10 steps11nameCheckout Code12 usesactions/checkout@v313nameLogin to Azure14 usesazure/login@v115 with16 client-id$ secrets.AZURE_CLIENT_ID 17 tenant-id$ secrets.AZURE_TENANT_ID 18 client-secret$ secrets.AZURE_CLIENT_SECRET 19nameUpload JMeter Script to Azure Load Testing20 run21 az load test upload-file \22 --resource-group ${{ secrets.LOAD_TEST_RESOURCE_GROUP }} \23 --resource-name ${{ secrets.LOAD_TEST_RESOURCE }} \24 --file-path ./load-test.jmx \25 --file-name load-test.jmx26nameRun Load Test27 run28 az load test run \29 --resource-group ${{ secrets.LOAD_TEST_RESOURCE_GROUP }} \30 --resource-name ${{ secrets.LOAD_TEST_RESOURCE }} \31 --test-id my-test \32 --test-name "GitHub Actions Load Test"33nameCheck Test Results34 run35 results=$(az load test-run show \36 --resource-group ${{ secrets.LOAD_TEST_RESOURCE_GROUP }} \37 --resource-name ${{ secrets.LOAD_TEST_RESOURCE }} \38 --test-run-id my-test)39 echo $results5. Workflow Details
Login to Azure: Authenticates using the service principal.
Upload JMeter Script: Uploads the load test definition (
.jmx) to Azure Load Testing.Run the Test: Executes the test using the
az load test runcommand.Check Results: Retrieves and prints the results of the load test.
6. Analyze Results for Performance Regressions
Use the Azure CLI or Azure Portal to view the results:
Response Time: Ensure response times meet your thresholds.
Error Rates: Check for increases in HTTP errors.
Throughput: Validate sustained request processing rates.
Set performance thresholds in your pipeline: Example: Fail the pipeline if the average response time exceeds 500ms or if the error rate is above 1%.
7. Example: Conditional Pass/Fail Based on Results
Add a step to analyze results and fail the workflow if thresholds are breached.
xxxxxxxxxx111nameValidate Test Results2 run3 results=$(az load test-run show \4 --resource-group ${{ secrets.LOAD_TEST_RESOURCE_GROUP }} \5 --resource-name ${{ secrets.LOAD_TEST_RESOURCE }} \6 --test-run-id my-test)7 avgResponseTime=$(echo $results | jq '.metrics.avgResponseTime')8 if [ "$avgResponseTime" -gt 500 ]; then9 echo "Average response time exceeded threshold. Failing workflow."10 exit 111 fi8. Monitor and Improve
Use Azure Monitor Logs and Application Insights for detailed telemetry.
Set up alerts for SLA breaches.
Continuously improve your application based on findings.
Summary
This integration ensures that performance regressions are detected automatically, helping maintain application quality and reliability. Feel free to write in comments and let me know if you need further help with specific steps.






















Leave a Reply