Skip to content

Commit

Permalink
fix(integration): reenable skipped integration tests (#89)
Browse files Browse the repository at this point in the history
* fix(integration): debugging bad config and mysql issues

* fix(integration): debugging bad config and mysql issues

* chore: cleanup console.log

* chore: appease linting gods

* fix(ci): debugging wait4 script

* fix(ci): debugging wait4 script
  • Loading branch information
lewisdaly authored Sep 16, 2021
1 parent 26a11e6 commit d2a4114
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 145 deletions.
9 changes: 7 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,25 @@ jobs:
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
docker-compose up -d
./scripts/wait4.js cicd-integration-tests
# use development env since we are connecting to db outside of docker
environment:
NODE_ENV: "integration"
NODE_ENV: "development"
- run:
name: Migrate DB
command: |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
npm -s run migrate
# use development env since we are connecting to db outside of docker
environment:
NODE_ENV: "development"
- run:
name: Execute integration tests
command: |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
npm -s run test:integration
# use development env since we are connecting to db outside of docker
environment:
NODE_ENV: "integration"
NODE_ENV: "development"
- run:
name: Prepare test results
command: |
Expand Down
2 changes: 1 addition & 1 deletion config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"PARTICIPANT_ID": "centralAuth",
"REDIS": {
"PORT": 6379,
"HOST": "redis",
"HOST": "localhost",
"TIMEOUT": 100
},
"INSPECT": {
Expand Down
2 changes: 1 addition & 1 deletion config/integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"client": "mysql",
"version": "5.5",
"connection": {
"host": "172.17.0.1",
"host": "mysql",
"port": 3306,
"user": "auth-service",
"password": "password",
Expand Down
20 changes: 0 additions & 20 deletions docker-compose.linux.yml

This file was deleted.

6 changes: 5 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ networks:
services:
auth-service:
container_name: as_auth-service
# image: mojaloop/auth-service:local
image: mojaloop/auth-service:local
build:
context: .
cache_from:
Expand All @@ -22,13 +22,17 @@ services:
volumes:
- ./scripts/wait4.js:/opt/auth-service/scripts/wait4.js
- ./scripts/wait4.config.js:/opt/auth-service/scripts/wait4.config.js
# Mount the config folder for easy config updates
- ./config:/opt/auth-service/config
environment:
- NODE_ENV=integration
- LOG_LEVEL=debug
healthcheck:
test: wget -q http://localhost:4004/health -O /dev/null || exit 1
timeout: 20s
retries: 30
interval: 15s
user: root

mysql:
image: mysql/mysql-server
Expand Down
83 changes: 46 additions & 37 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"@hapi/hapi": "^20.1.5",
"@hapi/inert": "^6.0.3",
"@hapi/vision": "^6.1.0",
"@mojaloop/api-snippets": "^12.6.2",
"@mojaloop/api-snippets": "^12.6.6",
"@mojaloop/central-services-error-handling": "11.3.0",
"@mojaloop/central-services-health": "^13.0.0",
"@mojaloop/central-services-logger": "10.6.1",
Expand Down
2 changes: 1 addition & 1 deletion src/domain/stateMachine/registerConsent.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export class RegisterConsentModel
}
const res = await axios.post(alsParticipantURI, payload, axiosConfig)
this.logger.push({ res, channel })
.log('POST /participants/{Type}/{ID} call sent to ALS, listening on response')
.debug('POST /participants/{Type}/{ID} call sent to ALS, listening on response')
})
.job(async (message: Message): Promise<void> => {
try {
Expand Down
2 changes: 2 additions & 0 deletions src/model/consent/consent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import { NotFoundError, RevokedConsentModificationError } from '../errors'
import Knex from 'knex'
import { thirdparty as tpAPI } from '@mojaloop/api-snippets'
import { logger } from '~/shared/logger'

/*
* Interface for Consent resource type as modelled in DB
Expand Down Expand Up @@ -89,6 +90,7 @@ export class ConsentDB {
// Add initial Consent parameters
// Error bubbles up in case of primary key violation
public async insert(consent: ConsentModel, trx?: Knex.Transaction): Promise<boolean> {
logger.debug(`ConsentDB.insert - ${JSON.stringify(consent)}`)
// optionally insert in transaction
const action = this.Db<ConsentModel>(tableName).insert(consent)
if (trx) {
Expand Down
13 changes: 12 additions & 1 deletion src/model/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
******/

import Knex from 'knex'
import { logger } from '~/shared/logger'
import Config from '../shared/config'
import { ConsentModel, ConsentDB } from './consent'
import { ScopeModel, ScopeDB } from './scope'
Expand All @@ -46,6 +47,7 @@ async function insertConsentWithScopes (consent: ConsentModel, scopes: ScopeMode
await scopeDB.insert(scopes, trx)
await trx.commit()
} catch (err) {
logger.push(err).debug('db.insertConsentWithScopes error')
await trx.rollback()
throw err
}
Expand All @@ -59,12 +61,21 @@ async function getScopesForConsentId (consentId: string): Promise<Array<ScopeMod
return scopeDB.getForConsentId(consentId)
}

async function testCleanupConsents (consentIds: Array<string>): Promise<void> {
await Promise.all(consentIds.map(async id => {
return consentDB.delete(id)
}))
}

export {
Db,
consentDB,
scopeDB,
closeKnexConnection,
insertConsentWithScopes,
getConsent,
getScopesForConsentId
getScopesForConsentId,

// Test utils
testCleanupConsents
}
Loading

0 comments on commit d2a4114

Please sign in to comment.