From 5068bc1bbe6b07de44859ffa0717a39543804bb3 Mon Sep 17 00:00:00 2001 From: vamsee Date: Wed, 11 Sep 2019 16:35:39 +0530 Subject: [PATCH 1/8] Using NPM_REGISTRY and CI_JOB_ID --- .gitlab-ci.yml | 16 +++++++--------- package.json | 8 ++++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 20fd2c5..373bba5 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,7 +21,7 @@ npminstall: - status_eslint=0 - exit_status=0 - npm set progress=false - - npm config set registry http://10.188.25.62:9002/ + - npm config set registry ${NPM_REGISTRY} - time npm install eslint babel-eslint --no-optional - if npm run lint; then status_eslint=0; else status_eslint=1; fi - if [ $status_eslint == 1 ]; then exit_status=1 && echo "esLint errors exist"; fi @@ -37,7 +37,6 @@ npminstall: - if [ $exit_status == 1 ]; then exit $exit_status; fi artifacts: - untracked: true expire_in: 2h paths: - node_modules/ @@ -52,12 +51,11 @@ mongotest: - export NODE_ENV=mongo - export MONGO_HOST="10.73.53.144" - export DB=mongo - - export DB_NAME=${CI_PIPELINE_ID}_mongo - - npm config set registry http://10.188.25.62:9002/ + - export DB_NAME=${CI_JOB_ID}_mongo + - npm config set registry ${NPM_REGISTRY} - time npm install --no-optional - npm run grunt-cover artifacts: - untracked: true expire_in: 2h paths: - coverage/ @@ -72,9 +70,9 @@ postgrestest: - export NODE_ENV=postgres - export DB=postgres - export POSTGRES_HOST="10.73.53.144" - - export DB_NAME=${CI_PIPELINE_ID}_pg + - export DB_NAME=${CI_JOB_ID}_pg - export ENABLE_DS_AUTOUPDATE=true - - npm config set registry http://10.188.25.62:9002/ + - npm config set registry ${NPM_REGISTRY} - time npm install --no-optional - npm run grunt-cover tags: @@ -90,9 +88,9 @@ oracletest: - export ORACLE_SYSUSER=oeadmin - export ORACLE_SYSPASSWORD=oeadmin - export ORACLE_SID=ORCLCDB - - export DB_NAME=${CI_PIPELINE_ID}_pg + - export DB_NAME=${CI_JOB_ID}_pg - export ENABLE_DS_AUTOUPDATE=true - - npm config set registry http://10.188.25.62:9002/ + - npm config set registry ${NPM_REGISTRY} - time npm install git+http://evgit/oecloud.io/oe-connector-oracle.git --no-optional - time npm install --no-optional - mv /oracledb node_modules/ diff --git a/package.json b/package.json index 598e810..7b98340 100755 --- a/package.json +++ b/package.json @@ -61,11 +61,11 @@ "grunt-mocha-istanbul": "5.0.2", "grunt-mocha-test": "0.13.3", "istanbul": "0.4.5", - "oe-node-red": "git+http://evgit/oecloud.io/oe-node-red.git#2.1.0", - "oe-cloud": "git+http://evgit/oecloud.io/oe-cloud.git#2.1.0", - "oe-multi-tenancy": "git+http://evgit/oecloud.io/oe-multi-tenancy.git#2.1.0", + "oe-node-red": "git+http://evgit/oecloud.io/oe-node-red.git#master", + "oe-cloud": "git+http://evgit/oecloud.io/oe-cloud.git#master", + "oe-multi-tenancy": "git+http://evgit/oecloud.io/oe-multi-tenancy.git#master", "loopback-connector-mongodb": "3.9.2", - "oe-connector-postgresql": "git+http://evgit/oecloud.io/oe-connector-postgresql.git#2.0.0", + "oe-connector-postgresql": "git+http://evgit/oecloud.io/oe-connector-postgresql.git#master", "mocha": "5.2.0", "superagent-defaults": "0.1.14", "supertest": "3.4.2" From cabccac144b5e2b724551a4dce3202d55f41392e Mon Sep 17 00:00:00 2001 From: vamsee Date: Wed, 11 Sep 2019 17:08:20 +0530 Subject: [PATCH 2/8] Fixed eslint errors --- postinstall.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/postinstall.js b/postinstall.js index 88cc681..3419af3 100644 --- a/postinstall.js +++ b/postinstall.js @@ -1,11 +1,13 @@ var fs = require('fs'); -var deleteFolderRecursive = function(path) { - if( fs.existsSync(path) ) { - fs.readdirSync(path).forEach(function(file,index){ - var curPath = path + "/" + file; - if(fs.lstatSync(curPath).isDirectory()) { // recurse +var deleteFolderRecursive = function (path) { + if (fs.existsSync(path)) { + fs.readdirSync(path).forEach(function (file, index) { + var curPath = path + '/' + file; + // recurse + if (fs.lstatSync(curPath).isDirectory()) { deleteFolderRecursive(curPath); - } else { // delete file + } else { + // delete file fs.unlinkSync(curPath); } }); @@ -13,7 +15,8 @@ var deleteFolderRecursive = function(path) { } }; var initDir = process.env.INIT_CWD; -deleteFolderRecursive(initDir + "/node_modules/node-red-node-email"); -deleteFolderRecursive(initDir + "/node_modules/mailparser"); -deleteFolderRecursive(initDir + "/node_modules/mimelib"); -console.log("Removed node-red-node-email module"); +deleteFolderRecursive(initDir + '/node_modules/node-red-node-email'); +deleteFolderRecursive(initDir + '/node_modules/mailparser'); +deleteFolderRecursive(initDir + '/node_modules/mimelib'); +// eslint-disable-next-line no-console +console.log('Removed node-red-node-email module'); From 9dccaddb01183f1dbe6b2e317a9db33631108c42 Mon Sep 17 00:00:00 2001 From: vamsee Date: Mon, 23 Sep 2019 11:20:56 +0530 Subject: [PATCH 3/8] Using node 10.16.0 in CI --- .gitlab-ci.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 373bba5..081e6e4 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,15 +4,19 @@ stages: - build - cleanup -image: $REGISTRY/debian-node-oracle-docker variables: + DOMAIN_NAME: oecloud.local + PERF_DOMAIN_NAME: oecloud.perf REGISTRY: registry.${DOMAIN_NAME} + EXECUTOR_IMAGE: oecloud-executor:10.x + EXECUTOR_IMAGE_ORACLE: debian-node-oracle-docker:10.x + +image: ${REGISTRY}/${EXECUTOR_IMAGE} before_script: - export project=${CI_PROJECT_NAME//[^[:alnum:]]/} - export group=${CI_PROJECT_NAMESPACE//[^[:alnum:]]/} - export branch=${CI_BUILD_REF_NAME//[^[:alnum:]]/} - - export pipelineId=${CI_PIPELINE_ID//[^[:alnum:]]/} npminstall: stage: pre-build @@ -79,6 +83,7 @@ postgrestest: - CEP_RUNNER oracletest: + image: ${REGISTRY}/${EXECUTOR_IMAGE_ORACLE} stage: pre-build-test script: - echo 'Performing Oracle Test' From 9a202dae6fd7b48cf1753edf16cdb47ec811195a Mon Sep 17 00:00:00 2001 From: vamsee Date: Fri, 8 Nov 2019 11:05:14 +0530 Subject: [PATCH 4/8] Using node 12.13.0 in CI --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 081e6e4..712234d 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,8 +8,8 @@ variables: DOMAIN_NAME: oecloud.local PERF_DOMAIN_NAME: oecloud.perf REGISTRY: registry.${DOMAIN_NAME} - EXECUTOR_IMAGE: oecloud-executor:10.x - EXECUTOR_IMAGE_ORACLE: debian-node-oracle-docker:10.x + EXECUTOR_IMAGE: oecloud-executor:12.x + EXECUTOR_IMAGE_ORACLE: debian-node-oracle-docker:12.x image: ${REGISTRY}/${EXECUTOR_IMAGE} From 3587c88f098913b74391eda81fb65b2f3532a466 Mon Sep 17 00:00:00 2001 From: vamsee Date: Fri, 8 Nov 2019 11:27:28 +0530 Subject: [PATCH 5/8] Removing user and password from mongo db config --- test/datasources.mongo.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/datasources.mongo.js b/test/datasources.mongo.js index ba17367..a0cb280 100755 --- a/test/datasources.mongo.js +++ b/test/datasources.mongo.js @@ -21,10 +21,8 @@ module.exports = 'port': 27017, 'url': 'mongodb://' + mongoHost + ':27017/' + dbName, 'database': dbName, - 'password': 'admin', 'name': 'db', 'connector': 'mongodb', - 'user': 'admin', 'connectionTimeout': 500000 } }; From 8fbbc4ff4e10ce23d19890fde20113c2fd4b8c56 Mon Sep 17 00:00:00 2001 From: vamsee Date: Fri, 10 Jan 2020 16:52:03 +0530 Subject: [PATCH 6/8] removed unneeded packages and updated ci --- .eslintignore | 13 ++- .eslintrc | 2 +- .gitignore | 1 + .gitlab-ci.yml | 145 ++++++++++++++++++++--------- Gruntfile.js | 38 +------- package.json | 15 +-- test/datasources.json | 3 +- test/datasources.mongo.js | 10 +- test/datasources.oracle.js | 10 +- test/datasources.postgres.js | 9 +- test/node-red-settings.js | 12 +-- test/oracle-utility.js | 176 +++++++++++++++++++---------------- 12 files changed, 229 insertions(+), 205 deletions(-) diff --git a/.eslintignore b/.eslintignore index ce467ba..9c8d714 100755 --- a/.eslintignore +++ b/.eslintignore @@ -1,8 +1,7 @@ -/client/ -/coverage/ -/node_modules/ -server/dropdb.js -/lib/expression-language/expression-syntax-parser.js +build/ +client/ +coverage/ +node_modules/ +test/ drop.js -/test/ - +Gruntfile.js diff --git a/.eslintrc b/.eslintrc index 8f2f7cc..6edc78f 100755 --- a/.eslintrc +++ b/.eslintrc @@ -111,7 +111,7 @@ "no-undefined": 1, // http://eslint.org/docs/rules/no-undefined "no-with": 2, // http://eslint.org/docs/rules/no-with "handle-callback-err": 1, // http://eslint.org/docs/rules/handle-callback-err - "radix": 2, // http://eslint.org/docs/rules/radix + "radix": 0, // http://eslint.org/docs/rules/radix "wrap-iife": [2, "any"], // http://eslint.org/docs/rules/wrap-iife "yoda": 2, // http://eslint.org/docs/rules/yoda diff --git a/.gitignore b/.gitignore index 3bff760..7b1734a 100755 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ out/ *.zip /common/models/test package-lock.json +oracle-user.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 712234d..b903e41 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,8 @@ stages: - pre-build - pre-build-test - - build - - cleanup + - push-artifacts + - performance variables: DOMAIN_NAME: oecloud.local @@ -17,102 +17,161 @@ before_script: - export project=${CI_PROJECT_NAME//[^[:alnum:]]/} - export group=${CI_PROJECT_NAMESPACE//[^[:alnum:]]/} - export branch=${CI_BUILD_REF_NAME//[^[:alnum:]]/} + - if [ ${group} == "oecloudio" ]; then export APP_IMAGE_NAME=$project; else export APP_IMAGE_NAME=$group"-"$project; fi + - export APP_IMAGE_NAME=$(echo $APP_IMAGE_NAME | tr '[:upper:]' '[:lower:]') + - if [ ${branch} == "master" ]; then export APP_TAG=latest; else export APP_TAG=${branch}; fi + - export APP_TAG=$(echo $APP_TAG | tr '[:upper:]' '[:lower:]') + + - npm config set unsafe-perm true + - npm config set progress false + - npm config set registry ${NPM_REGISTRY} + # - npm config set registry https://registry.npmjs.org/ npminstall: stage: pre-build script: - echo "Performing code style check..." - - status_eslint=0 - - exit_status=0 - - npm set progress=false - - npm config set registry ${NPM_REGISTRY} + - export status_eslint=0 + - export exit_status=0 - time npm install eslint babel-eslint --no-optional - if npm run lint; then status_eslint=0; else status_eslint=1; fi - - if [ $status_eslint == 1 ]; then exit_status=1 && echo "esLint errors exist"; fi + - if [ $status_eslint == 1 ]; then export exit_status=1 && echo "esLint errors exist"; fi - if [ $exit_status == 1 ]; then exit $exit_status; fi - echo "Code style check done successfully" - time npm install --no-optional - echo "Node Modules Installed" - - npm config delete registry - - mkdir -p ./artifacts/${CI_PROJECT_NAME}/ - - npm audit --json > ./artifacts/${CI_PROJECT_NAME}/vulnerabilities.json || true + - npm config rm registry + - npm audit --json > vulnerabilities.json || true - if npm audit; then status_vulnerabilities=0; else status_vulnerabilities=1; fi - if [ $status_vulnerabilities == 1 ]; then echo "Dependency vulnerabilities exist"; fi - if [ $exit_status == 1 ]; then exit $exit_status; fi - artifacts: expire_in: 2h paths: - node_modules/ + - vulnerabilities.json tags: - CEP_RUNNER - mongotest: + coverage: /Statements.*?(\d+(?:\.\d+)?)%/ stage: pre-build-test + variables: + NODE_ENV: mongo + DB: mongo + MONGO_HOST: 10.73.53.144 + MONGO_PORT: '27017' + DB_NAME: ${CI_JOB_ID}_mongo script: - echo 'Performing MongoDB Test' - - export NODE_ENV=mongo - - export MONGO_HOST="10.73.53.144" - - export DB=mongo - - export DB_NAME=${CI_JOB_ID}_mongo - - npm config set registry ${NPM_REGISTRY} - time npm install --no-optional - npm run grunt-cover artifacts: expire_in: 2h paths: - coverage/ - when: on_failure tags: - CEP_RUNNER postgrestest: + coverage: /Statements.*?(\d+(?:\.\d+)?)%/ stage: pre-build-test + variables: + NODE_ENV: postgres + DB: postgres + POSTGRES_HOST: 10.73.53.144 + POSTGRES_PORT: '5432' + DB_NAME: ${CI_JOB_ID}_pg + ENABLE_DS_AUTOUPDATE: 'true' script: - echo 'Performing PostgreSQL Test' - - export NODE_ENV=postgres - - export DB=postgres - - export POSTGRES_HOST="10.73.53.144" - - export DB_NAME=${CI_JOB_ID}_pg - - export ENABLE_DS_AUTOUPDATE=true - - npm config set registry ${NPM_REGISTRY} - time npm install --no-optional - npm run grunt-cover tags: - - CEP_RUNNER + - CEP_RUNNER oracletest: + coverage: /Statements.*?(\d+(?:\.\d+)?)%/ image: ${REGISTRY}/${EXECUTOR_IMAGE_ORACLE} stage: pre-build-test + variables: + NODE_ENV: oracle + DB: oracle + ORACLE_HOST: 10.73.53.144 + ORACLE_PORT: '1521' + ORACLE_SYSUSER: oeadmin + ORACLE_SYSPASSWORD: oeadmin + ORACLE_SID: ORCLCDB + ENABLE_DS_AUTOUPDATE: 'true' script: - echo 'Performing Oracle Test' - - export APP_TAG=oracle - - export NODE_ENV=oracle - - export ORACLE_HOST=10.73.53.144 - - export ORACLE_SYSUSER=oeadmin - - export ORACLE_SYSPASSWORD=oeadmin - - export ORACLE_SID=ORCLCDB - - export DB_NAME=${CI_JOB_ID}_pg - - export ENABLE_DS_AUTOUPDATE=true - - npm config set registry ${NPM_REGISTRY} - - time npm install git+http://evgit/oecloud.io/oe-connector-oracle.git --no-optional + # - export DB_NAME=${CI_JOB_ID}_pg + # - time npm install git+http://evgit/oecloud.io/oe-connector-oracle.git#master --no-optional - time npm install --no-optional - mv /oracledb node_modules/ - - export CI_PROJECT_NAMESPACE=${group} - node test/oracle-utility.js - - export ORACLE_USERNAME=${CI_PROJECT_NAMESPACE}"-"${CI_PROJECT_NAME} - - export ORACLE_USERNAME=$(echo $ORACLE_USERNAME | tr '[:lower:]' '[:upper:]') - - export ORACLE_PASSWORD=$(echo $CI_PROJECT_NAMESPACE | tr '[:upper:]' '[:lower:]') + # - export ORACLE_USERNAME=${group}"_"${project} + # - export ORACLE_USERNAME=$(echo $ORACLE_USERNAME | tr '[:lower:]' '[:upper:]') + # - export ORACLE_PASSWORD=$(echo $group | tr '[:upper:]' '[:lower:]') + - . ./oracle-user.sh + - env | grep -i oracle - echo "Oracle user details:"${ORACLE_USERNAME}"/"${ORACLE_PASSWORD} - npm run grunt-cover tags: - - CEP_RUNNER + - CEP_RUNNER -lastcleanup: - stage: cleanup +pushartifacts: + stage: push-artifacts script: - - echo "Finishing CI CD" + - echo "Copying all artifacts" + - mkdir -p ./artifacts/${CI_PROJECT_NAME}/${CI_BUILD_REF_NAME}/ + - cp vulnerabilities.json ./artifacts/${CI_PROJECT_NAME}/${CI_BUILD_REF_NAME}/ + - cp -r coverage/ ./artifacts/${CI_PROJECT_NAME}/${CI_BUILD_REF_NAME}/ + - git clone http://10.73.97.24/oecloud.io/build-tools.git + - sh ./build-tools/push_artifacts.sh tags: - CEP_RUNNER + only: + - /^.*/@oecloud.io/oe-node-red-nodes +.performancejob: + image: $REGISTRY/jmeter:docker + stage: performance + variables: + NODE_ENV: "mongo" + MONGO_HOST: "10.73.97.17" + MONGO_PORT: "27017" + DB_NAME: "${CI_JOB_ID}_mongo" + APP_PROTOCOL: "https" + APP_PORT: "443" + PERF_USERS: "1" + PERF_LOOPCOUNT: "50000" + script: + - export STACK_NAME=${APP_IMAGE_NAME}-${APP_TAG} + - export APP_URL=${APP_IMAGE_NAME}-${APP_TAG}.${PERF_DOMAIN_NAME} + - if [ ${branch} == "master" ]; then export STACK_NAME=${APP_IMAGE_NAME}; export APP_URL=${APP_IMAGE_NAME}.${PERF_DOMAIN_NAME}; fi + - if docker stack rm ${STACK_NAME}; then echo "stack removed"; else echo "nothing found in stack"; fi + - time npm install --no-optional + - git clone http://10.73.97.24/oecloud.io/build-tools.git + - sed 's/\$REGISTRY/'"$REGISTRY"'/g' ./build-tools/performance/Dockerfile > Dockerfile + - echo "Building ${APP_IMAGE_NAME}:${APP_TAG} image and pushing to registry..." + - time docker image build -t ${REGISTRY}/${APP_IMAGE_NAME}:${APP_TAG} --no-cache --pull . + - time docker image push ${REGISTRY}/${APP_IMAGE_NAME}:${APP_TAG} + - echo "Image (${REGISTRY}/${APP_IMAGE_NAME}:${APP_TAG}) built and pushed to registry" + - docker stack deploy --compose-file ./build-tools/performance/docker-compose.yml ${STACK_NAME} + - export HTTP_RESPONSE_CODE=200 + - export countElapsed=0 + - export app_exit_status=0 + - export no_proxy=$no_proxy,${APP_URL} + - export NO_PROXY=$no_proxy + - echo "${DOCKER_ROUTER_HOST} ${APP_URL}" >> /etc/hosts + - export isStarted=$(curl -k --write-out %{http_code} --output curl.out --silent https://${APP_URL}/api/ModelDefinitions) + - while [ ${isStarted} -ne ${HTTP_RESPONSE_CODE} ]; do let countElapsed=countElapsed+1; echo ""; sleep 10; export isStarted=$(curl -k --write-out %{http_code} --output curl.out --silent https://${APP_URL}/api/ModelDefinitions); echo -n "Waiting till the URL is up..."; echo ${isStarted}; if [ $countElapsed -eq 18 ] ; then export app_exit_status=1; export isStarted=${HTTP_RESPONSE_CODE}; fi; done + - if [ $app_exit_status -eq 1 ]; then echo "App failed to start....."; docker stack ps ${STACK_NAME}; docker service logs ${STACK_NAME}_web; docker stack rm ${STACK_NAME}; exit $app_exit_status; else echo "Your application URL is accessible @ https://${APP_URL}/"; fi + - mkdir -p ./artifacts/${CI_PROJECT_NAME}/${CI_BUILD_REF_NAME}/performance + - sh ./build-tools/performance/performance.sh + - sh ./build-tools/push_artifacts.sh + - if docker stack rm ${STACK_NAME}; then echo "stack removed"; else echo "nothing found in stack"; fi + when: manual + tags: + - PERF_RUNNER diff --git a/Gruntfile.js b/Gruntfile.js index 0cb2a73..a6628dd 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -10,38 +10,6 @@ module.exports = function GruntConfig(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), - mkdir: { - all: { - options: { - create: ['dist'] - } - } - }, - - copy: { - main: { - files: [ - // includes files within path and its sub-directories - { - expand: true, - src: ['**', '!node_modules/**', '!coverage/**'], - dest: 'dist/' - } - ] - } - }, - - mochaTest: { - test: { - options: { - quiet: false, - clearRequireCache: true, - timeout: 100000 - }, - src: ['test/test.js'] - } - }, - clean: { coverage: { src: ['coverage/'] @@ -72,12 +40,8 @@ module.exports = function GruntConfig(grunt) { }); // Add the grunt-mocha-test tasks. - grunt.loadNpmTasks('grunt-mocha-test'); - grunt.loadNpmTasks('grunt-mocha-istanbul'); grunt.loadNpmTasks('grunt-contrib-clean'); - - grunt.loadNpmTasks('grunt-mkdir'); - grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-mocha-istanbul'); grunt.registerTask('test-with-coverage', ['clean:coverage', 'mocha_istanbul']); }; diff --git a/package.json b/package.json index 7b98340..741c9a3 100755 --- a/package.json +++ b/package.json @@ -47,26 +47,21 @@ "devDependencies": { "babel-eslint": "7.2.3", "chai": "3.4.1", - "chai-datetime": "1.4.0", "chai-things": "0.2.0", "chalk": "1.1.1", "eslint": "4.10.0", "grunt": "1.0.4", - "grunt-banner": "0.6.0", "grunt-cli": "1.3.2", "grunt-contrib-clean": "2.0.0", - "grunt-contrib-copy": "1.0.0", - "grunt-jsbeautifier": "0.2.13", - "grunt-mkdir": "1.0.0", "grunt-mocha-istanbul": "5.0.2", - "grunt-mocha-test": "0.13.3", "istanbul": "0.4.5", - "oe-node-red": "git+http://evgit/oecloud.io/oe-node-red.git#master", + "mocha": "5.2.0", "oe-cloud": "git+http://evgit/oecloud.io/oe-cloud.git#master", - "oe-multi-tenancy": "git+http://evgit/oecloud.io/oe-multi-tenancy.git#master", - "loopback-connector-mongodb": "3.9.2", + "oe-connector-mongodb": "git+http://evgit/oecloud.io/oe-connector-mongodb.git#master", + "oe-connector-oracle": "git+http://evgit/oecloud.io/oe-connector-oracle.git#master", "oe-connector-postgresql": "git+http://evgit/oecloud.io/oe-connector-postgresql.git#master", - "mocha": "5.2.0", + "oe-multi-tenancy": "git+http://evgit/oecloud.io/oe-multi-tenancy.git#master", + "oe-node-red": "git+http://evgit/oecloud.io/oe-node-red.git#master", "superagent-defaults": "0.1.14", "supertest": "3.4.2" } diff --git a/test/datasources.json b/test/datasources.json index b7f31ca..3409e84 100755 --- a/test/datasources.json +++ b/test/datasources.json @@ -7,7 +7,6 @@ "name": "transient", "connector": "transient" }, - "db": { "host": "localhost", "port": 27017, @@ -15,7 +14,7 @@ "database": "oe-node-red-nodes-test", "password": "admin", "name": "db", - "connector": "mongodb", + "connector": "oe-connector-mongodb", "user": "admin", "connectionTimeout": 500000, "connectTimeoutMS": 500000, diff --git a/test/datasources.mongo.js b/test/datasources.mongo.js index a0cb280..c6e3998 100755 --- a/test/datasources.mongo.js +++ b/test/datasources.mongo.js @@ -5,9 +5,9 @@ * */ var mongoHost = process.env.MONGO_HOST || 'localhost'; +var mongoPort = process.env.MONGO_PORT ? parseInt(process.env.MONGO_PORT) : 27017; var dbName = process.env.DB_NAME || 'oe-node-red-nodes-test'; -module.exports = -{ +module.exports = { 'memdb': { 'name': 'memdb', 'connector': 'memory' @@ -18,11 +18,11 @@ module.exports = }, 'db': { 'host': mongoHost, - 'port': 27017, - 'url': 'mongodb://' + mongoHost + ':27017/' + dbName, + 'port': mongoPort, + 'url': 'mongodb://' + mongoHost + ':' + mongoPort + '/' + dbName, 'database': dbName, 'name': 'db', - 'connector': 'mongodb', + 'connector': 'oe-connector-mongodb', 'connectionTimeout': 500000 } }; diff --git a/test/datasources.oracle.js b/test/datasources.oracle.js index 8792ffd..a5db290 100755 --- a/test/datasources.oracle.js +++ b/test/datasources.oracle.js @@ -4,16 +4,10 @@ * Bangalore, India. All Rights Reserved. * */ -/** - ** - ** ©2016-2017 EdgeVerve Systems Limited (a fully owned Infosys subsidiary), - ** Bangalore, India. All Rights Reserved. - ** - **/ -var oracleSID = process.env.ORACLE_SID || 'orclpdb.ad.infosys.com'; +var oracleSID = process.env.ORACLE_SID || 'ORCLCDB'; var oracleHost = process.env.ORACLE_HOST || 'localhost'; -var oraclePort = process.env.ORACLE_PORT || 1521; +var oraclePort = process.env.ORACLE_PORT ? parseInt(process.env.ORACLE_PORT) : 1521; var oracleUserName = process.env.ORACLE_USERNAME || 'oeadmin'; var oracleUserPassword = process.env.ORACLE_PASSWORD || 'oeadmin'; diff --git a/test/datasources.postgres.js b/test/datasources.postgres.js index 946a524..7339f67 100755 --- a/test/datasources.postgres.js +++ b/test/datasources.postgres.js @@ -5,9 +5,9 @@ * */ var postgresHost = process.env.POSTGRES_HOST || 'localhost'; +var postgresPort = process.env.POSTGRES_PORT ? parseInt(process.env.POSTGRES_PORT) : 5432; var dbName = process.env.DB_NAME || 'oe-node-red-nodes-test'; -module.exports = -{ +module.exports = { 'memdb': { 'name': 'memdb', 'connector': 'memory' @@ -16,11 +16,10 @@ module.exports = 'name': 'transient', 'connector': 'transient' }, - 'db': { 'host': postgresHost, - 'port': 5432, - 'url': 'postgres://postgres:postgres@' + postgresHost + ':5432/' + dbName, + 'port': postgresPort, + 'url': 'postgres://postgres:postgres@' + postgresHost + ':' + postgresPort + '/' + dbName, 'database': dbName, 'password': 'postgres', 'name': 'db', diff --git a/test/node-red-settings.js b/test/node-red-settings.js index b564aff..20d72c4 100755 --- a/test/node-red-settings.js +++ b/test/node-red-settings.js @@ -81,7 +81,7 @@ module.exports = { // Node-RED scans the `nodes` directory in the install directory to find nodes. // The following property can be used to specify an additional directory to scan. - nodesDir: './', + nodesDir: './' // By default, the Node-RED UI is available at http://localhost:1880/ // The following property can be used to specify a different root path. @@ -204,11 +204,11 @@ module.exports = { // context.global.os // functionGlobalContext: { - // os:require('os'), - // octalbonescript:require('octalbonescript'), - // jfive:require("johnny-five"), - // j5board:require("johnny-five").Board({repl:false}) - //} + // os:require('os'), + // octalbonescript:require('octalbonescript'), + // jfive:require("johnny-five"), + // j5board:require("johnny-five").Board({repl:false}) + // } // The following property can be used to order the categories in the editor // palette. If a node's category is not in the list, the category will get diff --git a/test/oracle-utility.js b/test/oracle-utility.js index 153da7f..40a1734 100755 --- a/test/oracle-utility.js +++ b/test/oracle-utility.js @@ -15,22 +15,29 @@ // ORACLE_SYSUSER // ORACLE_SYSPASSWORD // ORACLE_SID -// CI_PROJECT_NAME // CI_PROJECT_NAMESPACE +// CI_PROJECT_NAME var oracledb = require('oracledb'); var async = require('async'); +var fs = require('fs'); +var os = require('os'); + var oracleHost = process.env.ORACLE_HOST || 'localhost'; -var oraclePort = process.env.ORACLE_PORT || 1521; +var oraclePort = process.env.ORACLE_PORT ? parseInt(process.env.ORACLE_PORT) : 1521; +var oracleSID = process.env.ORACLE_SID || 'ORCLCDB'; var oracleConnectSettings = { 'password': process.env.ORACLE_SYSPASSWORD || 'manager1', 'user': process.env.ORACLE_SYSUSER || 'sys', - 'connectString': oracleHost + ':' + oraclePort + '/' + (process.env.ORACLE_SID || 'orclpdb.ad.infosys.com') + 'connectString': oracleHost + ':' + oraclePort + '/' + oracleSID }; -var userName = process.env.CI_PROJECT_NAMESPACE.toUpperCase() + '-' + (process.env.CI_PROJECT_NAME || 'oecloud').toUpperCase(); -var password = process.env.CI_PROJECT_NAMESPACE.toLowerCase(); +var namespace = process.env.CI_PROJECT_NAMESPACE ? process.env.CI_PROJECT_NAMESPACE.replace(/[^a-zA-Z0-9]/g, '') : 'oecloudio'; +var name = process.env.CI_PROJECT_NAME ? process.env.CI_PROJECT_NAME.replace(/[^a-zA-Z0-9]/g, '') : 'oecloud'; + +var userName = namespace.toUpperCase() + '_' + name.toUpperCase(); +var password = namespace.toLowerCase(); var grants = [ 'CREATE VIEW', @@ -44,30 +51,32 @@ var grants = [ ]; function createUser(connection, cb) { - var sql = 'alter session set "_ORACLE_SCRIPT"=true'; - connection.execute(sql, function (e, r) { - if (e) { - console.error('Ignoring error of alter session. UserName : ' + userName + ' Error :' + e); + var alterSQL = 'alter session set "_ORACLE_SCRIPT"=true'; + connection.execute(alterSQL, function (alterErr, alterRes) { + if (alterErr) { + console.error('Ignoring error of alter session. UserName : ' + userName + ' Error :' + alterErr); } - console.log(sql, ' ......... ok'); - var sql = 'CREATE USER "' + userName + '" IDENTIFIED BY ' + password; + console.log(alterSQL, ' ......... ok'); - connection.execute(sql, function (err, result) { - if (err) { - throw new Error('Unable to create user ' + userName + ' Error :' + err); + var createUserSQL = 'CREATE USER "' + userName + '" IDENTIFIED BY ' + password; + connection.execute(createUserSQL, function (createErr, createRes) { + if (createErr) { + console.error(createErr); + throw new Error('Unable to create user ' + userName); } - console.log(sql, ' ......... ok'); - async.each(grants, function (g, callback) { - var sql = 'GRANT ' + g + ' to "' + userName + '"'; + console.log(createUserSQL, ' ......... ok'); - connection.execute(sql, function (err2, result2) { - if (err2) { - throw new Error('Unable to execute grant ' + sql); + async.each(grants, function (g, callback) { + var grantSQL = 'GRANT ' + g + ' to "' + userName + '"'; + connection.execute(grantSQL, function (grantErr, grantRes) { + if (grantErr) { + console.error(grantErr); + throw new Error('Unable to execute grant ' + grantSQL); } - console.log(sql, ' ......... ok'); + console.log(grantSQL, ' ......... ok'); return callback(); }); - }, function (err) { + }, function (grantAsyncErr) { console.log('User ' + userName + ' Created successfully'); return cb(); }); @@ -75,78 +84,83 @@ function createUser(connection, cb) { }); } - function dropTables(cb) { - var oracleConnectSettings2 = Object.assign({}, oracleConnectSettings); - oracleConnectSettings2.user = userName; - oracleConnectSettings2.password = password; - - oracledb.getConnection( - oracleConnectSettings2, - function (err, connection) { - if (err) { - throw new Error('Unable to connect to Oracle Database ' + JSON.stringify(oracleConnectSettings)); + var oracleUserConnectSettings = { + 'password': password, + 'user': userName, + 'connectString': oracleHost + ':' + oraclePort + '/' + oracleSID + }; + + oracledb.getConnection(oracleUserConnectSettings, function (userConnectionErr, connection) { + if (userConnectionErr) { + console.error(userConnectionErr); + throw new Error('Unable to connect to Oracle Database ' + JSON.stringify(oracleUserConnectSettings)); + } + + var totalRows = 1000; + var selectDropTableSQL = "select 'drop table \"' || table_name || '\"' from all_tables where owner = '" + userName + "'"; + connection.execute(selectDropTableSQL, {}, { maxRows: totalRows }, function (selectDropErr, selectDropRes) { + if (selectDropErr) { + console.error(selectDropErr); + throw new Error('Unable to find tables ' + userName); } - var sql = "select 'drop table \"' || table_name || '\"' from all_tables where owner = '" + userName + "'"; - var totalRows = 1000; - connection.execute(sql, {}, {maxRows: totalRows}, function (err, result) { - if (err) { - throw new Error('Unable to find tables ' + userName + ' Error :' + err); - } - connection.execute(sql, {}, {maxRows: totalRows}, function (err2, result2) { - if (err2) { - throw new Error('Unable to execute droping of table ' + sql); - } - if (!result2 || !result2.rows || result2.rows.length === 0) { - return cb(); + if (!selectDropRes || !selectDropRes.rows || selectDropRes.rows.length === 0) { + return cb(); + } + + async.each(selectDropRes.rows, function (row, callback) { + var dropTableSQL = row[0]; + connection.execute(dropTableSQL, function (dropTableErr, dropTableRes) { + if (dropTableErr) { + console.error(dropTableErr); + throw new Error('Unable to drop table\nSQL: ' + sql); } - async.each(result2.rows, function (row, callback) { - var sql = row[0]; - connection.execute(sql, function (err2, result2) { - if (err2) { - throw new Error('Unable to drop table\nERROR : ' + err2 + '\nSQL : ' + sql); - } - console.log(sql, ' ......... ok'); - return callback(); - }); - }, function (err) { - console.log('Tables of user ' + userName + ' dropped successfully'); - return cb(); - }); + console.log(dropTableSQL, ' ......... ok'); + return callback(); }); + }, function (dropAsyncErr) { + console.log('Tables of user ' + userName + ' dropped successfully'); + return cb(); }); }); + }); } -oracledb.getConnection( - oracleConnectSettings, - function (err, connection) { +function generateUserBundle() { + console.log("Generating oracle user details shell script"); + fs.writeFileSync('./oracle-user.sh', '#!/bin/sh' + os.EOL); + fs.appendFileSync('./oracle-user.sh', 'export ORACLE_USERNAME=' + userName + os.EOL); + fs.appendFileSync('./oracle-user.sh', 'export ORACLE_PASSWORD=' + password + os.EOL); +} + +oracledb.getConnection(oracleConnectSettings, function (connectionErr, connection) { + if (connectionErr) { + console.error(connectionErr); + throw new Error('Unable to connect to Oracle Database ' + JSON.stringify(oracleConnectSettings)); + } + var sql = "select username, user_id from dba_users where username = '" + userName + "'"; + console.log(sql); + connection.execute(sql, function (err, result) { if (err) { - throw new Error('Unable to connect to Oracle Database ' + JSON.stringify(oracleConnectSettings)); + console.error(err); return; } - var sql = "select username, user_id from dba_users where username = '" + userName + "'"; - console.log(sql); - connection.execute(sql, - function (err, result) { + if (!result.rows || result.rows.length == 0) { + createUser(connection, function (err) { if (err) { - console.error(err); return; + return process.exit(1); } - if (!result.rows || result.rows.length == 0) { - createUser(connection, function (err) { - if (err) { - return process.exit(1); - } - return process.exit(); - }); - } else { - dropTables(function (err) { - if (err) { - return process.exit(1); - } - return process.exit(); - }); + generateUserBundle(); + return process.exit(); + }); + } else { + dropTables(function (err) { + if (err) { + return process.exit(1); } + generateUserBundle(); + return process.exit(); }); + } }); - +}); From 82d5da8971cf6c4419d250824e5c2ddb1767a3a8 Mon Sep 17 00:00:00 2001 From: Atul Date: Fri, 17 Jan 2020 16:19:53 +0530 Subject: [PATCH 7/8] autoEnableMixins --- test/app-list.json | 1 + 1 file changed, 1 insertion(+) diff --git a/test/app-list.json b/test/app-list.json index c5de11b..beedf32 100755 --- a/test/app-list.json +++ b/test/app-list.json @@ -5,6 +5,7 @@ }, { "path": "oe-multi-tenancy", + "autoEnableMixins" : true, "enabled": true }, { From 6513e8308e5c4ae848f02c5a1cf762698711c037 Mon Sep 17 00:00:00 2001 From: vamsee Date: Thu, 23 Jan 2020 14:32:52 +0530 Subject: [PATCH 8/8] commit for version 2.2.0 --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 741c9a3..55255a7 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oe-node-red-nodes", - "version": "2.1.0", + "version": "2.2.0", "description": "Node-RED nodes for oeCloud based applications", "main": "node-red.js", "scripts": { @@ -56,12 +56,12 @@ "grunt-mocha-istanbul": "5.0.2", "istanbul": "0.4.5", "mocha": "5.2.0", - "oe-cloud": "git+http://evgit/oecloud.io/oe-cloud.git#master", - "oe-connector-mongodb": "git+http://evgit/oecloud.io/oe-connector-mongodb.git#master", - "oe-connector-oracle": "git+http://evgit/oecloud.io/oe-connector-oracle.git#master", - "oe-connector-postgresql": "git+http://evgit/oecloud.io/oe-connector-postgresql.git#master", - "oe-multi-tenancy": "git+http://evgit/oecloud.io/oe-multi-tenancy.git#master", - "oe-node-red": "git+http://evgit/oecloud.io/oe-node-red.git#master", + "oe-cloud": "git+http://evgit/oecloud.io/oe-cloud.git#2.2.0", + "oe-connector-mongodb": "git+http://evgit/oecloud.io/oe-connector-mongodb.git#2.2.0", + "oe-connector-oracle": "git+http://evgit/oecloud.io/oe-connector-oracle.git#2.2.0", + "oe-connector-postgresql": "git+http://evgit/oecloud.io/oe-connector-postgresql.git#2.2.0", + "oe-multi-tenancy": "git+http://evgit/oecloud.io/oe-multi-tenancy.git#2.2.0", + "oe-node-red": "git+http://evgit/oecloud.io/oe-node-red.git#2.2.0", "superagent-defaults": "0.1.14", "supertest": "3.4.2" }