AMBARI-19696 Move HS2 does not install dependent components on the target host. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/dab389d9 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/dab389d9 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/dab389d9 Branch: refs/heads/branch-dev-patch-upgrade Commit: dab389d94634e6c21935a7034a0389a70390176e Parents: b9200e0 Author: Andrii Tkach <[email protected]> Authored: Tue Jan 24 21:44:43 2017 +0200 Committer: Andrii Tkach <[email protected]> Committed: Wed Jan 25 12:42:27 2017 +0200 ---------------------------------------------------------------------- .../main/service/reassign/step4_controller.js | 29 +++++++- .../manage_alert_groups_controller_test.js | 6 +- .../service/reassign/step4_controller_test.js | 78 ++++++++++++++++---- 3 files changed, 92 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/dab389d9/ambari-web/app/controllers/main/service/reassign/step4_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/reassign/step4_controller.js b/ambari-web/app/controllers/main/service/reassign/step4_controller.js index b383da7..2e9d431 100644 --- a/ambari-web/app/controllers/main/service/reassign/step4_controller.js +++ b/ambari-web/app/controllers/main/service/reassign/step4_controller.js @@ -70,6 +70,8 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro hostComponents: [], + dependentHostComponents: [], + dbPropertyMap: { 'HIVE_SERVER': { type: 'hive-site', @@ -89,16 +91,35 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro * load step info */ loadStep: function () { - if (this.get('content.reassign.component_name') === 'NAMENODE' && App.get('isHaEnabled')) { + var componentName = this.get('content.reassign.component_name'); + if (componentName === 'NAMENODE' && App.get('isHaEnabled')) { this.set('hostComponents', ['NAMENODE', 'ZKFC']); } else { - this.set('hostComponents', [this.get('content.reassign.component_name')]); + this.set('hostComponents', [componentName]); } + this.setDependentHostComponents(componentName); this.set('serviceName', [this.get('content.reassign.service_id')]); this._super(); }, /** + * Set dependent host-components to <code>dependentHostComponents</code> + * @param {string} componentName + */ + setDependentHostComponents: function(componentName) { + var installedComponents = App.Host.find(this.get('content.reassignHosts.target')) + .get('hostComponents') + .mapProperty('componentName'); + var dependenciesToInstall = App.StackServiceComponent.find(componentName) + .get('dependencies') + .mapProperty('componentName') + .filter(function(component) { + return !installedComponents.contains(component); + }); + this.set('dependentHostComponents', dependenciesToInstall); + }, + + /** * concat host-component names into string * @return {String} */ @@ -213,7 +234,7 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro }, createHostComponents: function () { - var hostComponents = this.get('hostComponents'); + var hostComponents = this.get('hostComponents').concat(this.get('dependentHostComponents')); var hostName = this.get('content.reassignHosts.target'); this.set('multiTaskCounter', hostComponents.length); for (var i = 0; i < hostComponents.length; i++) { @@ -245,7 +266,7 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro }, installHostComponents: function () { - var hostComponents = this.get('hostComponents'); + var hostComponents = this.get('hostComponents').concat(this.get('dependentHostComponents')); var hostName = this.get('content.reassignHosts.target'); this.set('multiTaskCounter', hostComponents.length); for (var i = 0; i < hostComponents.length; i++) { http://git-wip-us.apache.org/repos/asf/ambari/blob/dab389d9/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js b/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js index 2c58017..7a2f35b 100644 --- a/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js +++ b/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js @@ -21,7 +21,11 @@ var App = require('app'); var manageAlertGroupsController; function getController() { - return App.ManageAlertGroupsController.create({}); + return App.ManageAlertGroupsController.create({ + selectedAlertGroup: Em.Object.create({ + name: '' + }) + }); } describe('App.ManageAlertGroupsController', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/dab389d9/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js b/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js index aac15b8..6bf381a 100644 --- a/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js +++ b/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js @@ -367,17 +367,24 @@ describe('App.ReassignMasterWizardStep4Controller', function () { }); afterEach(function () { controller.createComponent.restore(); + controller.set('dependentHostComponents', []); }); - it('One host-component', function () { + it('createComponent should be called for each host-component', function () { controller.set('hostComponents', ['COMP1']); + controller.set('dependentHostComponents', ['COMP2']); controller.set('content.reassignHosts.target', 'host1'); controller.set('content.reassign.service_id', 'SERVICE1'); controller.createHostComponents(); - expect(controller.get('multiTaskCounter')).to.equal(1); - expect(controller.createComponent.calledWith('COMP1', 'host1', 'SERVICE1')).to.be.true; + expect(controller.get('multiTaskCounter')).to.equal(2); + expect(controller.createComponent.getCall(0).args).to.be.eql([ + 'COMP1', 'host1', 'SERVICE1' + ]); + expect(controller.createComponent.getCall(1).args).to.be.eql([ + 'COMP2', 'host1', 'SERVICE1' + ]); }); }); @@ -427,6 +434,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () { }); afterEach(function () { controller.updateComponent.restore(); + controller.set('dependentHostComponents', []); }); it('No host-components', function () { @@ -437,15 +445,21 @@ describe('App.ReassignMasterWizardStep4Controller', function () { expect(controller.get('multiTaskCounter')).to.equal(0); expect(controller.updateComponent.called).to.be.false; }); - it('One host-component', function () { + it('createComponent should be called for each host-component', function () { controller.set('hostComponents', ['COMP1']); + controller.set('dependentHostComponents', ['COMP2']); controller.set('content.reassignHosts.target', 'host1'); controller.set('content.reassign.service_id', 'SERVICE1'); controller.installHostComponents(); - expect(controller.get('multiTaskCounter')).to.equal(1); - expect(controller.updateComponent.calledWith('COMP1', 'host1', 'SERVICE1', 'Install', 1)).to.be.true; + expect(controller.get('multiTaskCounter')).to.equal(2); + expect(controller.updateComponent.getCall(0).args).to.be.eql([ + 'COMP1', 'host1', 'SERVICE1', 'Install', 2 + ]); + expect(controller.updateComponent.getCall(1).args).to.be.eql([ + 'COMP2', 'host1', 'SERVICE1', 'Install', 2 + ]); }); }); @@ -473,24 +487,21 @@ describe('App.ReassignMasterWizardStep4Controller', function () { }); describe('#loadStep()', function () { - var isHaEnabled = true; - beforeEach(function () { controller.set('content.reassign.service_id', 'service1'); sinon.stub(controller, 'onTaskStatusChange', Em.K); sinon.stub(controller, 'initializeTasks', Em.K); - sinon.stub(App, 'get', function () { - return isHaEnabled; - }); + sinon.stub(controller, 'setDependentHostComponents'); + this.mockGet = sinon.stub(App, 'get').returns(true); }); afterEach(function () { + controller.setDependentHostComponents.restore(); controller.onTaskStatusChange.restore(); controller.initializeTasks.restore(); - App.get.restore(); + this.mockGet.restore(); }); it('reassign component is NameNode and HA enabled', function () { - isHaEnabled = true; controller.set('content.reassign.component_name', 'NAMENODE'); controller.loadStep(); @@ -498,7 +509,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () { expect(controller.get('serviceName')).to.eql(['service1']); }); it('reassign component is NameNode and HA disabled', function () { - isHaEnabled = false; + this.mockGet.returns(false); controller.set('content.reassign.component_name', 'NAMENODE'); controller.loadStep(); @@ -506,7 +517,6 @@ describe('App.ReassignMasterWizardStep4Controller', function () { expect(controller.get('serviceName')).to.eql(['service1']); }); it('reassign component is JOBTRACKER and HA enabled', function () { - isHaEnabled = true; controller.set('content.reassign.component_name', 'JOBTRACKER'); controller.loadStep(); @@ -514,13 +524,18 @@ describe('App.ReassignMasterWizardStep4Controller', function () { expect(controller.get('serviceName')).to.eql(['service1']); }); it('reassign component is RESOURCEMANAGER and HA enabled', function () { - isHaEnabled = true; controller.set('content.reassign.component_name', 'RESOURCEMANAGER'); controller.loadStep(); expect(controller.get('hostComponents')).to.eql(['RESOURCEMANAGER']); expect(controller.get('serviceName')).to.eql(['service1']); }); + it('setDependentHostComponents should be called', function () { + controller.set('content.reassign.component_name', 'RESOURCEMANAGER'); + + controller.loadStep(); + expect(controller.setDependentHostComponents.calledOnce).to.be.true; + }); }); describe('#saveConfigsToServer()', function () { @@ -1065,4 +1080,35 @@ describe('App.ReassignMasterWizardStep4Controller', function () { }); }); }); + + describe('#setDependentHostComponents', function() { + beforeEach(function() { + sinon.stub(App.Host, 'find').returns(Em.Object.create({ + hostComponents: [ + Em.Object.create({ + componentName: 'C1' + }) + ] + })); + sinon.stub(App.StackServiceComponent, 'find').returns(Em.Object.create({ + dependencies: [ + Em.Object.create({ + componentName: 'C1' + }), + Em.Object.create({ + componentName: 'C2' + }) + ] + })); + }); + afterEach(function() { + App.Host.find.restore(); + App.StackServiceComponent.find.restore(); + }); + + it('should set dependentHostComponents', function() { + controller.setDependentHostComponents(); + expect(controller.get('dependentHostComponents')).to.be.eql(['C2']); + }); + }); });
