Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 181 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,198 @@
# EHRbase Integration Tests with Robot Framework

## Running the tests locally
## Running Robot tests outside of Docker

Before running the tests, make sure the following prerequisites are in place:
1. Python 3.11.* & Pip are installed:
- https://www.python.org/downloads/
- https://pip.pypa.io/en/stable/installation/
2. Robot Framework & dependencies are installed (run `pip install -r requirements.txt` inside the `tests` folder)
3. An EHRbase instance is running on port `8080`
<details>
<summary><b>Prerequisites</b></summary>
<br>

This command will run all tests from `tests/robot` folder.
DB and server have to be started prior to running the tests.
1. **Docker installed**
* [Get Docker](https://docs.docker.com/get-started/get-docker/)
2. **Python 3.11.x & Pip installed:**
* [Python Downloads](https://www.python.org/downloads/)
* [Pip Installation Guide](https://pip.pypa.io/en/stable/installation/)
3. **Robot Framework & dependencies installed:**
* Run the following command inside your `.\integration-tests\tests` folder path:
```bash
pip install -r requirements.txt
```
4. **An EHRbase instance running on port `8080`:**
<details>
<summary><i>Click to expand: Configure & run EHRbase instance</i></summary>
<br>

1. Create the Docker network:
```bash
docker network create ehrbase-net
```
2. Spin up the Postgres database:
```bash
docker run --name ehrdb --network ehrbase-net -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 ehrbase/ehrbase-v2-postgres:16.2
```
3. Get EHRBase repository locally from https://github.com/ehrbase/ehrbase
4. Change the following properties in `ehrbase/configuration/src/main/resources/application.yml`:
```yaml
ehrscape.enabled: true
tags.enabled: true
aql.debugging-enabled: true
aql.response.generator-details-enabled: true
```
> **Note:** If you need to modify other settings, feel free to do so. However, please note that existing Robot tests are tightly coupled to the default configuration and may fail if other values are changed.

5. Build the project (run from the root `/ehrbase` folder):
```bash
mvn clean install -Dmaven.test.skip=true
```
6. Start the application (run from the root `/ehrbase` folder):
```bash
java -jar application/target/ehrbase.jar --server.nodename=local.ehrbase.org
```
7. Wait for the confirmation message in your console:
`Started EhrBase in X seconds`
</details>
</details>

From `.\integration-tests` root project directory, run:
```bash
cd tests
./run_local_tests.sh
.\run_local_tests.sh
```
Results will be stored in `.\integration-tests\results\test-suites`

---
## Running Robot tests in Docker

<details>
<summary><b>Prerequisites</b></summary>
<br>

## Running the test using docker
1. Get EHRBase repository locally from https://github.com/ehrbase/ehrbase (if not present)
2. Change the following properties in `.\ehrbase\configuration\src\main\resources\application.yml`:
```yaml
ehrscape.enabled: true
tags.enabled: true
aql.debugging-enabled: true
aql.response.generator-details-enabled: true
```
> **Note:** If you need to modify other settings, feel free to do so. However, please note that existing Robot tests are tightly coupled to the default configuration and may fail if other values are changed.
2. Build the project (run from the root `.\ehrbase` folder):
```bash
mvn clean install -Dmaven.test.skip=true
```
3. Build Docker image (run from the root `.\ehrbase` folder):
```bash
docker build -t ehrbase/ehrbase:next .
```
4. Set environment variable `EHRBASE_IMAGE`:
```bash
SET EHRBASE_IMAGE=ehrbase/ehrbase:next
```
</details>

Execute a single test suite (run from the root `.\ehrbase` folder).
* Results will be stored in `.\ehrbase\tests\results\(folder_with_test_suite_path_name)`.
* Example:
- .\ehrbase\tests\results\SANITY
- .\ehrbase\tests\results\STORED_QUERY
<details>
<summary><b>Expand commands to run tests in Docker</b></summary>
<br>

Execute a single test suite and store results in `./results`:
```bash
docker run -ti -v ./results:/integration-tests/results ehrbase/integration-tests:build runRobotTest \
docker compose -f docker-compose.yml -f tests/docker-compose-int-test.yml run \
--remove-orphans --rm ehrbase-integration-tests runRobotTest \
--serverBase http://ehrbase:8080 \
--name SANITY \
--path SANITY_TESTS \
--tags Sanity
--tags Sanity \
--env NONE
```
For the other suites, just replace below lines (for example) in the above full command:
```bash
...
--name STORED_QUERY \
--path STORED_QUERY_TESTS \
--tags stored_query \
...
```

Collect results of multiple tests into a single report
```bash
docker run -ti -v ./results:/integration-tests/results -v ./report:/integration-tests/report ehrbase/integration-tests:build collectRebotResults
...
--name COMPOSITION \
--path COMPOSITION_TESTS \
--tags COMPOSITION \
...
```
```bash
...
--name CONTRIBUTION \
--path CONTRIBUTION_TESTS \
--tags CONTRIBUTION \
...
```
```bash
...
--name DIRECTORY \
--path DIRECTORY_TESTS \
--tags DIRECTORY \
...
```
```bash
...
--name AQL \
--path AQL_TESTS \
--tags AQL_TESTS_PACKAGE \
...
```
```bash
...
--name EHR_SERVICE \
--path EHR_SERVICE_TESTS \
--tags EHR_SERVICE \
...
```
```bash
...
--name EHR_STATUS \
--path EHR_STATUS_TESTS \
--tags EHR_STATUS \
...
```
```bash
...
--name EHRSCAPE \
--path EHRSCAPE_TESTS \
--tags EhrScapeTag \
...
```
```bash
...
--name TAGS \
--path TAGS_TESTS \
--tags TAGS_SUITES \
...
```
```bash
...
--name TEMPLATE \
--path TEMPLATE_TESTS \
--tags template \
...
```
```bash
...
--name SWAGGER \
--path SWAGGER_TESTS \
--tags SWAGGER_EHRBASE \
...
```
</details>


## Reading results
For both options, log.html and output.xml files will be created where:
1. **output.xml** - generated during test execution. After test execution is completed, it will be automatically post-processed by [Rebot](https://robot-framework.readthedocs.io/en/stable/_modules/robot/rebot.html) tool, which is an integral part of Robot Framework, generating the user-friendly **log.html** file.
2. **log.html** - contains details about the executed test cases in HTML format. Test suite, test case and keyword details have a hierarchical structure for better readability.

References:
- [output.xml](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#output-file)
- [log.html](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#log-file)
44 changes: 22 additions & 22 deletions tests/run_local_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


# Set desired loglevel: NONE, INFO, DEBUG, TRACE (most details)
export LOG_LEVEL=TRACE
export LOG_LEVEL=DEBUG


# # UNCOMMENT NEXT LINE & COMMENT-OUT ALL OTHERS BELOW TO RUN ONLY 'XXX' TESTS
Expand All @@ -28,7 +28,7 @@ export LOG_LEVEL=TRACE

# RUN SANITY TESTS
robot -i Sanity -e circleci -e EHRSCAPE -e obsolete -e libtest \
--outputdir results/test-suites/SANITY_TESTS \
--outputdir ../results/test-suites/SANITY_TESTS \
--skiponfailure not-ready \
--flattenkeywords for \
--flattenkeywords foritem \
Expand All @@ -39,7 +39,7 @@ robot -i Sanity -e circleci -e EHRSCAPE -e obsolete -e libtest \

# RUN CONTRIBUTION SERVICE TESTS
robot -i CONTRIBUTION -e circleci -e EHRSCAPE -e obsolete -e libtest \
--outputdir results/test-suites/CONTRIBUTION_SERVICE \
--outputdir ../results/test-suites/CONTRIBUTION_SERVICE \
--skiponfailure not-ready \
--flattenkeywords for \
--flattenkeywords foritem \
Expand All @@ -50,7 +50,7 @@ robot -i CONTRIBUTION -e circleci -e EHRSCAPE -e obsolete -e libtest \

# RUN SWAGGER TESTS
robot -i SWAGGER_EHRBASE -e circleci -e EHRSCAPE -e obsolete -e libtest \
--outputdir results/test-suites/SWAGGER_TESTS \
--outputdir ../results/test-suites/SWAGGER_TESTS \
--skiponfailure not-ready \
--flattenkeywords for \
--flattenkeywords foritem \
Expand All @@ -61,7 +61,7 @@ robot -i SWAGGER_EHRBASE -e circleci -e EHRSCAPE -e obsolete -e libtest \

# RUN TEMPLATE TESTS
robot -i template -e circleci -e EHRSCAPE -e obsolete -e libtest \
--outputdir results/test-suites/TEMPLATE_TESTS \
--outputdir ../results/test-suites/TEMPLATE_TESTS \
--skiponfailure not-ready \
--flattenkeywords for \
--flattenkeywords foritem \
Expand All @@ -72,7 +72,7 @@ robot -i template -e circleci -e EHRSCAPE -e obsolete -e libtest \

# RUN STORED QUERY TESTS
robot -i stored_query -e circleci -e EHRSCAPE -e obsolete -e libtest \
--outputdir results/test-suites/STORED_QUERY_TESTS \
--outputdir ../results/test-suites/STORED_QUERY_TESTS \
--skiponfailure not-ready \
--flattenkeywords for \
--flattenkeywords foritem \
Expand All @@ -83,7 +83,7 @@ robot -i stored_query -e circleci -e EHRSCAPE -e obsolete -e libtest \

# RUN TAGS TESTS
robot -i TAGS_SUITES -e circleci -e EHRSCAPE -e obsolete -e libtest \
--outputdir results/test-suites/TAGS_TESTS \
--outputdir ../results/test-suites/TAGS_TESTS \
--skiponfailure not-ready \
--flattenkeywords for \
--flattenkeywords foritem \
Expand All @@ -94,7 +94,7 @@ robot -i TAGS_SUITES -e circleci -e EHRSCAPE -e obsolete -e libtest \

# RUN COMPOSITION SERVICE TESTS
robot -i COMPOSITION -e circleci -e EHRSCAPE -e obsolete -e libtest \
--outputdir results/test-suites/COMPOSITION_SERVICE \
--outputdir ../results/test-suites/COMPOSITION_SERVICE \
--skiponfailure not-ready \
--flattenkeywords for \
--flattenkeywords foritem \
Expand All @@ -105,7 +105,7 @@ robot -i COMPOSITION -e circleci -e EHRSCAPE -e obsolete -e libtest \

# RUN DIRECTORY SERVICE TESTS
robot -i DIRECTORY -e circleci -e EHRSCAPE -e obsolete -e libtest \
--outputdir results/test-suites/DIRECTORY_SERVICE \
--outputdir ../results/test-suites/DIRECTORY_SERVICE \
--skiponfailure not-ready \
--flattenkeywords for \
--flattenkeywords foritem \
Expand All @@ -116,7 +116,7 @@ robot -i DIRECTORY -e circleci -e EHRSCAPE -e obsolete -e libtest \

# RUN AQL TESTS
robot -i AQL_TESTS_PACKAGE -e circleci -e EHRSCAPE -e obsolete -e libtest \
--outputdir results/test-suites/AQL_TESTS \
--outputdir ../results/test-suites/AQL_TESTS \
--skiponfailure not-ready \
--flattenkeywords for \
--flattenkeywords foritem \
Expand All @@ -127,43 +127,43 @@ robot -i AQL_TESTS_PACKAGE -e circleci -e EHRSCAPE -e obsolete -e libtest \

# RUN EHR SERVICE TESTS
robot -i EHR_SERVICE -e circleci -e EHRSCAPE -e obsolete -e libtest \
--outputdir results/test-suites/EHR_SERVICE \
--outputdir ../results/test-suites/EHR_SERVICE \
--skiponfailure not-ready \
--flattenkeywords for \
--flattenkeywords foritem \
--flattenkeywords name:_resources.* \
--loglevel $LOG_LEVEL \
--name EHR \
--name EHR_SERVICE \
robot/EHR_SERVICE_TESTS/

# RUN EHR STATUS TESTS
robot -i EHR_STATUS -e circleci -e EHRSCAPE -e obsolete -e libtest \
--outputdir results/test-suites/EHR_STATUS \
--outputdir ../results/test-suites/EHR_STATUS \
--skiponfailure not-ready \
--flattenkeywords for \
--flattenkeywords foritem \
--flattenkeywords name:_resources.* \
--loglevel $LOG_LEVEL \
--name EHR \
--name EHR_STATUS \
robot/EHR_STATUS_TESTS/

# RUN KNOWLEDGE SERVICE TESTS
robot -i KNOWLEDGE -e circleci -e EHRSCAPE -e obsolete -e libtest \
--outputdir results/test-suites/KNOWLEDGE_SERVICE \
# RUN EHRSCAPE TESTS
robot -i EhrScapeTag -e circleci -e EHRSCAPE -e obsolete -e libtest \
--outputdir ../results/test-suites/EHRSCAPE \
--skiponfailure not-ready \
--flattenkeywords for \
--flattenkeywords foritem \
--flattenkeywords name:_resources.* \
--loglevel $LOG_LEVEL \
--name KNOWLEDGE \
robot/KNOWLEDGE_TESTS/
--name EHRSCAPE \
robot/EHRSCAPE_TESTS/


# POST PROCESS & MERGE OUTPUTS

# Create Log/Report with ALL DETAILS
rebot --outputdir results \
--name EHRbase \
rebot --outputdir ../results \
--name EHRbase Open Source Robot Tests \
--exclude TODO -e future -e obsolete -e libtest \
--removekeywords for \
--removekeywords wuks \
Expand All @@ -173,7 +173,7 @@ rebot --outputdir results \
--output EHRbase-output.xml \
--log EHRbase-log.html \
--report EHRbase-report.html \
results/test-suites/*/*.xml
../results/test-suites/*/*.xml



Expand Down
Loading