Przeglądaj źródła

AMBARI-5982. Fix UI unit tests for step3 controller, models. (Buzhor Denys via onechiporenko)

Oleg Nechiporenko 11 lat temu
rodzic
commit
c37130f7a1

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

@@ -179,10 +179,7 @@ require('test/views/login_test');
 require('test/models/jobs/job_test');
 require('test/models/jobs/tez_dag_test');
 require('test/models/service/flume_test');
-require('test/models/service/hbase_test');
 require('test/models/service/hdfs_test');
-require('test/models/service/mapreduce_test');
-require('test/models/service/mapreduce2_test');
 require('test/models/service/yarn_test');
 require('test/models/alert_test');
 require('test/models/authentication_test');

+ 5 - 3
ambari-web/app/controllers/wizard/step3_controller.js

@@ -842,8 +842,8 @@ App.WizardStep3Controller = Em.Controller.extend({
 
   /**
    * return the supported agent os types for a repo os type
-   * @param {string} repoType
-   * @return {array} supported agent os type array
+   * @param {String} repoType
+   * @return {Array} supported agent os type array
    * @method repoToAgentOsType
    */
   repoToAgentOsType : function (repoType) {
@@ -856,6 +856,8 @@ App.WizardStep3Controller = Em.Controller.extend({
         return ["suse11", "sles11", "opensuse11"];
       case "debian12":
         return ["debian12", "ubuntu12"];
+      default:
+        return [];
     }
   },
 
@@ -1302,4 +1304,4 @@ App.WizardStep3Controller = Em.Controller.extend({
     })
   }
 
-});
+});

+ 7 - 5
ambari-web/test/app_test.js

@@ -69,6 +69,9 @@ describe('#App', function() {
 
   describe('Disable/enable components', function() {
 
+    App.set('handleStackDependencyTest', true);
+    modelSetup.setupStackVersion(this, 'HDP-2.1');
+
     var testableComponent =  Em.Object.create({
       componentName: 'APP_TIMELINE_SERVER',
       serviceName: 'YARN'
@@ -86,16 +89,13 @@ describe('#App', function() {
         name: 'AppTimelineServer'
       }
     };
+
     var globalProperties = require('data/HDP2/global_properties');
     var siteProperties = require('data/HDP2/site_properties');
     var reviewConfigs = require('data/review_configs');
-    var disableResult;
-
-    App.set('currentStackVersion', 'HDP-2.1');
-    App.set('handleStackDependencyTest', true);
+    var disableResult = App.disableComponent(testableComponent);
 
     describe('#disableComponent()', function() {
-      disableResult = App.disableComponent(testableComponent);
       // copy
       var _globalProperties = $.extend({}, globalProperties);
       var _siteProperties = $.extend({}, siteProperties);
@@ -166,6 +166,8 @@ describe('#App', function() {
         expect(reviewConfig).to.include(expectedInfo.reviewConfigs.component_name);
       });
     });
+
+    modelSetup.restoreStackVersion(this);
   });
 
   describe('#stackVersionURL', function () {

+ 5 - 1
ambari-web/test/controllers/global/cluster_controller_test.js

@@ -25,6 +25,8 @@ require('models/service');
 require('models/host');
 require('utils/ajax/ajax');
 
+var modelSetup = require('test/init_model_test');
+
 describe('App.clusterController', function () {
   var controller = App.ClusterController.create();
   App.Service.FIXTURES = [
@@ -63,9 +65,11 @@ describe('App.clusterController', function () {
   describe('#loadClusterName()', function () {
 
     beforeEach(function () {
+      modelSetup.setupStackVersion(this, 'HDP-2.0.5');
       sinon.spy(App.ajax, 'send');
     });
     afterEach(function () {
+      modelSetup.restoreStackVersion(this);
       App.ajax.send.restore();
     });
 
@@ -449,4 +453,4 @@ describe('App.clusterController', function () {
     });
   });
 
-});
+});

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

@@ -453,12 +453,16 @@ describe('App.MainServiceItemController', function () {
   describe("#refreshConfigs", function () {
     var temp = batchUtils.restartHostComponents;
     beforeEach(function () {
+      sinon.stub(App.ajax, 'send', function(opt) {
+        return opt.data.callback({ items: [] });
+      });
       batchUtils.restartHostComponents = Em.K;
       sinon.spy(batchUtils, "restartHostComponents");
     });
     afterEach(function () {
       batchUtils.restartHostComponents.restore();
       batchUtils.restartHostComponents = temp;
+      App.ajax.send.restore();
     });
     var tests = [
       {

+ 0 - 55
ambari-web/test/models/service/hbase_test.js

@@ -1,55 +0,0 @@
-/**
- * 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 modelSetup = require('test/init_model_test');
-require('models/service/hbase');
-
-var hBaseService,
-  hBaseServiceData = {
-    id: 'hbase'
-  },
-  hostComponentsData = [
-    {
-      id: 'regionserver',
-      componentName: 'HBASE_REGIONSERVER'
-    }
-  ];
-
-describe('App.HBaseService', function () {
-
-  beforeEach(function () {
-    hBaseService = App.HBaseService.createRecord(hBaseServiceData);
-  });
-
-  afterEach(function () {
-    modelSetup.deleteRecord(hBaseService);
-  });
-
-  describe('#regionServers', function () {
-    it('should take one component from hostComponents', function () {
-      hBaseService.reopen({
-        hostComponents: hostComponentsData
-      });
-      expect(hBaseService.get('regionServers')).to.have.length(1);
-      expect(hBaseService.get('regionServers')[0].id).to.equal('regionserver');
-    });
-  });
-
-});

+ 0 - 8
ambari-web/test/models/service/hdfs_test.js

@@ -26,20 +26,12 @@ var hdfsService,
     id: 'hdfs'
   },
   hostComponentsData = [
-    {
-      id: 'datanode',
-      componentName: 'DATANODE'
-    },
     {
       id: 'journalnode',
       componentName: 'JOURNALNODE'
     }
   ],
   cases = [
-    {
-      propertyName: 'dataNodes',
-      componentId: 'datanode'
-    },
     {
       propertyName: 'journalNodes',
       componentId: 'journalnode'

+ 0 - 58
ambari-web/test/models/service/mapreduce2_test.js

@@ -1,58 +0,0 @@
-/**
- * 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 modelSetup = require('test/init_model_test');
-require('models/service/mapreduce2');
-
-var mapReduce2Service,
-  mapReduce2ServiceData = {
-    id: 'mr2'
-  },
-  hostComponentsData = [
-    {
-      id: 'mr2client',
-      componentName: 'MAPREDUCE2_CLIENT',
-      host: {
-        id: 'host'
-      }
-    }
-  ];
-
-describe('App.MapReduce2Service', function () {
-
-  beforeEach(function () {
-    mapReduce2Service = App.MapReduce2Service.createRecord(mapReduce2ServiceData);
-  });
-
-  afterEach(function () {
-    modelSetup.deleteRecord(mapReduce2Service);
-  });
-
-  describe('#mapReduce2Clients', function () {
-    it('should take one component from hostComponents', function () {
-      mapReduce2Service.reopen({
-        hostComponents: hostComponentsData
-      });
-      expect(mapReduce2Service.get('mapReduce2Clients')).to.have.length(1);
-      expect(mapReduce2Service.get('mapReduce2Clients')[0].id).to.equal('host');
-    });
-  });
-
-});

+ 0 - 55
ambari-web/test/models/service/mapreduce_test.js

@@ -1,55 +0,0 @@
-/**
- * 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 modelSetup = require('test/init_model_test');
-require('models/service/mapreduce');
-
-var mapReduceService,
-  mapReduceServiceData = {
-    id: 'mr'
-  },
-  hostComponentsData = [
-    {
-      id: 'tasktracker',
-      componentName: 'TASKTRACKER'
-    }
-  ];
-
-describe('App.MapReduceService', function () {
-
-  beforeEach(function () {
-    mapReduceService = App.MapReduceService.createRecord(mapReduceServiceData);
-  });
-
-  afterEach(function () {
-    modelSetup.deleteRecord(mapReduceService);
-  });
-
-  describe('#taskTrackers', function () {
-    it('should take one component from hostComponents', function () {
-      mapReduceService.reopen({
-        hostComponents: hostComponentsData
-      });
-      expect(mapReduceService.get('taskTrackers')).to.have.length(1);
-      expect(mapReduceService.get('taskTrackers')[0].id).to.equal('tasktracker');
-    });
-  });
-
-});

+ 7 - 5
ambari-web/test/models/service/yarn_test.js

@@ -58,10 +58,6 @@ var yarnService,
     }
   ],
   nodeCases = [
-    {
-      propertyName: 'nodeManagerNodes',
-      componentId: 'nodemanager'
-    },
     {
       propertyName: 'yarnClientNodes',
       componentId: 'host'
@@ -70,6 +66,9 @@ var yarnService,
   nodeCountCases = [
     {
       assets: {
+        nodeManagersStarted: 0,
+        nodeManagersInstalled: 1,
+        nodeManagersTotal: 1,
         nodeManagersCountActive: 0,
         nodeManagersCountRebooted: 0,
         nodeManagersCountUnhealthy: 0,
@@ -79,8 +78,11 @@ var yarnService,
     },
     {
       assets: {
+        nodeManagersStarted: 1,
+        nodeManagersInstalled: 1,
+        nodeManagersTotal: 1,
         nodeManagersCountActive: 1,
-        nodeManagersCountRebooted: 0,
+        nodeManagersCountRebooted: 1,
         nodeManagersCountUnhealthy: 0,
         nodeManagersCountDecommissioned: 0
       },