Skip to content

Commit 6131f46

Browse files
Change default variant map and refactor poll helper
1 parent 5325c0e commit 6131f46

4 files changed

Lines changed: 26 additions & 7 deletions

File tree

infrastructure/terraform/components/api/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ No requirements.
3535
| <a name="input_kms_deletion_window"></a> [kms\_deletion\_window](#input\_kms\_deletion\_window) | When a kms key is deleted, how long should it wait in the pending deletion state? | `string` | `"30"` | no |
3636
| <a name="input_letter_event_source"></a> [letter\_event\_source](#input\_letter\_event\_source) | Source value to use for the letter status event updates | `string` | `"/data-plane/supplier-api/nhs-supplier-api-prod/main/update-status"` | no |
3737
| <a name="input_letter_table_ttl_hours"></a> [letter\_table\_ttl\_hours](#input\_letter\_table\_ttl\_hours) | Number of hours to set as TTL on letters table | `number` | `24` | no |
38-
| <a name="input_letter_variant_map"></a> [letter\_variant\_map](#input\_letter\_variant\_map) | n/a | `map(object({ supplierId = string, specId = string, priority = number, billingId = string }))` | <pre>{<br/> "lv1": {<br/> "billingId": "billing1",<br/> "priority": 10,<br/> "specId": "spec1",<br/> "supplierId": "supplier1"<br/> },<br/> "lv2": {<br/> "billingId": "billing1",<br/> "priority": 10,<br/> "specId": "spec2",<br/> "supplierId": "supplier1"<br/> },<br/> "lv3": {<br/> "billingId": "billing1",<br/> "priority": 10,<br/> "specId": "spec3",<br/> "supplierId": "supplier2"<br/> }<br/>}</pre> | no |
38+
| <a name="input_letter_variant_map"></a> [letter\_variant\_map](#input\_letter\_variant\_map) | n/a | `map(object({ supplierId = string, specId = string, priority = number, billingId = string }))` | <pre>{<br/> "digitrials-aspiring": {<br/> "billingId": "digitrials-aspiring-billing",<br/> "priority": "0",<br/> "specId": "digitrials-aspiring",<br/> "supplierId": "supplier1"<br/> },<br/> "digitrials-dmapp": {<br/> "billingId": "notify-admail-billing",<br/> "priority": "1",<br/> "specId": "notify-admail",<br/> "supplierId": "supplier1"<br/> },<br/> "digitrials-globalminds": {<br/> "billingId": "digitrials-globalminds-billing",<br/> "priority": "2",<br/> "specId": "digitrials-globalminds",<br/> "supplierId": "supplier1"<br/> },<br/> "digitrials-mymelanoma": {<br/> "billingId": "digitrials-mymelanoma-billing",<br/> "priority": "3",<br/> "specId": "digitrials-mymelanoma",<br/> "supplierId": "supplier1"<br/> },<br/> "digitrials-ofh": {<br/> "billingId": "digitrials-ofh-billing",<br/> "priority": "4",<br/> "specId": "digitrials-ofh",<br/> "supplierId": "supplier1"<br/> },<br/> "digitrials-prostateprogress": {<br/> "billingId": "digitrials-prostateprogress-billing",<br/> "priority": "5",<br/> "specId": "digitrials-prostateprogress",<br/> "supplierId": "supplier1"<br/> },<br/> "digitrials-protectc": {<br/> "billingId": "notify-c5-colour-billing",<br/> "priority": "6",<br/> "specId": "notify-c5-colour",<br/> "supplierId": "supplier1"<br/> },<br/> "digitrials-restore": {<br/> "billingId": "digitrials-restore-billing",<br/> "priority": "7",<br/> "specId": "digitrials-restore",<br/> "supplierId": "supplier1"<br/> },<br/> "gpreg-admail": {<br/> "billingId": "notify-admail-billing",<br/> "priority": "8",<br/> "specId": "notify-admail",<br/> "supplierId": "supplier1"<br/> },<br/> "nces-abnormal-results": {<br/> "billingId": "nces-abnormal-results-billing",<br/> "priority": "9",<br/> "specId": "nces-abnormal-results",<br/> "supplierId": "supplier1"<br/> },<br/> "nces-abnormal-results-braille": {<br/> "billingId": "nces-abnormal-results-braille-billing",<br/> "priority": "10",<br/> "specId": "nces-abnormal-results-braille",<br/> "supplierId": "supplier1"<br/> },<br/> "nces-invites": {<br/> "billingId": "nces-invites-billing",<br/> "priority": "10",<br/> "specId": "nces-invites",<br/> "supplierId": "supplier1"<br/> },<br/> "nces-invites-braille": {<br/> "billingId": "nces-invites-braille-billing",<br/> "priority": "10",<br/> "specId": "nces-invites-braille",<br/> "supplierId": "supplier1"<br/> },<br/> "nces-standard": {<br/> "billingId": "notify-c5-whitemail-billing",<br/> "priority": "11",<br/> "specId": "notify-c5-whitemail",<br/> "supplierId": "supplier1"<br/> },<br/> "nces-standard-braille": {<br/> "billingId": "notify-braille-whitemail-billing",<br/> "priority": "12",<br/> "specId": "notify-braille-whitemail",<br/> "supplierId": "supplier1"<br/> },<br/> "notify-braille": {<br/> "billingId": "notify-braille-billing",<br/> "priority": "13",<br/> "specId": "notify-braille",<br/> "supplierId": "supplier1"<br/> },<br/> "notify-digital-letters-standard": {<br/> "billingId": "notify-c5-billing",<br/> "priority": "97",<br/> "specId": "notify-c5",<br/> "supplierId": "supplier1"<br/> },<br/> "notify-standard": {<br/> "billingId": "notify-c5-billing",<br/> "priority": "98",<br/> "specId": "notify-c5",<br/> "supplierId": "supplier1"<br/> },<br/> "notify-standard-colour": {<br/> "billingId": "notify-c5-colour-billing",<br/> "priority": "99",<br/> "specId": "notify-c5-colour",<br/> "supplierId": "supplier1"<br/> }<br/>}</pre> | no |
3939
| <a name="input_log_level"></a> [log\_level](#input\_log\_level) | The log level to be used in lambda functions within the component. Any log with a lower severity than the configured value will not be logged: https://docs.python.org/3/library/logging.html#levels | `string` | `"INFO"` | no |
4040
| <a name="input_log_retention_in_days"></a> [log\_retention\_in\_days](#input\_log\_retention\_in\_days) | The retention period in days for the Cloudwatch Logs events to be retained, default of 0 is indefinite | `number` | `0` | no |
4141
| <a name="input_manually_configure_mtls_truststore"></a> [manually\_configure\_mtls\_truststore](#input\_manually\_configure\_mtls\_truststore) | Manually manage the truststore used for API Gateway mTLS (e.g. for prod environment) | `bool` | `false` | no |

infrastructure/terraform/components/api/variables.tf

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,25 @@ variable "eventpub_control_plane_bus_arn" {
138138
variable "letter_variant_map" {
139139
type = map(object({ supplierId = string, specId = string, priority = number, billingId = string }))
140140
default = {
141-
"lv1" = { supplierId = "supplier1", specId = "spec1", priority = 10, billingId = "billing1" },
142-
"lv2" = { supplierId = "supplier1", specId = "spec2", priority = 10, billingId = "billing1" },
143-
"lv3" = { supplierId = "supplier2", specId = "spec3", priority = 10, billingId = "billing1" }
141+
"digitrials-aspiring" = { supplierId = "supplier1", specId = "digitrials-aspiring", priority = "0", billingId = "digitrials-aspiring-billing" },
142+
"digitrials-dmapp" = { supplierId = "supplier1", specId = "notify-admail", priority = "1", billingId = "notify-admail-billing" },
143+
"digitrials-globalminds" = { supplierId = "supplier1", specId = "digitrials-globalminds", priority = "2", billingId = "digitrials-globalminds-billing" },
144+
"digitrials-mymelanoma" = { supplierId = "supplier1", specId = "digitrials-mymelanoma", priority = "3", billingId = "digitrials-mymelanoma-billing" },
145+
"digitrials-ofh" = { supplierId = "supplier1", specId = "digitrials-ofh", priority = "4", billingId = "digitrials-ofh-billing" },
146+
"digitrials-prostateprogress" = { supplierId = "supplier1", specId = "digitrials-prostateprogress", priority = "5", billingId = "digitrials-prostateprogress-billing" },
147+
"digitrials-protectc" = { supplierId = "supplier1", specId = "notify-c5-colour", priority = "6", billingId = "notify-c5-colour-billing" },
148+
"digitrials-restore" = { supplierId = "supplier1", specId = "digitrials-restore", priority = "7", billingId = "digitrials-restore-billing" },
149+
"gpreg-admail" = { supplierId = "supplier1", specId = "notify-admail", priority = "8", billingId = "notify-admail-billing" },
150+
"nces-abnormal-results" = { supplierId = "supplier1", specId = "nces-abnormal-results", priority = "9", billingId = "nces-abnormal-results-billing" },
151+
"nces-abnormal-results-braille" = { supplierId = "supplier1", specId = "nces-abnormal-results-braille", priority = "10", billingId = "nces-abnormal-results-braille-billing" },
152+
"nces-invites" = { supplierId = "supplier1", specId = "nces-invites", priority = "10", billingId = "nces-invites-billing" },
153+
"nces-invites-braille" = { supplierId = "supplier1", specId = "nces-invites-braille", priority = "10", billingId = "nces-invites-braille-billing" },
154+
"nces-standard" = { supplierId = "supplier1", specId = "notify-c5-whitemail", priority = "11", billingId = "notify-c5-whitemail-billing" },
155+
"nces-standard-braille" = { supplierId = "supplier1", specId = "notify-braille-whitemail", priority = "12", billingId = "notify-braille-whitemail-billing" },
156+
"notify-braille" = { supplierId = "supplier1", specId = "notify-braille", priority = "13", billingId = "notify-braille-billing" },
157+
"notify-digital-letters-standard" = { supplierId = "supplier1", specId = "notify-c5", priority = "97", billingId = "notify-c5-billing" },
158+
"notify-standard" = { supplierId = "supplier1", specId = "notify-c5", priority = "98", billingId = "notify-c5-billing" },
159+
"notify-standard-colour" = { supplierId = "supplier1", specId = "notify-c5-colour", priority = "99", billingId = "notify-c5-colour-billing" }
144160
}
145161
}
146162

tests/component-tests/integration-tests/urgent-letter-priority.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ test.describe("Urgent Letter Priority Tests", () => {
6868
await verifyAllocationLogsContainPriority(urgencyNineLetterIds, 9);
6969
await verifyAllocationLogsContainPriority(urgencyTenLetterIds, 10);
7070

71+
// TODO CCM-15589 below is failing as still not fetching from letters queue using the queueSortOrder index
7172
const header = createValidRequestHeaders(supplier);
7273
const response = await request.get(`${baseUrl}/${SUPPLIER_LETTERS}`, {
7374
headers: header,

tests/helpers/poll-for-letters-helper.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export async function pollForLetterStatus(
1313
let statusCode = 0;
1414
let letterStatus: string | undefined;
1515
const RETRY_DELAY_MS = 10_000;
16-
const MAX_ATTEMPTS = 5;
16+
const MAX_ATTEMPTS = 6;
1717

1818
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
1919
const getLetterResponse = await request.get(
@@ -33,7 +33,7 @@ export async function pollForLetterStatus(
3333
logger.info(
3434
`Attempt ${attempt}: Received status code ${statusCode} for domainId: ${domainId}`,
3535
);
36-
break;
36+
return { letterStatus, statusCode };
3737
}
3838

3939
if (attempt < MAX_ATTEMPTS) {
@@ -46,5 +46,7 @@ export async function pollForLetterStatus(
4646
}
4747
}
4848

49-
return { letterStatus, statusCode };
49+
throw new Error(
50+
`Max attempts reached while polling for letter status for domainId: ${domainId}`,
51+
);
5052
}

0 commit comments

Comments
 (0)