Skip to content

Commit 0aa9012

Browse files
authored
VED-788 Refactor ack_backend (#844)
* init * lint * smells * typo * imports * cleanup * sonarcloud * sonarcloud II * local Makefile * tests for get_s3_client * tests for get_s3_client II * delete .coverage * use_ms_precision * lint * shared helper functions * prefix * missing cache tests * test_errors * terraform fixes per VED-810 * review fixes * review fixes II * review fixes III
1 parent 5a6639e commit 0aa9012

Some content is hidden

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

43 files changed

+656
-228
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ version: 2
77
updates:
88
- package-ecosystem: "docker"
99
directories:
10-
- "/ack_backend"
10+
- "/lambdas/ack_backend"
1111
- "/delta_backend"
1212
- "/filenameprocessor"
1313
- "/grafana/non-prod/docker"
@@ -49,7 +49,6 @@ updates:
4949
- package-ecosystem: "pip"
5050
directories:
5151
- "/"
52-
- "/ack_backend"
5352
- "/backend"
5453
- "/batch_processor_filter"
5554
- "/delta_backend"
@@ -58,6 +57,7 @@ updates:
5857
- "/filenameprocessor"
5958
- "/mesh_processor"
6059
- "/recordprocessor"
60+
- "/lambdas/ack_backend"
6161
- "/lambdas/redis_sync"
6262
- "/lambdas/id_sync"
6363
- "/lambdas/mns_subscription"

.github/workflows/quality-checks.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,6 @@ jobs:
106106
poetry run coverage run -m unittest discover -p "*batch*.py" || echo "recordforwarder tests failed" >> ../failed_tests.txt
107107
poetry run coverage xml -o ../recordforwarder-coverage.xml
108108
109-
- name: Run unittest with coverage-ack-lambda
110-
working-directory: ack_backend
111-
id: acklambda
112-
env:
113-
PYTHONPATH: ${{ github.workspace }}/ack_backend/src:${{ github.workspace }}/ack_backend/tests
114-
continue-on-error: true
115-
run: |
116-
poetry install
117-
poetry run coverage run -m unittest discover || echo "ack-lambda tests failed" >> ../failed_tests.txt
118-
poetry run coverage xml -o ../ack-lambda-coverage.xml
119-
120109
- name: Run unittest with coverage-delta
121110
working-directory: delta_backend
122111
id: delta
@@ -148,6 +137,17 @@ jobs:
148137
poetry run coverage run -m unittest discover || echo "mesh_processor tests failed" >> ../failed_tests.txt
149138
poetry run coverage xml -o ../mesh_processor-coverage.xml
150139
140+
- name: Run unittest with coverage-ack-lambda
141+
working-directory: lambdas/ack_backend
142+
id: acklambda
143+
env:
144+
PYTHONPATH: ${{ env.LAMBDA_PATH }}/ack_backend/src:${{ github.workspace }}/ack_backend/tests
145+
continue-on-error: true
146+
run: |
147+
poetry install
148+
poetry run coverage run --source=src -m unittest discover || echo "ack-lambda tests failed" >> ../../failed_tests.txt
149+
poetry run coverage xml -o ../../ack-lambda-coverage.xml
150+
151151
- name: Run unittest with coverage-mns-subscription
152152
working-directory: lambdas/mns_subscription
153153
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 = ack_backend backend batch_processor_filter delta_backend filenameprocessor mesh_processor recordprocessor lambdas/redis_sync lambdas/id_sync lambdas/mns_subscription lambdas/shared
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
44
PYTHON_PROJECT_DIRS = e2e e2e_batch $(PYTHON_PROJECT_DIRS_WITH_UNIT_TESTS)
55

66
#Installs dependencies using poetry.

ack_backend/Makefile

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

ack_backend/src/clients.py

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

ack_backend/src/errors.py

Lines changed: 0 additions & 5 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": "ack_backend"
17-
},
1815
{
1916
"path": "delta_backend"
2017
},
@@ -27,6 +24,9 @@
2724
{
2825
"path": "e2e_batch"
2926
},
27+
{
28+
"path": "lambdas/ack_backend"
29+
},
3030
{
3131
"path": "lambdas/redis_sync"
3232
},
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"python.analysis.extraPaths": [
3+
"./src"
4+
],
5+
"python.testing.unittestArgs": [
6+
"-v",
7+
"-s",
8+
"./",
9+
"-p",
10+
"test_*.py"
11+
],
12+
"python.testing.pytestEnabled": false,
13+
"python.testing.unittestEnabled": true,
14+
"pylint.args": [
15+
"--init-hook",
16+
"import sys; sys.path.append('./src')"
17+
]
18+
}
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,31 @@ RUN mkdir -p /home/appuser && \
55
echo 'appuser:x:1001:' >> /etc/group && \
66
chown -R 1001:1001 /home/appuser && pip install "poetry~=2.1.4"
77

8-
COPY poetry.lock pyproject.toml README.md ./
8+
# Install Poetry dependencies
9+
# Copy ack_backend Poetry files
10+
COPY ./ack_backend/poetry.lock ./ack_backend/pyproject.toml ./
11+
12+
# Install ack_backend dependencies
13+
WORKDIR /var/task
914
RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi --no-root --only main
15+
1016
# -----------------------------
1117
FROM base AS build
12-
COPY src .
18+
19+
# Set working directory back to Lambda task root
20+
WORKDIR /var/task
21+
22+
# Copy shared source code
23+
COPY ./shared/src/common ./common
24+
25+
# Copy ack_backend source code
26+
COPY ./ack_backend/src .
27+
28+
# Set correct permissions
1329
RUN chmod 644 $(find . -type f) && chmod 755 $(find . -type d)
30+
1431
# Switch to the non-root user for running the container
1532
USER 1001:1001
33+
34+
# Set the Lambda handler
1635
CMD ["ack_processor.lambda_handler"]

lambdas/ack_backend/Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
TEST_ENV := @PYTHONPATH=src:tests:../shared/src
2+
3+
build:
4+
docker build -t ack-lambda-build .
5+
6+
package: build
7+
mkdir -p build
8+
docker run --rm -v $(shell pwd)/build:/build ack-lambda-build
9+
10+
test:
11+
$(TEST_ENV) python -m unittest
12+
13+
coverage-run:
14+
$(TEST_ENV) coverage run --source=src -m unittest discover -v
15+
16+
coverage-report:
17+
$(TEST_ENV) coverage report -m
18+
19+
coverage-html:
20+
$(TEST_ENV) coverage html
21+
22+
.PHONY: build package

0 commit comments

Comments
 (0)