Skip to content

Commit

Permalink
feat: add integration tests (#552)
Browse files Browse the repository at this point in the history
* chore: add documentation

* fix: makefile

* chore: remove postman

* feat: add tests data

* feat: add purge test

* chore: update tests version

* chore: add integration tests in CI
  • Loading branch information
Thomgrus authored Dec 1, 2021
1 parent e147926 commit d66d91a
Show file tree
Hide file tree
Showing 12 changed files with 459 additions and 11 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,11 @@ jobs:
uses: github/codeql-action/analyze@v1
with:
category: "ara_api"
-
name: Integration tests
run: |
pushd code/tests
make start-local
make test-karate BATCH=true
make destroy-local
popd
3 changes: 0 additions & 3 deletions code/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ version: '3'
services:
ara-db:
image: "postgres:12"
pull_policy: always
restart: unless-stopped
environment:
- POSTGRES_DB=ara
Expand All @@ -18,7 +17,6 @@ services:
- 5432:5432
ara-api:
image: "decathlon/ara-api:${API_VERSION:-latest}"
pull_policy: always
restart: unless-stopped
environment:
- ARA_DATABASE_TARGET=postgresql
Expand All @@ -32,7 +30,6 @@ services:
db_net: {}
ara-web-ui:
image: "decathlon/ara-web-ui:${WEB_UI_VERSION:-latest}"
pull_policy: always
restart: unless-stopped
environment:
- ARA_API_HOST=ara-api
Expand Down
10 changes: 9 additions & 1 deletion code/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@ start-local: ## Start local environment
destroy-local: ## Destroy local environment
@docker compose -f ../docker-compose.yaml down

# WITH JAVA MAVEN
logs-local: ## Display logs for local, SERVICE can be set to choose service to log
@docker compose -f ../docker-compose.yaml logs $(SERVICE) -f --tail 200

test-karate: ## Run tests. You can specify TARGET_ENV to change tests env.
@echo '-- Run tests With env: $(TARGET_ENV) --'
@echo 'Check app availability'
@docker compose -f docker-compose-tests.yaml run available-check
ifeq ($(TARGET_ENV),local)
@docker compose -f docker-compose-tests.yaml run load-data && echo 'Test data initialized'
endif
-@mvn clean verify -DargLine="-Dkarate.env=$(TARGET_ENV) -Dkarate.config.dir=secrets"
ifneq ($(BATCH),true)
@open file:///$$PWD/target/karate-reports/karate-summary.html
endif


#####################################
Expand Down
21 changes: 21 additions & 0 deletions code/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,24 @@ To clear local environment you can destroy it with:
```shell
make destroy-local
```

You can see application logs with:

```shell
make logs-local
```

You can also specify one service:

```shell
make logs-local SERVICE=ara-api
```

There is actually 4 services you can target:

* ara-api
* ara-db
* ara-web-ui
* oauth2-dev-server

This service correspond to declared service in `../code/docker-compose.yaml`
62 changes: 62 additions & 0 deletions code/tests/data/clear-data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
START transaction;

alter TABLE communication ALTER CONSTRAINT "FK5t8uwtv8vxpxkji11v5bl338e" DEFERRABLE;

alter TABLE country_deployment ALTER CONSTRAINT "FK7huof3ay98nqnd2qo1tpha9jr" DEFERRABLE;
alter TABLE country_deployment ALTER CONSTRAINT "FKocj9121ua7k7mlefbpv2yn0a7" DEFERRABLE;

alter TABLE error ALTER CONSTRAINT "FK84lin3r56t0fr1ebbfdp7jyco" DEFERRABLE;

alter TABLE executed_scenario ALTER CONSTRAINT "FK9klaki5wrqxytpd8mc0rhme2q" DEFERRABLE;

alter TABLE execution ALTER CONSTRAINT "FK9ima3x6oi0lhaq4y7t6uxpk42" DEFERRABLE;

alter TABLE functionality_coverage ALTER CONSTRAINT "FK9svcjqg009nq3occpvd7sfx5k" DEFERRABLE;
alter TABLE functionality_coverage ALTER CONSTRAINT "FKpcol94n02a8mv94ls64ao6p" DEFERRABLE;

alter TABLE problem ALTER CONSTRAINT "FKmou64hw0xh3mdspog4s9si9gv" DEFERRABLE;
alter TABLE problem ALTER CONSTRAINT "FKpjf9330s0digv54qmyjnx2p8y" DEFERRABLE;

alter TABLE problem_occurrence ALTER CONSTRAINT "FK7lub23f9xbi92jqumgrjts9tk" DEFERRABLE;
alter TABLE problem_occurrence ALTER CONSTRAINT "FKm3twuhvstqk2icoycegrcmu69" DEFERRABLE;

alter TABLE problem_pattern ALTER CONSTRAINT "FK38mpcmm4yrd45j8acvhb4hpbj" DEFERRABLE;
alter TABLE problem_pattern ALTER CONSTRAINT "FKbeunicbf28ol04ycus2ufc306" DEFERRABLE;
alter TABLE problem_pattern ALTER CONSTRAINT "FKs01euft4h2f624wmm2tc2yjc9" DEFERRABLE;

alter TABLE run ALTER CONSTRAINT "FK8smfl4y1xptsycam7l2t0im88" DEFERRABLE;
alter TABLE run ALTER CONSTRAINT "FKi98yyj4el7fl24gpwngrg5462" DEFERRABLE;
alter TABLE run ALTER CONSTRAINT "FKj1gpmjyluw5u1lw3fn1x0r6pr" DEFERRABLE;

alter TABLE scenario ALTER CONSTRAINT "FKt6q9f0vta0y064s3fi4usfd5k" DEFERRABLE;

alter TABLE "type" ALTER CONSTRAINT "FK420i11bbyj0gxc6ukecynerb0" DEFERRABLE;

SET CONSTRAINTS ALL DEFERRED;
delete from communication cascade;
delete from country cascade;
delete from country_deployment cascade;
delete from cycle_definition cascade;
delete from databasechangelog cascade;
delete from databasechangeloglock cascade;
delete from error cascade;
delete from executed_scenario cascade;
delete from execution cascade;
delete from execution_completion_request cascade;
delete from functionality cascade;
delete from functionality_coverage cascade;
delete from problem cascade;
delete from problem_occurrence cascade;
delete from problem_pattern cascade;
delete from project cascade;
delete from root_cause cascade;
delete from run cascade;
delete from scenario cascade;
delete from setting cascade;
delete from severity cascade;
delete from "source" cascade;
delete from team cascade;
delete from technology_setting cascade;
delete from "type" cascade;

COMMIT;
Loading

0 comments on commit d66d91a

Please sign in to comment.