Skip to content

Commit b0aa7c1

Browse files
committed
Running the flow, but getting 401 errors
1 parent 01b5653 commit b0aa7c1

5 files changed

Lines changed: 33 additions & 52 deletions

File tree

artillery/helper/allowed_odscodes.mjs

Lines changed: 0 additions & 28 deletions
This file was deleted.

artillery/helper/odscodes.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// These ODS codes should match the values in AWS parameter store. They're assumed to be enabled in the whitelist
2+
export const allowedOdsCodes = [
3+
"FA565"
4+
]
5+
6+
export const blockedOdsCodes = [
7+
"B3J1Z"
8+
]

artillery/notify_entrypoint.mjs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {v4 as uuidv4} from "uuid"
22
import pino from "pino"
33
import {getSharedAuthToken, getBody} from "./helper/psu.mjs"
4-
import {allowedOdsCodes} from "./helper/allowed_odscodes.mjs"
4+
import {allowedOdsCodes, blockedOdsCodes} from "./helper/odscodes.mjs"
55

6-
const logger = pino()
6+
export { getSharedAuthToken }
77

8-
const NUM_ODS_CODES = 1000
8+
const logger = pino()
99

1010
const LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
1111
const DIGITS = "0123456789";
@@ -26,8 +26,8 @@ function buildFullOdsCodes(targetCount, seedCodes) {
2626
return Array.from(codes);
2727
}
2828

29-
/** The complete list of 10k ODS codes */
30-
const fullOdsCodes = buildFullOdsCodes(NUM_ODS_CODES, allowedOdsCodes);
29+
// The complete list of ODS codes
30+
const fullOdsCodes = allowedOdsCodes.concat(blockedOdsCodes)
3131

3232
function computeCheckDigit(nhsNumber) {
3333
const factors = [10,9,8,7,6,5,4,3,2]
@@ -71,11 +71,13 @@ export function initUser(context, events, done) {
7171
if (prescriptionCount < 1) prescriptionCount = 1 // just truncate at 1.
7272
context.vars.prescriptionCount = prescriptionCount
7373

74+
logger.info(`Patient ${context.vars.nhsNumber}, ODS ${context.vars.odsCode} has ${context.vars.prescriptionCount} prescriptions`)
75+
7476
done()
7577
}
7678

77-
// beforeEach request
7879
export function generatePrescData(requestParams, context, ee, next) {
80+
logger.info(`Generating a prescription for patient ${context.vars.nhsNumber}`)
7981
const body = getBody(
8082
true, /* isValid */
8183
"ready to collect", /* status */
@@ -91,8 +93,8 @@ export function generatePrescData(requestParams, context, ee, next) {
9193
let delay = sampleNormal(150, 60)
9294
if (delay < 0) delay = 0
9395
context.vars.nextDelay = delay
96+
logger.info(`Patient ${context.vars.nhsNumber} will think for ${context.vars.nextDelay} seconds`)
9497

9598
next()
9699
}
97100

98-
export { getSharedAuthToken }

artillery/notify_load_test.yml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ config:
1212
maxVusers: "{{ $env.maxVusers }}"
1313
environments:
1414
dev:
15-
target: https://internal-dev.api.service.nhs.uk
15+
target: https://internal-dev.api.service.nhs.uk/
1616
ref:
17-
target: https://ref.api.service.nhs.uk
17+
target: https://ref.api.service.nhs.uk/
1818
int:
19-
target: https://int.api.service.nhs.uk
19+
target: https://int.api.service.nhs.uk/
2020
pr:
21-
target: https://psu-pr-{{ prNumber }}.dev.eps.national.nhs.uk
21+
target: https://psu-pr-{{ prNumber }}.dev.eps.national.nhs.uk/
2222
defaults:
2323
headers:
2424
Authorization: "Bearer {{ authToken }}"
@@ -29,21 +29,19 @@ scenarios:
2929
# grab token once per VU
3030
before:
3131
- function: getSharedAuthToken
32-
32+
3333
flow:
3434
- function: initUser
3535

3636
# for each prescription (number of prescriptions is variable)
3737
- loop:
38-
- count: "{{ prescriptionCount }}"
39-
steps:
40-
- beforeRequest: generatePrescData
41-
- post:
42-
url: "/prescription-status-update/"
43-
headers:
44-
x-request-id: "{{ x_request_id }}"
45-
x-correlation-id: "{{ x_correlation_id }}"
46-
expect:
47-
- statusCode: 201
48-
# wait before next prescription
49-
- think: "{{ nextDelay }}"
38+
- post:
39+
url: "/prescription-status-update/"
40+
beforeRequest: "generatePrescData"
41+
headers:
42+
x-request-id: "{{ x_request_id }}"
43+
x-correlation-id: "{{ x_correlation_id }}"
44+
expect:
45+
- statusCode: 201
46+
- think: "{{ nextDelay }}"
47+
count: "{{ prescriptionCount }}"

scripts/test_notify_load_test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ EOF
5555

5656
echo "Running Artillery test locally..."
5757
echo ""
58+
echo "Environment: ${environment}"
5859
echo "Max Virtual Users: ${maxVusers}"
5960
echo "Phase Duration: ${duration}"
6061
echo "Arrival Rate: ${arrivalRate}"

0 commit comments

Comments
 (0)