AMBARI-19014. Add Service Wizard: error thrown during transition on deploy step (akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1b6a92d5 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1b6a92d5 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1b6a92d5 Branch: refs/heads/branch-feature-AMBARI-18456 Commit: 1b6a92d5527c68523be755f4e4ab9eb7a8f142e6 Parents: cfeb391 Author: Aleksandr Kovalenko <akovale...@hortonworks.com> Authored: Tue Nov 29 15:27:22 2016 +0200 Committer: Aleksandr Kovalenko <akovale...@hortonworks.com> Committed: Tue Nov 29 17:10:13 2016 +0200 ---------------------------------------------------------------------- .../controllers/main/service/add_controller.js | 11 +++++--- .../main/service/add_controller_test.js | 29 ++++++++++++++++---- 2 files changed, 30 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/1b6a92d5/ambari-web/app/controllers/main/service/add_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/add_controller.js b/ambari-web/app/controllers/main/service/add_controller.js index 4310f8d..f312a5a 100644 --- a/ambari-web/app/controllers/main/service/add_controller.js +++ b/ambari-web/app/controllers/main/service/add_controller.js @@ -467,7 +467,7 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs, { installSelectedServices: function (callback) { var name = 'common.services.update'; var selectedServices = this.get('content.services').filterProperty('isInstalled', false).filterProperty('isSelected', true).mapProperty('serviceName'); - var dependentServices = this.getDependentServices(); + var dependentServices = this.getServicesBySelectedSlaves(); var data = this.generateDataForInstallServices(selectedServices.concat(dependentServices)); this.installServicesRequest(name, data, callback.bind(this)); }, @@ -484,14 +484,17 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs, { }, /** - * return list of services by dependent slave components + * return list of services by selected and not installed slave components * @returns {Array} */ - getDependentServices: function () { + getServicesBySelectedSlaves: function () { var result = []; this.get('content.slaveComponentHosts').forEach(function (slaveComponent) { if (slaveComponent.hosts.someProperty('isInstalled', false)) { - result.push(App.StackServiceComponent.find().findProperty('componentName', slaveComponent.componentName).get('serviceName')); + var stackComponent = App.StackServiceComponent.find().findProperty('componentName', slaveComponent.componentName); + if (stackComponent) { + result.push(stackComponent.get('serviceName')); + } } }); return result.uniq(); http://git-wip-us.apache.org/repos/asf/ambari/blob/1b6a92d5/ambari-web/test/controllers/main/service/add_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/add_controller_test.js b/ambari-web/test/controllers/main/service/add_controller_test.js index 7470f89..715f46a 100644 --- a/ambari-web/test/controllers/main/service/add_controller_test.js +++ b/ambari-web/test/controllers/main/service/add_controller_test.js @@ -566,14 +566,14 @@ describe('App.AddServiceController', function() { }); - describe('#getDependentServices', function () { + describe('#getServicesBySelectedSlaves', function () { beforeEach(function () { sinon.stub(App.StackServiceComponent, 'find').returns([ - Em.Object.create({ - componentName: 'c1', - serviceName: 's1' - }), + Em.Object.create({ + componentName: 'c1', + serviceName: 's1' + }), Em.Object.create({ componentName: 'c2', serviceName: 's2' @@ -596,6 +596,23 @@ describe('App.AddServiceController', function() { expect: [] }, { + title: 'should return empty array if component is absent in StackServiceComponent model', + sch: [ + { + componentName: 'c5', + hosts: [ + { + isInstalled: false + }, + { + isInstalled: true + } + ] + }, + ], + expect: [] + }, + { title: 'should return services for not installed slaves', sch: [ { @@ -638,7 +655,7 @@ describe('App.AddServiceController', function() { describe(test.title, function () { it(function () { addServiceController.set('content.slaveComponentHosts', test.sch); - expect(addServiceController.getDependentServices()).to.eql(test.expect); + expect(addServiceController.getServicesBySelectedSlaves()).to.eql(test.expect); }); }) });