ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject ambari git commit: AMBARI-18311 Cover controllers of Resource Manager HA with unit tests. (atkach)
Date Tue, 06 Sep 2016 09:38:10 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 2a18fe4fe -> 151bde11f


AMBARI-18311 Cover controllers of Resource Manager HA with unit tests. (atkach)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/151bde11
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/151bde11
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/151bde11

Branch: refs/heads/trunk
Commit: 151bde11f66882fbe67733edf287c31c7881d9c4
Parents: 2a18fe4
Author: Andrii Tkach <atkach@apache.org>
Authored: Mon Sep 5 21:22:06 2016 +0300
Committer: Andrii Tkach <atkach@apache.org>
Committed: Tue Sep 6 12:37:20 2016 +0300

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |   2 +
 .../resourceManager/step3_controller_test.js    | 301 ++++++++++++++++--
 .../resourceManager/step4_controller_test.js    | 305 +++++++++++++++++++
 .../resourceManager/wizard_controller_test.js   | 282 +++++++++++++++++
 .../service/reassign/step6_controller_test.js   |   3 +-
 5 files changed, 859 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/151bde11/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 4c9b192..d2f3637 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -79,6 +79,8 @@ var files = [
   'test/controllers/main/admin/highAvailability/nameNode/step3_controller_test',
   'test/controllers/main/admin/highAvailability/nameNode/step4_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',
   'test/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller_test',
   'test/controllers/main/admin/highAvailability/hawq/removeStandby/step2_controller_test',
   'test/controllers/main/admin/highAvailability/hawq/activateStandby/step2_controller_test',

http://git-wip-us.apache.org/repos/asf/ambari/blob/151bde11/ambari-web/test/controllers/main/admin/highAvailability/resourceManager/step3_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/highAvailability/resourceManager/step3_controller_test.js
b/ambari-web/test/controllers/main/admin/highAvailability/resourceManager/step3_controller_test.js
index 3e6f7bb..665d8e6 100644
--- a/ambari-web/test/controllers/main/admin/highAvailability/resourceManager/step3_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/highAvailability/resourceManager/step3_controller_test.js
@@ -19,15 +19,20 @@
 var App = require('app');
 require('controllers/main/admin/highAvailability/resourceManager/step3_controller');
 var testHelpers = require('test/helpers');
+var blueprintUtils = require('utils/blueprint');
 
 describe('App.RMHighAvailabilityWizardStep3Controller', function () {
+  var controller;
+
+  beforeEach(function() {
+    controller = App.RMHighAvailabilityWizardStep3Controller.create({
+      content: Em.Object.create({})
+    });
+  });
 
   describe('#isSubmitDisabled', function () {
 
-    var controller = App.RMHighAvailabilityWizardStep3Controller.create({
-        content: Em.Object.create({})
-      }),
-      cases = [
+    var cases = [
         {
           isLoaded: false,
           isSubmitDisabled: true,
@@ -51,10 +56,6 @@ describe('App.RMHighAvailabilityWizardStep3Controller', function () {
 
   describe('#loadConfigTagsSuccessCallback', function () {
 
-    var controller = App.RMHighAvailabilityWizardStep3Controller.create({
-      content: Em.Object.create({})
-    });
-
     it('should send proper ajax request', function () {
       controller.loadConfigTagsSuccessCallback({
         'Clusters': {
@@ -82,10 +83,7 @@ describe('App.RMHighAvailabilityWizardStep3Controller', function () {
 
   describe('#loadConfigsSuccessCallback', function () {
 
-    var controller = App.RMHighAvailabilityWizardStep3Controller.create({
-        content: Em.Object.create({})
-      }),
-      cases = [
+    var cases = [
         {
           'items': [],
           'params': {
@@ -184,10 +182,6 @@ describe('App.RMHighAvailabilityWizardStep3Controller', function () {
 
   describe('#loadConfigsSuccessCallback=loadConfigsErrorCallback(we have one callback for
bouth cases)', function () {
 
-    var controller = App.RMHighAvailabilityWizardStep3Controller.create({
-      content: Em.Object.create({})
-    });
-
     beforeEach(function () {
       sinon.stub(controller, 'setDynamicConfigValues', Em.K);
     });
@@ -232,23 +226,7 @@ describe('App.RMHighAvailabilityWizardStep3Controller', function () {
       ]
     };
 
-    var controller = App.RMHighAvailabilityWizardStep3Controller.create({
-        content: Em.Object.create({
-          masterComponentHosts: [
-            {component: 'RESOURCEMANAGER', hostName: 'h0', isInstalled: true},
-            {component: 'RESOURCEMANAGER', hostName: 'h1', isInstalled: false},
-            {component: 'ZOOKEEPER_SERVER', hostName: 'h2', isInstalled: true},
-            {component: 'ZOOKEEPER_SERVER', hostName: 'h3', isInstalled: true}
-          ],
-          slaveComponentHosts: [],
-          hosts: {},
-          rmHosts: {
-            currentRM: 'h0',
-            additionalRM: 'h1'
-          }
-        })
-      }),
-      configs = {
+    var configs = {
         configs: [
           Em.Object.create({
             name: 'yarn.resourcemanager.hostname.rm1'
@@ -300,6 +278,20 @@ describe('App.RMHighAvailabilityWizardStep3Controller', function () {
           })
         ];
       });
+      controller.set('content', Em.Object.create({
+        masterComponentHosts: [
+          {component: 'RESOURCEMANAGER', hostName: 'h0', isInstalled: true},
+          {component: 'RESOURCEMANAGER', hostName: 'h1', isInstalled: false},
+          {component: 'ZOOKEEPER_SERVER', hostName: 'h2', isInstalled: true},
+          {component: 'ZOOKEEPER_SERVER', hostName: 'h3', isInstalled: true}
+        ],
+        slaveComponentHosts: [],
+        hosts: {},
+        rmHosts: {
+          currentRM: 'h0',
+          additionalRM: 'h1'
+        }
+      }));
       controller.setDynamicConfigValues(configs, data);
     });
 
@@ -363,7 +355,250 @@ describe('App.RMHighAvailabilityWizardStep3Controller', function ()
{
     it('hadoop.proxyuser.yarn.hosts recommendedValue', function () {
       expect(configs.configs.findProperty('name', 'hadoop.proxyuser.yarn.hosts').get('recommendedValue')).to.equal('h0,h1');
     });
+  });
+
+  describe("#loadStep()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'renderConfigs');
+    });
+
+    afterEach(function() {
+      controller.renderConfigs.restore();
+    });
+
+    it("renderConfigs should be called", function() {
+      controller.loadStep();
+      expect(controller.renderConfigs.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#renderConfigs()", function () {
+    var serviceConfig = App.ServiceConfig.create({
+      serviceName: 'MISC',
+      displayName: 'MISC',
+      configCategories: [],
+      showConfig: true,
+      configs: []
+    });
 
+    beforeEach(function() {
+      sinon.stub(controller, 'renderConfigProperties');
+      sinon.stub(App.Service, 'find').returns([Em.Object.create({
+        serviceName: 'S1'
+      })]);
+    });
+
+    afterEach(function() {
+      controller.renderConfigProperties.restore();
+      App.Service.find.restore();
+    });
+
+    it("renderConfigProperties should be called", function() {
+      controller.renderConfigs();
+      expect(controller.renderConfigProperties.getCall(0).args[1]).to.be.eql(serviceConfig);
+    });
+
+    it("App.ajax.send should be called", function() {
+      controller.renderConfigs();
+      var args = testHelpers.findAjaxRequest('name', 'config.tags');
+      expect(args[0]).to.be.eql({
+        name: 'config.tags',
+        sender: controller,
+        success: 'loadConfigTagsSuccessCallback',
+        error: 'loadConfigsErrorCallback',
+        data: {
+          serviceConfig: serviceConfig
+        }
+      });
+    });
+  });
+
+  describe("#renderConfigProperties()", function () {
+
+    beforeEach(function() {
+      sinon.stub(App.ServiceConfigProperty, 'create', function(obj) {
+        return obj;
+      });
+    });
+
+    afterEach(function() {
+      App.ServiceConfigProperty.create.restore();
+    });
+
+    it("config should be added", function() {
+      var componentConfig = {
+        configs: []
+      };
+      var _componentConfig = {
+        configs: [
+          Em.Object.create({
+            isReconfigurable: true
+          })
+        ]
+      };
+      controller.renderConfigProperties(_componentConfig, componentConfig);
+      expect(componentConfig.configs[0].get('isEditable')).to.be.true;
+    });
+  });
+
+  describe("#submit()", function () {
+    var container = {
+      getKDCSessionState: Em.clb
+    };
+
+    beforeEach(function() {
+      sinon.stub(App, 'get').returns(container);
+      sinon.stub(App.router, 'send');
+    });
+
+    afterEach(function() {
+      App.get.restore();
+      App.router.send.restore();
+    });
+
+    it("App.router.send should not be called", function() {
+      controller.reopen({
+        isSubmitDisabled: true
+      });
+      controller.submit();
+      expect(App.router.send.called).to.be.false;
+    });
+
+    it("App.router.send should be called", function() {
+      controller.reopen({
+        isSubmitDisabled: false
+      });
+      controller.submit();
+      expect(App.router.send.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#loadRecommendations()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'getCurrentMasterSlaveBlueprint').returns({
+        blueprint: {}
+      });
+      sinon.stub(blueprintUtils, 'getHostGroupByFqdn').returns('g1');
+      sinon.stub(blueprintUtils, 'addComponentToHostGroup');
+      sinon.stub(App.Service, 'find').returns([{serviceName: 'S1'}]);
+      this.mockGet = sinon.stub(App, 'get');
+      this.mockGet.withArgs('allHostNames').returns(['host1']);
+      this.mockGet.withArgs('stackVersionURL').returns('/stacks/HDP/versions/2.2');
+    });
+
+    afterEach(function() {
+      controller.getCurrentMasterSlaveBlueprint.restore();
+      blueprintUtils.getHostGroupByFqdn.restore();
+      blueprintUtils.addComponentToHostGroup.restore();
+      App.Service.find.restore();
+      this.mockGet.restore();
+    });
+
+    it("addComponentToHostGroup should be called", function() {
+      controller.loadRecommendations({});
+      expect(blueprintUtils.addComponentToHostGroup.getCall(0).args).to.be.eql([
+        {blueprint: {configurations:{}}}, 'RESOURCEMANAGER', 'g1'
+      ]);
+    });
+
+    it("App.ajax.send should be called", function() {
+      controller.loadRecommendations({});
+      var args = testHelpers.findAjaxRequest('name', 'config.recommendations');
+      expect(JSON.stringify(args[0])).to.be.equal(JSON.stringify({
+        name: 'config.recommendations',
+        sender: controller,
+        data: {
+          stackVersionUrl: "/stacks/HDP/versions/2.2",
+          dataToSend: {
+            recommend: 'configurations',
+            hosts: ["host1"],
+            services: ['S1'],
+            recommendations: {blueprint: {configurations:{}}}
+          }
+        }
+      }));
+    });
+  });
+
+  describe("#applyRecommendedConfigurations()", function () {
+    var configurations = Em.Object.create({
+        items: [
+          {
+            type: 'yarn-env',
+            properties: {
+              'yarn_user': 'user1'
+            }
+          }
+        ]
+      }),
+      recommendations = {
+        resources: [{
+          recommendations: {
+            blueprint: {
+              configurations: {
+                'core-site': {
+                  properties: {
+                    'hadoop.proxyuser.user1.hosts': 'host1',
+                    'hadoop.proxyuser.user2.hosts': 'host1'
+                  }
+                }
+              }
+            }
+          }
+        }]
+      };
+
+    beforeEach(function() {
+      sinon.stub(App.config, 'createDefaultConfig').returns({});
+      sinon.stub(App.config, 'getConfigTagFromFileName').returns('file1');
+      sinon.stub(App.ServiceConfigProperty, 'create', function(obj) {
+        return obj;
+      });
+    });
+
+    afterEach(function() {
+      App.config.createDefaultConfig.restore();
+      App.config.getConfigTagFromFileName.restore();
+      App.ServiceConfigProperty.create.restore();
+    });
+
+    it("config value should be set", function() {
+      var stepConfigs = Em.Object.create({
+        configs: [
+          Em.Object.create({
+            name: 'hadoop.proxyuser.user1.hosts'
+          })
+        ]
+      });
+      controller.applyRecommendedConfigurations(recommendations, configurations, stepConfigs);
+      expect(stepConfigs.get('configs')[0].get('recommendedValue')).to.be.equal('host1');
+      expect(stepConfigs.get('configs')[0].get('value')).to.be.equal('host1');
+    });
+
+    it("new property should be added", function() {
+      var stepConfigs = Em.Object.create({
+        configs: [
+          Em.Object.create({
+            name: 'hadoop.proxyuser.user2.hosts'
+          })
+        ]
+      });
+      controller.applyRecommendedConfigurations(recommendations, configurations, stepConfigs);
+      expect(App.config.createDefaultConfig.getCall(0).args).to.be.eql(['hadoop.proxyuser.user1.hosts',
'core-site', false, {
+        category : "HDFS",
+        isUserProperty: false,
+        isEditable: false,
+        isOverridable: false,
+        serviceName: 'MISC',
+        value: 'host1',
+        recommendedValue: 'host1'
+      }]);
+      expect(stepConfigs.get('configs')[1]).to.be.eql({
+        filename: 'file1'
+      });
+    });
   });
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/151bde11/ambari-web/test/controllers/main/admin/highAvailability/resourceManager/step4_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/highAvailability/resourceManager/step4_controller_test.js
b/ambari-web/test/controllers/main/admin/highAvailability/resourceManager/step4_controller_test.js
new file mode 100644
index 0000000..b2bc940
--- /dev/null
+++ b/ambari-web/test/controllers/main/admin/highAvailability/resourceManager/step4_controller_test.js
@@ -0,0 +1,305 @@
+/**
+ * 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/resourceManager/step4_controller');
+var testHelpers = require('test/helpers');
+
+describe('App.RMHighAvailabilityWizardStep4Controller', function () {
+  var controller;
+
+  beforeEach(function() {
+    controller = App.RMHighAvailabilityWizardStep4Controller.create({
+      content: Em.Object.create({})
+    });
+  });
+
+  describe("#initializeTasks()", function () {
+
+    beforeEach(function() {
+      sinon.stub(App.Service, 'find').returns([]);
+    });
+
+    afterEach(function() {
+      App.Service.find.restore();
+    });
+
+    it("reconfigureHAWQ should be removed", function() {
+      controller.initializeTasks();
+      expect(controller.get('tasks').mapProperty('command')).to.not.contain('reconfigureHAWQ');
+    });
+  });
+
+  describe("#stopRequiredServices()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'stopServices');
+    });
+
+    afterEach(function() {
+      controller.stopServices.restore();
+    });
+
+    it("stopServices should be called", function() {
+      controller.stopRequiredServices();
+      expect(controller.stopServices.calledWith(['HDFS'])).to.be.true;
+    });
+  });
+
+  describe("#installResourceManager()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'createInstallComponentTask');
+    });
+
+    afterEach(function() {
+      controller.createInstallComponentTask.restore();
+    });
+
+    it("createInstallComponentTask should be called", function() {
+      controller.set('content.rmHosts', {additionalRM: 'host1'});
+      controller.installResourceManager();
+      expect(controller.createInstallComponentTask.calledWith('RESOURCEMANAGER', 'host1',
'YARN')).to.be.true;
+    });
+  });
+
+  describe("#reconfigureYARN()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'loadConfigsTags');
+    });
+
+    afterEach(function() {
+      controller.loadConfigsTags.restore();
+    });
+
+    it("loadConfigsTags should be called", function() {
+      controller.reconfigureYARN();
+      expect(controller.loadConfigsTags.calledWith('Yarn')).to.be.true;
+    });
+  });
+
+  describe("#reconfigureHAWQ()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'loadConfigsTags');
+    });
+
+    afterEach(function() {
+      controller.loadConfigsTags.restore();
+    });
+
+    it("loadConfigsTags should be called", function() {
+      controller.reconfigureHAWQ();
+      expect(controller.loadConfigsTags.calledWith('Hawq')).to.be.true;
+    });
+  });
+
+  describe("#reconfigureHDFS()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'loadConfigsTags');
+    });
+
+    afterEach(function() {
+      controller.loadConfigsTags.restore();
+    });
+
+    it("loadConfigsTags should be called", function() {
+      controller.reconfigureHDFS();
+      expect(controller.loadConfigsTags.calledWith('Hdfs')).to.be.true;
+    });
+  });
+
+  describe("#loadConfigsTags()", function () {
+
+    it("App.ajax.send should be called", function() {
+      controller.loadConfigsTags('S1');
+      var args = testHelpers.findAjaxRequest('name', 'config.tags');
+      expect(args[0]).to.be.eql({
+        name: 'config.tags',
+        sender: controller,
+        success: 'onLoadS1ConfigsTags',
+        error: 'onTaskError'
+      });
+    });
+  });
+
+  describe("#onLoadYarnConfigsTags()", function () {
+
+    it("App.ajax.send should be called", function() {
+      var data = {
+        Clusters: {
+          desired_configs: {
+            'yarn-site': {
+              tag: 1
+            }
+          }
+        }
+      };
+      controller.onLoadYarnConfigsTags(data);
+      var args = testHelpers.findAjaxRequest('name', 'reassign.load_configs');
+      expect(args[0]).to.be.eql({
+        name: 'reassign.load_configs',
+        sender: controller,
+        data: {
+          urlParams: '(type=yarn-site&tag=1)',
+          type: 'yarn-site'
+        },
+        success: 'onLoadConfigs',
+        error: 'onTaskError'
+      });
+    });
+  });
+
+  describe("#onLoadHawqConfigsTags()", function () {
+
+    it("App.ajax.send should be called", function() {
+      var data = {
+        Clusters: {
+          desired_configs: {
+            'yarn-client': {
+              tag: 1
+            }
+          }
+        }
+      };
+      controller.onLoadHawqConfigsTags(data);
+      var args = testHelpers.findAjaxRequest('name', 'reassign.load_configs');
+      expect(args[0]).to.be.eql({
+        name: 'reassign.load_configs',
+        sender: controller,
+        data: {
+          urlParams: '(type=yarn-client&tag=1)',
+          type: 'yarn-client'
+        },
+        success: 'onLoadConfigs',
+        error: 'onTaskError'
+      });
+    });
+  });
+
+  describe("#onLoadHdfsConfigsTags()", function () {
+
+    it("App.ajax.send should be called", function() {
+      var data = {
+        Clusters: {
+          desired_configs: {
+            'core-site': {
+              tag: 1
+            }
+          }
+        }
+      };
+      controller.onLoadHdfsConfigsTags(data);
+      var args = testHelpers.findAjaxRequest('name', 'reassign.load_configs');
+      expect(args[0]).to.be.eql({
+        name: 'reassign.load_configs',
+        sender: controller,
+        data: {
+          urlParams: '(type=core-site&tag=1)',
+          type: 'core-site'
+        },
+        success: 'onLoadConfigs',
+        error: 'onTaskError'
+      });
+    });
+  });
+
+  describe("#onLoadConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'reconfigureSites').returns({});
+      controller.set('content.configs', [
+        {
+          filename: 't1',
+          name: 'p1',
+          value: 'val1'
+        }
+      ]);
+      sinon.stub(App.format, 'role').returns('comp1');
+    });
+
+    afterEach(function() {
+      controller.reconfigureSites.restore();
+      App.format.role.restore();
+    });
+
+    it("reconfigureSites should be called", function() {
+      var data = {
+        items: [{
+          properties: {}
+        }]
+      };
+      var str = Em.I18n.t('admin.highAvailability.step4.save.configuration.note').format('comp1');
+      controller.onLoadConfigs(data, {}, {type: 't1'});
+      expect(controller.reconfigureSites.getCall(0).args).to.be.eql([['t1'], data, str]);
+    });
+
+    it("App.ajax.send should be called", function() {
+      var data = {
+        items: [{
+          properties: {}
+        }]
+      };
+      controller.onLoadConfigs(data, {}, {type: 't1'});
+      var args = testHelpers.findAjaxRequest('name', 'common.service.configurations');
+      expect(args[0]).to.be.eql({
+        name: 'common.service.configurations',
+        sender: controller,
+        data: {
+          desired_config: {}
+        },
+        success: 'onSaveConfigs',
+        error: 'onTaskError'
+      });
+    });
+  });
+
+  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;
+    });
+  });
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/151bde11/ambari-web/test/controllers/main/admin/highAvailability/resourceManager/wizard_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/highAvailability/resourceManager/wizard_controller_test.js
b/ambari-web/test/controllers/main/admin/highAvailability/resourceManager/wizard_controller_test.js
new file mode 100644
index 0000000..5a991d3
--- /dev/null
+++ b/ambari-web/test/controllers/main/admin/highAvailability/resourceManager/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');
+require('controllers/main/admin/highAvailability/resourceManager/wizard_controller');
+var testHelpers = require('test/helpers');
+
+describe('App.RMHighAvailabilityWizardController', function () {
+  var controller;
+
+  beforeEach(function() {
+    controller = App.RMHighAvailabilityWizardController.create({
+      content: Em.Object.create({})
+    });
+  });
+
+  describe("#loadMap 1st step callback", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'load');
+    });
+
+    afterEach(function() {
+      controller.load.restore();
+    });
+
+    it("load should be called", function() {
+      controller.get('loadMap.1')[0].callback.apply(controller);
+      expect(controller.load.calledWith('cluster')).to.be.true;
+    });
+  });
+
+  describe("#loadMap 2nd step callback", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'loadRmHosts');
+      sinon.stub(controller, 'loadServicesFromServer');
+      sinon.stub(controller, 'loadMasterComponentHosts').returns({done: Em.clb});
+      sinon.stub(controller, 'loadConfirmedHosts');
+      controller.get('loadMap.2')[0].callback.apply(controller);
+    });
+
+    afterEach(function() {
+      controller.loadRmHosts.restore();
+      controller.loadServicesFromServer.restore();
+      controller.loadMasterComponentHosts.restore();
+      controller.loadConfirmedHosts.restore();
+    });
+
+    it("loadRmHosts should be called", function() {
+      expect(controller.loadRmHosts.calledOnce).to.be.true;
+    });
+
+    it("loadServicesFromServer should be called", function() {
+      expect(controller.loadServicesFromServer.calledOnce).to.be.true;
+    });
+
+    it("loadMasterComponentHosts should be called", function() {
+      expect(controller.loadMasterComponentHosts.calledOnce).to.be.true;
+    });
+
+    it("loadConfirmedHosts should be called", function() {
+      expect(controller.loadConfirmedHosts.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#loadMap 4th step callback", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'loadTasksStatuses');
+      sinon.stub(controller, 'loadTasksRequestIds');
+      sinon.stub(controller, 'loadRequestIds');
+      sinon.stub(controller, 'loadConfigs');
+      controller.get('loadMap.4')[0].callback.apply(controller);
+    });
+
+    afterEach(function() {
+      controller.loadTasksStatuses.restore();
+      controller.loadTasksRequestIds.restore();
+      controller.loadRequestIds.restore();
+      controller.loadConfigs.restore();
+    });
+
+    it("loadTasksStatuses should be called", function() {
+      expect(controller.loadTasksStatuses.calledOnce).to.be.true;
+    });
+
+    it("loadTasksRequestIds should be called", function() {
+      expect(controller.loadTasksRequestIds.calledOnce).to.be.true;
+    });
+
+    it("loadRequestIds should be called", function() {
+      expect(controller.loadRequestIds.calledOnce).to.be.true;
+    });
+
+    it("loadConfigs should be called", function() {
+      expect(controller.loadConfigs.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#init()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'clearStep');
+    });
+
+    afterEach(function() {
+      controller.clearStep.restore();
+    });
+
+    it("clearStep should be called", function() {
+      controller.init();
+      expect(controller.clearStep.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#clearStep()", function () {
+
+    it("isFinished should be false", function() {
+      controller.clearStep();
+      expect(controller.get('isFinished')).to.be.false;
+    });
+  });
+
+  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("#saveRmHosts()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'setDBProperty');
+    });
+
+    afterEach(function() {
+      controller.setDBProperty.restore();
+    });
+
+    it("rmHosts should be set", function() {
+      controller.saveRmHosts(['host1']);
+      expect(controller.get('content.rmHosts')).to.be.eql(['host1']);
+    });
+
+    it("setDBProperty should be called", function() {
+      controller.saveRmHosts(['host1']);
+      expect(controller.setDBProperty.calledWith('rmHosts', ['host1'])).to.be.true;
+    });
+  });
+
+  describe("#loadRmHosts()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'getDBProperty').returns(['host1']);
+    });
+
+    afterEach(function() {
+      controller.getDBProperty.restore();
+    });
+
+    it("rmHosts should be set", function() {
+      controller.loadRmHosts();
+      expect(controller.get('content.rmHosts')).to.be.eql(['host1']);
+    });
+  });
+
+  describe("#saveConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'setDBProperty');
+    });
+
+    afterEach(function() {
+      controller.setDBProperty.restore();
+    });
+
+    it("configs should be set", function() {
+      controller.saveConfigs([{}]);
+      expect(controller.get('content.configs')).to.be.eql([{}]);
+    });
+
+    it("setDBProperty should be called", function() {
+      controller.saveConfigs([{}]);
+      expect(controller.setDBProperty.calledWith('configs', [{}])).to.be.true;
+    });
+  });
+
+  describe("#loadConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'getDBProperty').returns([{}]);
+    });
+
+    afterEach(function() {
+      controller.getDBProperty.restore();
+    });
+
+    it("configs should be set", function() {
+      controller.loadConfigs();
+      expect(controller.get('content.configs')).to.be.eql([{}]);
+    });
+  });
+
+  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;
+    });
+  });
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/151bde11/ambari-web/test/controllers/main/service/reassign/step6_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/reassign/step6_controller_test.js b/ambari-web/test/controllers/main/service/reassign/step6_controller_test.js
index d155c01..c901bf6 100644
--- a/ambari-web/test/controllers/main/service/reassign/step6_controller_test.js
+++ b/ambari-web/test/controllers/main/service/reassign/step6_controller_test.js
@@ -30,7 +30,8 @@ describe('App.ReassignMasterWizardStep6Controller', function () {
         reassign: Em.Object.create(),
         reassignHosts: Em.Object.create()
       }),
-      startServices: Em.K
+      startServices: Em.K,
+      tasks: []
     });
   });
 


Mime
View raw message