Skip to content

Commit 9631dcc

Browse files
authored
CCM-13562 Component tests for ttl-create (#222)
1 parent 9bf7fdb commit 9631dcc

12 files changed

Lines changed: 221 additions & 61 deletions

File tree

infrastructure/terraform/components/dl/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ No requirements.
4343
| <a name="input_region"></a> [region](#input\_region) | The AWS Region | `string` | n/a | yes |
4444
| <a name="input_report_scheduler_schedule"></a> [report\_scheduler\_schedule](#input\_report\_scheduler\_schedule) | Schedule to trigger sender reports | `string` | `"cron(30 4 * * ? *)"` | no |
4545
| <a name="input_shared_infra_account_id"></a> [shared\_infra\_account\_id](#input\_shared\_infra\_account\_id) | The AWS Shared Infra Account ID (numeric) | `string` | n/a | yes |
46+
| <a name="input_sqs_max_receive_count"></a> [sqs\_max\_receive\_count](#input\_sqs\_max\_receive\_count) | Maximum number of times a message can be received before being sent to the DLQ | `string` | `"3"` | no |
4647
| <a name="input_ttl_poll_schedule"></a> [ttl\_poll\_schedule](#input\_ttl\_poll\_schedule) | Schedule to poll for any overdue TTL records | `string` | `"rate(10 minutes)"` | no |
4748
## Modules
4849

infrastructure/terraform/components/dl/module_sqs_ttl.tf

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
module "sqs_ttl" {
22
source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.30/terraform-sqs.zip"
33

4-
aws_account_id = var.aws_account_id
5-
component = local.component
6-
environment = var.environment
7-
project = var.project
8-
region = var.region
9-
name = "ttl"
10-
11-
sqs_kms_key_arn = module.kms.key_arn
12-
4+
aws_account_id = var.aws_account_id
5+
component = local.component
6+
environment = var.environment
7+
project = var.project
8+
region = var.region
9+
name = "ttl"
10+
sqs_kms_key_arn = module.kms.key_arn
1311
visibility_timeout_seconds = 60
14-
15-
create_dlq = true
16-
17-
sqs_policy_overload = data.aws_iam_policy_document.sqs_ttl.json
12+
create_dlq = true
13+
max_receive_count = var.sqs_max_receive_count
14+
sqs_policy_overload = data.aws_iam_policy_document.sqs_ttl.json
1815
}
1916

2017
data "aws_iam_policy_document" "sqs_ttl" {

infrastructure/terraform/components/dl/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,9 @@ variable "metadata_refresh_schedule" {
219219
description = "Schedule for refreshing reporting metadata."
220220
default = "cron(10 6-22 * * ? *)" # 10 minutes past the hour, between 06:00 - 22:00
221221
}
222+
223+
variable "sqs_max_receive_count" {
224+
type = string
225+
description = "Maximum number of times a message can be received before being sent to the DLQ"
226+
default = "3"
227+
}

lambdas/ttl-create-lambda/src/__tests__/infra/ttl-repository.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ describe('TtlRepository', () => {
100100
expect(gsiPk).toMatch(/^\d{4}-\d{2}-\d{2}#\d{1,2}$/);
101101
});
102102

103-
it('throws and logs error when sender not found', async () => {
103+
it('throws and logs error when sender not retrieved', async () => {
104104
senderRepository.getSender.mockResolvedValue(null);
105105

106106
await expect(repo.insertTtlRecord(messageDownloadedEvent)).rejects.toThrow(
107-
`Sender not found for sender ID ${messageDownloadedEvent.data.senderId}`,
107+
`Sender ${messageDownloadedEvent.data.senderId} could not be retrieved`,
108108
);
109109

110110
expect(logger.error).toHaveBeenCalledWith({
111-
description: `Sender not found for sender ID ${messageDownloadedEvent.data.senderId}`,
111+
description: `Sender ${messageDownloadedEvent.data.senderId} could not be retrieved`,
112112
});
113113
});
114114
});

lambdas/ttl-create-lambda/src/infra/ttl-repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export class TtlRepository {
2222
});
2323
if (!sender) {
2424
this.logger.error({
25-
description: `Sender not found for sender ID ${item.data.senderId}`,
25+
description: `Sender ${item.data.senderId} could not be retrieved`,
2626
});
27-
throw new Error(`Sender not found for sender ID ${item.data.senderId}`);
27+
throw new Error(`Sender ${item.data.senderId} could not be retrieved`);
2828
}
2929

3030
const ttlTime =

package-lock.json

Lines changed: 41 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
"overrides": {
3939
"brace-expansion": "^5.0.2",
4040
"fast-xml-parser": "^5.3.7",
41-
"minimatch": "^10.2.2",
41+
"minimatch": "^10.2.4",
4242
"pretty-format": {
4343
"react-is": "^19.0.0"
4444
},
4545
"react": "^19.0.0",
46-
"test-exclude": "^7.0.0"
46+
"test-exclude": "^8.0.0"
4747
},
4848
"scripts": {
4949
"build-schemas": "make -C src/cloudevents/domains/digital-letters build-no-bundle publish-bundled-json",

src/cloudevents/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"main": "tools/generator/example-generator/generate-example.ts",
2323
"name": "digital-letters-cloudevents-schemas",
2424
"overrides": {
25-
"glob": "13.0.3",
26-
"minimatch": "^10.2.2"
25+
"glob": "^13.0.6",
26+
"minimatch": "^10.2.4"
2727
},
2828
"scripts": {
2929
"build": "tsx tools/builder/build-schema.ts",

src/eventcatalog/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"name": "digital-letters",
99
"overrides": {
10-
"minimatch": "^10.2.2"
10+
"minimatch": "^10.2.4"
1111
},
1212
"private": true,
1313
"scripts": {

tests/playwright/constants/backend-constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const CORE_NOTIFIER_DLQ_NAME = `${CSI}-core-notifier-dlq`;
2626
export const FILE_SCANNER_DLQ_NAME = `${CSI}-scanner-dlq`;
2727
export const PRINT_STATUS_HANDLER_DLQ_NAME = `${CSI}-print-status-handler-dlq`;
2828
export const HANDLE_TTL_DLQ_NAME = `${CSI}-ttl-handle-expiry-errors-queue`;
29+
export const CREATE_TTL_DLQ_NAME = `${CSI}-ttl-dlq`;
2930
export const PRINT_ANALYSER_DLQ_NAME = `${CSI}-print-analyser-dlq`;
3031
export const PRINT_SENDER_DLQ_NAME = `${CSI}-print-sender-dlq`;
3132
export const MOVE_SCANNED_FILES_NAME = `${CSI}-move-scanned-files-queue`;
@@ -63,3 +64,4 @@ export const PRINT_STATUS_HANDLER_LAMBDA_LOG_GROUP_NAME = `/aws/lambda/${CSI}-pr
6364
export const PRINT_ANALYSER_LAMBDA_LOG_GROUP_NAME = `/aws/lambda/${CSI}-print-analyser`;
6465
export const PRINT_SENDER_LAMBDA_LOG_GROUP_NAME = `/aws/lambda/${CSI}-print-sender`;
6566
export const MOVE_SCANNED_FILES_LAMBDA_LOG_GROUP_NAME = `/aws/lambda/${CSI}-move-scanned-files`;
67+
export const CREATE_TTL_LAMBDA_LOG_GROUP_NAME = `/aws/lambda/${CSI}-ttl-create`;

0 commit comments

Comments
 (0)