Skip to content

Commit 3c63231

Browse files
authored
[NDR-323] Run E2E tests on pre prod deploy (#918)
1 parent 211efb3 commit 3c63231

16 files changed

+89
-41
lines changed

.github/workflows/base-e2e-backendtest.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ jobs:
7878
- name: Get E2e Test Variables
7979
run: |
8080
AWS_WORKSPACE="${SANDBOX}"
81-
API_URL="api-${SANDBOX}.access-request-fulfilment.patient-deductions.nhs.uk"
82-
echo "NDR_API_ENDPOINT=$API_URL" >> $GITHUB_ENV
8381
echo "AWS_WORKSPACE=$AWS_WORKSPACE" >> $GITHUB_ENV
8482
env:
8583
SANDBOX: ${{ inputs.sandbox }}

.github/workflows/full-deploy-to-pre-prod.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,15 @@ jobs:
135135
sandbox: pre-prod
136136
secrets:
137137
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}
138+
139+
run_backend_e2e_tests:
140+
name: Run E2E Tests
141+
needs: ["deploy_all_lambdas"]
142+
uses: ./.github/workflows/ndr-e2e-test-sandbox.yml
143+
with:
144+
build_branch: ${{ needs.tag_and_release.outputs.version }}
145+
environment: pre-prod
146+
sandbox: pre-prod
147+
secrets:
148+
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}
149+

.github/workflows/lambdas-deploy-to-pre-prod.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,15 @@ jobs:
6565
environment: pre-prod
6666
secrets:
6767
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}
68+
69+
run_backend_e2e_tests:
70+
name: Run E2E Tests
71+
needs: ["deploy_all"]
72+
uses: ./.github/workflows/ndr-e2e-test-sandbox.yml
73+
with:
74+
build_branch: ${{ needs.tag_and_release.outputs.version }}
75+
environment: pre-prod
76+
sandbox: pre-prod
77+
secrets:
78+
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}
79+

.github/workflows/ndr-e2e-test-sandbox.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ on:
1919
type: string
2020
default: development
2121

22+
workflow_call:
23+
inputs:
24+
build_branch:
25+
required: true
26+
type: string
27+
sandbox:
28+
required: true
29+
type: string
30+
environment:
31+
required: true
32+
type: string
33+
secrets:
34+
AWS_ASSUME_ROLE:
35+
required: true
36+
2237
permissions:
2338
pull-requests: write
2439
id-token: write

lambdas/tests/e2e/api/fhir/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
pdm_data_helper = PdmDataHelper()
1313

14-
PDM_SNOMED = 717391000000106
14+
PDM_SNOMED = pdm_data_helper.snomed_code
1515
PDM_METADATA_TABLE = pdm_data_helper.dynamo_table
1616
PDM_S3_BUCKET = pdm_data_helper.s3_bucket
17-
MTLS_ENDPOINT = os.environ.get("MTLS_ENDPOINT")
17+
MTLS_ENDPOINT = pdm_data_helper.mtls_endpoint
1818
CLIENT_CERT_PATH = os.environ.get("CLIENT_CERT_PATH")
1919
CLIENT_KEY_PATH = os.environ.get("CLIENT_KEY_PATH")
2020

lambdas/tests/e2e/api/fhir/test_search_patient_fhir_api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
from lambdas.tests.e2e.api.fhir.conftest import (
44
MTLS_ENDPOINT,
5+
PDM_SNOMED,
56
create_and_store_pdm_record,
67
create_mtls_session,
78
)
8-
from lambdas.tests.e2e.conftest import APIM_ENDPOINT, PDM_SNOMED
9+
from lambdas.tests.e2e.conftest import APIM_ENDPOINT
910
from lambdas.tests.e2e.helpers.data_helper import PdmDataHelper
1011

1112
pdm_data_helper = PdmDataHelper()
@@ -31,7 +32,7 @@ def search_document_reference(nhs_number, client_cert_path=None, client_key_path
3132

3233

3334
def test_search_nonexistent_document_references_for_patient_details():
34-
response = search_document_reference("9912003071")
35+
response = search_document_reference("9449305943")
3536
assert response.status_code == 200
3637

3738
bundle = response.json()

lambdas/tests/e2e/api/fhir/test_upload_document_fhir_api_success.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
from lambdas.tests.e2e.api.fhir.conftest import (
66
MTLS_ENDPOINT,
7+
PDM_SNOMED,
78
create_mtls_session,
89
fetch_with_retry_mtls,
910
)
10-
from lambdas.tests.e2e.conftest import APIM_ENDPOINT, PDM_SNOMED
11+
from lambdas.tests.e2e.conftest import APIM_ENDPOINT
1112
from lambdas.tests.e2e.helpers.data_helper import PdmDataHelper
1213

1314
pdm_data_helper = PdmDataHelper()

lambdas/tests/e2e/api/test_login_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import pytest
2+
from tests.e2e.helpers.data_helper import LloydGeorgeDataHelper
23
from tests.e2e.helpers.lloyd_george_mockcis2_helper import LloydGeorgeMockcis2Helper
34

45
# Note this is testing a mock, but this test is valuable to ensure the login code is working for other tests
56

7+
data_helper = LloydGeorgeDataHelper()
68

9+
10+
@pytest.mark.skipif(
11+
data_helper.workspace == "pre-prod", reason="CIS2 login is not mocked in pre-prod"
12+
)
713
@pytest.mark.parametrize(
814
"ods_code, role_to_assume, expected_granted_role",
915
[

lambdas/tests/e2e/api/test_upload_document_api.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ def test_create_document_virus(test_data, snapshot_json):
165165
lloyd_george_record["nhs_number"] = "9730154260"
166166

167167
# Attach EICAR data
168-
eicar_string = r"X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"
168+
eicar_string = (
169+
r"X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"
170+
)
169171
lloyd_george_record["data"] = base64.b64encode(eicar_string.encode()).decode()
170172

171173
payload = create_upload_payload(lloyd_george_record)
@@ -185,14 +187,16 @@ def test_create_document_virus(test_data, snapshot_json):
185187
def condition(response_json):
186188
logging.info(response_json)
187189
return response_json.get("docStatus") in (
188-
"cancelled",
189-
"final",
190+
"cancelled",
191+
"final",
190192
)
191193

192194
raw_retrieve_response = fetch_with_retry(retrieve_url, condition)
193195
retrieve_response = raw_retrieve_response.json()
194196

195-
assert upload_response == snapshot_json(exclude=paths("id", "date", "content.0.attachment.url"))
197+
assert upload_response == snapshot_json(
198+
exclude=paths("id", "date", "content.0.attachment.url")
199+
)
196200
assert retrieve_response == snapshot_json(exclude=paths("id", "date"))
197201

198202

lambdas/tests/e2e/apim/conftest.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
import os
2-
31
import pytest
42

53
from lambdas.tests.e2e.helpers.data_helper import PdmDataHelper
64

75
pdm_data_helper = PdmDataHelper()
86

9-
PDM_METADATA_TABLE = (
10-
os.environ.get("PDM_METADATA_TABLE") or "ndr-dev_COREDocumentMetadata"
11-
)
12-
PDM_S3_BUCKET = os.environ.get("PDM_S3_BUCKET") or "ndr-dev-pdm-document-store"
7+
PDM_METADATA_TABLE = pdm_data_helper.dynamo_table
8+
PDM_S3_BUCKET = pdm_data_helper.s3_bucket
139

1410

1511
@pytest.fixture

0 commit comments

Comments
 (0)