Repository: ambari Updated Branches: refs/heads/trunk 0028d667c -> c37130f7a
AMBARI-5982. Fix UI unit tests for step3 controller, models. (Buzhor Denys via onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c37130f7 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c37130f7 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c37130f7 Branch: refs/heads/trunk Commit: c37130f7a1476254191e84b13f96a64d8e20ad17 Parents: 0028d66 Author: Oleg Nechiporenko <[email protected]> Authored: Mon Jun 2 13:36:30 2014 +0300 Committer: Oleg Nechiporenko <[email protected]> Committed: Mon Jun 2 13:36:30 2014 +0300 ---------------------------------------------------------------------- ambari-web/app/assets/test/tests.js | 3 - .../app/controllers/wizard/step3_controller.js | 8 ++- ambari-web/test/app_test.js | 12 ++-- .../global/cluster_controller_test.js | 6 +- .../test/controllers/main/service/item_test.js | 4 ++ ambari-web/test/models/service/hbase_test.js | 55 ------------------- ambari-web/test/models/service/hdfs_test.js | 8 --- .../test/models/service/mapreduce2_test.js | 58 -------------------- .../test/models/service/mapreduce_test.js | 55 ------------------- ambari-web/test/models/service/yarn_test.js | 12 ++-- 10 files changed, 28 insertions(+), 193 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/c37130f7/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 d9d61d7..fc64341 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/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'); http://git-wip-us.apache.org/repos/asf/ambari/blob/c37130f7/ambari-web/app/controllers/wizard/step3_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step3_controller.js b/ambari-web/app/controllers/wizard/step3_controller.js index 61526be..1b70ddc 100644 --- a/ambari-web/app/controllers/wizard/step3_controller.js +++ b/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({ }) } -}); \ No newline at end of file +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/c37130f7/ambari-web/test/app_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/app_test.js b/ambari-web/test/app_test.js index e24ff9a..3b0565b 100644 --- a/ambari-web/test/app_test.js +++ b/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 () { http://git-wip-us.apache.org/repos/asf/ambari/blob/c37130f7/ambari-web/test/controllers/global/cluster_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/global/cluster_controller_test.js b/ambari-web/test/controllers/global/cluster_controller_test.js index 6e822de..d7423c2 100644 --- a/ambari-web/test/controllers/global/cluster_controller_test.js +++ b/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 () { }); }); -}); \ No newline at end of file +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/c37130f7/ambari-web/test/controllers/main/service/item_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/item_test.js b/ambari-web/test/controllers/main/service/item_test.js index f7b43ed..40546b8 100644 --- a/ambari-web/test/controllers/main/service/item_test.js +++ b/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 = [ { http://git-wip-us.apache.org/repos/asf/ambari/blob/c37130f7/ambari-web/test/models/service/hbase_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/service/hbase_test.js b/ambari-web/test/models/service/hbase_test.js deleted file mode 100644 index 861cf03..0000000 --- a/ambari-web/test/models/service/hbase_test.js +++ /dev/null @@ -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'); - }); - }); - -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/c37130f7/ambari-web/test/models/service/hdfs_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/service/hdfs_test.js b/ambari-web/test/models/service/hdfs_test.js index 93c3174..d923967 100644 --- a/ambari-web/test/models/service/hdfs_test.js +++ b/ambari-web/test/models/service/hdfs_test.js @@ -27,20 +27,12 @@ var hdfsService, }, hostComponentsData = [ { - id: 'datanode', - componentName: 'DATANODE' - }, - { id: 'journalnode', componentName: 'JOURNALNODE' } ], cases = [ { - propertyName: 'dataNodes', - componentId: 'datanode' - }, - { propertyName: 'journalNodes', componentId: 'journalnode' } http://git-wip-us.apache.org/repos/asf/ambari/blob/c37130f7/ambari-web/test/models/service/mapreduce2_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/service/mapreduce2_test.js b/ambari-web/test/models/service/mapreduce2_test.js deleted file mode 100644 index b75321a..0000000 --- a/ambari-web/test/models/service/mapreduce2_test.js +++ /dev/null @@ -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'); - }); - }); - -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/c37130f7/ambari-web/test/models/service/mapreduce_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/service/mapreduce_test.js b/ambari-web/test/models/service/mapreduce_test.js deleted file mode 100644 index e94020f..0000000 --- a/ambari-web/test/models/service/mapreduce_test.js +++ /dev/null @@ -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'); - }); - }); - -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/c37130f7/ambari-web/test/models/service/yarn_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/service/yarn_test.js b/ambari-web/test/models/service/yarn_test.js index deaf55e..728a452 100644 --- a/ambari-web/test/models/service/yarn_test.js +++ b/ambari-web/test/models/service/yarn_test.js @@ -59,10 +59,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 },
