Test plans for load testing GOV.UK frontend apps using Gatling.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
project
scripts
src/test
.gitignore
LICENCE
README.md Move test-data-scripts into a scripts folder Jan 16, 2019
build.sbt
test-data

README.md

GOV.UK Load Testing

Test plans for load testing GOV.UK frontend apps using Gatling.

In this README, $GATLING_HOME is the directory where Gatling is installed to.

For example, if you download version 3.0.0-RC4 of the Gatling bundle zip and extract it in your ~/Downloads folder, $GATLING_HOME is ~/Downloads/gatling-charts-highcharts-bundle-3.0.0-RC4

Set up

  1. Install a JDK, Gatling needs at least version 8

  2. Download and extract Gatling, these test plans are written for version 3

  3. Copy or symlink the src/test/scala/govuk directory in this repository to $GATLING_HOME/user-files/simulations/

How to run a test plan

We use Java properties to pass options to the script which we don't want to hard-code. These can be set using the JAVA_OPTS environment variable:

> export JAVA_OPTS="-Dkey1=value1 -Dkey2=value2 ..."

The following property is required:

  • baseUrl, prepended to all requests, at the least it should include the scheme and domain name

The following properties are necessary depending on the environment or scenario:

  • username, the HTTP basic auth username
  • password, the HTTP basic auth password

The property signonUrl and environment variables USERNAME and PASSWORD are required for scenarios authenticating with a signon application.

The following properties are optional:

  • dataDir (default: "test-data"), the directory to look in for test data files
  • rateLimitToken (default: no header sent), the value of the Rate-Limit-Token header
  • workers (default: 1), the number of threads making requests
  • ramp (default: 0), the duration, in seconds, over which the workers are started
  • bust (default: false), whether to pass a unique cache-busting string with every request or not

These properties can be set using the JAVA_OPTS environment variable:

On a single machine

Gatling provides a wrapper script to compile and launch test plans in its user-files directory:

> $GATLING_HOME/bin/gatling.sh
GATLING_HOME is set to /Users/michaelswalker/Downloads/gatling-charts-highcharts-bundle-3.0.0-RC4
Choose a simulation number:
     [0] computerdatabase.BasicSimulation
     [1] computerdatabase.advanced.AdvancedSimulationStep01
     [2] computerdatabase.advanced.AdvancedSimulationStep02
     [3] computerdatabase.advanced.AdvancedSimulationStep03
     [4] computerdatabase.advanced.AdvancedSimulationStep04
     [5] computerdatabase.advanced.AdvancedSimulationStep05
     [6] govuk.Frontend

"computerdatabase" is a collection of example test plans for http://computer-database.gatling.io

Across multiple machines

to do

https://gatling.io/docs/3.0/cookbook/scaling_out/

List of test plans

Tets plans live in the src/test/scala directory. Their data files live in the src/test/resources directory.

govuk.Frontend

Data files: paths.csv

Properties: factor (default: 1), the multiplier to apply to the amount of desired traffic

For an entry base_path,hits, each worker requests base_path ceil(hits * factor / workers) times, with no delay between requests. Each worker proceeds through the csv in order.

If you are having difficulty running the entire test plan on a single machine within your desired duration, try splitting up the data file and running multiple instances of Gatling simultaneously on different machines.

govuk.WhitehallPublishing

Requires: signonUrl property. USERNAME and PASSWORD environment variables.

Optional: schedule property will schedule publication.
This value must be a timestamp in the format yyyy-MM-ddTHH:mm (eg. 2019-01-10T17:30). The value must be at least 15 minutes before the test run as Whitehall enforces this rule for scheduled publishing.

Steps:

  • Authenticates with signon
  • Drafts a publication
  • Attaches an HTML attachment
  • Tags to taxonomy
  • Force publishes or force schedules

govuk.WhitehallPublishingCollections

Requires: signonUrl property. USERNAME and PASSWORD environment variables.

Optional: documentSearches property - How many document searches to make when adding to the collection.

Steps:

  • Authenticates with signon
  • Drafts a collection
  • Searches for Gatling Test publications
  • Adds search results to collection
  • Tags to taxonomy
  • Force publishes

Troubleshooting

My requests are being rate limited

Set the rateLimitToken property, and make sure the token is valid for the environment you're testing. These tokens live in the encrypted hieradata in govuk-secrets.