Skip to content

Commit

Permalink
Add integration tests (#6)
Browse files Browse the repository at this point in the history
* Add integration tests

* remove unneeded comments

* Whitelist pyest functions

* Add integration_tests to github actions

* Add psycopg2 to pipfile

* Update pipfile lockfile

* Remove unneeded services and move data setup to tests

* Update Pipfile

* Update whitelist

* Update docker-compose file

* Update workflow

* Remove unused code

* use shared conftest.py

* Update Makefile

Co-authored-by: Adam <[email protected]>

---------

Co-authored-by: Hugh Brace <[email protected]>
Co-authored-by: Adam <[email protected]>
  • Loading branch information
3 people authored Sep 18, 2023
1 parent d02d07c commit f0483f1
Show file tree
Hide file tree
Showing 15 changed files with 477 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: make load_templates

- name: Run Tests and Checks
run: make unit_test
run: make unit_test integration_test

- name: Check Docker Build
run: make docker_build
Expand Down
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ update_vulture_whitelist:
lint: flake vulture

unit_test: lint
APP_CONFIG=TestingConfig pipenv run pytest --cov rh_ui --cov-report term-missing --cov-report xml
APP_CONFIG=TestingConfig pipenv run pytest tests/unit --cov rh_ui --cov-report term-missing --cov-report xml

test: install unit_test
test: install unit_test integration_test

build: test docker_build

Expand All @@ -52,4 +52,16 @@ compile_translations:
translate:
pipenv run pybabel extract -F babel.cfg -o rh_ui/translations/messages.pot . # update the .pot files basing on templates
pipenv run pybabel update -i rh_ui/translations/messages.pot -d rh_ui/translations # update .po files basing on .pot
pipenv run pybabel compile -d rh_ui/translations
pipenv run pybabel compile -d rh_ui/translations

up:
docker compose up -d
bash ./tests/integration/wait_for_dependencies.sh

down:
docker compose down

integration_test: up
APP_CONFIG=TestingConfig pipenv run pytest tests/integration
docker compose down

130 changes: 70 additions & 60 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ class DevelopmentConfig(BaseConfig):

class TestingConfig(DevelopmentConfig):
DEBUG = False
RH_SVC_URL = os.getenv("RH_SVC_URL", "http://localhost:9071/")
54 changes: 54 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
version: '3.8'
services:
pubsub-emulator-rh-ui-it:
container_name: pubsub-emulator-rh-ui-it
image: europe-west2-docker.pkg.dev/ssdc-rm-ci/docker/gcloud-pubsub-emulator:latest
ports:
- "9538:8538"

setup-pubsub-emulator-rh-ui-it:
container_name: setup-pubsub-emulator-rh-ui-it
image: europe-west2-docker.pkg.dev/ssdc-rm-ci/docker/gcloud-pubsub-emulator:latest
environment:
- PUBSUB_SETUP_HOST=pubsub-emulator-rh-ui-it:8538
volumes:
- ./tests/integration/setup_pubsub.sh:/setup_pubsub.sh
depends_on:
- pubsub-emulator-rh-ui-it
entrypoint: sh -c "/setup_pubsub.sh"

firestore-emulator:
container_name: firestore-emulator-rh-ui-it
image: europe-west2-docker.pkg.dev/ssdc-rm-ci/docker/gcloud-firestore-emulator:latest
ports:
- "9542:8540"

rh-service:
container_name: rh-service-rh-ui-it
image: europe-west2-docker.pkg.dev/ssdc-rm-ci/docker/ssdc-rh-service:latest
ports:
- "9071:8071"
environment:
- spring.cloud.gcp.pubsub.emulator-host=pubsub-emulator-rh-ui-it:8538
- spring.cloud.gcp.pubsub.project-id=rh-ui-project
- QUEUECONFIG_SHARED-PUBSUB-PROJECT=rh-ui-project
- firestore.project-id=rh-ui-project
- FIRESTORE_EMULATOR_HOST=firestore-emulator-rh-ui-it:8540
- GOOGLE_APPLICATION_CREDENTIALS=/gcp/config/google-credentials.json
- GOOGLE_CLOUD_PROJECT=rh-ui-dummy-local
- EQ_RESPONSE-ID-PEPPER=TABASCO_SAUCE
- JWT_KEYS=/home/rh-service/keys/eq-keys.json
- MESSAGELOGGING_LOGSTACKTRACES=true
volumes:
- type: bind
source: ./tests/resources/fake-service-account.json # The spring Firestore client requires google credentials, give it a dummy account locally
target: /gcp/config/google-credentials.json
- ./tests/resources/java_healthcheck:/opt/healthcheck
- ./tests/resources/dummy_keys:/home/rh-service/keys
restart: always
healthcheck:
test: [ "CMD", "java", "-jar", "/opt/healthcheck/HealthCheck.jar", "http://localhost:8071/actuator/health" ]
interval: 5s
timeout: 3s
retries: 20
start_period: 5s
Empty file added tests/integration/__init__.py
Empty file.
Loading

0 comments on commit f0483f1

Please sign in to comment.