Skip to content

Commit 85d0491

Browse files
authored
VED-802 Refactor delta_backend (#925)
* init * terraform fmt * mappings -> shared * exclude for http: * Dockerfile * utils * log_firehose * log_firehose II * log_firehose III * log_firehose * mappings not shared * ruff * sqs_client * get_delta_table * ruff format * exclude_snomed_urls * noqa S5332 * noqa S5332 II * NOSONAR(S5332) * review changes * test: touch file without removing NOSONAR * test: remove NOSONAR * PoC: sonar exclusions: filepaths * resubmit with comments * ruff * restored NOSONAR directives
1 parent d1fc352 commit 85d0491

File tree

71 files changed

+257
-409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+257
-409
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ updates:
88
- package-ecosystem: "docker"
99
directories:
1010
- "/lambdas/ack_backend"
11-
- "/delta_backend"
11+
- "/lambdas/delta_backend"
1212
- "/filenameprocessor"
1313
- "/infrastructure/grafana/non-prod/docker"
1414
- "/mesh_processor"
@@ -50,13 +50,13 @@ updates:
5050
- "/"
5151
- "/backend"
5252
- "/batch_processor_filter"
53-
- "/delta_backend"
5453
- "/tests/e2e"
5554
- "/tests/e2e_batch"
5655
- "/filenameprocessor"
5756
- "/mesh_processor"
5857
- "/recordprocessor"
5958
- "/lambdas/ack_backend"
59+
- "/lambdas/delta_backend"
6060
- "/lambdas/redis_sync"
6161
- "/lambdas/id_sync"
6262
- "/lambdas/mns_subscription"

.github/workflows/quality-checks.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,6 @@ jobs:
140140
poetry run coverage run -m unittest discover -p "*batch*.py" || echo "recordforwarder tests failed" >> ../failed_tests.txt
141141
poetry run coverage xml -o ../recordforwarder-coverage.xml
142142
143-
- name: Run unittest with coverage-delta
144-
working-directory: delta_backend
145-
id: delta
146-
env:
147-
PYTHONPATH: delta_backend/src:delta_backend/tests
148-
continue-on-error: true
149-
run: |
150-
poetry install
151-
poetry run coverage run -m unittest discover || echo "delta tests failed" >> ../failed_tests.txt
152-
poetry run coverage xml -o ../delta-coverage.xml
153-
154143
- name: Run unittest with coverage-fhir-api
155144
working-directory: backend
156145
env:
@@ -182,6 +171,17 @@ jobs:
182171
poetry run coverage run --source=src -m unittest discover || echo "ack-lambda tests failed" >> ../../failed_tests.txt
183172
poetry run coverage xml -o ../../ack-lambda-coverage.xml
184173
174+
- name: Run unittest with coverage-delta
175+
working-directory: lambdas/delta_backend
176+
id: delta
177+
env:
178+
PYTHONPATH: ${{ env.LAMBDA_PATH }}/delta_backend/src:${{ env.LAMBDA_PATH }}/delta_backend/tests:${{ env.SHARED_PATH }}/src
179+
continue-on-error: true
180+
run: |
181+
poetry install
182+
poetry run coverage run -m unittest discover || echo "delta tests failed" >> ../../failed_tests.txt
183+
poetry run coverage xml -o ../../delta-coverage.xml
184+
185185
- name: Run unittest with coverage-mns-subscription
186186
working-directory: lambdas/mns_subscription
187187
id: mns_subscription

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SHELL=/usr/bin/env bash -euo pipefail
22

3-
PYTHON_PROJECT_DIRS_WITH_UNIT_TESTS = backend batch_processor_filter delta_backend filenameprocessor mesh_processor recordprocessor lambdas/ack_backend lambdas/redis_sync lambdas/id_sync lambdas/mns_subscription lambdas/shared
3+
PYTHON_PROJECT_DIRS_WITH_UNIT_TESTS = backend batch_processor_filter filenameprocessor mesh_processor recordprocessor lambdas/ack_backend lambdas/delta_backend lambdas/redis_sync lambdas/id_sync lambdas/mns_subscription lambdas/shared
44
PYTHON_PROJECT_DIRS = tests/e2e tests/e2e_batch quality_checks $(PYTHON_PROJECT_DIRS_WITH_UNIT_TESTS)
55

66
.PHONY: install lint format format-check clean publish build-proxy release initialise-all-python-venvs update-all-python-dependencies run-all-python-unit-tests build-all-docker-images

delta_backend/src/log_firehose.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

delta_backend/src/utils.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

delta_backend/tests/test_log_firehose.py

Lines changed: 0 additions & 72 deletions
This file was deleted.

delta_backend/tests/test_utils.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

immunisation-fhir-api.code-workspace

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
{
1313
"path": "recordprocessor",
1414
},
15-
{
16-
"path": "delta_backend",
17-
},
1815
{
1916
"path": "mesh_processor",
2017
},
@@ -27,6 +24,9 @@
2724
{
2825
"path": "lambdas/ack_backend",
2926
},
27+
{
28+
"path": "lambdas/delta_backend",
29+
},
3030
{
3131
"path": "lambdas/redis_sync",
3232
},

infrastructure/instance/delta.tf

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
locals {
2-
delta_lambda_dir = abspath("${path.root}/../../delta_backend")
2+
delta_lambda_dir = abspath("${path.root}/../../lambdas/delta_backend")
33
delta_files = fileset(local.delta_lambda_dir, "**")
44
delta_dir_sha = sha1(join("", [for f in local.delta_files : filesha1("${local.delta_lambda_dir}/${f}")]))
55
function_name = "delta"
@@ -16,8 +16,9 @@ resource "aws_ecr_repository" "delta_lambda_repository" {
1616
}
1717

1818
module "delta_docker_image" {
19-
source = "terraform-aws-modules/lambda/aws//modules/docker-build"
20-
version = "8.1.0"
19+
source = "terraform-aws-modules/lambda/aws//modules/docker-build"
20+
version = "8.1.0"
21+
docker_file_path = "./delta_backend/Dockerfile"
2122

2223
create_ecr_repo = false
2324
ecr_repo = "${local.prefix}-delta-lambda-repo"
@@ -40,9 +41,10 @@ module "delta_docker_image" {
4041

4142
platform = "linux/amd64"
4243
use_image_tag = false
43-
source_path = local.delta_lambda_dir
44+
source_path = abspath("${path.root}/../../lambdas")
4445
triggers = {
45-
dir_sha = local.delta_dir_sha
46+
dir_sha = local.delta_dir_sha
47+
shared_dir_sha = local.shared_dir_sha
4648
}
4749

4850
}

lambdas/ack_backend/tests/test_logging_decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def setUp(self):
99
# Patch logger and firehose_client
1010
self.logger_patcher = patch("common.log_decorator.logger")
1111
self.mock_logger = self.logger_patcher.start()
12-
self.firehose_patcher = patch("common.log_decorator.firehose_client")
12+
self.firehose_patcher = patch("common.log_firehose.firehose_client")
1313
self.mock_firehose = self.firehose_patcher.start()
1414

1515
def tearDown(self):

0 commit comments

Comments
 (0)