Skip to content

Commit fb73335

Browse files
authored
Merge pull request #78 from MitocGroup/dev
Merge dev branch
2 parents e7906b1 + 9fd927e commit fb73335

File tree

31 files changed

+445
-71
lines changed

31 files changed

+445
-71
lines changed

bin/test/GitDiffWalker.es6

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ export class GitDiffWalker {
8080
return 'BACKEND_MICROAPP_IDENTIFIERS';
8181
}
8282

83+
/**
84+
* @returns {string}
85+
* @constructor
86+
*/
87+
static get CI_FULL() {
88+
return 'CI_FULL';
89+
}
90+
8391
/**
8492
* @returns {string}
8593
* @constructor
@@ -133,6 +141,7 @@ export class GitDiffWalker {
133141
content.push(`${GitDiffWalker.FRONTEND_MICROAPP_PATHS}="{frontendMicroAppPaths}"`);
134142
content.push(`${GitDiffWalker.BACKEND_MICROAPP_PATHS}="{backendMicroAppPaths}"`);
135143
content.push(`${GitDiffWalker.BACKEND_MICROAPP_IDENTIFIERS}="{backendMicroAppIdentifiers}"`);
144+
content.push(`${GitDiffWalker.CI_FULL}="{ciFull}"`);
136145
content.push('');
137146

138147
return content.join(os.EOL);
@@ -560,13 +569,14 @@ export class GitDiffWalker {
560569
let varsContent = GitDiffWalker.TEST_PATHS_TPL
561570
.replace(/\{frontendMicroAppPaths\}/g, frontendMicroAppPaths)
562571
.replace(/\{backendMicroAppPaths\}/g, backendMicroAppPaths)
563-
.replace(/\{backendMicroAppIdentifiers\}/g, backendMicroAppIdentifiers);
572+
.replace(/\{backendMicroAppIdentifiers\}/g, backendMicroAppIdentifiers)
573+
.replace(/\{ciFull\}/g, this.isFullCIRun);
564574

565575
fsExtra.writeFileSync(GitDiffWalker.VARS_SHELL_PATH, varsContent, 'utf8');
566576

567577
console.log("TRAVIS_COMMIT_MESSAGE: ", GitDiffWalker.commitMessage);
568578
console.log(`isFullCIRun: ${this.isFullCIRun}`);
569-
console.log(`isSkipTests: ${this.isSkipTests}`);
579+
console.log(`isSkipTests: ${this.isSkipTests && !this.isFullCIRun}`);
570580
console.log(`isFrontedCodeChanged: ${this.isFrontedCodeChanged}`);
571581
console.log(`isFrontendTestsChanged: ${this.isFrontendTestsChanged}`);
572582
console.log(`isBackendCodeChanged: ${this.isBackendCodeChanged}`);

bin/test/_head.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ subpath_run_cmd () {
112112
FRONTEND_CMD="${3}"
113113
fi
114114

115-
##############################
116-
### run tests for frontend ###
117-
##############################
118-
if [ "$__IS_CONCURRENT_SCRIPT" == "$__NONE" ] || [ "$__IS_CONCURRENT_SCRIPT" == "$__FRONTEND" ]; then
115+
###############################################
116+
### run tests for frontend or if [ci full] ###
117+
###############################################
118+
if [ "$__IS_CONCURRENT_SCRIPT" == "$__NONE" ] || [ "$__IS_CONCURRENT_SCRIPT" == "$__FRONTEND" ] || \
119+
([ "${CI_FULL}" == "true" ] && [ "$__IS_CONCURRENT_SCRIPT" == "$__BACKEND" ]); then
119120

120121
for subpath in "${__FRONTEND_MODULES[@]}"
121122
do
@@ -127,7 +128,7 @@ subpath_run_cmd () {
127128
### replace ./frontend to absolute file path to fix karma issue after combining coverage reports ###
128129
####################################################################################################
129130
if [ "${FRONTEND_CMD}" == "npm run test" ]; then
130-
SEARCH_VALUE='.\/frontend\/'
131+
SEARCH_VALUE='\.\/frontend\/'
131132
subpath=${subpath/tests\/frontend/frontend}
132133

133134
#######################################################

bin/test/coverage.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,29 @@ source $(dirname $0)/_head.sh
88
##############################
99
### Merge Coverage Results ###
1010
##############################
11-
istanbul-combine -d ${__COVERAGE_PATH} -r lcov -p both \
11+
istanbul-combine -d ${__COVERAGE_PATH} -r lcovonly -p both \
1212
${__SRC_PATH}*/tests/frontend/coverage/report.json \
13-
${__SRC_PATH}*/tests/backend/coverage/*.json
13+
${__SRC_PATH}*/tests/backend/coverage/coverage.json
14+
15+
################################################################
16+
### Update paths to have src/* file in coverage report ###
17+
### https://github.com/codacy/node-codacy-coverage/issues/26 ###
18+
################################################################
19+
SEARCH_VALUE=$(pwd -P)"/"
20+
REPLACE_VALUE=""
21+
22+
sed -e "s@${SEARCH_VALUE}@${REPLACE_VALUE}@g" ${__COVERAGE_PATH}"/lcov.info" > ${__COVERAGE_PATH}"/coverage.info"
23+
1424

1525
######################################
1626
### Upload Coverage info to Codacy ###
1727
######################################
18-
cat ${__COVERAGE_PATH}"/lcov.info" | codacy-coverage
28+
cat ${__COVERAGE_PATH}"/coverage.info" | codacy-coverage --debug
1929

2030
#####################################################################
2131
### Log top 20 file paths to be able see paths format from travis ###
2232
#####################################################################
23-
head -n 20 ${__COVERAGE_PATH}"/lcov.info"
33+
head -n 20 ${__COVERAGE_PATH}"/coverage.info"
2434

2535
#############################################
2636
### Cleanup! Remove all generated reports ###

bin/test/preinstall.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,24 @@ source $(dirname $0)/_head.sh
88
####################################################
99
### Install dependencies globally if don't exist ###
1010
####################################################
11+
(npm list -g babel-cli --depth=0 || npm install -g babel-cli) &&\
12+
(npm list -g babel-polyfill --depth=0 || npm install -g babel-polyfill) &&\
13+
(npm list -g babel-preset-es2015 --depth=0 || npm install -g babel-preset-es2015) &&\
1114
(npm list -g deepify@$(npm show deepify version) --depth=0 || npm install -g deepify) &&\
1215
(npm list -g jspm --depth=0 || npm install -g jspm@0.16.15) &&\
1316
(npm list -g browserify --depth=0 || npm install -g browserify@11.2.x) &&\
1417
(npm list -g jscs --depth=0 || npm install -g jscs@2.1.x) &&\
15-
(npm list -g mocha --depth=0 || npm install -g mocha@2.3.x) &&\
18+
(npm list -g mocha --depth=0 || npm install -g mocha@2.4.x) &&\
1619
(npm list -g codacy-coverage --depth=0 || npm install -g codacy-coverage@1.1.x) &&\
1720
(npm list -g chai --depth=0 || npm install -g chai@3.3.x) &&\
1821
(npm list -g jasmine-core --depth=0 || npm install -g jasmine-core@2.3.x) &&\
19-
(npm list -g istanbul --depth=0 || npm install -g istanbul@0.3.x) &&\
22+
(npm list -g istanbul@^1.0.0-alpha --depth=0 || npm install -g istanbul@^1.0.0-alpha) &&\
2023
(npm list -g istanbul-combine --depth=0 || npm install -g istanbul-combine@0.3.x) &&\
2124
(npm list -g karma --depth=0 || npm install -g karma@0.13.x) &&\
2225
(npm list -g karma-jspm --depth=0 || npm install -g karma-jspm@2.0.x) &&\
2326
(npm list -g karma-jasmine --depth=0 || npm install -g karma-jasmine@0.3.x) &&\
2427
(npm list -g karma-babel-preprocessor --depth=0 || npm install -g karma-babel-preprocessor@5.2.x) &&\
25-
(npm list -g karma-coverage@douglasduteil/karma-coverage#next --depth=0 || npm install -g karma-coverage@douglasduteil/karma-coverage#next) &&\
28+
(npm list -g karma-coverage@1.0.x --depth=0 || npm install -g karma-coverage@1.0.x) &&\
2629
(npm list -g karma-verbose-reporter --depth=0 || npm install -g karma-verbose-reporter@0.0.x) &&\
2730
(npm list -g karma-phantomjs-launcher --depth=0 || npm install -g karma-phantomjs-launcher@0.2.x) &&\
2831
(npm list -g karma-ng-html2js-preprocessor --depth=0 || npm install -g karma-ng-html2js-preprocessor@0.2.x) &&\
@@ -57,8 +60,8 @@ if [ "${__E2E_WITH_PUBLIC_REPO}" = "${E2E_TESTING}" ] || [ "${__E2E_WITH_PRIVATE
5760
###############################################################
5861
### Install locally, protractor doesn't find babel globally ###
5962
###############################################################
60-
(if [ ! -d "node_modules/babel-cli" ]; then npm install babel-cli; fi) &&\
61-
(if [ ! -d "node_modules/babel-preset-es2015" ]; then npm install babel-preset-es2015; fi) &&\
63+
(if [ ! -d "node_modules/babel-cli" ]; then npm link babel-cli; fi) &&\
64+
(if [ ! -d "node_modules/babel-preset-es2015" ]; then npm link babel-preset-es2015; fi) &&\
6265
(if [ ! -d "node_modules/babel-plugin-add-module-exports" ]; then npm install babel-plugin-add-module-exports; fi) &&\
6366
(if [ ! -d "node_modules/jasmine2-custom-message" ]; then npm install jasmine2-custom-message@0.8.x; fi) &&\
6467
(if [ ! -d "node_modules/jasmine-utils" ]; then npm install jasmine-utils@0.2.x; fi)
@@ -93,6 +96,8 @@ if [ "$TRAVIS" == "true" ]; then
9396
git branch $TRAVIS_BRANCH
9497
git checkout $TRAVIS_BRANCH
9598
git checkout $TRAVIS_FROM_BRANCH
99+
else
100+
export TRAVIS_COMMIT_MESSAGE=$(git log -1 --pretty=%s)
96101
fi
97102

98103
############################################################################################

bin/test/protractor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Created by vcernomschi on 10/06/2015
44
#
55

6-
source $(dirname $0)/../_head.sh
6+
source $(dirname $0)/_head.sh
77

88
############################################################
99
### Initial protractor && support backward compatibility ###

src/deep-root-angular/backend/resources.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121
}
2222
},
2323
"ddb-eventual-consistency": {
24+
"listen-queues": {
25+
"description": "Listen for SQS offload queues messages",
26+
"type": "lambda",
27+
"forceUserIdentity": false,
28+
"scope": "private",
29+
"cron": "0/1 * * * ? *",
30+
"methods": ["GET"],
31+
"source": "src/ddb-eventual-consistency/listen-queues"
32+
},
2433
"pool-queue": {
2534
"description": "Pool the SQS queue for DynamoDB offloaded operations on alarm received from CloudWatchAlarm through an SNS topic",
2635
"type": "lambda",

src/deep-root-angular/backend/src/async-config/dump/Handler.es6

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ export default class extends DeepFramework.Core.AWS.Lambda.Runtime {
4141
if (error) {
4242
logger.warn('Error on invalidating cached async config.', error);
4343
} else if (asyncConfig.ready) {
44-
this._selfDisable();
44+
this._selfDisable(() => {
45+
this.createResponse(config).send();
46+
});
47+
48+
return;
4549
}
4650

4751
this.createResponse(config).send();
@@ -88,17 +92,26 @@ export default class extends DeepFramework.Core.AWS.Lambda.Runtime {
8892
}
8993

9094
/**
95+
*
96+
* @param {Function} cb
9197
* @private
9298
*/
93-
_selfDisable() {
99+
_selfDisable(cb) {
94100
let resource = this.kernel.get('resource');
95-
let lambda = resource.get('@deep-root-angular:scheduler:rule');
101+
let lambda = resource.get(this._selfDisableResourceId);
96102
let payload = {
97103
effect: 'disable',
98104
lambdaName: this.context.functionName
99105
};
100106

101-
lambda.request(payload).invokeAsync().send();
107+
lambda.request(payload).useDirectCall().send(cb);
108+
}
109+
110+
/**
111+
* @returns {String}
112+
*/
113+
get _selfDisableResourceId() {
114+
return `@${this.kernel.microservice().identifier}:scheduler:rule`;
102115
}
103116

104117
/**

src/deep-root-angular/backend/src/async-config/dump/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"bugs": {
13-
"url": "https://github.com/MitocGroup/deep-microservices-root-angularjs/issues"
13+
"url": "https://github.com/MitocGroup/deep-microservices-root-angular/issues"
1414
},
1515
"keywords": [
1616
"DEEP",
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/**
2+
* Created by acucer on 6/14/16.
3+
*/
4+
5+
'use strict';
6+
7+
import AWS from 'aws-sdk';
8+
import DeepFramework from 'deep-framework';
9+
10+
export default class extends DeepFramework.Core.AWS.Lambda.Runtime {
11+
/**
12+
* @param {*} args
13+
*/
14+
constructor(...args) {
15+
super(...args);
16+
}
17+
18+
/**
19+
* @param {*} request
20+
*/
21+
handle(request) {
22+
Promise
23+
.all(this._queues.map(queueConfig => this._checkQueue(queueConfig)))
24+
.then(this.createResponse({}).send);
25+
}
26+
27+
/**
28+
* @param {Object} queueConfig
29+
* @returns {Promise|*}
30+
*/
31+
_checkQueue(queueConfig) {
32+
return new Promise(resolve => {
33+
let payload = {
34+
QueueUrl: queueConfig.url,
35+
AttributeNames: ['ApproximateNumberOfMessages',],
36+
};
37+
38+
queueConfig.sqs.getQueueAttributes(payload, (error, data) => {
39+
if (error) {
40+
console.error(error);
41+
return resolve();
42+
}
43+
44+
let attrs = data.Attributes || {
45+
ApproximateNumberOfMessages: '0', // o_O AWS sends a string
46+
};
47+
48+
if (parseInt(attrs.ApproximateNumberOfMessages) > 0) {
49+
return this._invokePullQueue(queueConfig.name)
50+
.then(resolve)
51+
.catch(error => {
52+
console.error(error);
53+
resolve();
54+
});
55+
}
56+
57+
resolve();
58+
});
59+
});
60+
}
61+
62+
/**
63+
* @param {String} queueName
64+
* @returns {Promise|*}
65+
*/
66+
_invokePullQueue(queueName) {
67+
return new Promise((resolve, reject) => {
68+
let resource = this.kernel.get('resource');
69+
70+
resource
71+
.get(this._pullQueueResourceId)
72+
.request({queueName,})
73+
.invokeAsync()
74+
.send((response) => {
75+
response.isError ? reject(response.error) : resolve();
76+
});
77+
});
78+
}
79+
80+
/**
81+
* @returns {String}
82+
*/
83+
get _pullQueueResourceId() {
84+
return `@${this.kernel.microservice().identifier}:ddb-eventual-consistency:pool-queue`;
85+
}
86+
87+
/**
88+
* @param {String} queueUrl
89+
* @returns {String}
90+
* @private
91+
*/
92+
_getRegionFromSqsQueueUrl(queueUrl) {
93+
let regionParts = queueUrl.match(/\.([^\.]+)\.amazonaws\.com\/.*/i);
94+
95+
if (!regionParts || regionParts.length === 0) {
96+
throw new Error(queueUrl, 'Unable to extract AWS region.');
97+
}
98+
99+
return regionParts[1];
100+
}
101+
102+
/**
103+
* @returns {Object[]}
104+
*/
105+
get _queues() {
106+
let result = [];
107+
let queues = this.kernel.config.dbOffloadQueues;
108+
109+
for (let modelName in queues) {
110+
if (!queues.hasOwnProperty(modelName)) {
111+
continue;
112+
}
113+
114+
let queueConfig = queues[modelName];
115+
let name = queueConfig.name;
116+
let url = queueConfig.url;
117+
let region = this._getRegionFromSqsQueueUrl(url);
118+
let sqs = new AWS.SQS({region,});
119+
120+
result.push({name, url, region, sqs,});
121+
}
122+
123+
return result;
124+
}
125+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Created by acucer on 3/17/16.
3+
*/
4+
5+
'use strict';
6+
7+
import DeepFramework from 'deep-framework';
8+
import Handler from './Handler';
9+
10+
export default DeepFramework.LambdaHandler(Handler);

0 commit comments

Comments
 (0)