Skip to content

Commit b3478cd

Browse files
NRL-1666 Tidy up for review as-is
1 parent d2a05e4 commit b3478cd

File tree

5 files changed

+14
-59
lines changed

5 files changed

+14
-59
lines changed

Makefile

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ TF_WORKSPACE_NAME ?= $(shell terraform -chdir=terraform/infrastructure workspace
1313
ENV ?= dev
1414
ACCOUNT ?= dev
1515
APP_ALIAS ?= default
16-
# HOST ?= $(TF_WORKSPACE_NAME).api.record-locator.$(ENV).national.nhs.uk
17-
# HOST ?= dev.api.record-locator.$(ENV).national.nhs.uk
18-
# HOST ?= perftest.record-locator.national.nhs.uk
19-
HOST ?= api.perftest.record-locator.national.nhs.uk
16+
HOST ?= $(TF_WORKSPACE_NAME).api.record-locator.$(ENV).national.nhs.uk
2017
ENV_TYPE ?= $(ENV)
21-
# PERFTEST_TABLE_NAME ?= nhsd-nrlf--xaxel-deleteme-pointers-table
2218
PERFTEST_TABLE_NAME ?= perftest
19+
PERFTEST_HOST ?= api.perftest.record-locator.national.nhs.uk
2320

2421
export PATH := $(PATH):$(PWD)/.venv/bin
2522
export USE_SHARED_RESOURCES := $(shell poetry run python scripts/are_resources_shared_for_stack.py $(TF_WORKSPACE_NAME))
@@ -255,32 +252,28 @@ generate-models: check-warn ## Generate Pydantic Models
255252
generate-perftest-permissions: ## Generate perftest permissions and add to nrlf_permissions
256253
poetry run python tests/performance/producer/generate_permissions.py --output_dir="$(DIST_PATH)/nrlf_permissions/K6PerformanceTest"
257254

258-
# Run producer performance tests with configurable HOST and ENV_TYPE
259255
perftest-producer:
260-
@echo "Running producer performance tests with HOST=$(HOST) and ENV_TYPE=$(ENV_TYPE) and DIST_PATH=$(DIST_PATH)"
261-
k6 run tests/performance/producer/perftest.js -e HOST=$(HOST) -e ENV_TYPE=$(ENV_TYPE) -e DIST_PATH=$(DIST_PATH)
256+
@echo "Running producer performance tests with HOST=$(PERFTEST_HOST) and ENV_TYPE=$(ENV_TYPE) and DIST_PATH=$(DIST_PATH)"
257+
k6 run tests/performance/producer/perftest.js -e HOST=$(PERFTEST_HOST) -e ENV_TYPE=$(ENV_TYPE) -e DIST_PATH=$(DIST_PATH)
262258

263-
264-
# perftest-consumer: perftest-prep-generate-pointer-table-extract generate-perftest-permissions
265259
perftest-consumer:
266-
@echo "Running consumer performance tests with HOST=$(HOST) and ENV_TYPE=$(ENV_TYPE) and DIST_PATH=$(DIST_PATH)"
267-
k6 run tests/performance/consumer/perftest.js -e ENV_TYPE=$(ENV_TYPE) -e DIST_PATH=$(DIST_PATH) -e HOST=$(HOST)
260+
@echo "Running consumer performance tests with HOST=$(PERFTEST_HOST) and ENV_TYPE=$(ENV_TYPE) and DIST_PATH=$(DIST_PATH)"
261+
k6 run tests/performance/consumer/perftest.js -e HOST=$(PERFTEST_HOST) -e ENV_TYPE=$(ENV_TYPE) -e DIST_PATH=$(DIST_PATH)
268262

269263
perftest-prep-generate-producer-data:
264+
@echo "Generating producer reference with PERFTEST_TABLE_NAME=$(PERFTEST_TABLE_NAME) and DIST_PATH=$(DIST_PATH)"
270265
mkdir -p $(DIST_PATH)
271266
PYTHONPATH=. poetry run python tests/performance/perftest_environment.py generate_producer_data --output_dir="$(DIST_PATH)"
272267

273268
perftest-prep-extract-consumer-data:
269+
@echo "Generating consumer reference with PERFTEST_TABLE_NAME=$(PERFTEST_TABLE_NAME) and DIST_PATH=$(DIST_PATH)"
274270
mkdir -p $(DIST_PATH)
275271
PYTHONPATH=. poetry run python tests/performance/perftest_environment.py extract_consumer_data --output_dir="$(DIST_PATH)"
276272

277273
perftest-prep-generate-pointer-table-extract:
274+
@echo "Generating pointer table extract with PERFTEST_TABLE_NAME=$(PERFTEST_TABLE_NAME) and DIST_PATH=$(DIST_PATH)"
278275
mkdir -p $(DIST_PATH)
279276
PYTHONPATH=. poetry run python tests/performance/perftest_environment.py generate_pointer_table_extract --output_dir="$(DIST_PATH)"
280277

281278
perftest-prepare: perftest-prep-generate-producer-data perftest-prep-extract-consumer-data perftest-prep-generate-pointer-table-extract
282279
@echo "Prepared performance tests with PERFTEST_TABLE_NAME=$(PERFTEST_TABLE_NAME) and DIST_PATH=$(DIST_PATH)"
283-
284-
# perftest-seed-data: perftest-prepare
285-
# @echo "Seeding dynamo with data for performance tests with table_name=$(PERFTEST_TABLE_NAME) and ENV_TYPE=$(ENV_TYPE)"
286-
# poetry run python tests/performance/consumer/perftest.js --table_name="$(PERFTEST_TABLE_NAME)" --px_with_pointers="" --pointers_per_px="" --type_dists="" --custodian_dists=""

tests/performance/README.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
11
# Performance Testing
22

3+
<!-- TODO: make this proper -->
4+
35
some high level context short
46

57
## Run perf tests
68

7-
### Prepare
8-
99
```sh
1010
assume management
1111
make truststore-pull-all ENV=<env> # e.g. perftest
1212
cd ./terraform/infrastructure
1313
tf workspace select # perftest-1 or active stack
1414
cd ../../ # project root
15-
assume dev
16-
make perftest-prepare PERFTEST_TABLE_NAME=<POINTER_TABLE_NAME>
15+
assume
16+
make perftest-prepare PERFTEST_TABLE_NAME=<pointer table name>
1717

1818
make perftest-consumer ENV_TYPE=<env> # e.g. perftest
1919
```
2020
21-
choose existing table name/create table with this script > `PERFTEST_TABLE_NAME` env var
22-
makes these files
23-
24-
### Run
25-
26-
these/find profiles available
27-
28-
### Outputs
29-
30-
handy bits
21+
<!-- Mention relevant input files + any environment prep needed e.g. restoring tables from backup -->

tests/performance/constants.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ export const POINTERS_TO_DELETE = ALL_POINTER_IDS.slice(0, 3500);
1515
export const POINTER_IDS = ALL_POINTER_IDS.slice(3500);
1616
export const NHS_NUMBERS = REFERENCE_DATA["nhs_numbers"];
1717

18-
// export const POINTER_TYPES = CATEGORY_TYPE_GROUPS.flatMap((group) =>
19-
// group.types.map((t) => t.code)
20-
// );
2118
// filter only 736253001, 736253002, 1363501000000100, 861421000000109, 749001000000101 for now
2219
export const FILTERED_POINTER_TYPES = [
2320
"736253001",

tests/performance/consumer/client_perftest.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@ const lines = csv.trim().split("\n");
1111
// Skip header
1212
const dataLines = lines.slice(1);
1313

14-
// console.log("__ENV", JSON.stringify(__ENV, null, 2));
15-
console.log("__ENV.HOST", JSON.stringify(__ENV.HOST, null, 2));
16-
1714
function getNextPointer() {
1815
// pick the next line according to iteration in scenario
1916
const iter = exec.vu.iterationInScenario;
2017
const index = iter % dataLines.length;
2118
const line = dataLines[index];
22-
console.log("🚀 ~ getNextPointer ~ line:", line);
2319
const [count, pointer_id, pointer_type, custodian, nhs_number] = line
2420
.split(",")
2521
.map((field) => field.trim());
@@ -50,7 +46,6 @@ function getCustodianFromPointerId(pointer_id) {
5046
function checkResponse(res) {
5147
const is_success = check(res, { "status is 200": (r) => r.status === 200 });
5248
if (!is_success) {
53-
console.log("🚀 ~ checkResponse ~ res.status:", res.status);
5449
console.warn(res.json());
5550
}
5651
}
@@ -69,10 +64,6 @@ export function countDocumentReference() {
6964
`https://fhir.nhs.uk/Id/nhs-number|${nhs_number}`
7065
);
7166

72-
console.log(
73-
"🚀 ~ countDocumentReference ~ `https://${__ENV.HOST}/consumer/DocumentReference?_summary=count&subject:identifier=${identifier}`:",
74-
`https://${__ENV.HOST}/consumer/DocumentReference?_summary=count&subject:identifier=${identifier}`
75-
);
7667
const res = http.get(
7768
`https://${__ENV.HOST}/consumer/DocumentReference?_summary=count&subject:identifier=${identifier}`,
7869
{
@@ -86,8 +77,6 @@ export function readDocumentReference() {
8677
const { pointer_id } = getNextPointer();
8778
const custodian = getCustodianFromPointerId(pointer_id);
8879

89-
console.log("🚀 ~ countDocumentReference ~ __ENV.HOST:", __ENV.HOST);
90-
9180
const res = http.get(
9281
`https://${__ENV.HOST}/consumer/DocumentReference/${pointer_id}`,
9382
{
@@ -107,8 +96,6 @@ export function searchDocumentReference() {
10796
);
10897
const type = encodeURIComponent(`http://snomed.info/sct|${pointer_type}`);
10998

110-
console.log("🚀 ~ countDocumentReference ~ __ENV.HOST:", __ENV.HOST);
111-
11299
const res = http.get(
113100
`https://${__ENV.HOST}/consumer/DocumentReference?subject:identifier=${identifier}&type=${type}`,
114101
{
@@ -130,8 +117,6 @@ export function searchDocumentReferenceByCategory() {
130117
`http://snomed.info/sct|${category_code}`
131118
);
132119

133-
console.log("🚀 ~ countDocumentReference ~ __ENV.HOST:", __ENV.HOST);
134-
135120
const res = http.get(
136121
`https://${__ENV.HOST}/consumer/DocumentReference?subject:identifier=${identifier}&category=${category}`,
137122
{
@@ -150,8 +135,6 @@ export function searchPostDocumentReference() {
150135
type: `http://snomed.info/sct|${pointer_type}`,
151136
});
152137

153-
console.log("🚀 ~ countDocumentReference ~ __ENV.HOST:", __ENV.HOST);
154-
155138
const res = http.post(
156139
`https://${__ENV.HOST}/consumer/DocumentReference/_search`,
157140
body,
@@ -172,8 +155,6 @@ export function searchPostDocumentReferenceByCategory() {
172155
category: `http://snomed.info/sct|${category_code}`,
173156
});
174157

175-
console.log("🚀 ~ countDocumentReference ~ __ENV.HOST:", __ENV.HOST);
176-
177158
const res = http.post(
178159
`https://${__ENV.HOST}/consumer/DocumentReference/_search`,
179160
body,
@@ -192,7 +173,6 @@ export function countPostDocumentReference() {
192173
"subject:identifier": `https://fhir.nhs.uk/Id/nhs-number|${nhs_number}`,
193174
});
194175

195-
console.log("🚀 ~ countDocumentReference ~ __ENV.HOST:", __ENV.HOST);
196176
const res = http.post(
197177
`https://${__ENV.HOST}/consumer/DocumentReference/_search?_summary=count`,
198178
body,
@@ -219,8 +199,6 @@ export function searchPostDocumentReferenceAccessDenied() {
219199
"nrl.app-id": "K6PerformanceTest",
220200
});
221201

222-
console.log("🚀 ~ countDocumentReference ~ __ENV.HOST:", __ENV.HOST);
223-
224202
const res = http.post(
225203
`https://${__ENV.HOST}/consumer/DocumentReference/_search`,
226204
body,

tests/performance/perftest_environment.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@
66

77
import boto3
88

9-
# from nhs_number import generate
10-
11-
129
DYNAMODB = boto3.resource("dynamodb", region_name="eu-west-2")
1310

1411
default_table_name = "default-table-name"
15-
# default_table_name = "nhsd-nrlf--xaxel-deleteme-pointers-table"
1612

1713

1814
def _get_pointers_table_name():

0 commit comments

Comments
 (0)