Просмотр исходного кода

AMBARI-25539. Unit tests coverage improvement for highAvailability controllers (dpidhaiets via dgrinenko) (#3215)

pidhaietsdp 5 лет назад
Родитель
Сommit
3b4fba65d2
20 измененных файлов с 2338 добавлено и 40 удалено
  1. 8 0
      ambari-web/app/assets/test/tests.js
  2. 2 2
      ambari-web/test/controllers/main/admin/federation/wizard_controller_test.js
  3. 2 18
      ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/wizard_controller_test.js
  4. 2 2
      ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/wizard_controller_test.js
  5. 2 2
      ambari-web/test/controllers/main/admin/highAvailability/hawq/removeStandby/wizard_controller_test.js
  6. 132 0
      ambari-web/test/controllers/main/admin/highAvailability/journalNode/step3_controller_test.js
  7. 14 0
      ambari-web/test/controllers/main/admin/highAvailability/journalNode/step4_controller_test.js
  8. 53 0
      ambari-web/test/controllers/main/admin/highAvailability/journalNode/step5_controller_test.js
  9. 149 0
      ambari-web/test/controllers/main/admin/highAvailability/journalNode/wizard_controller_test.js
  10. 282 0
      ambari-web/test/controllers/main/admin/highAvailability/nameNode/rollbackHA/rollback_wizard_controller_test.js
  11. 49 0
      ambari-web/test/controllers/main/admin/highAvailability/nameNode/rollbackHA/step2_controller_test.js
  12. 898 0
      ambari-web/test/controllers/main/admin/highAvailability/nameNode/rollback_controller_test.js
  13. 60 14
      ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js
  14. 100 0
      ambari-web/test/controllers/main/admin/highAvailability/nameNode/step9_controller_test.js
  15. 147 0
      ambari-web/test/controllers/main/admin/highAvailability/nameNode/wizard_controller_test.js
  16. 43 0
      ambari-web/test/controllers/main/admin/highAvailability/rangerAdmin/step1_controller_test.js
  17. 182 0
      ambari-web/test/controllers/main/admin/highAvailability/rangerAdmin/step4_controller_test.js
  18. 211 0
      ambari-web/test/controllers/main/admin/highAvailability/rangerAdmin/wizard_controller_test.js
  19. 1 1
      ambari-web/test/controllers/main/admin/highAvailability/resourceManager/step3_controller_test.js
  20. 1 1
      ambari-web/test/controllers/main/service/item_test.js

+ 8 - 0
ambari-web/app/assets/test/tests.js

@@ -72,6 +72,7 @@ var files = [
   'test/controllers/main/admin/highAvailability_controller_test',
   'test/controllers/main/admin/highAvailability/progress_controller_test',
   'test/controllers/main/admin/highAvailability/progress_popup_controller_test',
+  'test/controllers/main/admin/highAvailability/nameNode/rollback_controller_test',
   'test/controllers/main/admin/highAvailability/nameNode/step1_controller_test',
   'test/controllers/main/admin/highAvailability/nameNode/step2_controller_test',
   'test/controllers/main/admin/highAvailability/nameNode/step3_controller_test',
@@ -82,6 +83,8 @@ var files = [
   'test/controllers/main/admin/highAvailability/nameNode/step8_controller_test',
   'test/controllers/main/admin/highAvailability/nameNode/step9_controller_test',
   'test/controllers/main/admin/highAvailability/nameNode/wizard_controller_test',
+  'test/controllers/main/admin/highAvailability/nameNode/rollbackHA/step2_controller_test',
+  'test/controllers/main/admin/highAvailability/nameNode/rollbackHA/rollback_wizard_controller_test',
   'test/controllers/main/admin/highAvailability/resourceManager/step3_controller_test',
   'test/controllers/main/admin/highAvailability/resourceManager/step4_controller_test',
   'test/controllers/main/admin/highAvailability/resourceManager/wizard_controller_test',
@@ -97,11 +100,16 @@ var files = [
   'test/controllers/main/admin/highAvailability/journalNode/progress_controller_test',
   'test/controllers/main/admin/highAvailability/journalNode/step1_controller_test',
   'test/controllers/main/admin/highAvailability/journalNode/step2_controller_test',
+  'test/controllers/main/admin/highAvailability/journalNode/step3_controller_test',
   'test/controllers/main/admin/highAvailability/journalNode/step4_controller_test',
+  'test/controllers/main/admin/highAvailability/journalNode/step5_controller_test',
   'test/controllers/main/admin/highAvailability/journalNode/step6_controller_test',
   'test/controllers/main/admin/highAvailability/journalNode/step7_controller_test',
   'test/controllers/main/admin/highAvailability/journalNode/wizard_controller_test',
+  'test/controllers/main/admin/highAvailability/rangerAdmin/step1_controller_test',
   'test/controllers/main/admin/highAvailability/rangerAdmin/step3_controller_test',
+  'test/controllers/main/admin/highAvailability/rangerAdmin/step4_controller_test',
+  'test/controllers/main/admin/highAvailability/rangerAdmin/wizard_controller_test',
   'test/controllers/main/dashboard/config_history_controller_test',
   'test/controllers/main/charts/heatmap_test',
   'test/controllers/main/charts/heatmap_metrics/heatmap_metric_test',

+ 2 - 2
ambari-web/test/controllers/main/admin/federation/wizard_controller_test.js

@@ -226,7 +226,7 @@ describe('App.NameNodeFederationWizardController', function() {
       });
     });
 
-    describe ('should load service hosts', function() {
+    describe('should load service hosts', function() {
       var loadServicesFromServer = false;
       var loadMasterComponentHosts = false;
       var loadConfirmedHosts = false;
@@ -278,7 +278,7 @@ describe('App.NameNodeFederationWizardController', function() {
       });
     });
 
-    describe ('should load tasks', function() {
+    describe('should load tasks', function() {
       var loadServiceConfigProperties = false;
       var loadTasksStatuses = false;
       var loadTasksRequestIds = false;

+ 2 - 18
ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/wizard_controller_test.js

@@ -65,7 +65,7 @@ describe('App.ActivateHawqStandbyWizardController', function () {
       });
     });
 
-    describe ('should load service hosts', function() {
+    describe('should load service hosts', function() {
       var loadServicesFromServer = false;
       var loadMasterComponentHosts = false;
       var loadHawqHosts = false;
@@ -100,7 +100,7 @@ describe('App.ActivateHawqStandbyWizardController', function () {
       });
     });
 
-    describe ('should load tasks', function() {
+    describe('should load tasks', function() {
       var loadConfigs = false;
       var loadTasksStatuses = false;
       var loadTasksRequestIds = false;
@@ -144,22 +144,6 @@ describe('App.ActivateHawqStandbyWizardController', function () {
     });
   });
 
-  describe("#setCurrentStep()", function () {
-
-    beforeEach(function() {
-      sinon.stub(App.clusterStatus, 'setClusterStatus');
-    });
-
-    afterEach(function() {
-      App.clusterStatus.setClusterStatus.restore();
-    });
-
-    it("App.clusterStatus.setClusterStatus should be called", function() {
-      controller.setCurrentStep();
-      expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
-    });
-  });
-
   describe("#saveHawqHosts()", function () {
 
     beforeEach(function() {

+ 2 - 2
ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/wizard_controller_test.js

@@ -65,7 +65,7 @@ describe('App.AddHawqStandbyWizardController', function () {
       });
     });
 
-    describe ('should load service hosts', function() {
+    describe('should load service hosts', function() {
       var loadServicesFromServer = false;
       var loadMasterComponentHosts = false;
       var loadHawqHosts = false;
@@ -108,7 +108,7 @@ describe('App.AddHawqStandbyWizardController', function () {
       });
     });
 
-    describe ('should load tasks', function() {
+    describe('should load tasks', function() {
       var loadConfigs = false;
       var loadTasksStatuses = false;
       var loadTasksRequestIds = false;

+ 2 - 2
ambari-web/test/controllers/main/admin/highAvailability/hawq/removeStandby/wizard_controller_test.js

@@ -65,7 +65,7 @@ describe('App.RemoveHawqStandbyWizardController', function () {
       });
     });
 
-    describe ('should load service hosts', function() {
+    describe('should load service hosts', function() {
       var loadServicesFromServer = false;
       var loadMasterComponentHosts = false;
       var loadHawqHosts = false;
@@ -100,7 +100,7 @@ describe('App.RemoveHawqStandbyWizardController', function () {
       });
     });
 
-    describe ('should load tasks', function() {
+    describe('should load tasks', function() {
       var loadConfigs = false;
       var loadTasksStatuses = false;
       var loadTasksRequestIds = false;

+ 132 - 0
ambari-web/test/controllers/main/admin/highAvailability/journalNode/step3_controller_test.js

@@ -0,0 +1,132 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+var testHelpers = require('test/helpers');
+
+describe('App.ManageJournalNodeWizardStep3Controller', function () {
+  var controller;
+
+  beforeEach(function () {
+    controller = App.ManageJournalNodeWizardStep3Controller.create({
+      isHDFSNameSpacesLoaded: false
+    });
+  });
+
+  describe('#pullCheckPointsStatuses()', function () {
+
+    beforeEach(function () {
+      this.mockHDFS = sinon.stub(App.HDFSService, 'find');
+      sinon.stub(App.HostComponent, 'find').returns(Em.Object.create({workStatus: 'STOPPED'}));
+      sinon.stub(controller, 'pullCheckPointStatus');
+      sinon.stub(controller, 'removeObserver');
+      sinon.stub(controller, 'addObserver');
+    })
+
+    afterEach(function () {
+      this.mockHDFS.restore();
+      App.HostComponent.find.restore();
+      controller.pullCheckPointStatus.restore();
+      controller.removeObserver.restore();
+      controller.addObserver.restore();
+    })
+
+    it('should execute addObserver function', function () {
+      controller.pullCheckPointsStatuses();
+      expect(controller.addObserver.calledOnce).to.be.true;
+    });
+
+    it('should send check point statuses{1}', function () {
+      controller.set('isHDFSNameSpacesLoaded', true);
+      this.mockHDFS.returns(Em.Object.create({
+        masterComponentGroups: [
+          {
+            hosts: ['host1']
+          },
+          {
+            hosts: ['host2']
+          }
+        ],
+        activeNameNodes: [{hostName: 'host1'}]
+      }));
+      controller.pullCheckPointsStatuses();
+      var args = testHelpers.findAjaxRequest('name', 'admin.high_availability.getNnCheckPointsStatuses');
+      expect(args[0].data.hostNames.join(', ')).to.eql('host1, host2');
+    });
+
+    it('should send check point statuses{2}', function () {
+      controller.set('isHDFSNameSpacesLoaded', true);
+      this.mockHDFS.returns(Em.Object.create({
+        masterComponentGroups: [
+          {
+            hosts: ['host1']
+          },
+          {
+            hosts: ['host2']
+          }
+        ],
+        activeNameNodes: [{hostName: 'host1'}, {hostName: 'host2'}]
+      }));
+      controller.pullCheckPointsStatuses();
+      var args = testHelpers.findAjaxRequest('name', 'admin.high_availability.getNnCheckPointsStatuses');
+      expect(args[0].data.hostNames.join(', ')).to.eql('host1, host2');
+    })
+
+    it('should execute pullCheckPointStatus function', function () {
+      controller.set('isHDFSNameSpacesLoaded', true);
+      this.mockHDFS.returns(Em.Object.create({
+        masterComponentGroups: [
+          {
+            hosts: ['host1']
+          }
+        ],
+        activeNameNodes: [{hostName: 'host1'}]
+      }));
+      controller.pullCheckPointsStatuses();
+      expect(controller.pullCheckPointStatus.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#checkNnCheckPointsStatuses()', function () {
+    var data = {};
+    beforeEach(function () {
+      sinon.stub(controller, 'pullCheckPointsStatuses');
+      sinon.stub(controller, 'setProperties');
+      this.clock = sinon.useFakeTimers();
+      controller.checkNnCheckPointsStatuses(data);
+    })
+
+    afterEach(function () {
+      controller.pullCheckPointsStatuses.restore();
+      controller.setProperties.restore();
+      this.clock.restore();
+    })
+
+    it('should execute setProperties function', function () {
+      expect(controller.setProperties.calledOnce).to.be.true;
+    });
+
+    it('should execute pullCheckPointsStatuses function', function () {
+      controller.set('POLL_INTERVAL', 1000);
+      this.clock.tick(controller.POLL_INTERVAL);
+      expect(controller.pullCheckPointsStatuses.calledOnce).to.be.true;
+    });
+  });
+
+});

+ 14 - 0
ambari-web/test/controllers/main/admin/highAvailability/journalNode/step4_controller_test.js

@@ -49,6 +49,20 @@ describe('App.ManageJournalNodeWizardStep4Controller', function () {
     });
   });
 
+  describe('#stopAllServices', function() {
+    beforeEach(function() {
+      sinon.stub(controller, 'stopServices');
+    });
+    afterEach(function() {
+      controller.stopServices.restore();
+    });
+
+    it('stopAllServices should be called', function() {
+      controller.stopAllServices();
+      expect(controller.stopServices.calledWith([], true, true)).to.be.true;
+    });
+  });
+
   describe('#installJournalNodes', function() {
     var wizardController = {
       getJournalNodesToAdd: Em.K

+ 53 - 0
ambari-web/test/controllers/main/admin/highAvailability/journalNode/step5_controller_test.js

@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+
+describe('App.ManageJournalNodeWizardStep5Controller', function () {
+  var controller;
+
+  beforeEach(function () {
+    controller = App.ManageJournalNodeWizardStep5Controller.create({
+      isHDFSNameSpacesLoaded: false
+    });
+  });
+
+  describe('#done', function() {
+
+    beforeEach(function() {
+      sinon.stub(App.router, 'send');
+    });
+
+    afterEach(function() {
+      App.router.send.restore();
+    });
+
+    it('App.router.send should not be called', function() {
+      controller.done();
+      expect(App.router.send.calledWith('next')).to.be.false;
+    });
+
+    it('App.router.send should be called', function() {
+      controller.set('isHDFSNameSpacesLoaded', true);
+      controller.done();
+      expect(App.router.send.calledWith('next')).to.be.true;
+    });
+  });
+
+});

+ 149 - 0
ambari-web/test/controllers/main/admin/highAvailability/journalNode/wizard_controller_test.js

@@ -401,4 +401,153 @@ describe('App.ManageJournalNodeWizardController', function () {
       expect(mock.updateAll.calledOnce).to.be.true;
     });
   });
+
+  describe('#loadMap', function() {
+
+    describe('should load hdfs user', function() {
+      var loadServicesFromServer = false;
+      var loadMasterComponentHosts = false;
+      var loadHosts = false;
+      var loadHdfsUserFromServer = false;
+      var loadCluster = false;
+      var loadHdfsUser = false;
+      var saveHdfsUser = false;
+      var saveNNs = false;
+      var loadNNs = false;
+
+      var checker = {
+        loadServicesFromServer: function () {
+          loadServicesFromServer = true;
+        },
+        loadMasterComponentHosts: function () {
+          loadMasterComponentHosts = true;
+          return $.Deferred().resolve().promise();
+        },
+        loadHosts: function () {
+          loadHosts = true;
+          return $.Deferred().resolve().promise();
+        },
+        loadHdfsUserFromServer: function () {
+          loadHdfsUserFromServer = true;
+          return $.Deferred().resolve().promise();
+        },
+        load: function () {
+          loadCluster = true;
+          loadHdfsUser = true;
+        },
+        save: function () {
+          saveHdfsUser = true;
+        },
+        saveNNs: function () {
+          saveNNs = true;
+        },
+        loadNNs: function () {
+          loadNNs = true;
+        },
+        getDBProperty: function () {
+          return true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['1'][0].callback.call(checker);
+      })
+
+      it('services from server are loaded', function () {
+        expect(loadServicesFromServer).to.be.true;
+      });
+
+      it('master component hosts are loaded', function () {
+        expect(loadMasterComponentHosts).to.be.true;
+      });
+
+      it('hosts are loaded', function () {
+        expect(loadHosts).to.be.true;
+      });
+
+      it('hdfs users are loaded', function () {
+        expect(loadHdfsUserFromServer).to.be.false;
+      });
+
+      it('cluster is loaded', function () {
+        expect(loadCluster).to.be.true;
+      });
+
+      it('hdfs user is loaded', function () {
+        expect(loadHdfsUser).to.be.true;
+      });
+
+      it('hdfs user is saved', function () {
+        expect(saveHdfsUser).to.be.true;
+      });
+
+      it('NNs are saved', function () {
+        expect(saveNNs).to.be.false;
+      });
+
+      it('NNs are loaded', function () {
+        expect(loadNNs).to.be.true;
+      });
+    });
+
+    describe('should service config properties', function() {
+      var loadNameServiceIds = false;
+      var loadServiceConfigProperties = false;
+
+      var checker = {
+        loadServiceConfigProperties: function () {
+          loadServiceConfigProperties = true;
+        },
+        loadNameServiceIds: function () {
+          loadNameServiceIds = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['2'][0].callback.call(checker);
+      });
+
+      it('name service ids are loaded', function () {
+        expect(loadNameServiceIds).to.be.true;
+      });
+
+      it('service config properties are loaded', function () {
+        expect(loadServiceConfigProperties).to.be.true;
+      });
+    });
+
+    describe('should load tasks', function() {
+      var loadTasksStatuses = false;
+      var loadTasksRequestIds = false;
+      var loadRequestIds = false;
+
+      var checker = {
+        loadTasksStatuses: function () {
+          loadTasksStatuses = true;
+        },
+        loadTasksRequestIds: function () {
+          loadTasksRequestIds = true;
+        },
+        loadRequestIds: function () {
+          loadRequestIds = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['4'][0].callback.call(checker);
+      });
+
+      it('task statuses are loaded', function () {
+        expect(loadTasksStatuses).to.be.true;
+      });
+
+      it('task request ids are loaded', function () {
+        expect(loadTasksRequestIds).to.be.true;
+      });
+
+      it('request ids are loaded', function () {
+        expect(loadRequestIds).to.be.true;
+      });
+    });
+  });
 });

+ 282 - 0
ambari-web/test/controllers/main/admin/highAvailability/nameNode/rollbackHA/rollback_wizard_controller_test.js

@@ -0,0 +1,282 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+describe('App.RollbackHighAvailabilityWizardController', function() {
+  var controller;
+
+  beforeEach(function() {
+    controller = App.RollbackHighAvailabilityWizardController.create();
+  });
+
+  describe('#setCurrentStep', function() {
+    beforeEach(function() {
+      sinon.stub(App.clusterStatus, 'setClusterStatus');
+    });
+    afterEach(function() {
+      App.clusterStatus.setClusterStatus.restore();
+    });
+
+    it('App.clusterStatus.setClusterStatus should be called', function() {
+      controller.setCurrentStep();
+      expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#getCluster', function() {
+    beforeEach(function() {
+      sinon.stub(App.router, 'getClusterName').returns('c1');
+    });
+    afterEach(function() {
+      App.router.getClusterName.restore();
+    });
+
+    it('should return cluster object', function() {
+      controller.set('clusterStatusTemplate', {});
+      expect(controller.getCluster()).to.be.eql({
+        name: 'c1'
+      });
+    });
+  });
+
+  describe('#saveClusterStatus', function() {
+    beforeEach(function() {
+      sinon.stub(controller, 'save');
+    });
+    afterEach(function() {
+      controller.save.restore();
+    });
+
+    it('cluster status should be saved', function() {
+      controller.set('content.cluster', {});
+      controller.saveClusterStatus({requestId: [1], oldRequestsId: []});
+      expect(controller.get('content.cluster')).to.be.eql({
+        requestId: [1],
+        oldRequestsId: [1]
+      });
+      expect(controller.save.calledWith('cluster')).to.be.true;
+    });
+  });
+
+  describe('#saveTasksStatuses', function() {
+    beforeEach(function() {
+      sinon.stub(App.db, 'setRollbackHighAvailabilityWizardTasksStatuses');
+    });
+    afterEach(function() {
+      App.db.setRollbackHighAvailabilityWizardTasksStatuses.restore();
+    });
+
+    it('setRollbackHighAvailabilityWizardTasksStatuses should be called', function() {
+      controller.saveTasksStatuses([{}]);
+      expect(App.db.setRollbackHighAvailabilityWizardTasksStatuses.calledWith([{}])).to.be.true;
+      expect(controller.get('content.tasksStatuses')).to.be.eql([{}]);
+    });
+  });
+
+  describe('#saveRequestIds', function() {
+    beforeEach(function() {
+      sinon.stub(App.db, 'setRollbackHighAvailabilityWizardRequestIds');
+    });
+    afterEach(function() {
+      App.db.setRollbackHighAvailabilityWizardRequestIds.restore();
+    });
+
+    it('setRollbackHighAvailabilityWizardRequestIds should be called', function() {
+      controller.saveRequestIds([1]);
+      expect(controller.get('content.requestIds')).to.be.eql([1]);
+      expect(App.db.setRollbackHighAvailabilityWizardRequestIds.calledWith([1])).to.be.true;
+    });
+  });
+
+  describe('#saveSelectedSNN', function() {
+    beforeEach(function() {
+      sinon.stub(App.db, 'setRollBackHighAvailabilityWizardSelectedSNN');
+    });
+    afterEach(function() {
+      App.db.setRollBackHighAvailabilityWizardSelectedSNN.restore();
+    });
+
+    it('setRollBackHighAvailabilityWizardSelectedSNN should be called', function() {
+      controller.saveSelectedSNN('addNN');
+      expect(controller.get('content.selectedAddNN')).to.be.eql('addNN');
+      expect(App.db.setRollBackHighAvailabilityWizardSelectedSNN.calledWith('addNN')).to.be.true;
+    });
+  });
+
+  describe('#saveSelectedAddNN', function() {
+    beforeEach(function() {
+      sinon.stub(App.db, 'setRollBackHighAvailabilityWizardSelectedAddNN');
+    });
+    afterEach(function() {
+      App.db.setRollBackHighAvailabilityWizardSelectedAddNN.restore();
+    });
+
+    it('setRollBackHighAvailabilityWizardSelectedAddNN should be called', function() {
+      controller.saveSelectedAddNN('sNN');
+      expect(controller.get('content.selectedSNN')).to.be.eql('sNN');
+      expect(App.db.setRollBackHighAvailabilityWizardSelectedAddNN.calledWith('sNN')).to.be.true;
+    });
+  });
+
+  describe('#loadAddNNHost', function() {
+    beforeEach(function() {
+      sinon.stub(App.db, 'getRollBackHighAvailabilityWizardAddNNHost').returns('host1');
+    });
+    afterEach(function() {
+      App.db.getRollBackHighAvailabilityWizardAddNNHost.restore();
+    });
+
+    it('addNNHost value should be set', function() {
+      controller.loadAddNNHost();
+      expect(controller.get('content.addNNHost')).to.be.equal('host1');
+    });
+  });
+
+  describe('#loadSNNHost', function() {
+    beforeEach(function() {
+      sinon.stub(App.db, 'getRollBackHighAvailabilityWizardSNNHost').returns('host1');
+    });
+    afterEach(function() {
+      App.db.getRollBackHighAvailabilityWizardSNNHost.restore();
+    });
+
+    it('sNNHost value should be set', function() {
+      controller.loadSNNHost();
+      expect(controller.get('content.sNNHost')).to.be.equal('host1');
+    });
+  });
+
+  describe('#loadTasksStatuses', function() {
+    beforeEach(function() {
+      sinon.stub(App.db, 'getRollbackHighAvailabilityWizardTasksStatuses').returns('st');
+    });
+    afterEach(function() {
+      App.db.getRollbackHighAvailabilityWizardTasksStatuses.restore();
+    });
+
+    it('tasksStatuses should be set', function() {
+      controller.loadTasksStatuses();
+      expect(controller.get('content.tasksStatuses')).to.be.eql('st');
+    });
+  });
+
+  describe('#loadRequestIds', function() {
+    beforeEach(function() {
+      sinon.stub(App.db, 'getRollbackHighAvailabilityWizardRequestIds').returns([1]);
+    });
+    afterEach(function() {
+      App.db.getRollbackHighAvailabilityWizardRequestIds.restore();
+    });
+
+    it('requestIds should be set', function() {
+      controller.loadRequestIds();
+      expect(controller.get('content.requestIds')).to.be.eql([1]);
+    });
+  });
+
+  describe('#loadAllPriorSteps', function() {
+    beforeEach(function() {
+      sinon.stub(controller, 'loadSNNHost');
+      sinon.stub(controller, 'loadAddNNHost');
+      sinon.stub(controller, 'load');
+    });
+    afterEach(function() {
+      controller.loadSNNHost.restore();
+      controller.loadAddNNHost.restore();
+      controller.load.restore();
+    });
+
+    ['1', '2', '3'].forEach(function(step) {
+      it('should load data for step '+step, function() {
+      controller.set('currentStep', step);
+      controller.loadAllPriorSteps();
+      expect(controller.loadSNNHost.calledOnce).to.be.true;
+      expect(controller.loadAddNNHost.calledOnce).to.be.true;
+      expect(controller.load.calledOnce).to.be.true;
+    })});
+  });
+
+  describe('#clearAllSteps', function() {
+    beforeEach(function() {
+      sinon.stub(controller, 'clearInstallOptions');
+      sinon.stub(controller, 'getCluster').returns({name: 'c1'});
+    });
+    afterEach(function() {
+      controller.clearInstallOptions.restore();
+      controller.getCluster.restore();
+    });
+
+    it('clearInstallOptions should be called', function() {
+      controller.clearAllSteps();
+      expect(controller.clearInstallOptions.calledOnce).to.be.true;
+      expect(controller.get('content.cluster')).to.be.eql({name: 'c1'});
+    });
+  });
+
+  describe('#clearTasksData', function() {
+    beforeEach(function() {
+      sinon.stub(controller, 'saveRequestIds');
+      sinon.stub(controller, 'saveTasksStatuses');
+      controller.clearTasksData();
+    });
+    afterEach(function() {
+      controller.saveRequestIds.restore();
+      controller.saveTasksStatuses.restore();
+    });
+
+    it('saveRequestIds should be called', function() {
+      expect(controller.saveRequestIds.calledWith(undefined)).to.be.true;
+    });
+
+    it('saveTasksStatuses should be called', function() {
+      expect(controller.saveTasksStatuses.calledWith(undefined)).to.be.true;
+    });
+  });
+
+  describe('#finish', function() {
+    var mock = {
+      updateAll: Em.K
+    };
+    beforeEach(function() {
+      sinon.spy(mock, 'updateAll');
+      sinon.stub(App.router, 'get').returns(mock);
+      sinon.stub(controller, 'setCurrentStep');
+      sinon.stub(controller, 'clearAllSteps');
+      controller.finish();
+    });
+    afterEach(function() {
+      controller.setCurrentStep.restore();
+      controller.clearAllSteps.restore();
+      mock.updateAll.restore();
+      App.router.get.restore();
+    });
+
+    it('setCurrentStep should be called', function() {
+      expect(controller.setCurrentStep.calledWith('1')).to.be.true;
+    });
+
+    it('clearAllSteps should be called', function() {
+      expect(controller.clearAllSteps.calledOnce).to.be.true;
+    });
+
+    it('updateAll should be called', function() {
+      expect(mock.updateAll.called).to.be.true;
+    });
+  });
+});

+ 49 - 0
ambari-web/test/controllers/main/admin/highAvailability/nameNode/rollbackHA/step2_controller_test.js

@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+var testHelpers = require('test/helpers');
+
+describe('App.RollbackHighAvailabilityWizardStep2Controller', function() {
+  var controller;
+
+  beforeEach(function() {
+    controller = App.RollbackHighAvailabilityWizardStep2Controller.create({
+      content: Em.Object.create()
+    });
+  });
+
+  describe('#pullCheckPointStatus', function() {
+
+    it('App.ajax.send should be called', function() {
+      controller.set('content.activeNNHost', 'host1');
+      controller.pullCheckPointStatus();
+      var args = testHelpers.findAjaxRequest('name', 'admin.high_availability.getNnCheckPointStatus');
+      expect(args[0]).to.be.eql({
+        name: 'admin.high_availability.getNnCheckPointStatus',
+        sender: controller,
+        data: {
+          hostName: 'host1'
+        },
+        success: 'checkNnCheckPointStatus'
+      });
+    });
+  });
+
+});
+

+ 898 - 0
ambari-web/test/controllers/main/admin/highAvailability/nameNode/rollback_controller_test.js

@@ -0,0 +1,898 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+var testHelpers = require('test/helpers');
+
+describe('App.HighAvailabilityRollbackController', function () {
+  var controller;
+  var masterComponentHosts = [
+    {
+      component: 'NAMENODE',
+      isInstalled: true,
+      hostName: 'host1'
+    },
+    {
+      component: 'NAMENODE',
+      isInstalled: false,
+      hostName: 'host2'
+    },
+    {
+      component: 'SECONDARY_NAMENODE',
+      isInstalled: false,
+      hostName: 'host2'
+    },
+    {
+      component: 'JORNALNODE',
+      isInstalled: false,
+      hostName: 'host2'
+    }
+  ];
+
+  beforeEach(function() {
+    controller = App.HighAvailabilityRollbackController.create({
+      popup: {
+        proceedOnClose: Em.K
+      },
+      saveLogs: Em.K
+    });
+  });
+
+  describe('#loadStep()', function() {
+    var initData = false;
+    var clearStep = false;
+    var loadTasks = false;
+    var addObserver = false;
+    var onTaskStatusChange = false;
+
+    var checker = {
+      initData: function () {
+        initData = true;
+        return $.Deferred().resolve().promise();
+      },
+      clearStep: function () {
+        clearStep = true;
+      },
+      loadTasks: function () {
+        loadTasks = true;
+      },
+      addObserver: function () {
+        addObserver = true;
+      },
+      onTaskStatusChange: function () {
+        onTaskStatusChange = true;
+      }
+    };
+
+    beforeEach(function () {
+      controller.loadStep.call(checker);
+    });
+
+    it('data is initialized', function () {
+      expect(initData).to.be.true;
+    });
+
+    it('step is cleared', function () {
+      expect(clearStep).to.be.true;
+    });
+
+    it('tasks are loaded', function () {
+      expect(loadTasks).to.be.true;
+    });
+
+    it('observer is added', function () {
+      expect(addObserver).to.be.true;
+    });
+
+    it('status is changed', function () {
+      expect(onTaskStatusChange).to.be.true;
+    });
+  });
+
+  describe('#initData()', function() {
+    var loadMasterComponentHosts = false;
+    var loadFailedTask = false;
+    var loadHdfsClientHosts = false;
+
+    var checker = {
+      loadMasterComponentHosts: function () {
+        loadMasterComponentHosts = true;
+        return $.Deferred().resolve().promise();
+      },
+      loadFailedTask: function () {
+        loadFailedTask = true;
+      },
+      loadHdfsClientHosts: function () {
+        loadHdfsClientHosts = true;
+      }
+    };
+
+    beforeEach(function () {
+      controller.initData.call(checker);
+    });
+
+    it('master component hosts are loaded', function () {
+      expect(loadMasterComponentHosts).to.be.true;
+    });
+
+    it('failed tasks are loaded', function () {
+      expect(loadFailedTask).to.be.true;
+    });
+
+    it('hdfs client hosts are loaded', function () {
+      expect(loadHdfsClientHosts).to.be.true;
+    });
+  });
+
+  describe('#skipTask()', function() {
+
+    it('should skip task', function () {
+      controller.set('tasks', [
+        Em.Object.create({
+          id: 'task1',
+          status: 'FAILED',
+          showRetry: true,
+          showSkip: true
+        })
+      ]);
+      controller.skipTask();
+      expect(controller.get('tasks').findProperty('id', 'task1')).to.eql(Em.Object.create({
+        id: 'task1',
+        status: 'COMPLETED',
+        showRetry: false,
+        showSkip: false
+      }));
+    });
+  });
+
+  describe('#retryTask()', function() {
+
+    it('should skip task', function () {
+      controller.set('tasks', [
+        Em.Object.create({
+          id: 'task1',
+          status: 'FAILED',
+          showRetry: true,
+          showSkip: true
+        })
+      ]);
+      controller.retryTask();
+      expect(controller.get('tasks').findProperty('id', 'task1')).to.eql(Em.Object.create({
+        id: 'task1',
+        status: 'PENDING',
+        showRetry: false,
+        showSkip: false
+      }));
+    });
+  });
+
+  describe('#onTaskCompleted()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'getTaskStatus');
+      sinon.stub(controller, 'setTaskStatus');
+    });
+
+    afterEach(function () {
+      controller.getTaskStatus.restore();
+      controller.setTaskStatus.restore();
+    });
+
+    it('should set task status', function () {
+      controller.set('currentTaskId', 'task1');
+      controller.onTaskCompleted();
+      expect(controller.getTaskStatus.calledWith('task1')).to.be.true;
+      expect(controller.setTaskStatus.calledWith('task1', 'COMPLETED')).to.be.true;
+    });
+  });
+
+  describe('#getTaskStatus()', function() {
+
+    it('should skip task', function () {
+      controller.set('tasks', [
+        Em.Object.create({
+          id: 'task1',
+          status: 'FAILED'
+        })
+      ]);
+      controller.set('currentTaskId', 'task1');
+      expect(controller.getTaskStatus('task1')).to.equal('FAILED');
+    });
+  });
+
+  describe('#loadFailedTask()', function() {
+
+    beforeEach(function () {
+      sinon.stub(App.db, 'getHighAvailabilityWizardFailedTask').returns({id: 'task1'});
+    });
+
+    afterEach(function () {
+      App.db.getHighAvailabilityWizardFailedTask.restore();
+    });
+
+    it('should load failed task', function () {
+      controller.loadFailedTask();
+      expect(controller.get('failedTask')).to.eql({id: 'task1'});
+    });
+  });
+
+  describe('#loadFailedTask()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'removeObserver');
+      sinon.stub(controller.popup, 'proceedOnClose');
+    });
+
+    afterEach(function () {
+      controller.removeObserver.restore();
+      controller.popup.proceedOnClose.restore();
+    });
+
+    it('should remove observer and proceed', function () {
+      controller.set('isSubmitDisabled', false);
+      controller.done();
+      expect(controller.removeObserver.calledOnce).to.be.true;
+      expect(controller.popup.proceedOnClose.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#stopAllServices()', function() {
+
+    it('should skip task', function () {
+      controller.stopAllServices();
+      var args = testHelpers.findAjaxRequest('name', 'common.services.update');
+      expect(args).to.exists;
+    });
+  });
+
+  describe('#restoreHBaseConfigs()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'loadConfigTag');
+    });
+
+    afterEach(function () {
+      controller.loadConfigTag.restore();
+    });
+
+    it('should restore hbase configs', function () {
+      controller.set('content.hbaseSiteTag', 'v1');
+      controller.restoreHBaseConfigs();
+      var args = testHelpers.findAjaxRequest('name', 'admin.high_availability.load_hbase_configs');
+      expect(args[0].data.hbaseSiteTag).to.equal('v1');
+    });
+  });
+
+  describe('#restoreAccumuloConfigs()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'loadConfigTag');
+    });
+
+    afterEach(function () {
+      controller.loadConfigTag.restore();
+    });
+
+    it('should restore accumulo configs', function () {
+      controller.set('content.accumuloSiteTag', 'v1');
+      controller.restoreAccumuloConfigs();
+      var args = testHelpers.findAjaxRequest('name', 'admin.high_availability.load_accumulo_configs');
+      expect(args[0].data.accumuloSiteTag).to.equal('v1');
+    });
+  });
+
+  describe('#restoreHawqConfigs()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'loadConfigTag');
+    });
+
+    afterEach(function () {
+      controller.loadConfigTag.restore();
+    });
+
+    it('should restore hawq configs', function () {
+      controller.set('content.hawqSiteTag', 'v1');
+      controller.set('content.hdfsClientTag', 'v2');
+      controller.restoreHawqConfigs();
+      var args = testHelpers.filterAjaxRequests('name', 'admin.high_availability.load_hawq_configs');
+      expect(args[0][0].data.tagName).to.equal('v1');
+      expect(args[1][0].data.tagName).to.equal('v2');
+    });
+  });
+
+  describe('#stopFailoverControllers()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'updateComponent');
+    });
+
+    afterEach(function () {
+      controller.updateComponent.restore();
+    });
+
+    it('should execute stopFailoverControllers function', function () {
+      controller.set('content.masterComponentHosts', masterComponentHosts);
+      controller.stopFailoverControllers();
+      expect(controller.updateComponent.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#deleteFailoverControllers()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'checkBeforeDelete');
+    });
+
+    afterEach(function () {
+      controller.checkBeforeDelete.restore();
+    });
+
+    it('should execute checkBeforeDelete function', function () {
+      controller.set('content.masterComponentHosts', masterComponentHosts);
+      controller.deleteFailoverControllers();
+      expect(controller.checkBeforeDelete.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#stopStandbyNameNode()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'updateComponent');
+    });
+
+    afterEach(function () {
+      controller.updateComponent.restore();
+    });
+
+    it('should execute updateComponent function', function () {
+      controller.set('content.masterComponentHosts', masterComponentHosts);
+      controller.stopStandbyNameNode();
+      expect(controller.updateComponent.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#stopNameNode()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'updateComponent');
+    });
+
+    afterEach(function () {
+      controller.updateComponent.restore();
+    });
+
+    it('should execute updateComponent function', function () {
+      controller.set('content.masterComponentHosts', masterComponentHosts);
+      controller.stopNameNode();
+      expect(controller.updateComponent.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#restoreHDFSConfigs()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'unInstallHDFSClients');
+    });
+
+    afterEach(function () {
+      controller.unInstallHDFSClients.restore();
+    });
+
+    it('should execute restoreHDFSConfigs function', function () {
+      controller.restoreHDFSConfigs();
+      expect(controller.unInstallHDFSClients.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#enableSecondaryNameNode()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'updateComponent');
+    });
+
+    afterEach(function () {
+      controller.updateComponent.restore();
+    });
+
+    it('should execute updateComponent function', function () {
+      controller.set('content.masterComponentHosts', masterComponentHosts);
+      controller.enableSecondaryNameNode();
+      expect(controller.updateComponent.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#stopJournalNodes()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'updateComponent');
+    });
+
+    afterEach(function () {
+      controller.updateComponent.restore();
+    });
+
+    it('should execute updateComponent function', function () {
+      controller.set('content.masterComponentHosts', masterComponentHosts);
+      controller.stopJournalNodes();
+      expect(controller.updateComponent.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#deleteJournalNodes()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'unInstallComponent');
+    });
+
+    afterEach(function () {
+      controller.unInstallComponent.restore();
+    });
+
+    it('should execute unInstallComponent function', function () {
+      controller.set('content.masterComponentHosts', masterComponentHosts);
+      controller.deleteJournalNodes();
+      expect(controller.unInstallComponent.calledOnce).to.be.true;
+    });
+  });
+
+  describe.skip('#deleteAdditionalNameNode()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'unInstallComponent');
+    });
+
+    afterEach(function () {
+      controller.unInstallComponent.restore();
+    });
+
+    it('should execute unInstallComponent function', function () {
+      controller.set('content.masterComponentHosts', masterComponentHosts);
+      controller.deleteAdditionalNameNode();
+      expect(controller.unInstallComponent.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#startAllServices()', function() {
+
+    it('should start all services', function () {
+      controller.startAllServices();
+      var args = testHelpers.findAjaxRequest('name', 'common.services.update');
+      expect(args).to.exists;
+    });
+  });
+
+  describe('#onLoadHbaseConfigs()', function() {
+
+    it('should make ajax send request', function () {
+      var data = {
+        items: [
+          {
+            type: 'hbase-site',
+            properties: {}
+          }
+        ]
+      };
+      controller.onLoadHbaseConfigs(data);
+      var args = testHelpers.findAjaxRequest('name', 'admin.save_configs');
+      expect(args).to.exists;
+    });
+  });
+
+  describe('#onLoadAccumuloConfigs()', function() {
+
+
+    it('should make ajax send request', function () {
+      var data = {items: [
+          {
+            type: 'accumulo-site',
+            properties: {}
+          }
+        ]};
+      controller.onLoadAccumuloConfigs(data);
+      var args = testHelpers.findAjaxRequest('name', 'admin.save_configs');
+      expect(args).to.exists;
+    });
+  });
+
+  describe('#onLoadHawqConfigs()', function() {
+
+    it('should make ajax send request', function () {
+      var data = {items: [
+          {
+            type: 'hawq-site',
+            properties: {}
+          }
+        ]};
+      controller.onLoadHawqConfigs(data);
+      var args = testHelpers.findAjaxRequest('name', 'admin.save_configs');
+      expect(args).to.exists;
+    });
+  });
+
+  describe('#onDeletedHDFSClient()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'loadConfigTag');
+    });
+
+    afterEach(function () {
+      controller.loadConfigTag.restore();
+    });
+
+    it('should make ajax send request', function () {
+      controller.set('deletedHdfsClients', 1);
+      controller.set('content.hdfsClientHostNames', ['host1', 'host2']);
+      controller.set('content.hdfsSiteTag', 'v1');
+      controller.set('content.coreSiteTag', 'v2');
+      controller.onDeletedHDFSClient();
+      var args = testHelpers.findAjaxRequest('name', 'admin.high_availability.load_configs');
+      expect(args[0].data).to.eql({
+        hdfsSiteTag: 'v1',
+        coreSiteTag: 'v2'
+      });
+    });
+
+    it('should set deletedHdfsClients property', function () {
+      controller.set('deletedHdfsClients', 0);
+      controller.set('content.hdfsClientHostNames', ['host1', 'host2']);
+      controller.onDeletedHDFSClient();
+      expect(controller.get('deletedHdfsClients')).to.equal(1);
+    });
+  });
+
+  describe('#onLoadConfigs()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'loadConfigTag');
+    });
+
+    afterEach(function () {
+      controller.loadConfigTag.restore();
+    });
+
+    it('should make 2 ajax send requests', function () {
+      var data = {
+        items: [
+          {
+            type: 'hdfs-site',
+            properties: {}
+          },
+          {
+            type: 'core-site',
+            properties: {}
+          }
+        ]
+      };
+      controller.onLoadConfigs(data);
+      var args = testHelpers.filterAjaxRequests('name', 'admin.save_configs');
+      expect(args[0][0].data.siteName).to.equal('hdfs-site');
+      expect(args[1][0].data.siteName).to.equal('core-site');
+    });
+  });
+
+  describe('#onHdfsConfigsSaved()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'onTaskCompleted');
+    });
+
+    afterEach(function () {
+      controller.onTaskCompleted.restore();
+    });
+
+    it('should execute onTaskCompleted function', function () {
+      controller.set('configsSaved', true);
+      controller.onHdfsConfigsSaved();
+      expect(controller.onTaskCompleted.calledOnce).to.be.true;
+    });
+
+    it('should set configsSaved property to true', function () {
+      controller.set('configsSaved', false);
+      controller.onHdfsConfigsSaved();
+      expect(controller.get('configsSaved')).to.be.true;
+    });
+  });
+
+  describe('#unInstallHDFSClients()', function() {
+
+    it('should make ajax send requests', function () {
+      controller.set('content.hdfsClientHostNames', ['host1', 'host2']);
+      controller.unInstallHDFSClients();
+      var args = testHelpers.filterAjaxRequests('name', 'common.delete.host_component');
+      expect(args.length).to.equal(2);
+    });
+  });
+
+  describe('#unInstallComponent()', function() {
+
+    it('should make ajax send request', function () {
+      controller.unInstallComponent('comp1', 'host1');
+      var args = testHelpers.findAjaxRequest('name', 'common.host.host_component.passive');
+      expect(args[0].data).to.eql({
+        hostName: 'host1',
+        componentName: 'comp1',
+        passive_state: "ON",
+        taskNum: 1,
+        callback: 'checkBeforeDelete'
+      });
+    });
+
+    it('should make ajax send requests', function () {
+      controller.unInstallComponent('comp1', ['host1', 'host2']);
+      var args = testHelpers.filterAjaxRequests('name', 'common.host.host_component.passive');
+      expect(args.length).to.equal(2);
+    });
+  });
+
+  describe('#checkBeforeDelete()', function() {
+
+    it('should make ajax send request', function () {
+      controller.checkBeforeDelete('comp1', 'host1');
+      var args = testHelpers.findAjaxRequest('name', 'admin.high_availability.getHostComponent');
+      expect(controller.get('hostsToPerformDel')).to.eql([]);
+      expect(args[0].data).to.eql({
+        componentName: 'comp1',
+        hostName: 'host1',
+        taskNum: 1,
+        callback: 'deleteComponent'
+      });
+    });
+
+    it('should make ajax send requests', function () {
+      controller.checkBeforeDelete('comp1', ['host1', 'host2']);
+      var args = testHelpers.filterAjaxRequests('name', 'admin.high_availability.getHostComponent');
+      expect(controller.get('hostsToPerformDel')).to.eql([]);
+      expect(args.length).to.equal(2);
+    });
+  });
+
+  describe('#checkResult()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'deleteComponent');
+      sinon.stub(controller, 'onTaskCompleted');
+    });
+
+    afterEach(function () {
+      controller.deleteComponent.restore();
+      controller.onTaskCompleted.restore();
+    });
+
+    it('should execute deleteComponent function', function () {
+      controller.set('hostsToPerformDel', []);
+      controller.checkResult({}, 'success', {
+        componentName: 'comp1',
+        hostName: 'host1',
+        taskNum: 1,
+        callback: 'deleteComponent'
+      });
+      expect(controller.deleteComponent.calledWith('comp1', ['host1'])).to.be.true;
+    });
+
+    it('should execute onTaskCompleted function', function () {
+      controller.set('hostsToPerformDel', []);
+      controller.checkResult({}, 'error', {
+        componentName: 'comp1',
+        hostName: 'host1',
+        taskNum: 1,
+        callback: 'deleteComponent'
+      });
+      expect(controller.onTaskCompleted.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#deleteComponent()', function() {
+
+    it('should make ajax send request', function () {
+      controller.deleteComponent('comp1', 'host1');
+      var args = testHelpers.findAjaxRequest('name', 'common.delete.host_component');
+      expect(controller.get('numOfDelOperations')).to.equal(1);
+      expect(args[0].data).to.eql({
+        componentName: 'comp1',
+        hostName: 'host1'
+      });
+    });
+
+    it('should make ajax send requests', function () {
+      controller.deleteComponent('comp1', ['host1', 'host2']);
+      var args = testHelpers.filterAjaxRequests('name', 'common.delete.host_component');
+      expect(controller.get('numOfDelOperations')).to.equal(2);
+      expect(args.length).to.equal(2);
+    });
+  });
+
+  describe('#onDeleteComplete()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'onTaskCompleted');
+    });
+
+    afterEach(function () {
+      controller.onTaskCompleted.restore();
+    });
+
+    it('should execute onTaskCompleted function', function () {
+      controller.set('numOfDelOperations', 1);
+      controller.onDeleteComplete();
+      expect(controller.onTaskCompleted.calledOnce).to.be.true;
+    });
+
+    it('should set numOfDelOperations property', function () {
+      controller.set('numOfDelOperations', 2);
+      controller.onDeleteComplete();
+      expect(controller.get('numOfDelOperations')).to.equal(1);
+    });
+  });
+
+  describe.skip('#deletePXF()', function() {
+
+    beforeEach(function () {
+      this.mock = sinon.stub(controller, 'getSlaveComponentHosts');
+      sinon.stub(controller, 'updateComponent');
+      sinon.stub(controller, 'checkBeforeDelete');
+    });
+
+    afterEach(function () {
+      this.mock.restore();
+      controller.updateComponent.restore();
+      controller.checkBeforeDelete.restore();
+    });
+
+    it('should remove PXF', function () {
+      this.mock.returns([
+        {
+          componentName: 'PXF',
+          hosts: [{hostName: 'host2'}]
+        },
+        {
+          componentName: 'DATANODE',
+          hosts: [{hostName: 'host1'}]
+        }
+      ]);
+      controller.set('content.masterComponentHosts', masterComponentHosts);
+      controller.deletePXF();
+      expect(controller.updateComponent.calledOnce).to.be.true;
+      expect(controller.checkBeforeDelete.calledOnce).to.be.true;
+    });
+
+    it('should not remove PXF', function () {
+      this.mock.returns([
+        {
+          componentName: 'PXF',
+          hosts: [{hostName: 'host1'}]
+        },
+        {
+          componentName: 'DATANODE',
+          hosts: [{hostName: 'host2'}]
+        }
+      ]);
+      controller.set('content.masterComponentHosts', masterComponentHosts);
+      controller.deletePXF();
+      expect(controller.updateComponent.calledOnce).to.be.false;
+      expect(controller.checkBeforeDelete.calledOnce).to.be.false;
+    });
+  });
+
+  describe('#setCommandsAndTasks()', function() {
+
+    beforeEach(function () {
+      sinon.stub(App.Service, 'find').returns([]);
+    });
+
+    afterEach(function () {
+      App.Service.find.restore();
+    });
+
+    it('should set tasks property', function () {
+      var tmpTasks = [
+        Em.Object.create({command: 'deleteSNameNode'}),
+        Em.Object.create({command: 'startAllServices'}),
+        Em.Object.create({command: 'reconfigureHBase'}),
+        Em.Object.create({command: 'reconfigureAMS'}),
+        Em.Object.create({command: 'reconfigureAccumulo'}),
+        Em.Object.create({command: 'reconfigureHawq'}),
+        Em.Object.create({command: 'installPXF'}),
+        Em.Object.create({command: 'startZKFC'}),
+        Em.Object.create({command: 'installZKFC'}),
+        Em.Object.create({command: 'startSecondNameNode'}),
+        Em.Object.create({command: 'startNameNode'}),
+        Em.Object.create({command: 'startZooKeeperServers'}),
+        Em.Object.create({command: 'reconfigureHDFS'}),
+        Em.Object.create({command: 'disableSNameNode'}),
+        Em.Object.create({command: 'startJournalNodes'}),
+        Em.Object.create({command: 'installJournalNodes'}),
+        Em.Object.create({command: 'installNameNode'}),
+        Em.Object.create({command: 'stopAllServices'}),
+        Em.Object.create({command: 'restoreHawqConfigs'}),
+        Em.Object.create({command: 'restoreAccumuloConfigs'}),
+        Em.Object.create({command: 'restoreHBaseConfigs'}),
+        Em.Object.create({command: 'deletePXF'})
+      ];
+      controller.set('failedTask', {command: 'reconfigureHDFS'});
+      controller.set('commands', []);
+      controller.setCommandsAndTasks(tmpTasks);
+      expect(controller.get('tasks').mapProperty('command').join(', ')).to.equal('startZooKeeperServers, reconfigureHDFS, disableSNameNode, startJournalNodes, installJournalNodes, installNameNode, stopAllServices');
+    });
+  });
+
+  describe('#clearStep()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'setCommandsAndTasks').returns([]);
+    });
+
+    afterEach(function () {
+      controller.setCommandsAndTasks.restore();
+    });
+
+    it('should clear step', function () {
+      controller.set('commands', ['deletePXF']);
+      controller.clearStep();
+      expect(controller.get('isSubmitDisabled')).to.be.true;
+      expect(controller.get('tasks')).to.eql([]);
+      expect(controller.get('logs')).to.eql([]);
+      expect(controller.get('currentRequestIds')).to.eql([]);
+      expect(controller.setCommandsAndTasks.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#onTaskStatusChange()', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'setTaskStatus');
+      sinon.stub(controller, 'runTask');
+      sinon.stub(controller, 'saveTasksStatuses');
+      sinon.stub(controller, 'saveRequestIds');
+      sinon.stub(controller, 'saveLogs');
+      sinon.stub(App.clusterStatus, 'setClusterStatus');
+    });
+
+    afterEach(function () {
+      controller.setTaskStatus.restore();
+      controller.runTask.restore();
+      controller.saveTasksStatuses.restore();
+      controller.saveRequestIds.restore();
+      controller.saveLogs.restore();
+      App.clusterStatus.setClusterStatus.restore();
+    });
+
+    it('should set cluster status{1}', function () {
+      controller.set('tasks', [
+        Em.Object.create({status: 'FAILED'})
+      ]);
+      controller.onTaskStatusChange();
+      expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
+    });
+
+    it('should set cluster status{2}', function () {
+      controller.onTaskStatusChange();
+      expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
+    });
+
+    it('should set cluster status{3}', function () {
+      controller.set('tasks', [
+        Em.Object.create({status: 'PENDING'})
+      ]);
+      controller.onTaskStatusChange();
+      expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
+    });
+  });
+
+});

+ 60 - 14
ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js

@@ -419,17 +419,35 @@ describe('App.HighAvailabilityWizardStep3Controller', function() {
 
   describe('#onLoadConfigsTags', function () {
 
-    var data = {Clusters: {desired_configs: {
-      'hdfs-site': {tag: 'v1'},
-      'core-site': {tag: 'v2'},
-      'zoo.cfg': {tag: 'v3'},
-      'hbase-site': {tag: 'v4'},
-      'accumulo-site': {tag: 'v5'},
-      'ams-hbase-site': {tag: 'v6'},
-      'hawq-site': {tag: 'v7'},
-      'hdfs-client': {tag: 'v8'},
-      'ranger-env': {tag: 'v9'}
-    }}};
+    var data = {
+      Clusters: {
+        desired_configs: {
+          'hdfs-site': {tag: 'v1'},
+          'core-site': {tag: 'v2'},
+          'zoo.cfg': {tag: 'v3'},
+          'hbase-site': {tag: 'v4'},
+          'accumulo-site': {tag: 'v5'},
+          'ams-hbase-site': {tag: 'v6'},
+          'hawq-site': {tag: 'v7'},
+          'hdfs-client': {tag: 'v8'},
+          'ranger-env': {tag: 'v9'},
+          'ranger-hdfs-plugin-properties': {tag: 'v10'},
+          'ranger-hdfs-audit': {tag: 'v11'},
+          'ranger-yarn-audit': {tag: 'v12'},
+          'ranger-hbase-audit': {tag: 'v13'},
+          'ranger-hbase-plugin-properties': {tag: 'v14'},
+          'ranger-kafka-audit': {tag: 'v15'},
+          'ranger-knox-audit': {tag: 'v16'},
+          'ranger-knox-plugin-properties': {tag: 'v17'},
+          'ranger-storm-audit': {tag: 'v18'},
+          'ranger-storm-plugin-properties': {tag: 'v19'},
+          'ranger-atlas-audit': {tag: 'v20'},
+          'ranger-hive-audit': {tag: 'v21'},
+          'ranger-hive-plugin-properties': {tag: 'v22'},
+          'ranger-kms-audit': {tag: 'v23'}
+        }
+      }
+    };
 
     beforeEach(function () {
       sinon.stub(App.Service, 'find', function () {
@@ -438,7 +456,13 @@ describe('App.HighAvailabilityWizardStep3Controller', function() {
           Em.Object.create({serviceName: 'ACCUMULO'}),
           Em.Object.create({serviceName: 'AMBARI_METRICS'}),
           Em.Object.create({serviceName: 'HAWQ'}),
-          Em.Object.create({serviceName: 'RANGER'})
+          Em.Object.create({serviceName: 'RANGER'}),
+          Em.Object.create({serviceName: 'RANGER_KMS'}),
+          Em.Object.create({serviceName: 'HIVE'}),
+          Em.Object.create({serviceName: 'ATLAS'}),
+          Em.Object.create({serviceName: 'STORM'}),
+          Em.Object.create({serviceName: 'KNOX'}),
+          Em.Object.create({serviceName: 'KAFKA'})
         ];
       });
       controller.onLoadConfigsTags(data);
@@ -450,9 +474,31 @@ describe('App.HighAvailabilityWizardStep3Controller', function() {
     });
 
     it('urlParams are valid', function () {
-      expect(this.args[0].data.urlParams).to.be.equal('(type=hdfs-site&tag=v1)|(type=core-site&tag=v2)|(type=zoo.cfg&tag=v3)|(type=hbase-site&tag=v4)|(type=accumulo-site&tag=v5)|(type=ams-hbase-site&tag=v6)|(type=hawq-site&tag=v7)|(type=hdfs-client&tag=v8)|(type=ranger-env&tag=v9)');
+      expect(this.args[0].data.urlParams).to.be.equal('(type=hdfs-site&tag=v1)' +
+        '|(type=core-site&tag=v2)' +
+        '|(type=zoo.cfg&tag=v3)' +
+        '|(type=hbase-site&tag=v4)' +
+        '|(type=accumulo-site&tag=v5)' +
+        '|(type=ams-hbase-site&tag=v6)' +
+        '|(type=hawq-site&tag=v7)' +
+        '|(type=hdfs-client&tag=v8)' +
+        '|(type=ranger-env&tag=v9)' +
+        '|(type=ranger-hdfs-plugin-properties&tag=v10)' +
+        '|(type=ranger-hdfs-audit&tag=v11)' +
+        '|(type=ranger-yarn-audit&tag=v12)' +
+        '|(type=ranger-hbase-audit&tag=v13)' +
+        '|(type=ranger-hbase-plugin-properties&tag=v14)' +
+        '|(type=ranger-kafka-audit&tag=v15)' +
+        '|(type=ranger-knox-audit&tag=v16)' +
+        '|(type=ranger-knox-plugin-properties&tag=v17)' +
+        '|(type=ranger-storm-audit&tag=v18)' +
+        '|(type=ranger-storm-plugin-properties&tag=v19)' +
+        '|(type=ranger-atlas-audit&tag=v20)' +
+        '|(type=ranger-hive-audit&tag=v21)' +
+        '|(type=ranger-hive-plugin-properties&tag=v22)' +
+        '|(type=ranger-kms-audit&tag=v23)'
+      );
     });
-
   });
 
   describe('#clearStep', function() {

+ 100 - 0
ambari-web/test/controllers/main/admin/highAvailability/nameNode/step9_controller_test.js

@@ -339,4 +339,104 @@ describe('App.HighAvailabilityWizardStep9Controller', function() {
       });
     });
   });
+
+  describe('#reconfigureRanger', function () {
+
+    var data = {
+      items: [
+        {
+          type: 'ranger-yarn-audit',
+          properties: {
+            'xasecure.audit.destination.hdfs.dir': 'd1'
+          }
+        },
+        {
+          type: 'ranger-yarn-audit',
+          properties: {
+            'ranger-storm-plugin-properties': 'd2'
+          }
+        },
+        {
+          type: 'ranger-storm-plugin-properties',
+          properties: {
+            'xasecure.audit.destination.hdfs.dir': 'd3'
+          }
+        },
+        {
+          type: 'ranger-storm-audit',
+          properties: {
+            'xasecure.audit.destination.hdfs.dir': 'd4'
+          }
+        },
+        {
+          type: 'ranger-kafka-audit',
+          properties: {
+            'xasecure.audit.destination.hdfs.dir': 'd5'
+          }
+        },
+        {
+          type: 'ranger-knox-plugin-properties',
+          properties: {
+            'xasecure.audit.destination.hdfs.dir': 'd6'
+          }
+        },
+        {
+          type: 'ranger-knox-audit',
+          properties: {
+            'xasecure.audit.destination.hdfs.dir': 'd7'
+          }
+        },
+        {
+          type: 'ranger-atlas-audit',
+          properties: {
+            'xasecure.audit.destination.hdfs.dir': 'd8'
+          }
+        },
+        {
+          type: 'ranger-hive-plugin-properties',
+          properties: {
+            'xasecure.audit.destination.hdfs.dir': 'd9'
+          }
+        },
+        {
+          type: 'ranger-hive-audit',
+          properties: {
+            'xasecure.audit.destination.hdfs.dir': 'd10'
+          }
+        },
+        {
+          type: 'ranger-kms-audit',
+          properties: {
+            'xasecure.audit.destination.hdfs.dir': 'd11'
+          }
+        }
+      ]
+    };
+
+    beforeEach(function () {
+      sinon.stub(App.Service, 'find', function () {
+        return [
+          Em.Object.create({serviceName: 'YARN'}),
+          Em.Object.create({serviceName: 'RANGER_KMS'}),
+          Em.Object.create({serviceName: 'HIVE'}),
+          Em.Object.create({serviceName: 'ATLAS'}),
+          Em.Object.create({serviceName: 'STORM'}),
+          Em.Object.create({serviceName: 'KNOX'}),
+          Em.Object.create({serviceName: 'KAFKA'})
+        ];
+      });
+      controller.set('content.serviceConfigProperties', data);
+      controller.reconfigureRanger();
+      this.args = testHelpers.findAjaxRequest('name', 'common.service.multiConfigurations');
+    });
+
+    afterEach(function () {
+      App.Service.find.restore();
+    });
+
+    it('configs are valid', function () {
+      expect(this.args[0].data.configs.mapProperty('Clusters.desired_config').length).to.be.equal(8);
+    });
+  });
+
 });

+ 147 - 0
ambari-web/test/controllers/main/admin/highAvailability/nameNode/wizard_controller_test.js

@@ -413,4 +413,151 @@ describe('App.HighAvailabilityWizardController', function() {
       expect(mock.updateAll.calledOnce).to.be.true;
     });
   });
+
+  describe('#loadMap', function() {
+
+    describe('should load hdfs user', function() {
+      var saveHdfsUser = false;
+      var loadHdfsUserFromServer = false;
+      var loadCluster = false;
+
+      var checker = {
+        saveHdfsUser: function () {
+          saveHdfsUser = true;
+        },
+        load: function () {
+          loadCluster = true;
+        },
+        loadHdfsUserFromServer: function () {
+          saveHdfsUser = true;
+          loadCluster = true;
+          return $.Deferred().done().promise();
+        }
+      };
+
+      beforeEach(function() {
+        sinon.stub(App.db, 'getHighAvailabilityWizardHdfsUser').returns('hdfs');
+        controller.loadMap['1'][0].callback.call(checker);
+      });
+      afterEach(function() {
+        App.db.getHighAvailabilityWizardHdfsUser.restore();
+      });
+
+      it('hdfs user is saved', function () {
+        expect(saveHdfsUser).to.be.true;
+      });
+
+      it('hdfs users are loaded', function () {
+        expect(loadHdfsUserFromServer).to.be.false;
+      });
+
+      it('cluster is loaded', function () {
+        expect(loadCluster).to.be.true;
+      });
+    });
+
+    describe('should load service hosts', function() {
+      var loadServicesFromServer = false;
+      var loadMasterComponentHosts = false;
+      var loadHosts = false;
+      var loadHdfsUser = false;
+
+      var checker = {
+        loadServicesFromServer: function () {
+          loadServicesFromServer = true;
+        },
+        loadMasterComponentHosts: function () {
+          loadMasterComponentHosts = true;
+          return $.Deferred().resolve().promise();
+        },
+        loadHosts: function () {
+          loadHosts = true;
+          return $.Deferred().resolve().promise();
+        },
+        loadHdfsUser: function () {
+          loadHdfsUser = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['2'][0].callback.call(checker);
+      });
+
+      it('services from server are loaded', function () {
+        expect(loadServicesFromServer).to.be.true;
+      });
+
+      it('master component hosts are loaded', function () {
+        expect(loadMasterComponentHosts).to.be.true;
+      });
+
+      it('hosts are loaded', function () {
+        expect(loadHosts).to.be.true;
+      });
+
+      it('hdfs user is loaded', function () {
+        expect(loadHdfsUser).to.be.true;
+      });
+    });
+
+    describe('should service config properties', function() {
+      var loadNameServiceId = false;
+      var loadServiceConfigProperties = false;
+
+      var checker = {
+        loadServiceConfigProperties: function () {
+          loadServiceConfigProperties = true;
+        },
+        loadNameServiceId: function () {
+          loadNameServiceId = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['3'][0].callback.call(checker);
+      });
+
+      it('name service ids are loaded', function () {
+        expect(loadNameServiceId).to.be.true;
+      });
+
+      it('service config properties are loaded', function () {
+        expect(loadServiceConfigProperties).to.be.true;
+      });
+    });
+
+    describe('should load tasks', function() {
+      var loadTasksStatuses = false;
+      var loadTasksRequestIds = false;
+      var loadRequestIds = false;
+
+      var checker = {
+        loadTasksStatuses: function () {
+          loadTasksStatuses = true;
+        },
+        loadTasksRequestIds: function () {
+          loadTasksRequestIds = true;
+        },
+        loadRequestIds: function () {
+          loadRequestIds = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['5'][0].callback.call(checker);
+      });
+
+      it('task statuses are loaded', function () {
+        expect(loadTasksStatuses).to.be.true;
+      });
+
+      it('task request ids are loaded', function () {
+        expect(loadTasksRequestIds).to.be.true;
+      });
+
+      it('request ids are loaded', function () {
+        expect(loadRequestIds).to.be.true;
+      });
+    });
+  });
 });

+ 43 - 0
ambari-web/test/controllers/main/admin/highAvailability/rangerAdmin/step1_controller_test.js

@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+require('controllers/main/admin/highAvailability/rangerAdmin/step1_controller');
+
+describe('App.RAHighAvailabilityWizardStep1Controller', function () {
+
+  var controller;
+
+  beforeEach(function () {
+    controller = App.RAHighAvailabilityWizardStep1Controller.create({content: Em.Object.create()});
+  });
+
+  describe('#isloadBalancerURLValid', function () {
+    it('should check if balancer url is valid', function () {
+      controller.set('content.loadBalancerURL', 'https://domain-name_0.com/');
+      expect(controller.get('isloadBalancerURLValid')).to.be.true;
+    });
+
+    it('should check if balancer url is not valid', function () {
+      controller.set('content.loadBalancerURL', 'https//domain-name_0.com/');
+      expect(controller.get('isloadBalancerURLValid')).to.be.false;
+    });
+  });
+
+});

+ 182 - 0
ambari-web/test/controllers/main/admin/highAvailability/rangerAdmin/step4_controller_test.js

@@ -0,0 +1,182 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+var testHelpers = require('test/helpers');
+
+describe('App.RAHighAvailabilityWizardStep4Controller', function() {
+  var controller;
+
+  beforeEach(function() {
+    controller = App.RAHighAvailabilityWizardStep4Controller.create({
+      content: Em.Object.create({
+        raHosts: Em.Object.create()
+      })
+    });
+  });
+
+  describe('#stopAllServices', function() {
+    beforeEach(function() {
+      sinon.stub(controller, 'stopServices');
+    });
+    afterEach(function() {
+      controller.stopServices.restore();
+    });
+
+    it('stopAllServices should be called', function() {
+      controller.stopAllServices();
+      expect(controller.stopServices.calledWith([], true, true)).to.be.true;
+    });
+  });
+
+  describe('#installRangerAdmin', function() {
+    beforeEach(function() {
+      sinon.stub(controller, 'createInstallComponentTask');
+    });
+    afterEach(function() {
+      controller.createInstallComponentTask.restore();
+    });
+
+    it('createInstallComponentTask should be called', function() {
+      controller.set('content.raHosts.additionalRA', 'host1');
+      controller.installRangerAdmin();
+      expect(controller.createInstallComponentTask.calledWith('RANGER_ADMIN', 'host1', "RANGER")).to.be.true;
+    });
+  });
+
+  describe('#reconfigureRanger', function() {
+    beforeEach(function() {
+      sinon.stub(controller, 'loadConfigsTags');
+    });
+
+    afterEach(function() {
+      controller.loadConfigsTags.restore();
+    });
+
+    it("loadConfigsTags should be called", function() {
+      controller.reconfigureRanger();
+      expect(controller.loadConfigsTags.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#loadConfigsTags()", function () {
+
+    it("should return ajax send request", function() {
+      controller.loadConfigsTags();
+      var args = testHelpers.findAjaxRequest('name', 'config.tags');
+      expect(args[0]).to.be.not.empty;
+    });
+  });
+
+  describe('#onLoadConfigsTags()', function () {
+    var dummyData = {
+      Clusters: {
+        desired_configs: {
+          'ranger-site': {
+            tag: 1
+          }
+        }
+      }
+    };
+
+    it('request is sent', function () {
+      controller.set('wizardController', {
+        configs: [{siteName: 'ranger-site'}, {siteName: 'hawq-site'}]
+      });
+      controller.onLoadConfigsTags(dummyData);
+      this.args = testHelpers.findAjaxRequest('name', 'reassign.load_configs');
+      expect(this.args[0].data.urlParams).to.equal('(type=ranger-site&tag=1)');
+    });
+
+  });
+
+  describe("#onLoadConfigs()", function () {
+    var data = {
+      items: [{
+        type: 'ranger-site',
+        properties: {}
+      }]
+    };
+
+    beforeEach(function() {
+      sinon.stub(controller, 'reconfigureSites').returns({});
+      sinon.stub(App.format, 'role').returns('comp1');
+      controller.set('wizardController', {
+        configs: [{siteName: 'ranger-site'}, {siteName: 'hawq-site'}]
+      });
+      controller.set('content', {
+        loadBalancerURL: 'https://https://domain-name_0.com/'
+      });
+    });
+
+    afterEach(function() {
+      controller.reconfigureSites.restore();
+      App.format.role.restore();
+    });
+
+    it("reconfigureSites should be called", function() {
+      controller.onLoadConfigs(data);
+      expect(controller.reconfigureSites.getCall(0).args).to.be.eql([['ranger-site'], data, 'This configuration is created by Enable comp1 HA wizard']);
+    });
+
+    it("App.ajax.send should be called", function() {
+      controller.onLoadConfigs(data);
+      var args = testHelpers.findAjaxRequest('name', 'common.service.multiConfigurations');
+      expect(args[0].data).to.be.eql({
+        configs: [
+          {
+            Clusters: {
+              desired_config: {}
+            }
+          }
+        ]
+      });
+    });
+  });
+
+  describe("#onSaveConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'onTaskCompleted');
+    });
+
+    afterEach(function() {
+      controller.onTaskCompleted.restore();
+    });
+
+    it("onTaskCompleted should be called", function() {
+      controller.onSaveConfigs();
+      expect(controller.onTaskCompleted.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#startAllServices', function() {
+    beforeEach(function() {
+      sinon.stub(controller, 'startServices');
+    });
+    afterEach(function() {
+      controller.startServices.restore();
+    });
+
+    it('startServices should be called', function() {
+      controller.startAllServices();
+      expect(controller.startServices.calledWith(true)).to.be.true;
+    });
+  });
+
+});

+ 211 - 0
ambari-web/test/controllers/main/admin/highAvailability/rangerAdmin/wizard_controller_test.js

@@ -0,0 +1,211 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+function getController() {
+  return App.RAHighAvailabilityWizardController.create({});
+}
+
+describe('App.RAHighAvailabilityWizardController', function () {
+  var controller;
+
+  beforeEach(function () {
+    controller = getController();
+  });
+
+  describe("#setCurrentStep()", function () {
+
+    beforeEach(function() {
+      sinon.stub(App.clusterStatus, 'setClusterStatus');
+    });
+
+    afterEach(function() {
+      App.clusterStatus.setClusterStatus.restore();
+    });
+
+    it("should set current step", function() {
+      controller.setCurrentStep();
+      expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#loadMap', function() {
+
+    describe('should load cluster', function() {
+      var loadCluster = false;
+      var loadBalancerURL = false;
+      var checker = {
+        load: function() {
+          loadCluster = true;
+          loadBalancerURL = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['1'][0].callback.call(checker);
+      });
+
+      it('cluster info and loadBalancerURL are loaded', function () {
+        expect(loadCluster).to.be.true;
+      });
+    });
+
+    describe('should load service hosts', function() {
+      var loadHosts = false;
+      var loadServicesFromServer = false;
+      var loadMasterComponentHosts = false;
+
+      var checker = {
+        loadHosts: function () {
+          loadHosts = true;
+          return $.Deferred().resolve().promise();
+        },
+        loadServicesFromServer: function () {
+          loadServicesFromServer = true;
+        },
+        loadMasterComponentHosts: function () {
+          loadMasterComponentHosts = true;
+          return $.Deferred().resolve().promise();
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['2'][0].callback.call(checker);
+      });
+
+      it('hosts are loaded', function () {
+        expect(loadHosts).to.be.true;
+      });
+
+      it('services from server are loaded', function () {
+        expect(loadServicesFromServer).to.be.true;
+      });
+
+      it('master component hosts are loaded', function () {
+        expect(loadMasterComponentHosts).to.be.true;
+      });
+    });
+
+    describe('should load cluster', function() {
+      var loadRaHosts = false;
+      var checker = {
+        load: function() {
+          loadRaHosts = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['3'][0].callback.call(checker);
+      });
+
+      it('raHosts are loaded', function () {
+        expect(loadRaHosts).to.be.true;
+      });
+    });
+
+    describe('should load tasks', function() {
+      var loadTasksStatuses = false;
+      var loadTasksRequestIds = false;
+      var loadRequestIds = false;
+
+      var checker = {
+        loadTasksStatuses: function () {
+          loadTasksStatuses = true;
+          return $.Deferred().resolve().promise();
+        },
+        loadTasksRequestIds: function () {
+          loadTasksRequestIds = true;
+        },
+        loadRequestIds: function () {
+          loadRequestIds = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['4'][0].callback.call(checker);
+      });
+
+      it('task statuses are loaded', function () {
+        expect(loadTasksStatuses).to.be.true;
+      });
+
+      it('task request ids are loaded', function () {
+        expect(loadTasksRequestIds).to.be.true;
+      });
+
+      it('request ids are loaded', function () {
+        expect(loadRequestIds).to.be.true;
+      });
+    });
+  });
+
+  describe("#clearAllSteps()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'clearInstallOptions');
+      sinon.stub(controller, 'getCluster').returns({});
+      controller.clearAllSteps();
+    });
+
+    afterEach(function() {
+      controller.clearInstallOptions.restore();
+      controller.getCluster.restore();
+    });
+
+    it("clearInstallOptions should be called", function() {
+      expect(controller.clearInstallOptions.calledOnce).to.be.true;
+    });
+
+    it("cluster should be set", function() {
+      expect(controller.get('content.cluster')).to.be.eql({});
+    });
+  });
+
+  describe("#finish()", function () {
+    var container = {
+      updateAll: Em.K
+    };
+
+    beforeEach(function() {
+      sinon.stub(controller, 'resetDbNamespace');
+      sinon.stub(App.router, 'get').returns(container);
+      sinon.stub(container, 'updateAll');
+      controller.finish();
+    });
+
+    afterEach(function() {
+      controller.resetDbNamespace.restore();
+      App.router.get.restore();
+      container.updateAll.restore();
+    });
+
+    it("resetDbNamespace should be called", function() {
+      expect(controller.resetDbNamespace.calledOnce).to.be.true;
+    });
+
+    it("updateAll should be called", function() {
+      expect(container.updateAll.calledOnce).to.be.true;
+    });
+
+    it("isFinished should be true", function() {
+      expect(controller.get('isFinished')).to.be.true;
+    });
+  });
+
+});

+ 1 - 1
ambari-web/test/controllers/main/admin/highAvailability/resourceManager/step3_controller_test.js

@@ -378,7 +378,7 @@ describe('App.RMHighAvailabilityWizardStep3Controller', function () {
     beforeEach(function() {
       sinon.stub(controller, 'renderConfigProperties');
       sinon.stub(App.Service, 'find').returns([Em.Object.create({
-        serviceName: 'S1'
+        serviceName: 'HAWQ'
       })]);
       controller.renderConfigs();
     });

+ 1 - 1
ambari-web/test/controllers/main/service/item_test.js

@@ -462,7 +462,7 @@ describe('App.MainServiceItemController', function () {
         expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.dependent.services')).to.not.be.ok;
       });
 
-      describe ("should display dependent list if other services depend on the one to be stopped", function() {
+      describe("should display dependent list if other services depend on the one to be stopped", function() {
         beforeEach(function () {
           var _mainServiceItemController = App.MainServiceItemController.create(
             {content: {