Skip to content

Commit

Permalink
resolved merge conflicts and updated version
Browse files Browse the repository at this point in the history
  • Loading branch information
RameshChoudhary committed May 17, 2018
2 parents f20fa0f + 1d7cdbf commit 2bfbba5
Show file tree
Hide file tree
Showing 161 changed files with 7,730 additions and 7,812 deletions.
57 changes: 45 additions & 12 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ stages:
- retry-service
- ldap-auth
- job-scheduler-service
- rule-engine-cluster-tests

cache:
untracked: true
paths:
paths:
- node_modules/

image: $REGISTRY/evfoundation-executor-docker13:node8alpine36
Expand Down Expand Up @@ -64,7 +65,7 @@ npminstall:
mongotest:
stage: pre-build-test
script:
- export NODE_ENV=docker
- export NODE_ENV=test
- export MONGO_HOST="10.73.53.144"
- export DB=mongo
- export DB_NAME=${CI_PIPELINE_ID}_mongo
Expand All @@ -80,10 +81,10 @@ mongotest:
tags:
- CEP_RUNNER

postgrestest:
.postgrestest:
stage: pre-build-test
script:
- export NODE_ENV=postgres
- export NODE_ENV=test
- export POSTGRES_HOST="10.73.53.144"
- export MONGO_HOST="10.73.53.144"
- export DB=postgres
Expand All @@ -99,14 +100,14 @@ postgrestest:
when: on_failure
tags:
- CEP_RUNNER

.oracletest:
image: $REGISTRY/debian-node-oracle-docker
stage: pre-build-test
script:
- cd .. && export PROJECT_DIR=$(pwd) && mv oe-cloud/ /root/ && cd /root/oe-cloud
- export APP_TAG=oracle
- export NODE_ENV=oracle
- export NODE_ENV=test
- export POSTGRES_HOST="10.73.53.144"
- export MONGO_HOST="10.73.53.144"
- export ORACLE_HOST=10.73.53.144
Expand All @@ -131,16 +132,21 @@ postgrestest:
- node server/oracle-utility.js
- cd .. && mv oe-cloud/ ${PROJECT_DIR} && cd ${PROJECT_DIR}/oe-cloud
tags:
- CEP_RUNNER
- CEP_RUNNER

.consistenthashtest:
consistenthashtest:
stage: pre-build-test
script:
- mkdir -p /data/db
- mongod --dbpath /data/db &
- haproxy -f ./test/consistenthash/haproxy.cfg -p /run/haproxy.pid -Ds &
- export APP_URL=http://localhost:8080/api
- NO_PROXY=$NO_PROXY,localhost,127.0.0.1
- git clone http://10.73.97.24/oecloud.io/oe-tx-router.git
- cd oe-tx-router
- time npm install --no-optional
- node . &
- cd ..
- time npm install --no-optional
- mocha test/consistenthash/server.js &
- sleep 60
Expand All @@ -152,9 +158,9 @@ postgrestest:

buildjob:
stage: build
script:
script:
- sed 's/\$REGISTRY/'"$REGISTRY"'/g' Dockerfile > Dockerfile2
- mv -f Dockerfile2 Dockerfile
- mv -f Dockerfile2 Dockerfile
- time npm install --no-optional
- time docker build -t ${REGISTRY}/${APP_IMAGE_NAME}:latest --no-cache --pull .
- docker push ${REGISTRY}/${APP_IMAGE_NAME}:latest
Expand All @@ -163,7 +169,7 @@ buildjob:
- CEP_RUNNER

swarm-actor-pattern:
stage: swarm-actor-pattern
stage: swarm-actor-pattern
script:
- export STARTUP_CMD="npm run grunt-cover"
- export FILE_NAME=docker-compose.test.env.yml
Expand All @@ -178,6 +184,8 @@ swarm-actor-pattern:
- echo "docker stack rm ${STACK_NAME}" > /removeStack.sh
- docker stack rm ${APP_IMAGE_NAME}
- time npm install --no-optional
- mkdir test/actor-tests/test-files/server
- node test/actor-tests/prepare-test.js
- cd test/actor-tests/test-files
- sed 's/\$REGISTRY/'"$REGISTRY"'/g' Dockerfile > Dockerfile2
- mv -f Dockerfile2 Dockerfile
Expand All @@ -204,7 +212,7 @@ swarm-actor-pattern:

retry-service:
stage: retry-service
script:
script:
- export ROUTER="cep_router"
#- export HAPROXY=10.73.96.214
- export ORIG_APP_IMAGE_NAME=${APP_IMAGE_NAME}
Expand All @@ -220,6 +228,8 @@ retry-service:
- docker stack rm ${RETRY_STACK_NAME}
- sleep 10
- time npm install --no-optional
- mkdir test/async-service-tests/test-files/server
- node test/async-service-tests/prepare-test.js
- cd test/async-service-tests/test-files
- sed 's/\$REGISTRY/'"$REGISTRY"'/g' Dockerfile > Dockerfile2
- mv -f Dockerfile2 Dockerfile
Expand Down Expand Up @@ -323,3 +333,26 @@ job-scheduler-service:
- sh /removeStack.sh
tags:
- CEP_RUNNER

rule-cluster-tests:
stage: rule-engine-cluster-tests
script:
- export STACK_NAME=${APP_IMAGE_NAME}
- export NETWORK_NAME=${APP_IMAGE_NAME}
- npm install mocha
- echo "docker stack rm $STACK_NAME" > ./remove.sh
- /bin/sh ./remove.sh
- sleep 30
- sed 's/\$NETWORK_NAME/'"$NETWORK_NAME"'/g' ./test/rule-engine-cluster-tests/rule-engine-cluster-setup.yml > ./test/rule-engine-cluster-tests/rule-engine-cluster-setup2.yml
- mv -f ./test/rule-engine-cluster-tests/rule-engine-cluster-setup2.yml test/rule-engine-cluster-tests/rule-engine-cluster-setup.yml
- docker stack deploy -c test/rule-engine-cluster-tests/rule-engine-cluster-setup.yml $STACK_NAME
- sleep 10
- /bin/sh ./test/rule-engine-cluster-tests/wait-all.sh "https://test.node1.oecloud.local/" "https://test.node2.oecloud.local/"
# - /bin/sh ./test/rule-engine-cluster-tests/wait-for-up.sh "https://test.node1.oecloud.local/"
- export NODE_TLS_REJECT_UNAUTHORIZED=0
- ./node_modules/.bin/mocha --bail --timeout 10000 ./test/rule-engine-cluster-tests/cluster-tests.js
after_script:
# - echo "done..."
- /bin/sh ./remove.sh
tags:
- CEP_RUNNER
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module.exports = function GruntConfig(grunt) {
clearRequireCache: true,
timeout: 100000
},
src: ['test/audit-field-mixin-test.js', 'test/auto-fields-test.js', 'test/basic-api-test.js', 'test/basic-test.js', 'test/bootstrap.js', 'test/business-rule-mixin-test.js', 'test/caching-test.js', 'test/composite-model-test.js', 'test/concurrency-test.js', 'test/config-merge-test.js', 'test/cr-model-test.js', 'test/crypto-test.js', 'test/data-acl-test.js', 'test/data-hierarchy-test.js', 'test/data-personalization-test.js', 'test/datasource-personalization.js', 'test/decision-table-test.js', 'test/delete-test.js', 'test/designer-boot-test.js', 'test/embedded-many-test.js', 'test/enum-test.js', 'test/failsafe-observer-test.js', 'test/fail-test.js', 'test/gridconfig-test.js', 'test/gridmetadata-test.js', 'test/health-test.js', 'test/history-mixin-test.js', 'test/idempotent-behavior-test.js', 'test/idempotent-mixin-test.js', 'test/import-export-test.js', 'test/integration-test.js', 'test/job-scheduler-test.js', 'test/literal-test.js', 'test/misclaneous-test.js', 'test/model-collection-test.js', 'test/model-definition-ACL-test.js', 'test/model-definition-inheritance-test.js', 'test/model-definition-relation-test.js', 'test/model-definition-test.js', 'test/model-definition-test2.js', 'test/model-definition-validation-test.js', 'test/model-personalization-test.js', 'test/model-transaction-test.js', 'test/model-validation-composite-uniqueness-test.js', 'test/model-validation-embeddedModel-test.js', 'test/model-validation-evValidation-custom-test.js', 'test/model-validation-evValidation-test.js', 'test/model-validation-relation-test.js', 'test/model-validation-test.js', 'test/model-validation-validateWhen.js', 'test/model-validation-xmodelvalidate-test.js', 'test/model-variant-of-test.js', 'test/multi-tenancy-test.js', 'test/node-red-test.js', 'test/otp-mixin-test.js', 'test/property-expressions-test.js', 'test/relation-has-one-test.js', 'test/service-personalization-relation-test.js', 'test/service-personalization-test.js', 'test/soft-delete-mixin-test.js', 'test/switch-data-source-test.js', 'test/uicomponent-test.js', 'test/uimetadata-test.js', 'test/unauthorised-write.js', 'test/update-data-acl-test.js', 'test/version-mixin-test.js', 'test/z-jwt-assertion-test.js', 'test/z-remove-demo-user-test.js', 'test/z-z-ap-state-test.js', 'test/z-z-business-validations-tests.js', 'test/z-z-rest-api-actors-mixin-tests.js', 'test/z-z-z-actor-pattern-test.js', 'test/z-z-z-actor-pattern-db-lock-test.js', 'test/z-z-journal-retry-tests.js', 'test/z-z-z-logger-config-test.js', 'test/z-z-z-z-mark-as-cache-able-test.js', 'test/instance-caching-test.js']
src: ['test/audit-field-mixin-test.js', 'test/auto-fields-test.js', 'test/basic-api-test.js', 'test/basic-test.js', 'test/batch-job-test.js', 'test/bootstrap.js', 'test/business-rule-mixin-test.js', 'test/caching-test.js', 'test/composite-model-test.js', 'test/concurrency-test.js', 'test/config-merge-test.js', 'test/cr-model-test.js', 'test/crypto-test.js', 'test/data-acl-test.js', 'test/data-hierarchy-test.js', 'test/data-personalization-test.js', 'test/datasource-personalization.js', 'test/decision-table-test.js', 'test/delete-test.js', 'test/designer-boot-test.js', 'test/embedded-many-test.js', 'test/enum-test.js', 'test/failsafe-observer-test.js', 'test/fail-test.js', 'test/gridconfig-test.js', 'test/gridmetadata-test.js', 'test/health-test.js', 'test/history-mixin-test.js', 'test/idempotent-behavior-test.js', 'test/idempotent-mixin-test.js', 'test/import-export-test.js', 'test/integration-test.js', 'test/job-scheduler-test.js', 'test/literal-test.js', 'test/misclaneous-test.js', 'test/model-collection-test.js', 'test/model-definition-ACL-test.js', 'test/model-definition-inheritance-test.js', 'test/model-definition-relation-test.js', 'test/model-definition-test.js', 'test/model-definition-test2.js', 'test/model-definition-validation-test.js', 'test/model-personalization-test.js', 'test/model-transaction-test.js', 'test/model-validation-composite-uniqueness-test.js', 'test/model-validation-embeddedModel-test.js', 'test/model-validation-evValidation-custom-test.js', 'test/model-validation-evValidation-test.js', 'test/model-validation-relation-test.js', 'test/model-validation-test.js', 'test/model-validation-validateWhen.js', 'test/model-validation-xmodelvalidate-test.js', 'test/model-variant-of-test.js', 'test/multi-tenancy-test.js', 'test/node-red-test.js', 'test/otp-mixin-test.js', 'test/property-expressions-test.js', 'test/relation-has-one-test.js', 'test/service-personalization-relation-test.js', 'test/service-personalization-test.js', 'test/soft-delete-mixin-test.js', 'test/switch-data-source-test.js', 'test/uicomponent-test.js', 'test/uimetadata-test.js', 'test/unauthorised-write.js', 'test/update-data-acl-test.js', 'test/version-mixin-test.js', 'test/z-jwt-assertion-test.js', 'test/z-remove-demo-user-test.js', 'test/z-z-ap-state-test.js', 'test/z-z-business-validations-tests.js', 'test/z-z-rest-api-actors-mixin-tests.js', 'test/z-z-z-actor-pattern-activity-check-test.js', 'test/z-z-z-actor-pattern-test.js', 'test/z-z-z-actor-pattern-db-lock-test.js', 'test/z-z-journal-retry-tests.js', 'test/z-z-z-actor-startup-test.js', 'test/z-z-z-logger-config-test.js', 'test/z-z-z-z-mark-as-cache-able-test.js', 'test/instance-caching-test.js']
},
oracle: {
options: {
Expand Down
54 changes: 15 additions & 39 deletions common/mixins/audit-fields-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,39 +48,30 @@
* @author Sivankar Jain
*/

var logger = require('oe-logger');
var log = logger('audit-fields-mixin');

module.exports = function AuditFieldsMixin(Model) {
if (Model.definition.name === 'BaseEntity') {
log.debug(log.defaultContext(), 'skipping mixin for - ', Model.definition.name);
return;
}

Model.defineProperty('_type', {
type: String,
length: 50,
required: true
length: 50
});
Model.defineProperty('_createdBy', {
type: String,
length: 50,
required: true
length: 50
});
Model.defineProperty('_modifiedBy', {
type: String,
length: 50,
required: true
length: 50
});

Model.defineProperty('_createdOn', {
type: 'timestamp',
required: true
type: 'timestamp'
});

Model.defineProperty('_modifiedOn', {
type: 'timestamp',
required: true
type: 'timestamp'
});

if ((Model.settings.overridingMixins && !Model.settings.overridingMixins.AuditFieldsMixin) || !Model.settings.mixins.AuditFieldsMixin) {
Expand All @@ -104,12 +95,6 @@ module.exports = function AuditFieldsMixin(Model) {
* @memberof Audit Mixin
*/
function injectAuditFields(ctx, next) {
if (!ctx.Model.definition.settings.mixins.AuditFieldsMixin) {
log.debug(ctx.options, 'AuditFieldsMixin disabled for model - ', ctx.Model.modelName);
return next();
}
log.debug(ctx.options, 'Before save called. Model Name - ', ctx.Model.modelName);

var context = ctx.options;
var cctx = context.ctx || {};

Expand All @@ -119,38 +104,29 @@ function injectAuditFields(ctx, next) {

var protectedFields = ['_type', '_createdBy', '_modifiedBy', '_createdOn', '_modifiedOn'];
var postData = ctx.instance || ctx.data;
var currentInstance = ctx.currentInstance;
// var currentInstance = ctx.currentInstance;
// if user provide data for any protectedField those data are removed, and
// auto set.
var isInstance = ctx.instance;
protectedFields.forEach(function AuditFieldsMixinProtectedFieldsForEachCb(field) {
if (currentInstance) {
postData[field] = currentInstance[field];
if (isInstance) {
postData.unsetAttribute(field);
} else {
delete postData[field];
if (postData[field]) {
postData.unsetAttribute(field);
}
}
});
if (ctx.instance) {
log.debug(ctx.options, 'isNewInstance = ', ctx.isNewInstance);
if (isInstance) {
// full save.
if (ctx.isNewInstance) {
// Auto-populate entity type
ctx.instance._type = ctx.Model.definition.name;
postData._type = ctx.Model.definition.name;

// Auto-populate created by user id and timestamp
ctx.instance._createdBy = remoteUser;
ctx.instance._createdOn = currentDateTime;
postData._createdBy = remoteUser;
postData._createdOn = currentDateTime;
}

// Update modified by user id and timestamp
ctx.instance._modifiedBy = remoteUser;
ctx.instance._modifiedOn = currentDateTime;
} else {
// partial update of possibly multiple models.
ctx.data._modifiedBy = remoteUser;
ctx.data._modifiedOn = currentDateTime;
}
postData._modifiedBy = remoteUser;
postData._modifiedOn = currentDateTime;
return next();
}
2 changes: 1 addition & 1 deletion common/mixins/crypto-mixin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* ©2016-2018 EdgeVerve Systems Limited (a fully owned Infosys subsidiary),
* 2016-2018 EdgeVerve Systems Limited (a fully owned Infosys subsidiary),
* Bangalore, India. All Rights Reserved.
*
*/
Expand Down
Loading

0 comments on commit 2bfbba5

Please sign in to comment.