From 0c1c7f0e7cdcd35e23c4df0e38d019e69f6ae658 Mon Sep 17 00:00:00 2001 From: Durgesh1988 Date: Wed, 21 Dec 2016 14:37:33 +0530 Subject: [PATCH 1/3] Resolved BOTs QA Issues --- .../aws-blueprint/aws-blueprint.js | 197 +++++++++--------- server/app/services/botsService.js | 4 +- 2 files changed, 100 insertions(+), 101 deletions(-) diff --git a/server/app/model/blueprint/blueprint-types/instance-blueprint/aws-blueprint/aws-blueprint.js b/server/app/model/blueprint/blueprint-types/instance-blueprint/aws-blueprint/aws-blueprint.js index d6747e94b..5cf1deb7b 100755 --- a/server/app/model/blueprint/blueprint-types/instance-blueprint/aws-blueprint/aws-blueprint.js +++ b/server/app/model/blueprint/blueprint-types/instance-blueprint/aws-blueprint/aws-blueprint.js @@ -607,7 +607,7 @@ AWSInstanceBlueprintSchema.methods.launch = function (launchParams, callback) { } else { - if (code == 0) { + if (code === 0) { instancesDao.updateInstanceBootstrapStatus(instance.id, 'success', function (err, updateData) { if (err) { logger.error("Unable to set instance bootstarp status. code 0", err); @@ -654,123 +654,122 @@ AWSInstanceBlueprintSchema.methods.launch = function (launchParams, callback) { } logger.debug("Domain name is updated successfully"); }); - instanceLog.endedOn = new Date().getTime(); - instanceLog.actionStatus = "success"; - instanceLog.logs = { - err: false, - log: "Instance Bootstrapped successfully", - timestamp: new Date().getTime() - }; - if (launchParams.auditTrailId !== null) { - var resultTaskExecution = { - actionStatus: "success", - status: "success", - endedOn: new Date().getTime() - } - auditTrailService.updateAuditTrail('BOTs', launchParams.auditTrailId, resultTaskExecution, function (err, auditTrail) { - if (err) { - logger.error("Failed to create or update bots Log: ", err); - } - }); + } + instanceLog.endedOn = new Date().getTime(); + instanceLog.actionStatus = "success"; + instanceLog.logs = { + err: false, + log: "Instance Bootstrapped successfully", + timestamp: new Date().getTime() + }; + if (launchParams.auditTrailId !== null) { + var resultTaskExecution = { + actionStatus: "success", + status: "success", + endedOn: new Date().getTime() } - instancesDao.updateActionLog(instance.id, actionLog._id, true, timestampEnded); - launchParams.infraManager.getNode(instance.chefNodeName, function (err, nodeData) { + auditTrailService.updateAuditTrail('BOTs', launchParams.auditTrailId, resultTaskExecution, function (err, auditTrail) { if (err) { - logger.error("Failed chef.getNode", err); - return; - } - instanceLog.platform = nodeData.automatic.platform; - instanceLogModel.createOrUpdate(actionLog._id, instance.id, instanceLog, function (err, logData) { - if (err) { - logger.error("Failed to create or update instanceLog: ", err); - } - }); - var hardwareData = {}; - hardwareData.architecture = nodeData.automatic.kernel.machine; - hardwareData.platform = nodeData.automatic.platform; - hardwareData.platformVersion = nodeData.automatic.platform_version; - hardwareData.memory = { - total: 'unknown', - free: 'unknown' - }; - if (nodeData.automatic.memory) { - hardwareData.memory.total = nodeData.automatic.memory.total; - hardwareData.memory.free = nodeData.automatic.memory.free; + logger.error("Failed to create or update bots Log: ", err); } - hardwareData.os = instance.hardware.os; - instancesDao.setHardwareDetails(instance.id, hardwareData, function (err, updateData) { - if (err) { - logger.error("Unable to set instance hardware details code (setHardwareDetails)", err); - } else { - logger.debug("Instance hardware details set successessfully"); - } - }); - //Checking docker status and updating - var _docker = new Docker(); - _docker.checkDockerStatus(instance.id, - function (err, retCode) { - if (err) { - logger.error("Failed _docker.checkDockerStatus", err); - res.send(500); - return; - //res.end('200'); - - } - logger.debug('Docker Check Returned:' + retCode); - if (retCode == '0') { - instancesDao.updateInstanceDockerStatus(instance.id, "success", '', function (data) { - logger.debug('Instance Docker Status set to Success'); - }); - - } - }); - }); - - } else { - instancesDao.updateInstanceBootstrapStatus(instance.id, 'failed', function (err, updateData) { + } + instancesDao.updateActionLog(instance.id, actionLog._id, true, timestampEnded); + launchParams.infraManager.getNode(instance.chefNodeName, function (err, nodeData) { + if (err) { + logger.error("Failed chef.getNode", err); + return; + } + instanceLog.platform = nodeData.automatic.platform; + instanceLogModel.createOrUpdate(actionLog._id, instance.id, instanceLog, function (err, logData) { if (err) { - logger.error("Unable to set instance bootstarp status code != 0", err); - } else { - logger.debug("Instance bootstrap status set to failed"); + logger.error("Failed to create or update instanceLog: ", err); } }); - instanceLog.endedOn = new Date().getTime(); - instanceLog.actionStatus = "failed"; - instanceLog.logs = { - err: false, - log: "Bootstrap Failed", - timestamp: new Date().getTime() + var hardwareData = {}; + hardwareData.architecture = nodeData.automatic.kernel.machine; + hardwareData.platform = nodeData.automatic.platform; + hardwareData.platformVersion = nodeData.automatic.platform_version; + hardwareData.memory = { + total: 'unknown', + free: 'unknown' }; - instanceLogModel.createOrUpdate(actionLog._id, instance.id, instanceLog, function (err, logData) { + if (nodeData.automatic.memory) { + hardwareData.memory.total = nodeData.automatic.memory.total; + hardwareData.memory.free = nodeData.automatic.memory.free; + } + hardwareData.os = instance.hardware.os; + instancesDao.setHardwareDetails(instance.id, hardwareData, function (err, updateData) { if (err) { - logger.error("Failed to create or update instanceLog: ", err); + logger.error("Unable to set instance hardware details code (setHardwareDetails)", err); + } else { + logger.debug("Instance hardware details set successessfully"); } }); - if (launchParams.auditTrailId !== null) { - var resultTaskExecution = { - actionStatus: "failed", - status: "failed", - endedOn: new Date().getTime() - } - auditTrailService.updateAuditTrail('BOTs', launchParams.auditTrailId, resultTaskExecution, function (err, auditTrail) { + //Checking docker status and updating + var _docker = new Docker(); + _docker.checkDockerStatus(instance.id, + function (err, retCode) { if (err) { - logger.error("Failed to create or update bot Log: ", err); + logger.error("Failed _docker.checkDockerStatus", err); + res.send(500); + return; + //res.end('200'); + + } + logger.debug('Docker Check Returned:' + retCode); + if (retCode == '0') { + instancesDao.updateInstanceDockerStatus(instance.id, "success", '', function (data) { + logger.debug('Instance Docker Status set to Success'); + }); + } }); + + }); + + }else { + instancesDao.updateInstanceBootstrapStatus(instance.id, 'failed', function (err, updateData) { + if (err) { + logger.error("Unable to set instance bootstarp status code != 0", err); + } else { + logger.debug("Instance bootstrap status set to failed"); } - var timestampEnded = new Date().getTime(); - logsDao.insertLog({ - referenceId: logsReferenceIds, - err: false, - log: "Bootstrap Failed", - timestamp: timestampEnded + }); + instanceLog.endedOn = new Date().getTime(); + instanceLog.actionStatus = "failed"; + instanceLog.logs = { + err: false, + log: "Bootstrap Failed", + timestamp: new Date().getTime() + }; + instanceLogModel.createOrUpdate(actionLog._id, instance.id, instanceLog, function (err, logData) { + if (err) { + logger.error("Failed to create or update instanceLog: ", err); + } + }); + if (launchParams.auditTrailId !== null) { + var resultTaskExecution = { + actionStatus: "failed", + status: "failed", + endedOn: new Date().getTime() + } + auditTrailService.updateAuditTrail('BOTs', launchParams.auditTrailId, resultTaskExecution, function (err, auditTrail) { + if (err) { + logger.error("Failed to create or update bot Log: ", err); + } }); - instancesDao.updateActionLog(instance.id, actionLog._id, false, timestampEnded); } + var timestampEnded = new Date().getTime(); + logsDao.insertLog({ + referenceId: logsReferenceIds, + err: false, + log: "Bootstrap Failed", + timestamp: timestampEnded + }); + instancesDao.updateActionLog(instance.id, actionLog._id, false, timestampEnded); } } - }, function (stdOutData) { instanceLog.logs = { diff --git a/server/app/services/botsService.js b/server/app/services/botsService.js index bb69680ad..713850460 100644 --- a/server/app/services/botsService.js +++ b/server/app/services/botsService.js @@ -51,8 +51,8 @@ botsService.createOrUpdateBots = function createOrUpdateBots(botsDetail,linkedCa botLinkedCategory: linkedCategory, botLinkedSubCategory:linkedSubCategory, manualExecutionTime:botsDetail.manualExecutionTime, - version:botsDetail.version, - domainNameCheck:botsDetail.domainNameCheck, + version:botsDetail.version ? botsDetail.version : 1, + domainNameCheck:botsDetail.domainNameCheck ? botsDetail.domainNameCheck : false, createdOn: new Date().getTime() }; bots.getBotsById(botsDetail._id,function(err,data){ From 7186e3ef71d25d9d9b2e74062122cd13704d4bc1 Mon Sep 17 00:00:00 2001 From: Durgesh1988 Date: Wed, 21 Dec 2016 16:37:46 +0530 Subject: [PATCH 2/3] Resolved BOTs QA Issues --- .../sections/dashboard/bots/controller/libraryCtrl.js | 2 +- server/app/model/audit-trail/bot-audit-trail.js | 4 ++++ server/app/model/classes/tasks/tasks.js | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js b/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js index b27d6eb34..2b22f9500 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js @@ -455,7 +455,7 @@ $scope.taskHistoryJenkinsGridOptions.data='taskHistoryJenkinsData'; $scope.taskHistoryJenkinsGridOptions.columnDefs = [ { name:'Job Number',field:'auditTrailConfig.jenkinsBuildNumber',cellTemplate:'{{row.entity.auditTrailConfig.jenkinsBuildNumber}}', sort:{ direction: 'desc'}, cellTooltip: true}, - { name:'Job Output',cellTemplate:'',cellTooltip: true}, + { name:'Job Output',cellTemplate:'',cellTooltip: true}, { name:'Log Info',width: 90,cellTemplate:'',cellTooltip: true}, { name:'Status',field:'status',cellTemplate:'
{{row.entity.status.toUpperCase()}}
'}, { name:'Start Time',field:'startedOn',cellTemplate:'{{row.entity.startedOn | timestampToLocaleTime}}',cellTooltip: true}, diff --git a/server/app/model/audit-trail/bot-audit-trail.js b/server/app/model/audit-trail/bot-audit-trail.js index 215b90f61..1c0cf258c 100644 --- a/server/app/model/audit-trail/bot-audit-trail.js +++ b/server/app/model/audit-trail/bot-audit-trail.js @@ -54,6 +54,10 @@ var BotAuditTrailSchema = new BaseAuditTrail({ type: String, trim:true }, + jobResultURL:{ + type: [String], + trim:true + }, manualExecutionTime:{ type: Number, required: false diff --git a/server/app/model/classes/tasks/tasks.js b/server/app/model/classes/tasks/tasks.js index 03fb2d04a..6aa1e548c 100755 --- a/server/app/model/classes/tasks/tasks.js +++ b/server/app/model/classes/tasks/tasks.js @@ -376,7 +376,8 @@ taskSchema.methods.execute = function(userName, baseUrl, choiceParam, appData, b "endedOn":self.timestampEnded, "actionLogId":taskHistory.jenkinsServerId, "auditTrailConfig.jenkinsBuildNumber":taskHistory.buildNumber, - "auditTrailConfig.jenkinsJobName":taskHistory.jobName + "auditTrailConfig.jenkinsJobName":taskHistory.jobName, + "auditTrailConfig.jobResultURL":taskHistory.jobResultURL }; }else{ resultTaskExecution = { From 80b241656f815db80bf2576790a9d98b9067ed95 Mon Sep 17 00:00:00 2001 From: Durgesh1988 Date: Wed, 21 Dec 2016 18:47:41 +0530 Subject: [PATCH 3/3] Resolved BOTs QA Issues --- .../dashboard/bots/controller/libraryCtrl.js | 29 ++++++++++++--- .../dashboard/bots/view/botSchedule.html | 36 +++++++++++++------ .../app/model/classes/tasks/taskTypeChef.js | 26 +++++++------- .../app/model/classes/tasks/taskTypeScript.js | 25 +++++++------ 4 files changed, 74 insertions(+), 42 deletions(-) diff --git a/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js b/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js index 175e7be09..e6845f740 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js +++ b/client/cat3/src/partials/sections/dashboard/bots/controller/libraryCtrl.js @@ -287,6 +287,13 @@ $modalInstance.dismiss('cancel'); }; }]).controller('botScheduleCtrl',['$scope', '$rootScope', 'genericServices', 'workzoneServices', 'toastr', '$modalInstance', 'items', '$timeout', function ($scope, $rootScope, genSevs, workzoneServices, toastr, $modalInstance, items, $timeout) { + if(items.isBotScheduled === true){ + $scope._isEventSelected = true; + $scope.isScheduled = true; + }else{ + $scope._isEventSelected = false; + $scope.isScheduled = false; + } $scope.scheduleDeatils = items; $scope.botId = items.botId; $scope.defaultSelection = function() { @@ -294,7 +301,13 @@ $scope.schedulerStartOn=moment(new Date()).format('MM/DD/YYYY'); $scope.schedulerEndOn=moment(new Date()).format('MM/DD/YYYY'); }; - + $scope.selectBotCheckbox = function(){ + if($scope.isScheduled === true || $scope.isScheduled === 'true') { + $scope._isEventSelected = true; + }else{ + $scope._isEventSelected = false; + } + } if(items.botScheduler){ if(items.botScheduler.cronStartOn && items.botScheduler.cronEndOn) { var newStartOn = parseInt(items.botScheduler.cronStartOn); @@ -364,9 +377,17 @@ cronDate: $scope.selectedDayOfTheMonth, cronMonth: $scope.selectedMonth }; - var reqBody = { - botScheduler:$scope.eventParams, - isBotScheduled:true + var reqBody = null; + if($scope.isScheduled === true || $scope.isScheduled === 'true'){ + reqBody = { + botScheduler:$scope.eventParams, + isBotScheduled:true + } + }else{ + reqBody = { + botScheduler:{}, + isBotScheduled:false + } } var param={ url:'/bots/' + $scope.botId + '/scheduler', diff --git a/client/cat3/src/partials/sections/dashboard/bots/view/botSchedule.html b/client/cat3/src/partials/sections/dashboard/bots/view/botSchedule.html index 014c1901b..855fe5333 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/view/botSchedule.html +++ b/client/cat3/src/partials/sections/dashboard/bots/view/botSchedule.html @@ -4,21 +4,34 @@ × +