Skip to content

Commit fff45f5

Browse files
NRL-1841 Tidy up test output
1 parent 5e514d1 commit fff45f5

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ perftest-producer-internal: ## Run producer perf tests
317317
k6 run tests/performance/producer/perftest.js -e HOST=$(PERFTEST_HOST) -e ENV_TYPE=$(ENV_TYPE) -e DIST_PATH=$(DIST_PATH)
318318

319319
perftest-producer-public: check-warn ## Run the producer perftests for the external access points
320-
@echo "Starting token refresher in background with ENV=$(ENV)"
320+
@echo "Starting token refresher in background with ENV=$(ENV) PERFTEST_TOKEN_REFRESH_PORT=$(PERFTEST_TOKEN_REFRESH_PORT)"
321321
ENV=$(ENV) TOKEN_REFRESH_PORT=$(PERFTEST_TOKEN_REFRESH_PORT) PYTHONPATH=. poetry run python ./tests/performance/token_refresher.py &
322322
trap "kill $$(lsof -t -i :$(PERFTEST_TOKEN_REFRESH_PORT)) 2>/dev/null" EXIT
323323
@echo "Fetching public mode configuration..."
@@ -337,7 +337,7 @@ perftest-consumer-internal:
337337
k6 run tests/performance/consumer/perftest.js -e HOST=$(PERFTEST_HOST) -e ENV_TYPE=$(ENV_TYPE) -e DIST_PATH=$(DIST_PATH)
338338

339339
perftest-consumer-public: check-warn ## Run the consumer perftests for the external access points
340-
@echo "Starting token refresher with ENV=$(ENV)"
340+
@echo "Starting token refresher in background with ENV=$(ENV) PERFTEST_TOKEN_REFRESH_PORT=$(PERFTEST_TOKEN_REFRESH_PORT)"
341341
ENV=$(ENV) TOKEN_REFRESH_PORT=$(PERFTEST_TOKEN_REFRESH_PORT) PYTHONPATH=. poetry run python ./tests/performance/token_refresher.py &
342342
trap "kill $$(lsof -t -i :$(PERFTEST_TOKEN_REFRESH_PORT)) 2>/dev/null" EXIT
343343
@echo "Fetching public mode configuration..."
@@ -362,7 +362,7 @@ perftest-generate-pointer-table-extract:
362362
aws s3 cp "${DIST_PATH}/pointer_extract-${PERFTEST_TABLE_NAME}.zip" "s3://nhsd-nrlf--${ENV}-metadata/performance/seed-pointers-extract-${PERFTEST_TABLE_NAME}.zip"
363363

364364
perftest-run-token-refresher:
365-
@echo "Starting token refresher with ENV=$(ENV)"
365+
@echo "Starting token refresher in background with ENV=$(ENV) PERFTEST_TOKEN_REFRESH_PORT=$(PERFTEST_TOKEN_REFRESH_PORT)"
366366
ENV=$(ENV) TOKEN_REFRESH_PORT=$(PERFTEST_TOKEN_REFRESH_PORT) PYTHONPATH=. poetry run python ./tests/performance/token_refresher.py &
367367
trap "kill $$(lsof -t -i :$(PERFTEST_TOKEN_REFRESH_PORT)) 2>/dev/null" EXIT
368368

tests/performance/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ make perftest-prepare PERFTEST_TABLE_NAME=nhsd-nrlf--perftest-baseline-pointers-
7575
#### Internal mode
7676

7777
```sh
78+
assume nhsd-nrlf-test
7879
make perftest-consumer-internal ENV_TYPE=perftest PERFTEST_HOST=perftest-1.perftest.record-locator.national.nhs.uk
7980
make perftest-producer-internal ENV_TYPE=perftest PERFTEST_HOST=perftest-1.perftest.record-locator.national.nhs.uk
8081
```
@@ -84,6 +85,7 @@ make perftest-producer-internal ENV_TYPE=perftest PERFTEST_HOST=perftest-1.perft
8485
Via apigee proxies - most similar to a supplier. Spins up a local http server in background responsible for refreshing bearer token (valid for 5 mins each).
8586

8687
```sh
88+
assume nhsd-nrlf-mgmt
8789
make perftest-consumer-public ENV=perftest
8890
make perftest-producer-public ENV=perftest
8991
```

tests/performance/test-config.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ function initConfig() {
2424
return config;
2525
}
2626

27-
const configData = fetchConfig();
28-
2927
if (connectMode === "public") {
28+
const configData = fetchConfig();
29+
3030
config = {
3131
connectMode: "public",
3232
baseUrl: __ENV.TEST_PUBLIC_BASE_URL.replace(/\/$/, ""),
@@ -40,7 +40,10 @@ function initConfig() {
4040
throw new Error("Public mode requires TEST_PUBLIC_BASE_URL");
4141
}
4242
if (!config.bearerToken) {
43-
throw new Error("Bearer token not found in config file");
43+
throw new Error(
44+
"Bearer token not found in config",
45+
Object.keys(configData)
46+
);
4447
}
4548
} else {
4649
config = {

tests/performance/token_refresher.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
#!/usr/bin/env python3
2+
"""
3+
Token refresher useful for running perf tests in public mode. Runs in background of test run and spins up two threads:
4+
- a looped task which fetches a new bearer token from APIM every 5 mins
5+
- http server which returns the most recently fetched token
6+
7+
See makefile perftest-consumer-public & perftest-producer-public for usage
8+
"""
29
import json
310
import os
411
import threading

tests/utilities/get_access_token.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def generate_client_assertion(app_secrets: dict):
109109
"sub": app_secrets["api_key"],
110110
"aud": app_secrets["oauth_url"],
111111
"jti": str(uuid4()),
112-
"exp": time() + 300, # max:312, still times out at just < 10 mins :(
112+
"exp": time() + 300, # max:312
113113
},
114114
app_secrets["private_key"],
115115
algorithm="RS512",

0 commit comments

Comments
 (0)