Skip to content

Commit

Permalink
Set baseUrl as env var, add README for perf tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cshnimble committed Jan 23, 2024
1 parent 8e91419 commit 7a6e157
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 10 deletions.
27 changes: 27 additions & 0 deletions Dfe.Academies.Performance/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Academies API Performance tests

This directory holds the performance test scripts for the Academies API.

Tests are written for the [k6](https://k6.io) performance testing tool.

## Setup

You will need k6 installed to be able to run these tests. Details on how to do so are available in their [documentation](https://grafana.com/docs/k6/latest/get-started/installation/).

## Configuration

The variables you will need to set are defined below:

| Variable | Description | Example |
|---|---|---|
| `BASE_URL` | The url of the service to be tested | `https//localhost:5001` |

## Running the tests

To run an individual script, navigate to the correct directory and run

`k6 run -e BASE_URL=<your-value> <your-script-name>`

## Results

By default, metrics are output to the console at the end of the tests, including any checks that are run as part of the test scripts.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const options = {
duration: '30s'
}

const baseUrl = 'https://localhost:5001'
const baseUrl = __ENV.BASE_URL

export default function () {

Expand Down
2 changes: 1 addition & 1 deletion Dfe.Academies.Performance/scripts/v2/baselineTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const options = {
duration: '30s'
}

const baseUrl = 'https://localhost:5001/v2'
const baseUrl = `${__ENV.BASE_URL}/v2`

export default function () {

Expand Down
2 changes: 1 addition & 1 deletion Dfe.Academies.Performance/scripts/v2/fssProjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const options = {
duration: '30s'
}

const baseUrl = 'https://localhost:5001/v2'
const baseUrl = `${__ENV.BASE_URL}/v2`

export default function () {

Expand Down
2 changes: 1 addition & 1 deletion Dfe.Academies.Performance/scripts/v3/trusts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const options = {
duration: '30s'
}

const baseUrl = 'https://localhost:5001/v3'
const baseUrl = `${__ENV.BASE_URL}/v3`

export default function () {

Expand Down
5 changes: 2 additions & 3 deletions Dfe.Academies.Performance/scripts/v4/establishments.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { check, sleep } from 'k6'

export const options = {
vus: 20,
duration: '30s',
// httpDebug: 'full',
duration: '30s'
}

const baseUrl = 'https://localhost:5001/v4'
const baseUrl = `${__ENV.BASE_URL}/v4`

export default function () {

Expand Down
5 changes: 2 additions & 3 deletions Dfe.Academies.Performance/scripts/v4/trusts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { check, sleep } from 'k6'

export const options = {
vus: 20,
duration: '30s',
// httpDebug: 'full',
duration: '30s'
}

const baseUrl = 'https://localhost:5001/v4'
const baseUrl = `${__ENV.BASE_URL}/v4`

export default function () {

Expand Down

0 comments on commit 7a6e157

Please sign in to comment.