Skip to content

Commit 9085952

Browse files
JamesW1-NHSKrupasindhu Baraldlzhry2nhs
committed
VED-1012 Automation test project (#1124)
* initial commit for automation end to end tests * Fix linting to meet baselines * Ignore Allure reports and run prettier checks * Fix up README * Sonarcloud advice * init: project & makefile * cleanup test results * full SHAs * TEMP: exclude tests/e2e_automation/ from ruff * Minor fixes and ignores * TEMP: exclude tests/e2e_automation/ from ruff * revert temp excludes * init: yml changes * dependabot * reverted changes * make smoke-test * reverted * README * README II * README III * .env.example * .env.example II * Makefile * .gitignore * pyproject.toml * .env.example III * .env.example IV --------- Co-authored-by: Krupasindhu Baral <krupasindhu.baral@nhs.net> Co-authored-by: Daniel Yip <daniel.yip4@nhs.net>
1 parent b56a9bc commit 9085952

8 files changed

Lines changed: 1179 additions & 88 deletions

File tree

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ updates:
6363
- "/lambdas/redis_sync"
6464
- "/lambdas/shared"
6565
- "/tests/e2e"
66+
- "/tests/e2e_automation"
6667
- "/tests/e2e_batch"
6768
schedule:
6869
interval: "daily"

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ newman/
1212
**/*.iml
1313

1414
__pycache__/
15+
.pytest_cache/
1516
.venv/
1617
.env
1718
.envrc
@@ -30,7 +31,6 @@ openapi.json
3031

3132
devtools/volume/
3233
**/.coverage
33-
3434
**/test-results.xml
3535
allure-results/
3636
allure-report/

tests/e2e_automation/.env.example

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
username=joebloggs
2+
scope=nhs-xyz
3+
aws_token_refresh= True
4+
########## INT env
5+
# baseUrl=https://int.api.service.nhs.uk/immunisation-fhir-api/FHIR/R4
6+
# auth_url=https://int.api.service.nhs.uk/oauth2-mock/authorize
7+
# token_url=https://int.api.service.nhs.uk/oauth2-mock/token
8+
# callback_url=https://oauth.pstmn.io/v1/callback
9+
# S3_env=int
10+
# aws_profile_name={your-aws-profile}
11+
## Id/Secret values - please contact Dev or Test team to get these values
12+
# Postman_Auth_client_Id=
13+
# Postman_Auth_client_Secret=
14+
# RAVS_client_Id=
15+
# RAVS_client_Secret=
16+
# MAVIS_client_Id=
17+
# MAVIS_client_Secret=
18+
# EMIS_client_Id=
19+
# EMIS_client_Secret=
20+
# SONAR_client_Id=
21+
# SONAR_client_Secret=
22+
# TPP_client_Id=
23+
# TPP_client_Secret=
24+
# MEDICUS_client_Id=
25+
# MEDICUS_client_Secret=
26+
########## Internal-QA env
27+
baseUrl=https://internal-qa.api.service.nhs.uk/immunisation-fhir-api/FHIR/R4
28+
auth_url=https://internal-qa.api.service.nhs.uk/oauth2-mock/authorize
29+
token_url=https://internal-qa.api.service.nhs.uk/oauth2-mock/token
30+
callback_url=https://oauth.pstmn.io/v1/callback
31+
S3_env=internal-qa
32+
aws_profile_name={your-aws-profile}
33+
## Id/Secret values - please contact Dev or Test team to get these values
34+
Postman_Auth_client_Id=
35+
Postman_Auth_client_Secret=
36+
RAVS_client_Id=
37+
RAVS_client_Secret=
38+
MAVIS_client_Id=
39+
MAVIS_client_Secret=
40+
EMIS_client_Id=
41+
EMIS_client_Secret=
42+
SONAR_client_Id=
43+
SONAR_client_Secret=
44+
TPP_client_Id=
45+
TPP_client_Secret=
46+
MEDICUS_client_Id=
47+
MEDICUS_client_Secret=

tests/e2e_automation/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-include .env
2+
3+
cmd = poetry run pytest
4+
5+
test:
6+
$(cmd)
7+
8+
test-api-smoke:
9+
$(cmd) features/APITests -m smoke
10+
11+
test-api-full:
12+
$(cmd) features/APITests -m functional
13+
14+
test-batch-smoke:
15+
$(cmd) features/batchTests -m smoke
16+
17+
test-batch-full:
18+
$(cmd) features/batchTests -m functional
19+
20+
collect-only:
21+
$(cmd) --collect-only

tests/e2e_automation/README.md

Lines changed: 39 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,56 @@
1-
# imms_fhir_api_automation
1+
# End-to-end Automation Tests
22

3-
pytest-bdd Automation for Immunisation FHIR API
3+
This directory contains End-to-end Automation Tests for the Immunisation FHIR API.
44

5-
## Need to check in case any other libraries to be added
5+
## Setting up e2e_automation tests to run locally
66

7-
## Installation
7+
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`).
88

9-
This test pack requires Python 3.10 installed on the system or greater to run.
9+
2. Add values to the .env file.
1010

11-
To execute the tests from your system, please follow the 4 easy steps below:
11+
For an example of a template .env file, see [.env.example](./.env.example).
1212

13-
1. Clone the repo to any local folder
14-
2. Create a virtual environment
13+
The following values should be added:
1514

16-
```console
17-
# python -m venv .venv
1815
```
19-
20-
3. Install all dependencies
21-
22-
```console
23-
# pip install -r .\requirements.txt
16+
aws_token_refresh=True
17+
baseUrl=https://internal-qa.api.service.nhs.uk/immunisation-fhir-api/FHIR/R4
18+
auth_url=https://internal-qa.api.service.nhs.uk/oauth2-mock/authorize
19+
token_url=https://internal-qa.api.service.nhs.uk/oauth2-mock/token
20+
callback_url=https://oauth.pstmn.io/v1/callback
21+
S3_env=internal-qa
22+
aws_profile_name={your-profile}
2423
```
2524
26-
4. To activate env
27-
a. in git bash terminal
28-
`console
29-
source .venv/Scripts/activate
30-
`
31-
b. in Terminal
32-
`console
33-
.venv\Scripts\Activate.ps1
34-
`
25+
3. Add login and secret values to the .env file.
3526
36-
5. Need to create .env file, please get in touch with Imms FHIR API Test team to get the content of the file
27+
**Please contact the Imms FHIR API Test team to get these values.**
3728
38-
6. run following command to see that test are discovered
29+
The following values should be added:
3930
40-
```console
41-
# pytest --collect-only
31+
```
32+
username
33+
scope
34+
Postman_Auth_client_Id
35+
Postman_Auth_client_Secret
36+
RAVS_client_Id
37+
RAVS_client_Secret
38+
MAVIS_client_Id
39+
MAVIS_client_Secret
40+
EMIS_client_Id
41+
EMIS_client_Secret
42+
SONAR_client_Id
43+
SONAR_client_Secret
44+
TPP_client_Id
45+
TPP_client_Secret
46+
MEDICUS_client_Id
47+
MEDICUS_client_Secret
4248
```
4349
44-
7. install and configure Aws CLI using following commands:
45-
1. pip install awscli
46-
2. aws configure
47-
3. if you want to use aws configure sso then install aws cli 2 and follow the instructions on AWS access key page.
48-
49-
8. to update the python packages run command 1 and to update requirement file run command 2.
50-
1. python -m pip install --upgrade <package name>
51-
2. python -m pip freeze > requirements.txt
52-
53-
----DO NOT USE BELOW---------------------------------------------
54-
55-
## Reporting
56-
57-
To create the json report -
58-
pip install allure-behave
59-
60-
Command -
61-
behave -f allure_behave.formatter:AllureFormatter -o output/allure-results
62-
63-
## To convert the json file to html in Allure Reporting
64-
65-
Dwnload the latest release allure-2.32.2.zip Allure Package from <https://github.com/allure-framework/allure2/releases>
66-
Unzip the folder and add the bin directory to system variable path
67-
68-
Command to convert the json reports to html -
69-
allure serve output/allure-results
70-
71-
Command to generate the html report manually if BROWSE does not work -
72-
allure generate output/allure-results -o output/allure-report --clean
73-
74-
Start a http server to view the results -
75-
python -m http.server
76-
77-
## To Open the index.html file
78-
79-
once the allure plug in place then we need to update the ymal with following code :
80-
'''
81-
82-
- script: |
83-
source venv/bin/activate
84-
pytest --junitxml=output/test-results.xml --alluredir=output/allure-results || true
85-
displayName: 'Run Pytest-BDD tests with Allure'
86-
87-
- task: Bash@3
88-
displayName: 'Generate Allure Report'
89-
inputs:
90-
targetType: 'inline'
91-
script: |
92-
allure generate output/allure-results --clean -o output/allure-report
93-
94-
- script: ls -la output/allure-report
95-
displayName: 'List Allure Report Contents'
50+
4. Run `poetry install --no-root` to install dependencies.
9651
97-
- task: PublishBuildArtifacts@1
98-
displayName: 'Publish Allure Report Artifact'
99-
inputs:
100-
pathToPublish: 'output/allure-report'
101-
artifactName: 'AllureReport'
102-
publishLocation: 'Pipeline'
52+
5. The `Makefile` in this directory provides the following commands:
10353
104-
'''
54+
- `make test` - run all tests (may take some time)
55+
- `make smoke-test` - run smoke tests only (quicker)
56+
- `make collect-only` - check that all tests are discovered

0 commit comments

Comments
 (0)