Skip to content

Commit 7f354d5

Browse files
committed
Documentation tidy up
1 parent 6478088 commit 7f354d5

7 files changed

Lines changed: 76 additions & 88 deletions

File tree

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ See https://nhsd-confluence.digital.nhs.uk/display/APM/Glossary.
5252

5353
### Tests
5454

55-
| Folder | Description |
56-
| ----------- | ------------------------------------------------------------------------------------ |
57-
| `e2e` | End-to-end tests executed during PR pipelines. |
58-
| `e2e_batch` | E2E tests specifically for batch-related functionality, also run in the PR pipeline. |
55+
| Folder | Description |
56+
| ---------------- | ----------------------------------------------------------------------------- |
57+
| `e2e_automation` | End-to-end tests executed during PR pipelines using the pytest-bdd framework. |
5958

6059
---
6160

@@ -143,7 +142,7 @@ Steps:
143142
144143
### Setting up a virtual environment with poetry
145144
146-
The steps below must be performed in each Lambda function folder and e2e folder to ensure the environment is correctly configured.
145+
The steps below must be performed in each Lambda function folder and e2e_automation folder to ensure the environment is correctly configured.
147146
148147
For detailed instructions on running individual Lambdas, refer to the README.md files located inside each respective Lambda folder.
149148

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ sonar.projectKey=NHSDigital_immunisation-fhir-api
33
sonar.organization=nhsdigital
44
sonar.host.url=https://sonarcloud.io
55
sonar.python.version=3.11
6-
sonar.exclusions=**/e2e/**,**/e2e_batch/**,**/devtools/**,**/proxies/**,**/utilities/scripts/**,**/infrastructure/account/**,**/infrastructure/instance/**,**/infrastructure/grafana/**,**/terraform_aws_backup/**,**/tests/**
6+
sonar.exclusions=**/devtools/**,**/proxies/**,**/utilities/scripts/**,**/infrastructure/account/**,**/infrastructure/instance/**,**/infrastructure/grafana/**,**/terraform_aws_backup/**,**/tests/**
77
sonar.coverage.exclusions=lambdas/shared/src/common/models/batch_constants.py
88
sonar.python.coverage.reportPaths=backend-coverage.xml,delta-coverage.xml,ack-lambda-coverage.xml,filenameprocessor-coverage.xml,recordforwarder-coverage.xml,recordprocessor-coverage.xml,mesh_processor-coverage.xml,redis_sync-coverage.xml,mns_subscription-coverage.xml,id_sync-coverage.xml,shared-coverage.xml,batchprocessorfilter-coverage.xml
99
sonar.cpd.exclusions=**/Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1+
# Do not change these 3 values. We always use internal-dev for dynamic mock auth in all APIM Apigee non-prod environments
12
auth_url=https://internal-dev.api.service.nhs.uk/oauth2-mock/authorize
23
token_url=https://internal-dev.api.service.nhs.uk/oauth2-mock/token
34
callback_url=https://oauth.pstmn.io/v1/callback
5+
46
# Obtain value from dev/testing team
57
STATUS_API_KEY=
8+
username=
9+
scope=
610

7-
username=aal3
8-
scope=nhs-cis2
9-
10-
# Internal-dev PR environment
11+
# Set all the below values based on the environment you are testing e.g. pr-xxx, internal-dev, internal-qa
1112
baseUrl=https://internal-dev.api.service.nhs.uk/immunisation-fhir-api/FHIR/R4-pr-123
1213
aws_token_refresh=False
13-
aws_profile_name=345594581768_DEV-IMMS-Devops
14+
aws_profile_name={your-aws-profile}
1415

1516
S3_env=pr-123
16-
# LOCAL_RUN_WITHOUT_S3_UPLOAD = True
1717
LOCAL_RUN_FILE_NAME=HPV_Vaccinations_v5_V0V8L_20251111T16304982.csv
1818
AWS_DOMAIN_NAME=pr-123.imms.dev.vds.platform.nhs.uk
1919

2020
PROXY_NAME=immunisation-fhir-api-pr-123
2121
# See README for details on how to obtain this
2222
APIGEE_ACCESS_TOKEN={use-the-apigee-get-token-utility}
2323
APIGEE_USERNAME={your-apigee-developer-email}
24-
APIGEE_ENVIRONMENT={the-relevant-apigee-env} # E.g. internal-dev, internal-qa
24+
APIGEE_ENVIRONMENT={the-relevant-apigee-env}# E.g. internal-dev, internal-qa
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
username=joebloggs
2-
scope=nhs-xyz
3-
aws_token_refresh= True
4-
########## INT env
1+
aws_token_refresh=True
2+
USE_STATIC_APPS=True
3+
4+
########## INT env variables
55
# baseUrl=https://int.api.service.nhs.uk/immunisation-fhir-api/FHIR/R4
66
# auth_url=https://int.api.service.nhs.uk/oauth2-mock/authorize
77
# token_url=https://int.api.service.nhs.uk/oauth2-mock/token
88
# callback_url=https://oauth.pstmn.io/v1/callback
99
# S3_env=int
1010
# aws_profile_name={your-aws-profile}
11+
# PROXY_NAME=immunisation-fhir-api-int
1112
## Id/Secret values - please contact Dev or Test team to get these values
13+
# username=
14+
# scope=
15+
# STATUS_API_KEY=
16+
# AWS_DOMAIN_NAME=
1217
# Postman_Auth_client_Id=
1318
# Postman_Auth_client_Secret=
1419
# RAVS_client_Id=
@@ -23,14 +28,18 @@ aws_token_refresh= True
2328
# TPP_client_Secret=
2429
# MEDICUS_client_Id=
2530
# MEDICUS_client_Secret=
26-
########## Internal-QA env
31+
32+
########## Internal-QA env variables
2733
baseUrl=https://internal-qa.api.service.nhs.uk/immunisation-fhir-api/FHIR/R4
2834
auth_url=https://internal-qa.api.service.nhs.uk/oauth2-mock/authorize
2935
token_url=https://internal-qa.api.service.nhs.uk/oauth2-mock/token
3036
callback_url=https://oauth.pstmn.io/v1/callback
3137
S3_env=internal-qa
3238
aws_profile_name={your-aws-profile}
39+
PROXY_NAME=immunisation-fhir-api-internal-qa
3340
## Id/Secret values - please contact Dev or Test team to get these values
41+
username=
42+
scope=
3443
STATUS_API_KEY=
3544
AWS_DOMAIN_NAME=
3645
Postman_Auth_client_Id=

tests/e2e_automation/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-include .env
22

33
cmd = poetry run pytest
4-
4+
# Add sandbox, add to README
55
test:
66
$(cmd)
77

@@ -17,5 +17,8 @@ test-batch-smoke:
1717
test-batch-full:
1818
$(cmd) features/batchTests -m functional
1919

20+
test-sandbox:
21+
$(cmd) features -m sandbox
22+
2023
collect-only:
2124
$(cmd) --collect-only

tests/e2e_automation/README.md

Lines changed: 45 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,81 +4,58 @@ This directory contains End-to-end Automation Tests for the Immunisation FHIR AP
44

55
## Setting up e2e_automation tests to run locally
66

7-
Update README with the changes to use get_token
8-
97
1. Follow the instructions in the root level README.md to setup the [dependencies](../../README.md#environment-setup) and create a [virtual environment](../../README.md#setting-up-a-virtual-environment-with-poetry) for this folder (`e2e_automation`).
8+
2. Run `poetry install --no-root` to install dependencies.
9+
3. Ensure you are authenticated with AWS in your terminal, using your preferred method.
10+
4. Choose which approach you wish to use: static apps or temporary apps. Temporary apps are the recommended way to go as
11+
they are spun up and torn down on each test run, therefore requiring fewer env vars and less operational overhead. Skip
12+
to the relevant section below depending on which approach you are going to use.
1013

11-
2. Add values to the .env file.
12-
13-
For an example of a template .env file, see [.env.example](./.env.example).
14-
15-
The following values should be added:
16-
17-
```
18-
aws_token_refresh=True
19-
baseUrl=https://internal-qa.api.service.nhs.uk/immunisation-fhir-api/FHIR/R4
20-
auth_url=https://internal-qa.api.service.nhs.uk/oauth2-mock/authorize
21-
token_url=https://internal-qa.api.service.nhs.uk/oauth2-mock/token
22-
callback_url=https://oauth.pstmn.io/v1/callback
23-
S3_env=internal-qa
24-
aws_profile_name={your-profile}
25-
```
26-
27-
3. Add login and secret values to the .env file.
28-
29-
**Please contact the Imms FHIR API Test team to get these values.**
30-
31-
The following values should be added:
32-
33-
```
34-
username
35-
scope
36-
STATUS_API_KEY
37-
AWS_DOMAIN_NAME
38-
Postman_Auth_client_Id
39-
Postman_Auth_client_Secret
40-
RAVS_client_Id
41-
RAVS_client_Secret
42-
MAVIS_client_Id
43-
MAVIS_client_Secret
44-
EMIS_client_Id
45-
EMIS_client_Secret
46-
SONAR_client_Id
47-
SONAR_client_Secret
48-
TPP_client_Id
49-
TPP_client_Secret
50-
MEDICUS_client_Id
51-
MEDICUS_client_Secret
52-
```
53-
54-
4. Run `poetry install --no-root` to install dependencies.
55-
56-
5. The `Makefile` in this directory provides the following commands:
14+
## Setup when using on demand apps
5715

58-
- `make test` - run all tests (may take some time)
59-
- `make test-api-full` - run API tests
60-
- `make test-api-smoke` - run API smoke tests only (quicker)
61-
- `make test-batch-full` - run Batch tests
62-
- `make test-batch-smoke` - run Batch smoke tests only (quicker)
63-
- `make collect-only` - check that all tests are discovered
16+
**NOTE:** this approach cannot be used in INT. Both INT and PROD (we do not test here) belong to the APIM Apigee prod
17+
organisation so there is no support for creating apps on the fly.
6418

65-
## Running e2e_automation tests against PR environments
19+
**Background:** this approach uses the Apigee API to create and teardown applications during a test run. This is the
20+
approach used in the pipeline for all APIM non-prod environments: internal-dev, internal-qa, pr and so forth.
6621

67-
Need to update this in PR and explain how to use static apps if desired locally.
22+
1. Configure your .env file with the required values.
6823

69-
The environment variables define a client ID and client secret for each of the Apigee test apps we use in static
70-
environments such as `internal-dev`, `internal-qa` and so on.
24+
The [.env.example.dynamic](./.env.example.dynamic) template defines all the values you will need and explains how
25+
to obtain them. Most will be simple enough, based on the environment you wish to test. However, there is the
26+
`STATUS_API_KEY` which you will need to ask the testers or tech lead for, and `APIGEE_ACCESS_TOKEN` which is outlined
27+
below.
7128

72-
However, creating pull requests will spin up a dynamic Apigee proxy and AWS backend which lives for the duration of the PR.
73-
To minimise admin overhead, the automation tests create dynamic applications for the duration of a test run rather than
74-
us having to manually create new apps each time we produce a pull request.
29+
2. [Install](https://docs.apigee.com/api-platform/system-administration/auth-tools#install) and run the Apigee [get_token](https://docs.apigee.com/api-platform/system-administration/using-gettoken) tool to obtain an access token.
30+
3. Set this value against the `APIGEE_ACCESS_TOKEN` variable in your .env file.
31+
4. Finally, use the Makefile to run your desired suite of tests.
7532

76-
These tests are run seamlessly in the pipeline. But if you are doing some local changes and want to test against your
77-
PR environment, please follow these pre-requisites to get it working:
33+
Note: the `get_token` tool is only supported in Linux environments, so if you are using a Windows environment, you will
34+
at least need to run the operation in WSL to obtain the access token.
7835

79-
1. [Install](https://docs.apigee.com/api-platform/system-administration/auth-tools#install) and run the Apigee [get_token](https://docs.apigee.com/api-platform/system-administration/using-gettoken) tool to obtain an access token.
80-
2. Set this value against the `APIGEE_ACCESS_TOKEN` in your .env file.
81-
3. Finally, use the [.env.example.pr](./.env.example.pr) as your baseline for your .env file and fill all of the required values.
36+
## Setup when using static apps
8237

83-
Note: the `get_token` tool is only supported in Linux environments, so if you are using a Windows environment, you will
84-
at least need to run the operation in WSL to obtain the access token.
38+
**NOTE:** you must use this approach in INT.
39+
40+
1. Configure your .env file with the required values.
41+
42+
The [.env.example.static](./.env.example.static) template defines all the values you will need and explains how
43+
to obtain them. A lot more configuration is required as you will need to obtain all the `{Supplier}_client_Id` and
44+
`{Supplier}_client_Secret` values for the static apps in your target environment.
45+
46+
2. Finally, use the Makefile to run your desired suite of tests.
47+
48+
## Test commands
49+
50+
The `Makefile` in this directory provides the following commands:
51+
52+
- `make test` - run all tests (may take some time)
53+
- `make test-api-full` - run API tests
54+
- `make test-api-smoke` - run API smoke tests only (quicker)
55+
- `make test-batch-full` - run Batch tests
56+
- `make test-batch-smoke` - run Batch smoke tests only (quicker)
57+
- `make test-sandbox` - run lightweight tests for the sandbox i.e. just checks /\_ping and /\_status
58+
- `make collect-only` - check that all tests are discovered
59+
60+
If you want even more granular control, you can run `poetry run pytest features -m` followed by the given suite you
61+
want to run e.g. `Delete_Feature`, `Create_Batch_Feature` and so on.

tests/e2e_automation/utilities/apigee/apigee_env_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def use_temp_apigee_apps() -> bool:
3434
if get_proxy_name() == INT_PROXY_NAME:
3535
return False
3636

37-
return os.getenv("USE_STATIC_APPS", "false") != "true"
37+
return os.getenv("USE_STATIC_APPS", "False") != "True"
3838

3939

4040
def is_pr_env() -> bool:

0 commit comments

Comments
 (0)