فهرست منبع

AMBARI-2362. Unit Tests: Added tests to install wizard for step 3, 5, 10. (Andrii Tkach via yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1492460 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 سال پیش
والد
کامیت
06a4ab09f0

+ 2 - 1
ambari-web/app/assets/test/tests.js

@@ -20,8 +20,8 @@ require('test/controllers/global/background_operations_test');
 require('test/controllers/global/cluster_controller_test');
 require('test/controllers/main/app_contoller_test');
 require('test/controllers/main/admin/cluster_test');
+require('test/controllers/main/admin/security/add/step3_test');
 require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_test');
-require('test/controllers/main/host/details_test');
 require('test/controllers/main/dashboard_test');
 require('test/controllers/main/host_test');
 require('test/controllers/main/item_test');
@@ -32,6 +32,7 @@ require('test/installer/step4_test');
 require('test/installer/step5_test');
 require('test/installer/step6_test');
 require('test/installer/step7_test');
+require('test/installer/step10_test');
 require('test/login_test');
 require('test/mappers/server_data_mapper_test');
 require('test/mappers/dataset_mapper_test');

+ 1 - 8
ambari-web/app/controllers/global/cluster_controller.js

@@ -58,7 +58,6 @@ App.ClusterController = Em.Controller.extend({
     'users':false,
     'datasets':false,
     'targetclusters':false
-
   }),
 
   /**
@@ -164,13 +163,7 @@ App.ClusterController = Em.Controller.extend({
   }.property('App.router.updateController.isUpdated', 'dataLoadList.services', 'dataLoadList.hosts'),
 
   isNagiosInstalled:function () {
-    if (App.testMode) {
-      return true;
-    } else {
-      var svcs = App.Service.find();
-      var nagiosSvc = svcs.findProperty("serviceName", "NAGIOS");
-      return nagiosSvc != null;
-    }
+    return !!App.Service.find().findProperty('serviceName', 'NAGIOS');
   }.property('App.router.updateController.isUpdated', 'dataLoadList.services'),
 
   /**

+ 14 - 7
ambari-web/app/controllers/wizard/step10_controller.js

@@ -375,16 +375,14 @@ App.WizardStep10Controller = Em.Controller.extend({
   },
 
   loadInstallTime: function () {
-    var secondsPerMinute = 60;
     var statement;
+    var time;
     if (this.get('content.cluster.installTime')) {
-      var minutes = Math.floor(this.get('content.cluster.installTime'));
-      var seconds = Math.floor((this.get('content.cluster.installTime') - minutes) * secondsPerMinute);
-      var statement;
-      if (minutes !== 0) {
-        statement = Em.I18n.t('installer.step10.installTime.minutes').format(minutes, seconds);
+      time = this.calculateInstallTime(this.get('content.cluster.installTime'));
+      if (time.minutes !== 0) {
+        statement = Em.I18n.t('installer.step10.installTime.minutes').format(time.minutes, time.seconds);
       } else {
-        statement = Em.I18n.t('installer.step10.installTime.seconds').format(seconds);
+        statement = Em.I18n.t('installer.step10.installTime.seconds').format(time.seconds);
       }
       this.get('clusterInfo').pushObject(Ember.Object.create({
         id: 5,
@@ -393,6 +391,15 @@ App.WizardStep10Controller = Em.Controller.extend({
         status: []
       }));
     }
+  },
+  calculateInstallTime: function(installTime){
+    var secondsPerMinute = 60;
+    var minutes = Math.floor(installTime);
+    var seconds = Math.floor((installTime - minutes) * secondsPerMinute);
+    return {
+      minutes: minutes,
+      seconds: seconds
+    }
   }
 });
 

+ 87 - 171
ambari-web/app/controllers/wizard/step5_controller.js

@@ -265,149 +265,32 @@ App.WizardStep5Controller = Em.Controller.extend({
     }
   }.observes('selectedServicesMasters.@each.selectedHost'),
 
-  getKerberosServer:function (noOfHosts) {
-    var hosts = this.get('hosts');
-    if (noOfHosts === 1) {
-      return hosts[0];
-    } else if (noOfHosts < 3) {
-      return hosts[1];
-    } else if (noOfHosts <= 5) {
-      return hosts[1];
-    } else if (noOfHosts <= 30) {
-      return hosts[3];
-    } else {
-      return hosts[5];
-    }
-  },
-
-  getNameNode:function (noOfHosts) {
-    var hosts = this.get('hosts');
-    return hosts[0];
-  },
-
-  getSNameNode:function (noOfHosts) {
-    var hosts = this.get('hosts');
-    if (noOfHosts === 1) {
-      return hosts[0];
-    } else {
-      return hosts[1];
-    }
-  },
-
-  getJobTracker:function (noOfHosts) {
-    var hosts = this.get('hosts');
-    if (noOfHosts === 1) {
-      return hosts[0];
-    } else if (noOfHosts < 3) {
-      return hosts[1];
-    } else if (noOfHosts <= 5) {
-      return hosts[1];
-    } else if (noOfHosts <= 30) {
-      return hosts[1];
-    } else {
-      return hosts[2];
-    }
-  },
-
-  getResourceManager: function (noOfHosts) {
-    var hosts = this.get('hosts');
-    if (noOfHosts === 1) {
-      return hosts[0];
-    } else if (noOfHosts < 3) {
-      return hosts[1];
-    } else if (noOfHosts <= 5) {
-      return hosts[1];
-    } else if (noOfHosts <= 30) {
-      return hosts[1];
-    } else {
-      return hosts[2];
-    }
-  },
-
-  getHistoryServer: function (noOfHosts) {
-    var hosts = this.get('hosts');
-    if (noOfHosts === 1) {
-      return hosts[0];
-    } else if (noOfHosts < 3) {
-      return hosts[1];
-    } else if (noOfHosts <= 5) {
-      return hosts[1];
-    } else if (noOfHosts <= 30) {
-      return hosts[1];
-    } else {
-      return hosts[2];
-    }
-  },
-
-  getHBaseMaster:function (noOfHosts) {
-    var hosts = this.get('hosts');
-    if (noOfHosts === 1) {
-      return hosts[0];
-    } else if (noOfHosts < 3) {
-      return hosts[0];
-    } else if (noOfHosts <= 5) {
-      return hosts[0];
-    } else if (noOfHosts <= 30) {
-      return hosts[2];
-    } else {
-      return hosts[3];
-    }
-  },
-
-  getOozieServer:function (noOfHosts) {
-    var hosts = this.get('hosts');
-    if (noOfHosts === 1) {
-      return hosts[0];
-    } else if (noOfHosts < 3) {
-      return hosts[1];
-    } else if (noOfHosts <= 5) {
-      return hosts[1];
-    } else if (noOfHosts <= 30) {
-      return hosts[2];
-    } else {
-      return hosts[3];
-    }
-  },
-
-  getHiveServer:function (noOfHosts) {
+  /**
+   * select and return host for component by scheme
+   * Scheme is an object that has keys which compared to number of hosts,
+   * if key more that number of hosts, then return value of that key.
+   * Value is index of host in hosts array.
+   *
+   * @param noOfHosts
+   * @param selectionScheme
+   * @return {*}
+   */
+  getHostForComponent: function(noOfHosts, selectionScheme){
     var hosts = this.get('hosts');
-    if (noOfHosts === 1) {
+    if(hosts.length === 1 || $.isEmptyObject(selectionScheme)){
       return hosts[0];
-    } else if (noOfHosts < 3) {
-      return hosts[1];
-    } else if (noOfHosts <= 5) {
-      return hosts[1];
-    } else if (noOfHosts <= 30) {
-      return hosts[2];
-    } else {
-      return hosts[4];
-    }
-  },
-
-  getHueServer:function (noOfHosts) {
-    var hosts = this.get('hosts');
-    var hostnames = [];
-    var inc = 0;
-    hosts.forEach(function (_hostname) {
-      hostnames[inc] = _hostname.host_name;
-      inc++;
-    });
-    var hostExcAmbari = hostnames.without(location.hostname);
-    if (noOfHosts > 1) {
-      return hostExcAmbari[0];
     } else {
-      return hostnames[0];
+      for(var i in selectionScheme){
+        if(window.isFinite(i)){
+          if(noOfHosts < window.parseInt(i)){
+            return hosts[selectionScheme[i]];
+          }
+        }
+      }
+      return hosts[selectionScheme['else']]
     }
   },
 
-  getHiveMetastore:function (noOfHosts) {
-    return this.getHiveServer(noOfHosts);
-  },
-
-  getWebHCatServer:function (noOfHosts) {
-    return this.getHiveServer(noOfHosts);
-  },
-
   getZooKeeperServer:function (noOfHosts) {
     var hosts = this.get('hosts');
     if (noOfHosts < 3) {
@@ -418,38 +301,22 @@ App.WizardStep5Controller = Em.Controller.extend({
   },
 
   getGangliaServer:function (noOfHosts) {
-    var hosts = this.get('hosts');
-    var hostnames = [];
-    var inc = 0;
-    hosts.forEach(function (_hostname) {
-      hostnames[inc] = _hostname.host_name;
-      inc++;
-    });
-    var hostExcAmbari = hostnames.without(location.hostname);
+    var hostNames = this.get('hosts').mapProperty('host_name');
+    var hostExcAmbari = hostNames.without(location.hostname);
     if (noOfHosts > 1) {
       return hostExcAmbari[0];
     } else {
-      return hostnames[0];
+      return hostNames[0];
     }
   },
 
   getNagiosServer:function (noOfHosts) {
-    var hosts = this.get('hosts');
-    var hostnames = [];
-    var inc = 0;
-    hosts.forEach(function (_hostname) {
-      hostnames[inc] = _hostname.host_name;
-      inc++;
-    });
-    var hostExcAmbari = hostnames.without(location.hostname);
-    if (noOfHosts > 1) {
-      return hostExcAmbari[0];
-    } else {
-      return hostnames[0];
-    }
+    return this.getGangliaServer(noOfHosts);
   },
 
-
+  getHueServer:function (noOfHosts) {
+    return this.getGangliaServer(noOfHosts);
+  },
   /**
    * Return hostName of masterNode for specified service
    * @param componentName
@@ -459,27 +326,76 @@ App.WizardStep5Controller = Em.Controller.extend({
     var noOfHosts = this.get('hosts').length;
     switch (componentName) {
       case 'KERBEROS_SERVER':
-        return this.getKerberosServer(noOfHosts).host_name;
+        return this.getHostForComponent(noOfHosts, {
+          "3" : 1,
+          "6" : 1,
+          "31" : 3,
+          "else" : 5
+        }).host_name;
       case 'NAMENODE':
-        return this.getNameNode(noOfHosts).host_name;
+        return this.getHostForComponent(noOfHosts, {
+          "else" : 1
+        }).host_name;
       case 'SECONDARY_NAMENODE':
-        return this.getSNameNode(noOfHosts).host_name;
+        return this.getHostForComponent(noOfHosts, {
+          "else" : 1
+        }).host_name;
       case 'JOBTRACKER':
-        return this.getJobTracker(noOfHosts).host_name;
+        return this.getHostForComponent(noOfHosts, {
+          "3" : 1,
+          "6" : 1,
+          "31" : 1,
+          "else" : 2
+        }).host_name;
       case 'HISTORYSERVER':
-        return this.getHistoryServer(noOfHosts).host_name;
+        return this.getHostForComponent(noOfHosts, {
+          "3" : 1,
+          "6" : 1,
+          "31" : 1,
+          "else" : 2
+        }).host_name;
       case 'RESOURCEMANAGER':
-        return this.getResourceManager(noOfHosts).host_name;
+        return this.getHostForComponent(noOfHosts, {
+          "3" : 1,
+          "6" : 1,
+          "31" : 1,
+          "else" : 2
+        }).host_name;
       case 'HBASE_MASTER':
-        return [this.getHBaseMaster(noOfHosts).host_name];
+        return [this.getHostForComponent(noOfHosts, {
+          "3" : 0,
+          "6" : 0,
+          "31" : 2,
+          "else" : 3
+        }).host_name];
       case 'OOZIE_SERVER':
-        return this.getOozieServer(noOfHosts).host_name;
+        return this.getHostForComponent(noOfHosts, {
+          "3" : 1,
+          "6" : 1,
+          "31" : 2,
+          "else" : 3
+        }).host_name;
       case 'HIVE_SERVER':
-        return this.getHiveServer(noOfHosts).host_name;
+        return this.getHostForComponent(noOfHosts, {
+          "3" : 1,
+          "6" : 1,
+          "31" : 2,
+          "else" : 4
+        }).host_name;
       case 'HIVE_METASTORE':
-        return this.getHiveMetastore(noOfHosts).host_name;
+        return this.getHostForComponent(noOfHosts, {
+          "3" : 1,
+          "6" : 1,
+          "31" : 2,
+          "else" : 4
+        }).host_name;
       case 'WEBHCAT_SERVER':
-        return this.getWebHCatServer(noOfHosts).host_name;
+        return this.getHostForComponent(noOfHosts, {
+          "3" : 1,
+          "6" : 1,
+          "31" : 2,
+          "else" : 4
+        }).host_name;
       case 'ZOOKEEPER_SERVER':
         return this.getZooKeeperServer(noOfHosts);
       case 'GANGLIA_SERVER':

+ 1 - 0
ambari-web/app/models/service.js

@@ -18,6 +18,7 @@
 
 
 var App = require('app');
+require('utils/config');
 
 App.Service = DS.Model.extend({
 

+ 25 - 16
ambari-web/test/controllers/global/cluster_controller_test.js

@@ -20,29 +20,38 @@
 var App = require('app');
 require('controllers/global/cluster_controller');
 require('utils/http_client');
+require('models/service');
 
 describe('App.clusterController', function () {
+  var controller = App.ClusterController.create();
+  App.Service.FIXTURES = [{service_name: 'NAGIOS'}];
 
   describe('#updateLoadStatus()', function () {
-    it('all items are loaded', function(){
-      var controller = App.ClusterController.create();
-      controller.set('dataLoadList', Em.Object.create({
-        'item1':true,
-        'item2':false
-      }));
-      controller.updateLoadStatus.call(controller, 'item2');
-      expect(controller.get('isLoaded')).to.equal(true);
-      expect(controller.get('clusterDataLoadedPercent')).to.equal('width:100%');
-    })
-    it('one item of two is loaded', function(){
-      var controller = App.ClusterController.create();
-      controller.set('dataLoadList', Em.Object.create({
-        'item1':false,
-        'item2':false
-      }));
+
+    controller.set('dataLoadList', Em.Object.create({
+      'item1':false,
+      'item2':false
+    }));
+
+    it('when none item is loaded then width should be "width:0"', function(){
+      expect(controller.get('clusterDataLoadedPercent')).to.equal('width:0');
+    });
+    it('when first item is loaded then isLoaded should be false', function(){
       controller.updateLoadStatus.call(controller, 'item1');
       expect(controller.get('isLoaded')).to.equal(false);
+    });
+    it('when first item is loaded then width should be "width:50%"', function(){
+      controller.updateLoadStatus.call(controller, 'item1');
       expect(controller.get('clusterDataLoadedPercent')).to.equal('width:50%');
     });
+
+    it('when all items are loaded then isLoaded should be true', function(){
+      controller.updateLoadStatus.call(controller, 'item2');
+      expect(controller.get('isLoaded')).to.equal(true);
+    });
+    it('when all items are loaded then width should be "width:100%"', function(){
+      controller.updateLoadStatus.call(controller, 'item2');
+      expect(controller.get('clusterDataLoadedPercent')).to.equal('width:100%');
+    });
   });
 });

+ 74 - 0
ambari-web/test/controllers/main/admin/security/add/step3_test.js

@@ -0,0 +1,74 @@
+/**
+ * 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/security/add/step3');
+require('utils/polling');
+require('models/cluster_states');
+
+describe('App.MainAdminSecurityAddStep3Controller', function () {
+
+  /**
+   * Test object
+   */
+  var controller = App.MainAdminSecurityAddStep3Controller.create();
+
+
+  describe('#moveToNextStage()', function () {
+    controller.reopen({
+      startStage: function(){},
+      saveStages: function(){}
+    });
+    App.clusterStatus.reopen({
+      setClusterStatus: function(){}
+    });
+
+    it('first stage is started', function(){
+      controller.set('stages', [
+        App.Poll.create({stage: 'stage1', isStarted: false, isCompleted: false}),
+        App.Poll.create({stage: 'stage2', isStarted: false, isCompleted: false}),
+        App.Poll.create({stage: 'stage3', isStarted: false, isCompleted: false})
+      ]);
+      controller.moveToNextStage();
+
+      expect(controller.get('stages').findProperty('stage', 'stage1').get('isStarted')).to.equal(true);
+    });
+    it('second stage is started', function(){
+      controller.set('stages', [
+        App.Poll.create({stage: 'stage1', isStarted: true, isCompleted: true}),
+        App.Poll.create({stage: 'stage2', isStarted: false, isCompleted: false}),
+        App.Poll.create({stage: 'stage3', isStarted: false, isCompleted: false})
+      ]);
+      controller.moveToNextStage();
+
+      expect(controller.get('stages').findProperty('stage', 'stage2').get('isStarted')).to.equal(true);
+    });
+    it('third stage is started', function(){
+      controller.set('stages', [
+        App.Poll.create({stage: 'stage1', isStarted: true, isCompleted: true}),
+        App.Poll.create({stage: 'stage2', isStarted: true, isCompleted: true}),
+        App.Poll.create({stage: 'stage3', isStarted: false, isCompleted: false})
+      ]);
+      controller.moveToNextStage();
+
+      expect(controller.get('stages').findProperty('stage', 'stage3').get('isStarted')).to.equal(true);
+    });
+
+  });
+});

+ 44 - 0
ambari-web/test/installer/step10_test.js

@@ -0,0 +1,44 @@
+/**
+ * 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/wizard/step10_controller');
+
+
+describe('App.WizardStep10Controller', function () {
+  var controller = App.WizardStep10Controller.create();
+
+  describe('#calculateInstallTime', function () {
+    it('from "9.21" to 9 minutes 12 seconds', function () {
+      expect(controller.calculateInstallTime('9.21')).to.eql({minutes: 9, seconds: 12});
+    });
+    it('from "0" to 0 minutes 0 seconds', function () {
+      expect(controller.calculateInstallTime('0')).to.eql({minutes: 0, seconds: 0});
+    });
+    it('from "10" to 10 minutes 0 seconds', function () {
+      expect(controller.calculateInstallTime('10')).to.eql({minutes: 10, seconds: 0});
+    });
+    it('from "0.5" to 0 minutes 30 seconds', function () {
+      expect(controller.calculateInstallTime('0.5')).to.eql({minutes: 0, seconds: 30});
+    });
+  });
+});
+
+

+ 102 - 29
ambari-web/test/installer/step5_test.js

@@ -23,64 +23,82 @@ var components = require('data/service_components');
 
 
 describe('App.WizardStep5Controller', function () {
+  var controller = App.WizardStep5Controller.create();
   var cpu = 2, memory = 4;
-
-  var methods = ['getKerberosServer', 'getNameNode', 'getSNameNode', 'getJobTracker', 'getResourceManager', 'getHistoryServer', 'getHBaseMaster', 'getOozieServer', 'getHiveServer', 'getHiveMetastore', 'getWebHCatServer'];
-
+  var schemes = [
+    {'description': 'empty condition'},
+    {
+      'description': 'second host if amount more than 1',
+      "else": 1
+    },
+    {
+      'description': 'first host if amount less than 3, third host if amount less than 6, fourth host if amount more than 5',
+      "3": 0,
+      "6": 2,
+      "else": 3
+    },
+    {
+      'description': 'second host if amount less than 3, second host if amount less than 6, third host if amount less than 31, sixth host if amount more than 30',
+      "3": 1,
+      "6": 1,
+      "31": 2,
+      "else": 5
+    }
+  ];
   var test_config = [
     {
       title: '1 host',
       hosts: ['host0'],
-      equals: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
+      equals: [0, 0, 0, 0]
     },
     {
       title: '2 hosts',
       hosts: ['host0', 'host1'],
-      equals: [1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]
+      equals: [0, 1, 0, 1]
     },
     {
       title: '3 hosts',
       hosts: ['host0', 'host1', 'host2'],
-      equals: [1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]
+      equals: [0, 1, 2, 1]
     },
     {
       title: '5 hosts',
       hosts: ['host0', 'host1', 'host2', 'host3', 'host4'],
-      equals: [1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]
+      equals: [0, 1, 2, 1]
     },
     {
       title: '6 hosts',
       hosts: ['host0', 'host1', 'host2', 'host3', 'host4', 'host6'],
-      equals: [3, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2]
+      equals: [0, 1, 3, 2]
     },
     {
       title: '10 hosts',
       hosts: ['host0', 'host1', 'host2', 'host3', 'host4', 'host5', 'host6', 'host7', 'host8', 'host9'],
-      equals: [3, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2]
+      equals: [0, 1, 3, 2]
     },
     {
       title: '31 hosts',
-      hosts: ['host0', 'host1', 'host2', 'host3', 'host4', 'host5', 'host6', 'host7', 'host8', 'host9', 'host0', 'host1', 'host2', 'host3', 'host4', 'host5', 'host6', 'host7', 'host8', 'host9', 'host0', 'host1', 'host2', 'host3', 'host4', 'host5', 'host6', 'host7', 'host8', 'host9', 'host0'],
-      equals: [5, 0, 1, 2, 2, 2, 3, 3, 4, 4, 4]
+      hosts: ['host0', 'host1', 'host2', 'host3', 'host4', 'host5', 'host6', 'host7', 'host8', 'host9', 'host10', 'host11', 'host12', 'host13', 'host14', 'host15', 'host16', 'host17', 'host18', 'host19', 'host20', 'host21', 'host22', 'host23', 'host24', 'host25', 'host26', 'host27', 'host28', 'host29', 'host30'],
+      equals: [0, 1, 3, 5]
     }
   ];
 
-  test_config.forEach(function(test) {
-    describe(test.title, function() {
-      var controller = App.WizardStep5Controller.create();
-      controller.clearStep();
-
-      test.hosts.forEach(function(_host) {
-        controller.get('hosts').pushObject(Em.Object.create({
-          host_name: _host,
-          cpu: cpu,
-          memory: memory
-        }));
-      });
+  schemes.forEach(function(scheme, index) {
+    describe('#getHostForComponent() condition: ' + scheme.description, function() {
+
+      delete scheme['description'];
 
-      methods.forEach(function(method, index) {
-        it('#' + method + '()', function() {
-          expect(controller[method](test.hosts.length).host_name).to.equal(test.hosts[test.equals[index]]);
+      test_config.forEach(function(test) {
+        it(test.title, function () {
+          controller.get('hosts').clear();
+          test.hosts.forEach(function(_host) {
+            controller.get('hosts').pushObject(Em.Object.create({
+              host_name: _host,
+              cpu: cpu,
+              memory: memory
+            }));
+          });
+          expect(controller.getHostForComponent(test.hosts.length, scheme).host_name).to.equal(test.hosts[test.equals[index]]);
         });
       });
 
@@ -88,19 +106,74 @@ describe('App.WizardStep5Controller', function () {
 
   });
 
+  describe('#getZooKeeperServer', function() {
+    it('should be array with three host names if hosts number more than three', function() {
+      var hosts = [
+        {host_name: 'host1'},
+        {host_name: 'host2'},
+        {host_name: 'host3'}
+      ];
+
+      controller.set('hosts', hosts);
+      expect(controller.getZooKeeperServer(hosts.length)).to.eql(['host1', 'host2', 'host3']);
+    });
+
+    it('should be array with one host names if hosts number less than three', function() {
+      var hosts = [
+        {host_name: 'host1'},
+        {host_name: 'host2'}
+      ];
+
+      controller.set('hosts', hosts);
+      expect(controller.getZooKeeperServer(hosts.length)).to.eql(['host1']);
+    });
+  });
+
+  describe('#getGangliaServer', function() {
+    it('should be host name if one host ', function() {
+      var hosts = [
+        {host_name: 'host1'}
+      ];
+
+      controller.set('hosts', hosts);
+      expect(controller.getGangliaServer(hosts.length)).to.eql('host1');
+    });
+
+    it('should be host name if hosts number more than one', function() {
+      var hosts = [
+        {host_name: 'host1'},
+        {host_name: 'host2'}
+      ];
+
+      controller.set('hosts', hosts);
+      expect(controller.getGangliaServer(hosts.length)).to.eql('host1');
+    });
+
+    it('should be host name different from localhost if hosts number more than one', function() {
+      var hosts = [
+        {host_name: ''},
+        {host_name: 'host2'}
+      ];
+      //first host_name is empty string, because of location.hostname = "" in console,
+      //to implement current test case
+
+      controller.set('hosts', hosts);
+      expect(controller.getGangliaServer(hosts.length)).to.eql('host2');
+    });
+  });
+
 
-  var controller = App.WizardStep5Controller.create();
   controller.set('content', {});
 
   describe('#isReassignWizard', function() {
     it('true if content.controllerName is reassignMasterController', function() {
       controller.set('content.controllerName', 'reassignMasterController');
       expect(controller.get('isReassignWizard')).to.equal(true);
-    })
+    });
     it('false if content.controllerName is not reassignMasterController', function() {
       controller.set('content.controllerName', 'mainController');
       expect(controller.get('isReassignWizard')).to.equal(false);
-    })
+    });
   });
 
 });

+ 4 - 4
ambari-web/test/mappers/dataset_mapper_test.js

@@ -58,8 +58,8 @@ describe('App.dataSetMapper', function () {
           }
         },
         "results": {
-          start_time: '3:0:AM',
-          end_time: '5:0:AM',
+          start_time: '2:0:AM',
+          end_time: '4:0:AM',
           frequency: 'minutes(1)',
           timezone: 'UTC',
           start_date: '1/5/2010',
@@ -84,8 +84,8 @@ describe('App.dataSetMapper', function () {
           }
         },
         "results": {
-          start_time: '6:0:PM',
-          end_time: '3:0:PM',
+          start_time: '5:0:PM',
+          end_time: '2:0:PM',
           frequency: 'minutes(5)',
           timezone: 'UTC',
           start_date: '1/2/2013',