Skip to content

Commit 2ec10d9

Browse files
authored
Release 1.0.36 (#534)
* Master - Develop merge (#520) * Issues with update/delete system microservices CLI and API (#521) * fix cli issues with /update/delete system microservices * fix according team solution * Update default.json * Update development.json * Update production.json * fix remove of not running system microservices * fix formating after merge from develop * fix code review comment * fix code review comment * feat(tracking): add tracking for some events (ENG-429) * feat(core) added seed with catalog item for logging microservice (ENG-194) * bug(fix): improve validation for parameters with type "number" (ENG-546) (#525) * bug(fix): improve validation for parameters with type "number" (ENG-546) * bug(fix): fix for types (ENG-546) * bug(fix): seconf fix type float (ENG-546) * feat(tracking): add tracking for some events (#527) fix data format Closes ENG-261 * Add Ian's improvements: integration for slack (#522) * add Ian's improvements * update to try to fix the TravisCI build * Update .travis.yml * feat(microservices): allow to delete system microservies via cli (#528) Closes ENG-534 * feat(tracking): create temp db for tests (#524) * feat(tracking): create temp db for tests + db backups + refactoring Closes ENG-556 * feat(tracking): create temp db for tests + refactoring + single api script + possibility to call one script from another + postman test start and stop controller api by itself - delete stop and start commands from travis Closes ENG-556 * feat(tracking): create temp db for tests + fix travis. start server on dev_deploy and pre_release Closes ENG-556 * feat(SCRIPTS): create temp db for tests + correct vars' names Closes ENG-556 * pre release version 1.0.36 * Update .travis.yml * Pre-release merge (#531) * feat(catalog): allow update catalog item image without regular fields (#529) * feat(catalog): allow update catalog item image without regular fields + fix createOrUpdate for catalogItemManager (create didn't work) Closes ENG-622 * feat(catalog): allow update catalog item image without regular fields + fix tests Closes ENG-622 * Maksimchepelev/fetaure cli validation ENG-546 (#530) * feat(cli): add correct validation for cli + args parsing using Mar of <arg, values> + throw error if value for number arg not provided or string was provided: `--number_arg string` or `--number_arg` - validation of number type (integer/float) because there is no info about type in help * feat(cli): add correct validation for cli + float/integer validation +- number -> float/integer in cli help * feat(cli): add correct validation for cli +- correct regexp for parsing cli * feat(cli): add correct validation for cli +- correct Integer and Float types +- fix some problems Closes ENG-621 * fixes for release (#533) * feat(catalog): allow update catalog item image without regular fields (#529) * feat(catalog): allow update catalog item image without regular fields + fix createOrUpdate for catalogItemManager (create didn't work) Closes ENG-622 * feat(catalog): allow update catalog item image without regular fields + fix tests Closes ENG-622 * Maksimchepelev/fetaure cli validation ENG-546 (#530) * feat(cli): add correct validation for cli + args parsing using Mar of <arg, values> + throw error if value for number arg not provided or string was provided: `--number_arg string` or `--number_arg` - validation of number type (integer/float) because there is no info about type in help * feat(cli): add correct validation for cli + float/integer validation +- number -> float/integer in cli help * feat(cli): add correct validation for cli +- correct regexp for parsing cli * feat(cli): add correct validation for cli +- correct Integer and Float types +- fix some problems Closes ENG-621 * Maksimchepelev/bugs (#532) * feat(cli): delete unnecessary output - delete status code and port mapping id output Closes ENG-621 * fix(microservice): add internal port validation in remove port mapping Closes ENG-623
1 parent bdd9961 commit 2ec10d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1271
-322
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Thank you for your contribution!
77
Code of Conduct: https://iofog.org/docs/contributing/code-of-conduct.html
88
-->
99

10-
- [ ] Does the iofog.org or README.md documentation need to change?
10+
- Does the iofog.org or README.md documentation need to change?
1111
- [ ] Yes <!-- include PR link -->
1212
- [ ] No
1313

.travis.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ notifications:
55
email: false
66
slack:
77
rooms:
8-
- secure: T6GjQi6ap7dvARwdxo619XBUO8aXyzeP4wB8LRpnLKgDQtd+EVw3hwMcHEB7C5+KBC9D0LE0i5HjnLKj2T9ih1L1zKM0QDYFVO8jTt+zhWbEs9Famdq0kmfGiTCbiVG/vxr+9bvFF4QkFhzK8kV44uyqZkmQrHuFnrCpJivsg7dsqvxZ6iU3FV1lMOLU0SJTBHwjbVnIOEqbYcbXmuBJerLMqU7kSlGdlDgBMX8xnzPo/Ccqft+CHDSEl5XU2RZZo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1dF5PxVQ4L58NR5A23zNduElWgzsME8UDtgT9/lac=
99
on_success: always
1010
on_failure: always
1111
template:
12-
- Repo `%{repository_slug}` *%{result}* build (<%{build_url}|#%{build_number}>)
13-
for commit (<%{compare_url}|%{commit}>) on branch `%{branch}`.
14-
- 'Execution time: *%{duration}*'
15-
- 'Message: %{message}'
12+
- "Build <%{build_url}|#%{build_number}> (<%{compare_url}|%{commit}>) of %{repository_slug}@%{branch} in PR <%{pull_request_url}|#%{pull_request_number}> by %{author} %{result} in %{duration}"
1613
stages:
1714
- name: build
1815
if: type = pull_request
@@ -28,18 +25,21 @@ jobs:
2825
- stage: build
2926
script:
3027
- npm test
31-
- NODE_ENV=production node /home/travis/build/ioFog/Controller/src/main.js start
3228
- npm run postman_test
3329
- stage: dev_deploy
3430
before_install:
3531
- sudo apt-get install sshpass
3632
script:
37-
- sshpass -p $DEV_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $DEV_MACHINE_USERNAME@$DEV_MACHINE_IP "cd /FogController; NODE_ENV=production node src/main.js stop; git pull; npm i; npm test; NODE_ENV=production node src/main.js start; npm run postman_test"
33+
- sshpass -p $DEV_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $DEV_MACHINE_USERNAME@$DEV_MACHINE_IP
34+
"cd /FogController; NODE_ENV=production node src/main.js stop; git pull; npm
35+
i; npm test; npm run postman_test; NODE_ENV=production node src/main.js start;"
3836
- stage: pre_release
3937
before_install:
4038
- sudo apt-get install sshpass
4139
script:
42-
- sshpass -p $PREPROD_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $PREPROD_MACHINE_USERNAME@$PREPROD_MACHINE_IP "cd /Controller; NODE_ENV=production node src/main.js stop; git pull; git checkout ${TRAVIS_BRANCH}; npm i; npm test; NODE_ENV=production node src/main.js start; npm run postman_test"
40+
- sshpass -p $PREPROD_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $PREPROD_MACHINE_USERNAME@$PREPROD_MACHINE_IP
41+
"cd /Controller; NODE_ENV=production node src/main.js stop; git checkout $TRAVIS_BRANCH; npm i;
42+
npm test; npm run postman_test; NODE_ENV=production node src/main.js start;"
4343
- stage: release
4444
#before_install:
4545
#- git clone "https://github.com/$TRAVIS_REPO_SLUG.git" "$TRAVIS_REPO_SLUG";
@@ -54,9 +54,10 @@ jobs:
5454
deploy:
5555
skip_cleanup: true
5656
provider: npm
57-
email: ${NPM_EMAIL_ADDRESS}
58-
api_key: ${NPM_AUTH_TOKEN}
57+
email: "${NPM_EMAIL_ADDRESS}"
58+
api_key: "${NPM_AUTH_TOKEN}"
5959
on:
6060
tags: false
6161
after_deploy:
62-
- sshpass -p $PROD_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $PROD_MACHINE_USERNAME@$PROD_MACHINE_IP "iofog-controller stop; npm update -g iofogcontroller; iofog-controller start"
62+
- sshpass -p $PROD_MACHINE_PASSWORD ssh -o StrictHostKeyChecking=no $PROD_MACHINE_USERNAME@$PROD_MACHINE_IP
63+
"iofog-controller stop; npm update -g iofogcontroller; iofog-controller start"

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iofogcontroller",
3-
"version": "1.0.35",
3+
"version": "1.0.36",
44
"description": "ioFog Controller project for Eclipse IoFog @ iofog.org \\nCopyright (c) 2018 Edgeworx, Inc.",
55
"main": "./src/main.js",
66
"author": "Saeid Baghbidi",
@@ -34,17 +34,17 @@
3434
"url": "https://github.com/ioFog/Controller"
3535
},
3636
"scripts": {
37-
"start": "node scripts/start.js",
38-
"start-dev": "node scripts/start-dev.js",
39-
"build": "node scripts/init.js",
40-
"preuninstall": "node scripts/preuninstall.js",
41-
"postinstall": "node scripts/postinstall.js",
37+
"start": "node scripts/scripts-api.js start",
38+
"start-dev": "node scripts/scripts-api.js start-dev",
39+
"build": "node scripts/scripts-api.js init",
40+
"preuninstall": "node scripts/scripts-api.js preuninstall",
41+
"postinstall": "node scripts/scripts-api.js postinstall",
4242
"lint": "./node_modules/.bin/eslint \"**/*.js\"",
4343
"automatic-release": "automatic-release",
44-
"test": "node scripts/test.js && node scripts/cli-tests.js",
45-
"postman_test": "node scripts/postmantest.js",
46-
"cli-tests": "node scripts/cli-tests.js",
47-
"coverage": "node scripts/coverage.js"
44+
"test": "node scripts/scripts-api.js test",
45+
"postman_test": "node scripts/scripts-api.js postmantest",
46+
"cli-tests": "node scripts/scripts-api.js cli-tests",
47+
"coverage": "node scripts/scripts-api.js coverage"
4848
},
4949
"preferGlobal": true,
5050
"bin": {

scripts/cli-tests.js

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
*/
1313

1414
const execSync = require('child_process').execSync;
15+
const {init} = require('./init');
16+
const {restoreDBs, backupDBs} = require('./util');
1517

1618
const options = {
1719
env: {
@@ -394,27 +396,41 @@ function responseContains(response, expectedResponsePart) {
394396
}
395397
}
396398

397-
try {
398-
testControllerSection();
399-
testUserSection();
400-
testConfigSection();
401-
testConnectorSection();
402-
testTunnelSection();
403-
testIoFogSection();
404-
testCatalogSection();
405-
testFlowSection();
406-
testMicroserviceSection();
407-
testRegistrySection();
408-
testDiagnosticsSection();
409-
} catch (exception) {
410-
console.log("\nException during execution: ");
411-
console.error(exception);
412-
process.exit(1);
399+
function cliTest() {
400+
try {
401+
backupDBs();
402+
//create new DBs
403+
init();
404+
405+
testControllerSection();
406+
testUserSection();
407+
testConfigSection();
408+
testConnectorSection();
409+
testTunnelSection();
410+
testIoFogSection();
411+
testCatalogSection();
412+
testFlowSection();
413+
testMicroserviceSection();
414+
testRegistrySection();
415+
testDiagnosticsSection();
416+
417+
restoreDBs();
418+
} catch (exception) {
419+
restoreDBs();
420+
421+
console.log("\nException during execution: ");
422+
console.error(exception);
423+
process.exit(1);
424+
}
425+
426+
if (testsFailed > 0) {
427+
console.log("\nFailed tests count: " + testsFailed);
428+
process.exit(1);
429+
} else {
430+
console.log("\nCLI Tests passed successfully.");
431+
}
413432
}
414433

415-
if (testsFailed > 0) {
416-
console.log("\nFailed tests count: " + testsFailed);
417-
process.exit(1);
418-
} else {
419-
console.log("\nCLI Tests passed successfully.");
420-
}
434+
module.exports = {
435+
cliTest: cliTest
436+
};

scripts/coverage.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@
1313

1414
const execSync = require('child_process').execSync;
1515

16-
const options = {
17-
env: {
18-
'NODE_ENV': 'test',
19-
"PATH": process.env.PATH
20-
},
21-
stdio: [process.stdin, process.stdout, process.stderr]
22-
};
16+
function coverage() {
17+
const options = {
18+
env: {
19+
'NODE_ENV': 'test',
20+
"PATH": process.env.PATH
21+
},
22+
stdio: [process.stdin, process.stdout, process.stderr]
23+
};
2324

24-
execSync('nyc mocha', options);
25+
execSync('nyc mocha', options);
26+
}
27+
28+
module.exports = {
29+
coverage: coverage
30+
};

scripts/init.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,19 @@
1313

1414
const execSync = require('child_process').execSync;
1515

16-
const options = {
17-
env: {
18-
'NODE_ENV': 'production',
19-
"PATH": process.env.PATH
20-
},
21-
stdio: [process.stdin, process.stdout, process.stderr]
22-
};
2316

24-
execSync('node ./src/main.js init', options);
17+
function init() {
18+
const options = {
19+
env: {
20+
'NODE_ENV': 'production',
21+
"PATH": process.env.PATH
22+
},
23+
stdio: [process.stdin, process.stdout, process.stderr]
24+
};
25+
26+
execSync('node ./src/main.js init', options);
27+
}
28+
29+
module.exports = {
30+
init: init
31+
};

scripts/postinstall.js

Lines changed: 37 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -16,89 +16,49 @@ const execSync = require('child_process').execSync;
1616
const fs = require('fs');
1717
const semver = require('semver');
1818
const currentVersion = require('../package').version;
19+
const {restoreDBs, restoreConfigs, INSTALLATION_VARIABLES_FILE} = require('./util');
1920

20-
const rootDir = `${__dirname}/..`;
21-
let installationVariablesFileName = 'iofogcontroller_install_variables';
22-
let tempDir = getTempDirLocation();
23-
const installationVariablesFile = tempDir + '/' + installationVariablesFileName;
24-
21+
function postinstall() {
2522
//restore all files
26-
const devDbBackup = `${tempDir}/dev_database.sqlite`;
27-
const devDb = `${rootDir}/src/sequelize/dev_database.sqlite`;
28-
moveFileIfExists(devDbBackup, devDb);
29-
30-
const prodDbBackup = `${tempDir}/prod_database.sqlite`;
31-
const prodDb = `${rootDir}/src/sequelize/prod_database.sqlite`;
32-
moveFileIfExists(prodDbBackup, prodDb);
33-
34-
const defConfigBackup = `${tempDir}/default_iofog_backup.json`;
35-
const defConfig = `${rootDir}/src/config/default.json`;
36-
moveFileIfExists(defConfigBackup, defConfig);
37-
38-
const prodConfigBackup = `${tempDir}/production_iofog_backup.json`;
39-
const prodConfig = `${rootDir}/src/config/production.json`;
40-
moveFileIfExists(prodConfigBackup, prodConfig);
41-
42-
const devConfigBackup = `${tempDir}/development_iofog_backup.json`;
43-
const devConfig = `${rootDir}/src/config/development.json`;
44-
moveFileIfExists(devConfigBackup, devConfig);
23+
restoreDBs();
24+
restoreConfigs();
4525

4626
//process migrations
47-
try {
48-
const installationVarsStr = fs.readFileSync(installationVariablesFile);
49-
const installationVars = JSON.parse(installationVarsStr);
50-
const prevVersion = installationVars.prevVer;
51-
52-
console.log(`previous version - ${prevVersion}`);
53-
console.log(`new version - ${currentVersion}`);
54-
55-
if (semver.satisfies(prevVersion, '<=1.0.0')) {
56-
console.log('upgrading from version <= 1.0.0 :');
57-
insertSeeds();
58-
}
59-
60-
if (semver.satisfies(prevVersion, '<=1.0.30')) {
61-
console.log('upgrading from version <= 1.0.30 :');
62-
updateEncryptionMethod();
63-
}
64-
65-
fs.unlinkSync(installationVariablesFile);
66-
} catch (e) {
67-
console.log('no previous version');
68-
}
27+
try {
28+
const installationVarsStr = fs.readFileSync(INSTALLATION_VARIABLES_FILE);
29+
const installationVars = JSON.parse(installationVarsStr);
30+
const prevVersion = installationVars.prevVer;
6931

70-
//init db
71-
const options = {
72-
env: {
73-
'NODE_ENV': 'production',
74-
"PATH": process.env.PATH
75-
},
76-
stdio: [process.stdin, process.stdout, process.stderr]
77-
};
32+
console.log(`previous version - ${prevVersion}`);
33+
console.log(`new version - ${currentVersion}`);
7834

79-
execSync('node ./src/main.js init', options);
35+
if (semver.satisfies(prevVersion, '<=1.0.0')) {
36+
console.log('upgrading from version <= 1.0.0 :');
37+
insertSeeds();
38+
}
8039

81-
//other functions definitions
40+
if (semver.satisfies(prevVersion, '<=1.0.30')) {
41+
console.log('upgrading from version <= 1.0.30 :');
42+
updateEncryptionMethod();
43+
}
8244

83-
function getTempDirLocation() {
84-
let tempDir;
85-
if (os.type() === 'Linux') {
86-
tempDir = '/tmp';
87-
} else if (os.type() === 'Darwin') {
88-
tempDir = '/tmp';
89-
} else if (os.type() === 'Windows_NT') {
90-
tempDir = `${process.env.APPDATA}`;
91-
} else {
92-
throw new Error("Unsupported OS found: " + os.type());
45+
fs.unlinkSync(INSTALLATION_VARIABLES_FILE);
46+
} catch (e) {
47+
console.log('no previous version');
9348
}
94-
return tempDir;
95-
}
9649

97-
function moveFileIfExists(from, to) {
98-
if (fs.existsSync(from)) {
99-
fs.renameSync(from, to);
100-
}
50+
//init db
51+
const options = {
52+
env: {
53+
'NODE_ENV': 'production',
54+
"PATH": process.env.PATH
55+
},
56+
stdio: [process.stdin, process.stdout, process.stderr]
57+
};
58+
59+
execSync('node ./src/main.js init', options);
10160
}
61+
//other functions definitions
10262

10363
function insertSeeds() {
10464
console.log(' inserting seeds meta info in db');
@@ -189,4 +149,8 @@ function updateEncryptionMethod() {
189149
updateEncryptionMethodForEmailService(defConfig, decryptTextVer30);
190150
updateEncryptionMethodForEmailService(devConfig, decryptTextVer30);
191151
updateEncryptionMethodForEmailService(prodConfig, decryptTextVer30);
192-
}
152+
}
153+
154+
module.exports = {
155+
postinstall: postinstall
156+
};

0 commit comments

Comments
 (0)