Skip to content

Commit

Permalink
feat(int): add integration tests (#118)
Browse files Browse the repository at this point in the history
* feat(test): add integration tests

* feat(test): add integration tests

* feat(test): add integration tests

* refactor: move unit tests into src/test/unit dir

* refactor: tidy up test runners

* feat(int): recreated issue with validateConsentRequests

* fix(rules): debugging rules engine issues

* feat(int): finish basic integration tests

* feat(ci): add integration tests to ci/cd

* fix(lint): add jest settings to eslint

* fix(ci): fix ci

* fix(ci): fix ci
  • Loading branch information
lewisdaly committed Oct 11, 2021
1 parent 1480d1c commit 823d4a2
Show file tree
Hide file tree
Showing 20 changed files with 2,149 additions and 119 deletions.
55 changes: 55 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,48 @@ jobs:
echo "Not a release (env CIRCLE_BRANCH != 'master'), skipping sending lcov.info to SonarQube."
fi
test-integration:
executor: default-machine
steps:
- checkout
- restore_cache:
key: dependency-cache-v1-{{ checksum "src/package-lock.json" }}
paths:
- src/node_modules
- src/lib/log/node_modules
- src/lib/validate/node_modules
- run:
name: Set up NVM
command: |
echo ${NVM_DIR}
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install v12.16.0
nvm alias default v12.16.0
- run:
name: install modules
command: |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
node --version
cd src && npm ci
- run:
name: Spin up core docker compose
command: |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
cd src && docker-compose build
docker-compose up -d
- run:
name: Sleep for 30 seconds while waiting for docker
command: |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
sleep 30
- run:
name: Execute integration tests
command: |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
cd ~/project/git/src
npm ci
npm -s run test:integration
vulnerability-check:
executor: default-docker
steps:
Expand Down Expand Up @@ -464,6 +506,18 @@ workflows:
- /feature*/
- /bugfix*/
- /hotfix*/
- test-integration:
context: org-global
requires:
- setup
filters:
tags:
only: /.*/
branches:
ignore:
- /feature*/
- /bugfix*/
- /hotfix*/
- vulnerability-check:
context: org-global
requires:
Expand Down Expand Up @@ -494,6 +548,7 @@ workflows:
- setup
- test-unit
- test-coverage
- test-integration
- vulnerability-check
- audit-licenses
filters:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ goldenpayeefsp
.vscode/
/init/.DS_Store
/.DS_Store


junit.xml
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,14 @@ curl -X POST \

## Mutual TLS

### Testing

#### Create secrets
Use the script in `./scripts/mutualtls.sh`. Secrets will be generated in `./src/secrets`

#### Test functionality
TODO

# Develop
# Developing

## Build
## Build tools

Dirty build, tagged with '-local' (will build clean if you don't have uncommitted local changes):
```bash
Expand All @@ -143,7 +140,7 @@ Specifically versioned build (dirty if you have local changes):
make build_clean VER=whatever-you-like
```

## Push to repo
## Push to docker hub repo
```bash
make push
```
Expand All @@ -152,3 +149,21 @@ make push
```bash
docker-compose up
```


## Unit Tests

```bash
cd ./src
npm run test:unit
```

## Integration Tests

```bash
cd ./src
docker-compose up -d

# wait until mojaloop-simulator is up and running
npm run test:integration
```
2 changes: 2 additions & 0 deletions src/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const config = {
extends: 'airbnb-base',
plugins: ['jest'],
env: {
node: true,
'jest/globals': true,
},
rules: {
indent: [
Expand Down
1 change: 1 addition & 0 deletions src/.nycrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ exclude:
- '**/test-api/**'
- '**/coverage/**'
- '**/.eslintrc.js'
- '**/jest.integration.config.js'
45 changes: 25 additions & 20 deletions src/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
version: '3'
services:
redis:
image: "redis:5.0.4-alpine"
sim:
image: "mojaloop-simulator-backend"
build: ../
env_file: ./sim-backend.env
ports:
- "3000:3000"
- "3001:3001"
- "3003:3003"
depends_on:
- scheme-adapter
scheme-adapter:
image: "mojaloop/sdk-scheme-adapter:latest"
env_file: ./scheme-adapter.env
ports:
- "3500:3000"
- "3501:4000"
depends_on:
- redis
redis:
image: "redis:5.0.4-alpine"

sim:
image: "mojaloop-simulator-backend"
build: ../
env_file: ./sim-backend.env
volumes:
- ./rules.json:/src/rules.json

ports:
- "3000:3000"
- "3001:3001"
- "3003:3003"
depends_on:
- scheme-adapter

scheme-adapter:
image: "mojaloop/sdk-scheme-adapter:latest"
env_file: ./scheme-adapter.env
ports:
- "3500:3000"
- "3501:4000"
depends_on:
- redis
11 changes: 11 additions & 0 deletions src/jest.integration.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

module.exports = {
// roots: ['<rootDir>/', '<rootDir>/test/integration'],
roots: ['<rootDir>/'],
verbose: true,
testEnvironment: 'node',
collectCoverage: false,
clearMocks: true,
reporters: ['jest-junit', 'default'],
};
Loading

0 comments on commit 823d4a2

Please sign in to comment.