Skip to content

Commit c17feb2

Browse files
NRL-1866 Remove duplicate script & fix broken imports
1 parent ab5cab7 commit c17feb2

8 files changed

Lines changed: 80 additions & 351 deletions

File tree

scripts/seed_nft_tables.py

Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@
1111
# import json
1212
import numpy as np
1313

14-
from nrlf.consumer.fhir.r4.model import DocumentReference
1514
from nrlf.core.constants import (
1615
CATEGORY_ATTRIBUTES,
1716
SNOMED_SYSTEM_URL,
1817
TYPE_ATTRIBUTES,
1918
TYPE_CATEGORIES,
20-
Categories,
21-
PointerTypes,
2219
)
2320
from nrlf.core.dynamodb.model import DocumentPointer
2421
from nrlf.core.logger import logger
2522
from nrlf.tests.data import load_document_reference
23+
from tests.performance.seed_data_constants import ( # DEFAULT_COUNT_DISTRIBUTIONS,
24+
CHECKSUM_WEIGHTS,
25+
DEFAULT_CUSTODIAN_DISTRIBUTIONS,
26+
DEFAULT_TYPE_DISTRIBUTIONS,
27+
)
2628

2729
dynamodb = boto3.client("dynamodb")
2830
resource = boto3.resource("dynamodb")
@@ -31,69 +33,6 @@
3133

3234
DOC_REF_TEMPLATE = load_document_reference("NFT-template")
3335

34-
CHECKSUM_WEIGHTS = [i for i in range(10, 1, -1)]
35-
36-
# These are based on the Nov 7th 2025 pointer stats report
37-
DEFAULT_TYPE_DISTRIBUTIONS = {
38-
"736253002": 65, # mental health crisis plan
39-
"1382601000000107": 5, # respect form
40-
"887701000000100": 15, # emergency healthcare plan
41-
"861421000000109": 5, # eol care coordination summary
42-
"735324008": 5, # treatment escalation plan
43-
"824321000000109": 5, # summary record
44-
}
45-
46-
DEFAULT_CUSTODIAN_DISTRIBUTIONS = {
47-
"736253002": {
48-
"TRPG": 9,
49-
"TRHA": 1,
50-
"TRRE": 20,
51-
"TRAT": 10,
52-
"TWR4": 4,
53-
"TRKL": 9,
54-
"TRW1": 5,
55-
"TRH5": 1,
56-
"TRP7": 13,
57-
"TRWK": 8,
58-
"TRQY": 3,
59-
"TRV5": 3,
60-
"TRJ8": 2,
61-
"TRXA": 4,
62-
"T11X": 1,
63-
"TG6V": 2,
64-
},
65-
"1382601000000107": {"T8GX8": 3, "TQUY": 2}, # respect form
66-
"887701000000100": {
67-
"TV1": 1,
68-
"TV2": 2,
69-
"TV3": 1,
70-
"TV4": 1,
71-
"TV5": 3,
72-
"TV6": 1,
73-
}, # emergency healthcare plan
74-
"861421000000109": {
75-
"TV1": 2,
76-
"TV2": 2,
77-
"TV3": 1,
78-
"TV4": 1,
79-
"TV5": 3,
80-
"TV6": 1,
81-
}, # eol care coordination summary
82-
"735324008": {
83-
"TV1": 1,
84-
"TV2": 1,
85-
"TV3": 1,
86-
"TV4": 2,
87-
"TV5": 2,
88-
"TV6": 1,
89-
}, # treatment escalation plan
90-
"824321000000109": {
91-
"TRXT": 1,
92-
}, # summary record currently has only one supplier
93-
}
94-
95-
DEFAULT_COUNT_DISTRIBUTIONS = {"1": 91, "2": 8, "3": 1}
96-
9736

9837
class TestNhsNumbersIterator:
9938
def __iter__(self):
@@ -262,7 +201,7 @@ def _get_pointer_count_poisson_distributions(
262201

263202

264203
def _set_up_custodian_iterators(
265-
custodian_dists: dict[str, dict[str, int]]
204+
custodian_dists: dict[str, dict[str, int]],
266205
) -> dict[str, Iterator[str]]:
267206
custodian_iters: dict[str, Iterator[str]] = {}
268207
for pointer_type in custodian_dists:

tests/performance/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,21 @@ make truststore-pull-all ENV=perftest
5050
You will need to generate pointer permissions the first time performance tests are run in an environment e.g. if the perftest environment is destroyed & recreated.
5151

5252
```sh
53+
# In project root
5354
make generate permissions # makes a bunch of json permission files for test organisations
5455
make build # will take all permissions & create nrlf_permissions.zip file
5556

5657
# apply this new permissions zip file to your environment
5758
cd ./terraform/infrastructure
58-
assume test
59+
assume nhsd-nrlf-test
5960
make init TF_WORKSPACE_NAME=perftest-1 ENV=perftest
6061
make ENV=perftest USE_SHARED_RESOURCES=true apply
6162
```
6263

6364
#### Generate input files
6465

6566
```sh
67+
assume nhsd-nrlf-test
6668
# creates 2 csv files and a json file
6769
make perftest-prepare PERFTEST_TABLE_NAME=perftest-baseline
6870
```

tests/performance/perftest_environment.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import re
66

77
import boto3
8+
from seed_data_constants import CHECKSUM_WEIGHTS
89

910
DYNAMODB = boto3.resource("dynamodb", region_name="eu-west-2")
1011

@@ -55,10 +56,6 @@ def extract_consumer_data(output_dir="."):
5556
print(f"Consumer data written to {out}") # noqa: T201
5657

5758

58-
# Semi-deterministic NHS number generator (duplicated from seed_nft_tables.py)
59-
CHECKSUM_WEIGHTS = [i for i in range(10, 1, -1)]
60-
61-
6259
class TestNhsNumbersIterator:
6360
def __iter__(self):
6461
self.first9 = 900000000

tests/performance/producer/delete_permissions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from pathlib import Path
22

33
import fire
4-
from seed_nft_tables import DEFAULT_CUSTODIAN_DISTRIBUTIONS
4+
5+
from tests.performance.seed_data_constants import DEFAULT_CUSTODIAN_DISTRIBUTIONS
56

67

78
def main(permissions_dir="../../dist/nrlf_permissions/K6PerformanceTest"):

tests/performance/producer/generate_distributions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import json
22
from pathlib import Path
33

4-
# Import the constants from your seed_nft_tables.py
5-
from seed_nft_tables import DEFAULT_CUSTODIAN_DISTRIBUTIONS, DEFAULT_TYPE_DISTRIBUTIONS
4+
from tests.performance.seed_data_constants import (
5+
DEFAULT_CUSTODIAN_DISTRIBUTIONS,
6+
DEFAULT_TYPE_DISTRIBUTIONS,
7+
)
68

79

810
def expand_distribution(dist):

tests/performance/producer/generate_permissions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
from pathlib import Path
33

44
import fire
5-
from seed_nft_tables import DEFAULT_CUSTODIAN_DISTRIBUTIONS
5+
6+
from tests.performance.seed_data_constants import DEFAULT_CUSTODIAN_DISTRIBUTIONS
67

78

89
def main(output_dir="../../dist/nrlf_permissions/K6PerformanceTest"):

0 commit comments

Comments
 (0)