You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2017/01/25 10:41:38 UTC

ambari git commit: AMBARI-19696 Move HS2 does not install dependent components on the target host. (atkach)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 15ec7c337 -> 9a2d32232


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/9a2d3223
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9a2d3223
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9a2d3223

Branch: refs/heads/branch-2.5
Commit: 9a2d32232325a6cb483405fa7e2835b1129a0269
Parents: 15ec7c3
Author: Andrii Tkach <at...@apache.org>
Authored: Wed Jan 25 12:37:16 2017 +0200
Committer: Andrii Tkach <at...@apache.org>
Committed: Wed Jan 25 12:41:04 2017 +0200

----------------------------------------------------------------------
 .../main/service/reassign/step4_controller.js   | 29 +++++++-
 .../service/reassign/step4_controller_test.js   | 78 ++++++++++++++++----
 2 files changed, 87 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9a2d3223/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 c9cc28f..431a67f 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: [],
+
   /**
    * List of components, that do not need reconfiguration for moving to another host
    * Reconfigure command will be skipped
@@ -337,16 +339,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}
    */
@@ -461,7 +482,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++) {
@@ -493,7 +514,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/9a2d3223/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 9a73524..32bbdbd 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
@@ -425,17 +425,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'
+      ]);
     });
   });
 
@@ -485,6 +492,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
     });
     afterEach(function () {
       controller.updateComponent.restore();
+      controller.set('dependentHostComponents', []);
     });
 
     it('No host-components', function () {
@@ -495,15 +503,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
+      ]);
     });
   });
 
@@ -707,24 +721,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();
@@ -732,7 +743,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();
@@ -740,7 +751,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();
@@ -748,13 +758,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 () {
@@ -1645,4 +1660,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']);
+    });
+  });
 });