This sub-project contains a solution to generate load on a web application based on the Playwright UI testing framework and Azure Functions.
See Getting Started on how to set this up for your own application.
It contains of the following components:
- Global Orchestrator Azure Function that controls regionally distributed test runner Azure Functions
- User flow test runner Azure Function which are getting deployed to N number of regions
- Terraform infrastructure-as-code definition to deploy the Azure Functions
- Azure DevOps pipeline definition to deploy the infrastructure and the Functions
This graph shows a sample load pattern that has been generated by the User Load Generator over 48 hours:
The user load generator uses the Playwright UI testing framework to generate load on the web application. The load generator does not contain a test definition file itself. Instead, the test definition is defined in a separate file /src/testing/ui-test-playwright/cataloguserflow.spec.js and being injected into the Function as part of the deployment process.
This is a Timer-triggered Azure Function that orchestrates the regional test runner Azure Functions.
For this it reads a load profile definition file daily_load_profile.json
which lets the user define various load patterns per day, split by different geographical regions.
The load profile definition file is a JSON file that contains the following structure:
{
"geos": [
{
"name": "EMEA",
"timezone": "UTC+01:00",
"enabled": true,
"timeframes": [
{
"start": "00:00:00",
"end": "03:00:00",
"numberOfUsers": 1000,
"transitionTimeMinutes": 40
},
//...
}
]
}
geos
: An array of geographical regions.name
: The name of the geographical region. Can be freely chosen but must match what is being used in the Terraform variable definitionregional_functions_workers
(insrc/testing/userload-generator/infra/variables.tf
).timezone
: The time zone of the geographical region, based on offset from UTC.enabled
: A flag to indicate if the geographical region is enabled and should be considered by the orchestrator.timeframes
: An array of timeframes.start
: The start time of the timeframe.end
: The end time of the timeframe.numberOfUsers
: The number of users that should be generated in this timeframe.transitionTimeMinutes
: The number of minutes to ramp up or down to the number of users from the previous timeframe.
Notes:
- Timeframes must not overlap
- Timeframes can be directly adjacent to each other but do not have to. There can be gaps. Gaps are being interpreted as "run 0 users".
This function gets deployed to a number of regionally distributed Azure Functions (as defined in the regional_functions_workers
variable in the Terraform definition). It executes the Playwright test definition file using an actual (headless) Chromium browser.
It is implemented as a Durable Function which gets controlled by the Global Orchestrator via an HttpTrigger. The durable Orchestrator will then kick off N number of local Activity Functions and restart them as soon as one batch is finished. It will do so until it gets a new command (a different number of users to run) by the Global Orchestrator (this is called an "Eternal Orchestrator").
To deploy the user load generator for your own application, you need to:
- Write a playwright test definition file (
cataloguserflow.spec.js
) that targets your web UI application.- Use the example provided here as a starting point. Note how environment variables are being used to pass parameters like the application URL and the user credentials. You can replicate this for other settings you might need.
- Update the
daily_load_profile.json
file with your desired load profile. To validate your profile, is recommended to start with only one geographical region enabled and then gradually add more regions as needed. - Update the Terraform variable file
variables.tf
with the correct values fortargeturl
,regional_functions_workers
and any other variables you might need to reflect test parameters and your geo(s).
To deploy the infrastructure and the Functions, you can use the Azure DevOps pipeline definition (/.ado/pipelines/azure-deploy-loadgenerator.yaml
). Import that pipeline definition into your Azure DevOps project and run the pipeline.