AMBARI-14626. UI UT cleanup (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c263626e Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c263626e Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c263626e Branch: refs/heads/branch-dev-patch-upgrade Commit: c263626ea920c7445788cb08b3a7ca0f4eab4e98 Parents: 7b916e2 Author: Oleg Nechiporenko <[email protected]> Authored: Tue Jan 12 12:52:02 2016 +0200 Committer: Nate Cole <[email protected]> Committed: Thu Jan 14 11:43:24 2016 -0500 ---------------------------------------------------------------------- ambari-web/app/views/common/modal_popup.js | 6 +- ambari-web/test/aliases/computed/alias.js | 2 +- .../test/aliases/computed/firstNotBlank.js | 2 +- ambari-web/test/app_test.js | 1 - .../test/controllers/experimental_test.js | 10 +- .../global/background_operations_test.js | 4 +- .../global/cluster_controller_test.js | 12 +- .../global/update_controller_test.js | 7 +- ambari-web/test/controllers/installer_test.js | 8 +- .../nameNode/step3_controller_test.js | 6 +- .../admin/kerberos/step2_controller_test.js | 5 +- .../admin/kerberos/step4_controller_test.js | 107 +++++++++--------- .../controllers/main/admin/kerberos_test.js | 2 +- .../admin/stack_and_upgrade_controller_test.js | 4 +- .../definitions_details_controller_test.js | 6 - ...anage_alert_notifications_controller_test.js | 8 +- .../heatmap_metrics/heatmap_metric_test.js | 2 +- .../controllers/main/charts/heatmap_test.js | 6 +- .../test/controllers/main/host/details_test.js | 18 ++- ambari-web/test/controllers/main/host_test.js | 1 - .../main/service/add_controller_test.js | 2 +- .../main/service/info/config_test.js | 4 +- .../main/service/info/summary_test.js | 10 +- .../test/controllers/main/service/item_test.js | 99 ++--------------- .../manage_config_groups_controller_test.js | 2 +- .../service/reassign/step1_controller_test.js | 1 - .../service/reassign/step2_controller_test.js | 3 - .../service/reassign/step4_controller_test.js | 4 +- .../widgets/create/step2_controller_test.js | 2 +- .../widgets/create/wizard_controller_test.js | 8 +- .../test/controllers/main/service_test.js | 2 +- ambari-web/test/controllers/main_test.js | 11 +- .../test/controllers/wizard/step10_test.js | 2 +- .../test/controllers/wizard/step2_test.js | 3 +- .../test/controllers/wizard/step3_test.js | 19 ++-- .../test/controllers/wizard/step4_test.js | 21 ++-- .../test/controllers/wizard/step5_test.js | 2 - .../test/controllers/wizard/step6_test.js | 8 +- .../test/controllers/wizard/step7_test.js | 110 ++++++++++++------- .../test/controllers/wizard/step8_test.js | 17 ++- .../test/controllers/wizard/step9_test.js | 27 +++-- ambari-web/test/controllers/wizard_test.js | 81 ++++++-------- .../test/data/HDP2.2/site_properties_test.js | 9 +- .../test/data/HDP2.3/site_properties_test.js | 9 +- .../test/data/HDP2/secure_mapping_test.js | 5 +- .../test/data/HDP2/site_properties_test.js | 9 +- ambari-web/test/init_computed_aliases.js | 5 +- ambari-web/test/init_test.js | 6 +- ambari-web/test/login_test.js | 23 +--- .../mappers/alert_definitions_mapper_test.js | 6 +- .../test/mappers/alert_groups_mapper_test.js | 11 +- .../test/mappers/alert_instances_mapper_test.js | 8 +- ambari-web/test/mappers/hosts_mapper_test.js | 1 - .../test/mappers/server_data_mapper_test.js | 7 +- ambari-web/test/mappers/service_mapper_test.js | 1 - ambari-web/test/mappers/stack_mapper_test.js | 5 +- ambari-web/test/mappers/status_mapper_test.js | 10 +- ambari-web/test/mappers/users_mapper_test.js | 1 - .../configs/config_recommendations_test.js | 4 +- .../mixins/common/configs/configs_saver_test.js | 2 +- .../common/configs/toggle_isrequired_test.js | 3 +- .../kdc_credentials_controller_mixin_test.js | 25 +++-- .../test/mixins/common/serverValidator_test.js | 6 +- .../test/mixins/common/widget_mixin_test.js | 46 ++++---- .../host_components/decommissionable_test.js | 24 ---- .../configs/widget_popover_support_test.js | 12 +- .../test/mixins/wizard/wizardEnableDone_test.js | 4 +- .../wizard/wizardProgressPageController_test.js | 6 +- .../test/mock_data_setup/configs_mock_data.js | 6 +- ambari-web/test/models/authentication_test.js | 4 +- .../objects/service_config_property_test.js | 53 +-------- .../configs/objects/service_config_test.js | 1 - .../test/models/configs/theme/tab_test.js | 5 - ambari-web/test/models/form_test.js | 2 + ambari-web/test/models/host_component_test.js | 4 +- ambari-web/test/models/host_test.js | 3 +- ambari-web/test/models/service/hdfs_test.js | 1 - ambari-web/test/models/service/yarn_test.js | 56 +--------- ambari-web/test/models/service_test.js | 66 ----------- .../stack_version/repository_version_test.js | 7 +- ambari-web/test/router_test.js | 1 - ambari-web/test/routes/views_test.js | 2 +- .../test/utils/batch_scheduled_requests_test.js | 3 +- ambari-web/test/utils/blueprint_test.js | 4 +- ambari-web/test/utils/config_test.js | 27 +++-- .../utils/configs/config_initializer_test.js | 69 ++---------- ambari-web/test/utils/configs/database_test.js | 1 - ambari-web/test/utils/data_manipulation_test.js | 10 +- ambari-web/test/utils/date/date_test.js | 13 +-- ambari-web/test/utils/helper_test.js | 31 +++--- .../test/utils/host_progress_popup_test.js | 83 ++------------ ambari-web/test/utils/load_timer_test.js | 4 +- ambari-web/test/utils/misc_test.js | 2 +- ambari-web/test/utils/number_utils_test.js | 2 +- ambari-web/test/utils/string_utils_test.js | 22 ++-- ambari-web/test/utils/ui_effects_test.js | 7 +- ambari-web/test/utils/validator_test.js | 7 +- .../test/views/common/chart/linear_time_test.js | 10 +- .../configs/overriddenProperty_view_test.js | 2 +- .../service_config_container_view_test.js | 5 +- .../service_configs_by_category_view_test.js | 8 +- .../test/views/common/filter_view_test.js | 12 +- .../test/views/common/quick_link_view_test.js | 2 +- ambari-web/test/views/common/sort_view_test.js | 1 - ambari-web/test/views/login_test.js | 9 +- .../stack_upgrade/upgrade_wizard_view_test.js | 4 +- .../admin/stack_upgrade/version_view_test.js | 2 +- .../views/main/alert_definitions_view_test.js | 4 +- .../alerts/manage_alert_groups_view_test.js | 6 - .../manage_alert_notifications_view_test.js | 2 +- .../widgets/hbase_master_uptime_test.js | 2 +- .../dashboard/widgets/namenode_uptime_test.js | 2 +- .../widgets/resource_manager_uptime_test.js | 2 +- .../widgets/uptime_text_widget_test.js | 4 +- .../test/views/main/dashboard/widgets_test.js | 28 +++-- ambari-web/test/views/main/dashboard_test.js | 14 +-- .../decommissionable_test.js | 16 +-- .../nodemanager_view_test.js | 4 +- ambari-web/test/views/main/host/summary_test.js | 2 +- .../ambari_metrics/regionserver_base_test.js | 2 +- .../views/main/service/info/summary_test.js | 3 +- ambari-web/test/views/main/service/item_test.js | 16 +-- ambari-web/test/views/wizard/step1_view_test.js | 10 +- 123 files changed, 539 insertions(+), 1032 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/app/views/common/modal_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/modal_popup.js b/ambari-web/app/views/common/modal_popup.js index 9c7f03e..3402e80 100644 --- a/ambari-web/app/views/common/modal_popup.js +++ b/ambari-web/app/views/common/modal_popup.js @@ -68,7 +68,7 @@ App.ModalPopup = Ember.View.extend({ if (this.autoHeight && !$.mocho) { var block = this.$().find('#modal > .modal-body').first(); if(block.offset()) { - block.css('max-height', $(window).height() - block.offset().top - this.marginBottom + $(window).scrollTop()); // fix popup height + block.css('max-height', $(window).height() - block.offset().top - this.marginBottom + $(window).scrollTop()); // fix popup height } } this.fitZIndex(); @@ -82,7 +82,7 @@ App.ModalPopup = Ember.View.extend({ */ fitZIndex: function () { var existedPopups = $('.modal-backdrop'); - if (existedPopups) { + if (existedPopups && !$.mocho) { var maxZindex = 1; existedPopups.each(function(index, popup) { if ($(popup).css('z-index') > maxZindex) { @@ -103,7 +103,7 @@ App.ModalPopup = Ember.View.extend({ var block = this.$().find('#modal > .modal-body'); var wh = $(window).height(); - var top = wh * .05; + var top = wh * 0.05; popup.css({ 'top': top + 'px', 'marginTop': 0 http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/aliases/computed/alias.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/aliases/computed/alias.js b/ambari-web/test/aliases/computed/alias.js index 9605d73..d65b976 100644 --- a/ambari-web/test/aliases/computed/alias.js +++ b/ambari-web/test/aliases/computed/alias.js @@ -40,7 +40,7 @@ App.TestAliases.testAsComputedAlias = function (context, propertyName, dependent } else { // all - testsCases = [].concat.call([], Object.keys(typesMap).map(function (key) {return typesMap[key]})); + testsCases = [].concat(Object.keys(typesMap).map(function (key) {return typesMap[key]})); } describe('#' + propertyName + ' as Em.computed.alias', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/aliases/computed/firstNotBlank.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/aliases/computed/firstNotBlank.js b/ambari-web/test/aliases/computed/firstNotBlank.js index 7099fe5..e6edba2 100644 --- a/ambari-web/test/aliases/computed/firstNotBlank.js +++ b/ambari-web/test/aliases/computed/firstNotBlank.js @@ -21,7 +21,7 @@ var helpers = App.TestAliases.helpers; function prepareHash(dependentKeys, index) { var hash = {}; dependentKeys.forEach(function (key, i) { - hash[key] = i < index ? null : '' + i; + hash[key] = i < index ? null : '' + i; }); return hash; } http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/app_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/app_test.js b/ambari-web/test/app_test.js index 972f57f..60e617a 100644 --- a/ambari-web/test/app_test.js +++ b/ambari-web/test/app_test.js @@ -20,7 +20,6 @@ var App = require('app'); require('views/common/quick_view_link_view'); require('models/host_component'); require('models/stack_service_component'); -var modelSetup = require('test/init_model_test'); App.auth = ["AMBARI.ADD_DELETE_CLUSTERS", "AMBARI.ASSIGN_ROLES", "AMBARI.EDIT_STACK_REPOS", "AMBARI.MANAGE_GROUPS", "AMBARI.MANAGE_STACK_VERSIONS", "AMBARI.MANAGE_USERS", "AMBARI.MANAGE_VIEWS", "AMBARI.RENAME_CLUSTER", "AMBARI.SET_SERVICE_USERS_GROUPS", "CLUSTER.TOGGLE_ALERTS", "CLUSTER.TOGGLE_KERBEROS", "CLUSTER.UPGRADE_DOWNGRADE_STACK", "CLUSTER.VIEW_ALERTS", "CLUSTER.VIEW_CONFIGS", "CLUSTER.VIEW_METRICS", "CLUSTER.VIEW_STACK_DETAILS", "CLUSTER.VIEW_STATUS_INFO", "HOST.ADD_DELETE_COMPONENTS", "HOST.ADD_DELETE_HOSTS", "HOST.TOGGLE_MAINTENANCE", "HOST.VIEW_CONFIGS", "HOST.VIEW_METRICS", "HOST.VIEW_STATUS_INFO", "SERVICE.ADD_DELETE_SERVICES", "SERVICE.COMPARE_CONFIGS", "SERVICE.DECOMMISSION_RECOMMISSION", "SERVICE.ENABLE_HA", "SERVICE.MANAGE_CONFIG_GROUPS", "SERVICE.MODIFY_CONFIGS", "SERVICE.MOVE", "SERVICE.RUN_CUSTOM_COMMAND", "SERVICE.RUN_SERVICE_CHECK", "SERVICE.START_STOP", "SERVICE.TOGGLE_ALERTS", "SERVICE.TOGGLE_MAINTENANCE", "SERVICE.VIEW_ALERTS", "SERVICE.VIEW_CONFIGS", "SERV ICE.VIEW_METRICS", "SERVICE.VIEW_STATUS_INFO", "VIEW.USE"]; describe('App', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/experimental_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/experimental_test.js b/ambari-web/test/controllers/experimental_test.js index bfb238f..0ff0758 100644 --- a/ambari-web/test/controllers/experimental_test.js +++ b/ambari-web/test/controllers/experimental_test.js @@ -21,9 +21,7 @@ var App = require('app'); require('controllers/experimental'); var controller, - transition, supports = {}, - transitionStubbed = false, controllerSupports = [ Em.Object.create({ name: 'sup0', @@ -65,10 +63,10 @@ describe('App.ExperimentalController', function () { describe.skip('#doSave', function () { before(function () { sinon.stub(Ember, 'set', function (p, v) { - if (p.indexOf('App.supports.' != -1)) { - p = p.replace('App.supports.', ''); - saveObject[p] = v; - return; + if (p.startsWith('App.supports.')) { + var key = p.replace('App.supports.', ''); + saveObject[key] = v; + return v; } return Ember.set(p, v); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/global/background_operations_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/global/background_operations_test.js b/ambari-web/test/controllers/global/background_operations_test.js index adc02c9..a602a32 100644 --- a/ambari-web/test/controllers/global/background_operations_test.js +++ b/ambari-web/test/controllers/global/background_operations_test.js @@ -660,7 +660,7 @@ describe('App.BackgroundOperationsController', function () { controller.set('services', [request]); controller.callBackFilteredByRequest(data); expect(request.get('previousTaskStatusMap')).to.eql({"1": "COMPLETED"}); - expect(request.get('hostsMap')['host1'].logTasks.length).to.equal(1); + expect(request.get('hostsMap.host1.logTasks.length')).to.equal(1); expect(request.get('isRunning')).to.equal(false); }); @@ -694,7 +694,7 @@ describe('App.BackgroundOperationsController', function () { controller.set('services', [request]); controller.callBackFilteredByRequest(data); expect(request.get('previousTaskStatusMap')).to.eql({"1": "COMPLETED", "2": "IN_PROGRESS"}); - expect(request.get('hostsMap')['host1'].logTasks.length).to.equal(2); + expect(request.get('hostsMap.host1.logTasks.length')).to.equal(2); expect(request.get('isRunning')).to.equal(true); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/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 a020b46..92808b4 100644 --- a/ambari-web/test/controllers/global/cluster_controller_test.js +++ b/ambari-web/test/controllers/global/cluster_controller_test.js @@ -52,20 +52,20 @@ describe('App.clusterController', 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'); + controller.updateLoadStatus('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'); + controller.updateLoadStatus('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'); + controller.updateLoadStatus('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'); + controller.updateLoadStatus('item2'); expect(controller.get('clusterDataLoadedPercent')).to.equal('width:100%'); }); }); @@ -115,7 +115,7 @@ describe('App.clusterController', function () { }); describe('#reloadSuccessCallback', function () { - var test_data = { + var testData = { "items": [ { "Clusters": { @@ -126,7 +126,7 @@ describe('App.clusterController', function () { ] }; it('Check cluster', function () { - controller.reloadSuccessCallback(test_data); + controller.reloadSuccessCallback(testData); expect(App.get('clusterName')).to.equal('tdk'); expect(App.get('currentStackVersion')).to.equal('HDP-1.3.0'); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/global/update_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/global/update_controller_test.js b/ambari-web/test/controllers/global/update_controller_test.js index 6a95871..25b2c5b 100644 --- a/ambari-web/test/controllers/global/update_controller_test.js +++ b/ambari-web/test/controllers/global/update_controller_test.js @@ -195,7 +195,7 @@ describe('App.UpdateController', function () { }); testCases.forEach(function (test) { it(test.title, function () { - App.cache['services'] = test.services; + App.cache.services = test.services; this.mock.withArgs('router.clusterController.isServiceMetricsLoaded').returns(true); expect(controller.getConditionalFields()).to.eql(test.result); }); @@ -203,7 +203,7 @@ describe('App.UpdateController', function () { testCasesByStackVersion.forEach(function (test) { it(test.title, function () { - App.cache['services'] = test.services; + App.cache.services = test.services; this.mock.withArgs('currentStackVersionNumber').returns(test.stackVersionNumber); this.mock.withArgs('router.clusterController.isServiceMetricsLoaded').returns(true); expect(controller.getConditionalFields()).to.eql(test.result); @@ -211,7 +211,7 @@ describe('App.UpdateController', function () { }); it('FLUME service, first load', function () { - App.cache['services'] = [ + App.cache.services = [ { ServiceInfo: { service_name: 'FLUME' @@ -410,7 +410,6 @@ describe('App.UpdateController', function () { }; } }, - mainAdminStackAndUpgradeController = App.get('router.mainAdminStackAndUpgradeController'), appGetMock; beforeEach(function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/installer_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/installer_test.js b/ambari-web/test/controllers/installer_test.js index 65b19ab..cd75ed7 100644 --- a/ambari-web/test/controllers/installer_test.js +++ b/ambari-web/test/controllers/installer_test.js @@ -194,6 +194,7 @@ describe('App.InstallerController', function () { ]) }) ]); + var resolve = false; var data = { osId: 1, repoId: 11, @@ -203,7 +204,6 @@ describe('App.InstallerController', function () { } } }; - var resolve = false; it ('Should check stacks for sucess', function() { installerController.set('content.stacks', stacks); @@ -277,6 +277,7 @@ describe('App.InstallerController', function () { ]) }) ]); + var resolve = false; var data = { osId: 1, repoId: 11, @@ -286,7 +287,6 @@ describe('App.InstallerController', function () { } } }; - var resolve = false; it ('Should check stacks for error', function() { var req = { @@ -962,7 +962,7 @@ describe('App.InstallerController', function () { describe('#loadMasterComponentHosts', function() { beforeEach(function () { - sinon.stub(installerController, 'getDBProperties', function(key) { + sinon.stub(installerController, 'getDBProperties', function() { return { masterComponentHosts: Em.A([ { @@ -1226,7 +1226,7 @@ describe('App.InstallerController', function () { var successCallback; - beforeEach(function () { + beforeEach(function () { sinon.stub(App.Stack, 'find').returns(test.stacks); sinon.stub(App.router, 'get').withArgs('clusterController.isCustomJDK').returns(test.isCustomJDK) .withArgs('clusterController.ambariProperties').returns(test.ambariProperties); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js b/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js index 1b0fe31..938b2c9 100644 --- a/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js +++ b/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js @@ -189,12 +189,12 @@ describe('App.HighAvailabilityWizardStep3Controller', function() { tests.forEach(function(test) { it(test.m, function() { - var controller = App.HighAvailabilityWizardStep3Controller.create({ + var _controller = App.HighAvailabilityWizardStep3Controller.create({ configsToRemove: test.toRemove, serverConfigData: test.configs }); - var result = controller.removeConfigs(test.toRemove, controller.get('serverConfigData')); - expect(JSON.stringify(controller.get('serverConfigData'))).to.equal(JSON.stringify(test.expected)); + var result = _controller.removeConfigs(test.toRemove, _controller.get('serverConfigData')); + expect(JSON.stringify(_controller.get('serverConfigData'))).to.equal(JSON.stringify(test.expected)); expect(JSON.stringify(result)).to.equal(JSON.stringify(test.expected)); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/admin/kerberos/step2_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/kerberos/step2_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step2_controller_test.js index 275588d..4cfa51c 100644 --- a/ambari-web/test/controllers/main/admin/kerberos/step2_controller_test.js +++ b/ambari-web/test/controllers/main/admin/kerberos/step2_controller_test.js @@ -54,11 +54,10 @@ describe('App.KerberosWizardStep2Controller', function() { $.extend(true, {}, preDefProp, { value: value, filename: 'some-site.xml', 'displayType': displayType, - isRequiredByAgent: preDefProp.isRequiredByAgent == undefined ? true : preDefProp.isRequiredByAgent + isRequiredByAgent: preDefProp.isRequiredByAgent === undefined ? true : preDefProp.isRequiredByAgent })); - } else { - return App.ServiceConfigProperty.create({name: name, value: value, isRequiredByAgent: true, filename: 'some-site.xml'}); } + return App.ServiceConfigProperty.create({name: name, value: value, isRequiredByAgent: true, filename: 'some-site.xml'}); }; var tests = [ http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js index 3f284f4..1174f0a 100644 --- a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js +++ b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js @@ -17,7 +17,7 @@ */ var App = require('app'); -var c = App.KerberosWizardStep4Controller.create({ +var c = App.KerberosWizardStep4Controller.create({ wizardController: Em.Object.create({ name: '' }) @@ -57,38 +57,6 @@ describe('App.KerberosWizardStep4Controller', function() { describe('#prepareConfigProperties', function() { - before(function() { - var controller = App.KerberosWizardStep4Controller.create({ - wizardController: { - getDBProperty: function() { - return Em.A([ - Em.Object.create({ name: 'realm', value: 'realm_value' }) - ]); - }, - loadCachedStepConfigValues: function() { - return null; - } - } - }); - sinon.stub(App.Service, 'find').returns(Em.A([ - { serviceName: 'HDFS' } - ])); - sinon.stub(App.configsCollection, 'getAll').returns([ - { - name: 'hadoop.security.auth_to_local', - displayType: 'multiLine' - } - ]); - sinon.stub(App.router, 'get').withArgs('mainAdminKerberosController.isManualKerberos').returns(false); - this.result = controller.prepareConfigProperties(properties); - }); - - after(function() { - App.Service.find.restore(); - App.configsCollection.getAll.restore(); - App.router.get.restore(); - }); - var properties = Em.A([ Em.Object.create({ name: 'realm', value: '', serviceName: 'Cluster' }), Em.Object.create({ name: 'spnego_keytab', value: 'spnego_keytab_value', serviceName: 'Cluster' }), @@ -98,7 +66,7 @@ describe('App.KerberosWizardStep4Controller', function() { Em.Object.create({ name: 'hdfs_principal', value: 'hdfs_principal_value', identityType: 'user', serviceName: 'HDFS' }), Em.Object.create({ name: 'hadoop.security.auth_to_local', serviceName: 'HDFS' }) ]); - + var propertyValidationCases = [ { property: 'spnego_keytab', @@ -129,9 +97,41 @@ describe('App.KerberosWizardStep4Controller', function() { ] } ]; - + var absentPropertiesTest = ['falcon_keytab', 'mapreduce_keytab']; - + + before(function() { + var controller = App.KerberosWizardStep4Controller.create({ + wizardController: { + getDBProperty: function() { + return Em.A([ + Em.Object.create({ name: 'realm', value: 'realm_value' }) + ]); + }, + loadCachedStepConfigValues: function() { + return null; + } + } + }); + sinon.stub(App.Service, 'find').returns(Em.A([ + { serviceName: 'HDFS' } + ])); + sinon.stub(App.configsCollection, 'getAll').returns([ + { + name: 'hadoop.security.auth_to_local', + displayType: 'multiLine' + } + ]); + sinon.stub(App.router, 'get').withArgs('mainAdminKerberosController.isManualKerberos').returns(false); + this.result = controller.prepareConfigProperties(properties); + }); + + after(function() { + App.Service.find.restore(); + App.configsCollection.getAll.restore(); + App.router.get.restore(); + }); + it('should contains properties only for installed services', function() { expect(this.result.mapProperty('serviceName').uniq()).to.be.eql(['Cluster', 'HDFS']); }); @@ -160,6 +160,24 @@ describe('App.KerberosWizardStep4Controller', function() { describe('#setStepConfigs', function() { describe('Add Service Wizard', function() { + + var properties = Em.A([ + Em.Object.create({ name: 'realm', value: '', serviceName: 'Cluster' }), + Em.Object.create({ name: 'spnego_keytab', value: 'spnego_keytab_value', serviceName: 'Cluster', isEditable: true }), + Em.Object.create({ name: 'hdfs_keytab', value: '', serviceName: 'HDFS', observesValueFrom: 'spnego_keytab', isEditable: true }), + Em.Object.create({ name: 'falcon_keytab', value: 'falcon_keytab_value', serviceName: 'FALCON', isEditable: true }), + Em.Object.create({ name: 'mapreduce_keytab', value: 'mapreduce_keytab_value', serviceName: 'MAPREDUCE2', isEditable: true }) + ]); + + var propertiesEditableTests = [ + { name: 'spnego_keytab', e: false }, + { name: 'falcon_keytab', e: true }, + { name: 'hdfs_keytab', e: false }, + { name: 'mapreduce_keytab', e: true }, + { name: 'admin_principal', e: true }, + { name: 'admin_password', e: true } + ]; + var res; var controller; before(function() { @@ -204,23 +222,6 @@ describe('App.KerberosWizardStep4Controller', function() { res = controller.get('stepConfigs')[0].get('configs').concat(controller.get('stepConfigs')[1].get('configs')); }); - var properties = Em.A([ - Em.Object.create({ name: 'realm', value: '', serviceName: 'Cluster' }), - Em.Object.create({ name: 'spnego_keytab', value: 'spnego_keytab_value', serviceName: 'Cluster', isEditable: true }), - Em.Object.create({ name: 'hdfs_keytab', value: '', serviceName: 'HDFS', observesValueFrom: 'spnego_keytab', isEditable: true }), - Em.Object.create({ name: 'falcon_keytab', value: 'falcon_keytab_value', serviceName: 'FALCON', isEditable: true }), - Em.Object.create({ name: 'mapreduce_keytab', value: 'mapreduce_keytab_value', serviceName: 'MAPREDUCE2', isEditable: true }) - ]); - - var propertiesEditableTests = [ - { name: 'spnego_keytab', e: false }, - { name: 'falcon_keytab', e: true }, - { name: 'hdfs_keytab', e: false }, - { name: 'mapreduce_keytab', e: true }, - { name: 'admin_principal', e: true }, - { name: 'admin_password', e: true } - ]; - propertiesEditableTests.forEach(function(test) { it('Add Service: property `{0}` should be {1} editable'.format(test.name, !!test.e ? '' : 'not '), function() { expect(res.findProperty('name', test.name).get('isEditable')).to.eql(test.e); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/admin/kerberos_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/kerberos_test.js b/ambari-web/test/controllers/main/admin/kerberos_test.js index d69e168..fa23082 100644 --- a/ambari-web/test/controllers/main/admin/kerberos_test.js +++ b/ambari-web/test/controllers/main/admin/kerberos_test.js @@ -98,7 +98,7 @@ describe('App.MainAdminKerberosController', function() { controller.startKerberosWizard.restore(); }); it("shows popup", function () { - var check = { items: [{ + var check = { items: [{ UpgradeChecks: { "check": "Work-preserving RM/NM restart is enabled in YARN configs", "status": "FAIL", http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js index 23652ed..045b0f1 100644 --- a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js +++ b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js @@ -466,7 +466,7 @@ describe('App.MainAdminStackAndUpgradeController', function() { ); expect(controller.upgrade.callCount).to.equal(item.upgradeCalledCount); expect(App.showClusterCheckPopup.callCount).to.equal(item.showClusterCheckPopupCalledCount); - if (item.check.id == 'CONFIG_MERGE') { + if (item.check.id === 'CONFIG_MERGE') { expect(App.showClusterCheckPopup.firstCall.args[2]).to.eql(item.configs); } }); @@ -2125,6 +2125,7 @@ describe('App.MainAdminStackAndUpgradeController', function() { }); it('new window content is valid', function () { + /*eslint-disable no-useless-concat */ expect(mock.document.write.calledWith('<table style="text-align: left;"><thead><tr>' + '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.configType') + '</th>' + '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.propertyName') + '</th>' + @@ -2146,6 +2147,7 @@ describe('App.MainAdminStackAndUpgradeController', function() { '<td>' + 'recommendedValue2' + '</td>' + '<td>' + 'resultingValue2' + '</td>' + '</tr></tbody></table>')).to.be.true; + /*eslint-enable no-useless-concat */ }); it('document.focus is called once', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js b/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js index 2eb91c8..28e1829 100644 --- a/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js +++ b/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js @@ -39,13 +39,7 @@ describe('App.MainAlertDefinitionDetailsController', function () { App.TestAliases.testAsComputedOr(getController(), 'isEditing', ['editing.label.isEditing', 'App.router.mainAlertDefinitionConfigsController.canEdit']); describe('#showSavePopup', function () { - var popup; - beforeEach(function () { - popup = getController().showSavePopup(); - }); - App.TestAliases.testAsComputedOr(getController().showSavePopup(), 'disablePrimary', ['App.router.mainAlertDefinitionDetailsController.editing.label.isError', 'App.router.mainAlertDefinitionConfigsController.hasErrors']); - }); describe('#labelValidation()', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js index 025ce86..9352116 100644 --- a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js +++ b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js @@ -942,13 +942,13 @@ describe('App.ManageAlertNotificationsController', function () { controller.set('inputFields.customProperties', []); }); + /*eslint-disable mocha-cleanup/asserts-limit */ it('should add custom Property to customProperties', function () { - controller.set('newCustomProperty', {name: 'n1', value: 'v1'}); controller.addCustomProperty(); helpers.nestedExpect([{name: 'n1', value: 'v1', defaultValue: 'v1'}], controller.get('inputFields.customProperties')); - }); + /*eslint-enable mocha-cleanup/asserts-limit */ }); @@ -964,8 +964,8 @@ describe('App.ManageAlertNotificationsController', function () { ]); }); + /*eslint-disable mocha-cleanup/asserts-limit */ it('should remove selected custom property', function () { - controller.removeCustomPropertyHandler({context: c}); helpers.nestedExpect( [ @@ -974,8 +974,8 @@ describe('App.ManageAlertNotificationsController', function () { ], controller.get('inputFields.customProperties') ); - }); + /*eslint-enable mocha-cleanup/asserts-limit */ }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js index 8d724d2..660e767 100644 --- a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js +++ b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js @@ -38,7 +38,7 @@ describe('MainChartHeatmapMetric', function () { expect(mainChartHeatmapMetric.formatLegendNumber(test.i)).to.equal(test.e); }); }); - it('NaN to NaN' + ' ', function () { + it('NaN to NaN', function () { expect(isNaN(mainChartHeatmapMetric.formatLegendNumber(NaN))).to.equal(true); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/charts/heatmap_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/charts/heatmap_test.js b/ambari-web/test/controllers/main/charts/heatmap_test.js index ec87ace..c3e70e8 100644 --- a/ambari-web/test/controllers/main/charts/heatmap_test.js +++ b/ambari-web/test/controllers/main/charts/heatmap_test.js @@ -366,9 +366,9 @@ describe('MainChartsHeatmapController', function () { {rack: 'r1'} ]; var rackMap = controller.indexByRackId(hosts); - expect(rackMap['r1'].name).to.equal('r1'); - expect(rackMap['r1'].rackId).to.equal('r1'); - expect(rackMap['r1'].hosts).to.eql([{rack: 'r1'}, {rack: 'r1'}]); + expect(rackMap.r1.name).to.equal('r1'); + expect(rackMap.r1.rackId).to.equal('r1'); + expect(rackMap.r1.hosts).to.eql([{rack: 'r1'}, {rack: 'r1'}]); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/host/details_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/host/details_test.js b/ambari-web/test/controllers/main/host/details_test.js index f4f0b33..a108c8d 100644 --- a/ambari-web/test/controllers/main/host/details_test.js +++ b/ambari-web/test/controllers/main/host/details_test.js @@ -827,10 +827,7 @@ describe('App.MainHostDetailsController', function () { describe('#showAddComponentPopup()', function () { - var message = 'Comp1', - component = Em.Object.create({ - componentName: ' Comp1' - }); + var message = 'Comp1'; beforeEach(function () { sinon.spy(App.ModalPopup, 'show'); @@ -857,7 +854,6 @@ describe('App.MainHostDetailsController', function () { }); it('data is null', function () { - var data = {Requests: null}; expect(controller.installNewComponentSuccessCallback(null, {}, {})).to.be.false; expect(controller.showBackgroundOperationsPopup.called).to.be.false; }); @@ -2152,7 +2148,7 @@ describe('App.MainHostDetailsController', function () { this.stub = sinon.stub(App.HostComponent, 'find').returns([{ id: 'TASKTRACKER_host1', componentName: 'TASKTRACKER' - }]);; + }]); }); afterEach(function () { @@ -3065,7 +3061,7 @@ describe('App.MainHostDetailsController', function () { describe(item.title, function () { beforeEach(function () { - sinon.stub(controller, 'checkComponentDependencies', function (componentName, params) { + sinon.stub(controller, 'checkComponentDependencies', function (componentName) { return item.dependencies[componentName]; }); controller.installClients({ @@ -3578,7 +3574,7 @@ describe('App.MainHostDetailsController', function () { describe("#removeHostComponentModel()", function () { beforeEach(function () { - App.cache['services'] = [ + App.cache.services = [ { ServiceInfo: { service_name: 'S1' @@ -3604,7 +3600,7 @@ describe('App.MainHostDetailsController', function () { App.serviceMapper.deleteRecord.restore(); }); it("App.cache is updated", function () { - expect(App.cache['services'][0].host_components).to.be.empty; + expect(App.cache.services[0].host_components).to.be.empty; }); it('Record is deleted', function () { expect(App.serviceMapper.deleteRecord.calledOnce).to.be.true; @@ -3823,8 +3819,8 @@ describe('App.MainHostDetailsController', function () { var makeHostComponentModel = function(componentName, hostNames) { if (Em.isArray(componentName)) { - return componentName.map(function(componentName, index) { - return makeHostComponentModel(componentName, hostNames[index]); + return componentName.map(function(cName, index) { + return makeHostComponentModel(cName, hostNames[index]); }).reduce(function(p,c) { return p.concat(c); }, []); } return hostNames.map(function(hostName) { http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/host_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/host_test.js b/ambari-web/test/controllers/main/host_test.js index 59ca14b..386434b 100644 --- a/ambari-web/test/controllers/main/host_test.js +++ b/ambari-web/test/controllers/main/host_test.js @@ -17,7 +17,6 @@ */ var App = require('app'); -var validator = require('utils/validator'); require('utils/batch_scheduled_requests'); require('controllers/main/host'); require('mappers/server_data_mapper'); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/service/add_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/add_controller_test.js b/ambari-web/test/controllers/main/service/add_controller_test.js index 601d7d8..3c7639c 100644 --- a/ambari-web/test/controllers/main/service/add_controller_test.js +++ b/ambari-web/test/controllers/main/service/add_controller_test.js @@ -381,7 +381,7 @@ describe('App.AddServiceController', function() { sinon.stub(this.controller, 'setDBProperty', function(key, value) { mock.db = value; }); - this.mockStackService = sinon.stub(App.StackService, 'find'); + this.mockStackService = sinon.stub(App.StackService, 'find'); this.mockService = sinon.stub(App.Service, 'find'); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/service/info/config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js index 60aa8d6..9ebd914 100644 --- a/ambari-web/test/controllers/main/service/info/config_test.js +++ b/ambari-web/test/controllers/main/service/info/config_test.js @@ -127,7 +127,7 @@ describe("App.MainServiceInfoConfigsController", function () { passwordConfigsAreChanged: false }); sinon.stub(mainServiceInfoConfigsController, "get", function(key) { - return key == 'isSubmitDisabled' ? false : Em.get(mainServiceInfoConfigsController, key); + return key === 'isSubmitDisabled' ? false : Em.get(mainServiceInfoConfigsController, key); }); sinon.stub(mainServiceInfoConfigsController, "restartServicePopup", Em.K); sinon.stub(mainServiceInfoConfigsController, "getHash", function () { @@ -340,7 +340,7 @@ describe("App.MainServiceInfoConfigsController", function () { mainServiceInfoConfigsController.set("content.displayName", t.displayName); mainServiceInfoConfigsController.set("content.passiveState", t.passiveState); mainServiceInfoConfigsController.rollingRestartStaleConfigSlaveComponents(t.componentName); - expect(batchUtils.launchHostComponentRollingRestart.calledWith(t.componentName.context, t.displayName, t.passiveState == "ON", true)).to.equal(true); + expect(batchUtils.launchHostComponentRollingRestart.calledWith(t.componentName.context, t.displayName, t.passiveState === "ON", true)).to.equal(true); }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/service/info/summary_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/info/summary_test.js b/ambari-web/test/controllers/main/service/info/summary_test.js index 3db7239..868cf67 100644 --- a/ambari-web/test/controllers/main/service/info/summary_test.js +++ b/ambari-web/test/controllers/main/service/info/summary_test.js @@ -288,11 +288,11 @@ App.TestAliases.testAsComputedOr(getController(), 'showTimeRangeControl', ['!isS App.ajax.send.restore(); }); it("make GET call", function () { - var controller = App.MainServiceInfoSummaryController.create({ + var _controller = App.MainServiceInfoSummaryController.create({ isServiceWithEnhancedWidgets: true, content: Em.Object.create({serviceName: 'HDFS'}) }); - controller.getActiveWidgetLayout(); + _controller.getActiveWidgetLayout(); expect(App.ajax.send.getCall(0).args[0].name).to.equal('widgets.layouts.active.get'); }); }); @@ -307,14 +307,14 @@ App.TestAliases.testAsComputedOr(getController(), 'showTimeRangeControl', ['!isS App.widgetMapper.map.restore(); }); it("isWidgetLayoutsLoaded should be set to true", function () { - var controller = App.MainServiceInfoSummaryController.create({ + var _controller = App.MainServiceInfoSummaryController.create({ isServiceWithEnhancedWidgets: true, content: Em.Object.create({serviceName: 'HDFS'}) }); - controller.getActiveWidgetLayoutSuccessCallback({items:[{ + _controller.getActiveWidgetLayoutSuccessCallback({items:[{ WidgetLayoutInfo: {} }]}); - expect(controller.get('isWidgetsLoaded')).to.be.true; + expect(_controller.get('isWidgetsLoaded')).to.be.true; }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/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 8b2f24e..7b75dbb 100644 --- a/ambari-web/test/controllers/main/service/item_test.js +++ b/ambari-web/test/controllers/main/service/item_test.js @@ -251,88 +251,6 @@ describe('App.MainServiceItemController', function () { }); }); - describe("#startStopPopupPrimary", function () { - - var mainServiceItemController; - var tests = [ - { - data: { - "serviceName": "HDFS", - "state": "STARTED", - "query": Em.Object.create({ServiceInfo: "FAIL"}) - }, - request: { - "RequestInfo": { - "context": "_PARSE_.START.HDFS" - }, - "Body": { - "ServiceInfo": { - "state": "STARTED" - } - } - }, - m: "Start HDFS" - }, - { - data: { - "serviceName": "YARN", - "state": "STOPPED", - "query": Em.Object.create({ServiceInfo: "FAIL"}) - }, - request: { - "RequestInfo": { - "context": "_PARSE_.STOP.YARN" - }, - "Body": { - "ServiceInfo": { - "state": "STOPPED" - } - } - }, - m: "Stop YARN" - } - ]; - - beforeEach(function () { - sinon.spy($, 'ajax'); - }); - - afterEach(function () { - $.ajax.restore(); - }); - - - tests.forEach(function (test, index) { - - describe('case #' + (index + 1), function () { - - beforeEach(function () { - mainServiceItemController = App.MainServiceItemController.create({content: {serviceName: test.data.serviceName}}); - mainServiceItemController.startStopPopupPrimary(test.data.state, test.data.query); - this.data = JSON.parse($.ajax.args[0][0].data); - }); - - it('request is sent with valid data ' + (index + 1), function () { - expect($.ajax.calledOnce).to.equal(true); - expect(this.data.Body.ServiceInfo.state).to.equal(test.request.Body.ServiceInfo.state); - expect(this.data.RequestInfo.context).to.equal(test.request.RequestInfo.context); - }); - - it('isStopDisabled is true ' + (index + 1), function () { - expect(mainServiceItemController.get('isStopDisabled')).to.equal(true); - }); - - it('isStartDisabled is true ' + (index + 1), function () { - expect(mainServiceItemController.get('isStartDisabled')).to.equal(true); - }); - - }); - - }); - - - }); - describe("#startService , #stopService", function () { var mainServiceItemController = App.MainServiceItemController.create({startStopPopup: Em.K}); beforeEach(function () { @@ -516,16 +434,15 @@ describe('App.MainServiceItemController', function () { }); it ("should not display a dependent list if it is to start a service", function() { - var mainServiceItemController = App.MainServiceItemController.create( + var _mainServiceItemController = App.MainServiceItemController.create( {content: {serviceName: "HDFS", passiveState:'OFF'}}); - mainServiceItemController.startStopPopup(event, ""); + _mainServiceItemController.startStopPopup(event, ""); 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() { - var mainServiceItemController; beforeEach(function () { - mainServiceItemController = App.MainServiceItemController.create( + var _mainServiceItemController = App.MainServiceItemController.create( {content: { serviceName: "HDFS", passiveState:'OFF', @@ -535,10 +452,10 @@ describe('App.MainServiceItemController', function () { }] }} ); - mainServiceItemController.startStopPopup(event, "INSTALLED"); + _mainServiceItemController.startStopPopup(event, "INSTALLED"); this.dependencies = Em.I18n.t('services.service.stop.warningMsg.dependent.services').format("HDFS", "HBase,YARN"); this.msg = Em.I18n.t('services.service.stop.warningMsg.turnOnMM').format("HDFS"); - this.fullMsg = mainServiceItemController.addAdditionalWarningMessage("INSTALLED", this.msg, "HDFS"); + this.fullMsg = _mainServiceItemController.addAdditionalWarningMessage("INSTALLED", this.msg, "HDFS"); }); it('turnOnMM message is shown', function () { @@ -555,12 +472,12 @@ describe('App.MainServiceItemController', function () { describe("should display the dependent service if another service depends on the one to be stopped", function() { beforeEach(function () { - var mainServiceItemController = App.MainServiceItemController.create( + var _mainServiceItemController = App.MainServiceItemController.create( {content: {serviceName: "HIVE", passiveState:'OFF'}}); - mainServiceItemController.startStopPopup(event, "INSTALLED"); + _mainServiceItemController.startStopPopup(event, "INSTALLED"); this.dependencies = Em.I18n.t('services.service.stop.warningMsg.dependent.services').format("HIVE", "Spark"); this.msg = Em.I18n.t('services.service.stop.warningMsg.turnOnMM').format("HIVE"); - this.fullMsg = mainServiceItemController.addAdditionalWarningMessage("INSTALLED", this.msg, "HIVE"); + this.fullMsg = _mainServiceItemController.addAdditionalWarningMessage("INSTALLED", this.msg, "HIVE"); }); it('message about dependent services is shown', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js index 0cc0f5f..119547f 100644 --- a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js +++ b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js @@ -194,7 +194,7 @@ describe('App.ManageConfigGroupsController', function() { var service = Em.Object.create({}); manageConfigGroupsController.set('hostsModifiedConfigGroups', {}); describe("#controller passed", function () { - var controller = Em.Object.create({ + controller = Em.Object.create({ content: Em.Object.create() }); var popup = manageConfigGroupsController.manageConfigurationGroups(controller, service); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/service/reassign/step1_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/reassign/step1_controller_test.js b/ambari-web/test/controllers/main/service/reassign/step1_controller_test.js index dee3251..f4a9714 100644 --- a/ambari-web/test/controllers/main/service/reassign/step1_controller_test.js +++ b/ambari-web/test/controllers/main/service/reassign/step1_controller_test.js @@ -92,7 +92,6 @@ describe('App.ReassignMasterWizardStep1Controller', function () { describe('#onLoadConfigs', function() { - var controller; var reassignCtrl; beforeEach(function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js b/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js index 7521d93..4483f94 100644 --- a/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js +++ b/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js @@ -35,7 +35,6 @@ describe('App.ReassignMasterWizardStep2Controller', function () { describe('#customClientSideValidation', function () { var hostComponents = []; - var isSubmitDisabled = false; beforeEach(function () { sinon.stub(App.HostComponent, 'find', function () { @@ -89,8 +88,6 @@ describe('App.ReassignMasterWizardStep2Controller', function () { }); it('submitDisabled is already true', function () { - isSubmitDisabled = true; - expect(controller.customClientSideValidation()).to.be.false; }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js b/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js index 7ea47c6..11bcae7 100644 --- a/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js +++ b/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js @@ -549,7 +549,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () { }); describe('#getConfigUrlParams()', function () { - var testCases = [ + var testCases = [ { componentName: 'NAMENODE', result: [ @@ -1577,7 +1577,7 @@ describe('App.ReassignMasterWizardStep4Controller', function () { }); - describe("#prepareDBCheckAction()", function() { + describe.skip("#prepareDBCheckAction()", function() { beforeEach(function () { sinon.stub(App.router, 'get').returns({ 'jdk_location': 'jdk_location', http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js b/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js index e860660..70a160b 100644 --- a/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js +++ b/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js @@ -263,7 +263,7 @@ describe('App.WidgetWizardStep2Controller', function () { }); it('check id', function () { - expect(controller.get('expressions').mapProperty('id')).to.eql([1, 2]);; + expect(controller.get('expressions').mapProperty('id')).to.eql([1, 2]); }); it('check isRemovable', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/service/widgets/create/wizard_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/widgets/create/wizard_controller_test.js b/ambari-web/test/controllers/main/service/widgets/create/wizard_controller_test.js index 83ce39f..4733716 100644 --- a/ambari-web/test/controllers/main/service/widgets/create/wizard_controller_test.js +++ b/ambari-web/test/controllers/main/service/widgets/create/wizard_controller_test.js @@ -37,9 +37,11 @@ describe('App.WidgetWizardController', function () { beforeEach(function () { controller = App.WidgetWizardController.create(); sinon.stub(App.YARNService, 'find', function (k) { - if ('YARN' === k) return Em.Object.create({ - 'allQueueNames': ["root", "root/queue1", "root/queue1/queue2", "root/queue1/queue3"] - }); + if ('YARN' === k) { + return Em.Object.create({ + 'allQueueNames': ["root", "root/queue1", "root/queue1/queue2", "root/queue1/queue3"] + }); + } }); }); afterEach(function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main/service_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service_test.js b/ambari-web/test/controllers/main/service_test.js index f9e6e8b..0e7f464 100644 --- a/ambari-web/test/controllers/main/service_test.js +++ b/ambari-web/test/controllers/main/service_test.js @@ -110,7 +110,7 @@ describe('App.MainServiceController', function () { describe('#cluster', function() { - var tests = Em.A([ + Em.A([ { isLoaded: true, cluster: [], http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/main_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main_test.js b/ambari-web/test/controllers/main_test.js index 2a4fe97..0061695 100644 --- a/ambari-web/test/controllers/main_test.js +++ b/ambari-web/test/controllers/main_test.js @@ -111,7 +111,6 @@ describe('App.MainController', function () { }); describe('#checkServerClientVersion', function() { - var initialize = false; beforeEach(function () { sinon.stub(mainController, 'getServerVersion').returns({ done: function(func) { @@ -156,14 +155,14 @@ describe('App.MainController', function () { }); }); - describe('#updateTitle', function() { + describe.skip('#updateTitle', function() { beforeEach(function () { sinon.stub(App.router, 'get', function(message){ - if (message == 'clusterController.clusterName') { + if (message === 'clusterController.clusterName') { return 'c1'; - } else if (message == 'clusterInstallCompleted') { + } else if (message === 'clusterInstallCompleted') { return true; - } else if (message == 'clusterController') { + } else if (message === 'clusterController') { return { get: function() { return true; @@ -175,7 +174,7 @@ describe('App.MainController', function () { afterEach(function () { App.router.get.restore(); }); - it ('Should update title', function() { + it('Should update title', function() { $('body').append('<title id="title-id">text</title>'); mainController.updateTitle(); expect($('title').text()).to.be.equal('Ambari - c1'); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/wizard/step10_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step10_test.js b/ambari-web/test/controllers/wizard/step10_test.js index 92743c3..1d9244c 100644 --- a/ambari-web/test/controllers/wizard/step10_test.js +++ b/ambari-web/test/controllers/wizard/step10_test.js @@ -410,7 +410,7 @@ describe('App.WizardStep10Controller', function () { tests.forEach(function(test) { it('Install time' + test.installTime ? ' available' : ' not available', function() { controller.set('content', {cluster: {installTime: test.installTime}}); - var r = controller.loadInstallTime(); + controller.loadInstallTime(); expect(controller.get('clusterInfo').mapProperty('id')).to.eql(test.e); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/wizard/step2_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step2_test.js b/ambari-web/test/controllers/wizard/step2_test.js index 843e4c2..1a67ca9 100644 --- a/ambari-web/test/controllers/wizard/step2_test.js +++ b/ambari-web/test/controllers/wizard/step2_test.js @@ -17,7 +17,6 @@ */ var App = require('app'); -var Ember = require('ember'); require('controllers/wizard/step2_controller'); require('models/host'); require('models/host_component'); @@ -412,7 +411,7 @@ describe('App.WizardStep2Controller', function () { var result = true; var hosts = controller.get('hostNameArr'); for (var i = 1; i<12; i++) { - var extra = (i.toString().length == 1) ? 0 : ''; + var extra = i.toString().length === 1 ? 0 : ''; if (hosts[i-1] !== 'host0' + extra + i) { result = false; } http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/wizard/step3_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step3_test.js b/ambari-web/test/controllers/wizard/step3_test.js index ca710f3..7b6684f 100644 --- a/ambari-web/test/controllers/wizard/step3_test.js +++ b/ambari-web/test/controllers/wizard/step3_test.js @@ -73,7 +73,7 @@ describe('App.WizardStep3Controller', function () { Em.Object.create({name: 'wst3_host2'}) ] }); - var test_data = { + var testData = { items: [ { Hosts: { @@ -92,7 +92,7 @@ describe('App.WizardStep3Controller', function () { } ] }; - c.getAllRegisteredHostsCallback(test_data); + c.getAllRegisteredHostsCallback(testData); expect(c.get('hasMoreRegisteredHosts')).to.equal(true); expect(c.get('registeredHosts').length).to.equal(1); }); @@ -107,7 +107,7 @@ describe('App.WizardStep3Controller', function () { {name: 'wst3_host4'} ] }); - var test_data = { + var testData = { items: [ { Hosts: { @@ -121,7 +121,7 @@ describe('App.WizardStep3Controller', function () { } ] }; - c.getAllRegisteredHostsCallback(test_data); + c.getAllRegisteredHostsCallback(testData); expect(c.get('hasMoreRegisteredHosts')).to.equal(false); expect(c.get('registeredHosts')).to.equal(''); }); @@ -135,7 +135,7 @@ describe('App.WizardStep3Controller', function () { {name: 'wst3_host1'} ] }); - var test_data = { + var testData = { items: [ { Hosts: { @@ -144,7 +144,7 @@ describe('App.WizardStep3Controller', function () { } ] }; - c.getAllRegisteredHostsCallback(test_data); + c.getAllRegisteredHostsCallback(testData); expect(c.get('hasMoreRegisteredHosts')).to.equal(false); expect(c.get('registeredHosts')).to.equal(''); }); @@ -2738,8 +2738,7 @@ describe('App.WizardStep3Controller', function () { it('should do request to ambari-server', function () { var data = null, - jdkRequestIndex = 'jdkRequestIndex', - url = '/requests/' + jdkRequestIndex + '?fields=*,tasks/Tasks/host_name,tasks/Tasks/status,tasks/Tasks/structured_out'; + jdkRequestIndex = 'jdkRequestIndex'; c.set('jdkRequestIndex', jdkRequestIndex); c.set('jdkCategoryWarnings', null); c.doCheckJDKsuccessCallback(data); @@ -2751,11 +2750,9 @@ describe('App.WizardStep3Controller', function () { describe('#doCheckJDKerrorCallback', function () { it('should set isJDKWarningsLoaded to true', function () { - c.set('isJDKWarningsLoaded', false); c.doCheckJDKerrorCallback(); - c.set('isJDKWarningsLoaded', true); - + expect(c.get('isJDKWarningsLoaded')).to.be.true; }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/wizard/step4_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step4_test.js b/ambari-web/test/controllers/wizard/step4_test.js index b6b99bb..9227279 100644 --- a/ambari-web/test/controllers/wizard/step4_test.js +++ b/ambari-web/test/controllers/wizard/step4_test.js @@ -40,7 +40,7 @@ describe('App.WizardStep4Controller', function () { 'isSelected': false, 'canBeSelected': true, 'isInstalled': false, - isPrimaryDFS: serviceName == 'HDFS', + isPrimaryDFS: serviceName === 'HDFS', isDFS: ['HDFS','GLUSTERFS'].contains(serviceName), isMonitoringService: ['GANGLIA'].contains(serviceName), requiredServices: App.StackService.find(serviceName).get('requiredServices'), @@ -58,7 +58,7 @@ describe('App.WizardStep4Controller', function () { return allServices; }; - services.forEach(function(serviceName, index){ + services.forEach(function(serviceName) { controller.pushObject(Ember.Object.create({ 'serviceName':serviceName, 'isSelected': true, 'isHiddenOnSelectServicePage': false, 'isInstalled': false, 'isDisabled': 'HDFS' === serviceName, isDFS: 'HDFS' === serviceName })); @@ -164,22 +164,25 @@ describe('App.WizardStep4Controller', function () { beforeEach(function () { controller.clear(); - for(var id in testCase.condition) { + Object.keys(testCase.condition).forEach(function (id) { controller.pushObject(Ember.Object.create({ - 'serviceName':id, 'isSelected': testCase.condition[id], 'canBeSelected': true, 'isInstalled': false, + serviceName: id, + isSelected: testCase.condition[id], + canBeSelected: true, + isInstalled: false, coSelectedServices: function() { return App.StackService.coSelected[this.get('serviceName')] || []; }.property('serviceName') })); - } + }); controller.setGroupedServices(); }); - for(var service in testCase.result) { + Object.keys(testCase.result).forEach(function (service) { it(service, function () { expect(controller.findProperty('serviceName', service).get('isSelected')).to.equal(testCase.result[service]); }); - } + }); }); }, this); }); @@ -335,7 +338,7 @@ describe('App.WizardStep4Controller', function () { controllerNames.forEach(function (name) { tests.forEach(function(test) { var errorsExpected = test.errorsExpected; - if (name != 'installerController') { + if (name !== 'installerController') { errorsExpected = test.errorsExpected.without('ambariMetricsCheck'); } var message = '{0}, {1} selected validation should be {2}, errors: {3}' @@ -442,7 +445,7 @@ describe('App.WizardStep4Controller', function () { beforeEach(function () { currentErrorObject = c.get('errorStack').findProperty('isShown', false); }); - test.errorsExpected.forEach(function(error, index, errors) { + test.errorsExpected.forEach(function(error) { it(error, function () { // validate current error if (currentErrorObject) { http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/wizard/step5_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step5_test.js b/ambari-web/test/controllers/wizard/step5_test.js index 033b067..e0f8b71 100644 --- a/ambari-web/test/controllers/wizard/step5_test.js +++ b/ambari-web/test/controllers/wizard/step5_test.js @@ -16,7 +16,6 @@ * limitations under the License. */ -var Ember = require('ember'); var App = require('app'); require('controllers/wizard/step5_controller'); var modelSetup = require('test/init_model_test'); @@ -30,7 +29,6 @@ describe('App.WizardStep5Controller', function () { var controller = App.WizardStep5Controller.create(); controller.set('content', {}); - var cpu = 2, memory = 4; controller.set('content', {}); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/wizard/step6_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step6_test.js b/ambari-web/test/controllers/wizard/step6_test.js index e18d991..4fdd642 100644 --- a/ambari-web/test/controllers/wizard/step6_test.js +++ b/ambari-web/test/controllers/wizard/step6_test.js @@ -90,13 +90,13 @@ describe('App.WizardStep6Controller', function () { describe('#installedServiceNames', function () { it(' should filter content.services by isInstalled property', function () { - var services = Em.A([]); - services.pushObjects(Em.A([{isInstalled: true, serviceName: "service1"}, + var _services = Em.A([]); + _services.pushObjects(Em.A([{isInstalled: true, serviceName: "service1"}, {isInstalled: false, serviceName: "service2"}, {isInstalled: true, serviceName: "service3"}, {isInstalled: false, serviceName: "service4"}, {isInstalled: true, serviceName: "service5"}])); - controller.set('content.services', services); + controller.set('content.services', _services); expect(controller.get('installedServiceNames')).to.eql(["service1", "service3", "service5"]); }); }); @@ -588,7 +588,7 @@ describe('App.WizardStep6Controller', function () { beforeEach(function () { sinon.stub(validationUtils, 'filterNotInstalledComponents', function () { - return Em.A([Em.Object.create({ + return Em.A([Em.Object.create({ componentName: 'c0', isSlave: true, type: 'host-component', http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/wizard/step7_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js index a6a5fab..2d82cbc 100644 --- a/ambari-web/test/controllers/wizard/step7_test.js +++ b/ambari-web/test/controllers/wizard/step7_test.js @@ -262,7 +262,7 @@ describe('App.InstallerStep7Controller', function () { describe('#_createSiteToTagMap', function () { it('should return filtered map', function () { - var desired_configs = { + var desiredConfigs = { site1: { tag: "tag1" }, @@ -277,7 +277,7 @@ describe('App.InstallerStep7Controller', function () { site1: true, site3: true }; - var siteToTagMap = installerStep7Controller._createSiteToTagMap(desired_configs,sites); + var siteToTagMap = installerStep7Controller._createSiteToTagMap(desiredConfigs,sites); expect(siteToTagMap).to.eql({ site1: "tag1", site3: "tag3" @@ -363,7 +363,7 @@ describe('App.InstallerStep7Controller', function () { }); it('should return serviceConfigTags', function () { - var desired_configs = { + var desiredConfigs = { site1: { tag: "tag1" }, @@ -376,10 +376,10 @@ describe('App.InstallerStep7Controller', function () { }; var data = { Clusters: { - desired_configs: desired_configs + desired_configs: desiredConfigs } }; - var siteToTagMap = installerStep7Controller.getConfigTagsSuccess(data); + installerStep7Controller.getConfigTagsSuccess(data); expect(installerStep7Controller.get('serviceConfigTags')).to.eql([ { "siteName": "site1", @@ -541,8 +541,7 @@ describe('App.InstallerStep7Controller', function () { {isDefault: false, n: 'n1'}, defaultGroup, {n: 'n3'} - ], - selectedConfigGroup = {}; + ]; installerStep7Controller.reopen({selectedService: {serviceName: 's1', configGroups: configGroups}}); installerStep7Controller.selectedServiceObserver(); expect(installerStep7Controller.get('configGroups').mapProperty('n')).to.eql(['n2', 'n1', 'n3']); @@ -1517,7 +1516,7 @@ describe('App.InstallerStep7Controller', function () { }); installerStep7Controller.set('wizardController', wizardController); installerStep7Controller.set('stepConfigs', Em.A([Em.Object.create({serviceName: 'OOZIE', configs: Em.A([]) })])); - var desired_configs = { + var desiredConfigs = { site1: { tag: "tag1" }, @@ -1543,7 +1542,7 @@ describe('App.InstallerStep7Controller', function () { }) })]), Clusters: { - desired_configs: desired_configs + desired_configs: desiredConfigs } }; installerStep7Controller.loadServiceTagsSuccess(data, {}, params); @@ -1687,14 +1686,16 @@ describe('App.InstallerStep7Controller', function () { recommendedValue: 'c6402.ambari.apache.org:50070' } ]; + var oldConfigs = configs.slice(); it('should copy properties from hdfs-site to hdfs-client for HAWQ', function() { - var oldConfigs = configs.slice(); installerStep7Controller.addHawqConfigsOnNnHa(configs); // ensure 6 new configs were added expect(configs.length - oldConfigs.length).to.be.eql(6); - oldConfigs.forEach(function(property){ - // find the same property in hdfs-client for HAWQ and see if attribute value matches with the corresponding property's attribute value in hdfs-site + }); + + it('find the same property in hdfs-client for HAWQ and see if attribute value matches with the corresponding property\'s attribute value in hdfs-site', function () { + oldConfigs.forEach(function(property) { expect(configs.findProperty('id', property.name + '__hdfs-client').description).to.be.eql(property.description); expect(configs.findProperty('id', property.name + '__hdfs-client').displayName).to.be.eql(property.displayName); expect(configs.findProperty('id', property.name + '__hdfs-client').value).to.be.eql(property.value); @@ -1719,26 +1720,32 @@ describe('App.InstallerStep7Controller', function () { } ]; - it('should update properties in yarn-client for HAWQ if yarn ha is enabled', function() { - var inputConfigsCount = configs.length; + beforeEach(function () { + this.inputConfigsCount = configs.length; installerStep7Controller.addHawqConfigsOnRMHa(configs); - var yarnRmDetails = configs.findProperty('id', 'yarn.resourcemanager.ha__yarn-client'); - var yarnRmSchedulerDetails = configs.findProperty('id', 'yarn.resourcemanager.scheduler.ha__yarn-client'); + this.yarnRmDetails = configs.findProperty('id', 'yarn.resourcemanager.ha__yarn-client'); + this.yarnRmSchedulerDetails = configs.findProperty('id', 'yarn.resourcemanager.scheduler.ha__yarn-client'); + }); + it('should update properties in yarn-client for HAWQ if yarn ha is enabled', function() { + var noOfConfigsAdded = 2; + expect(configs.length).to.be.equal(this.inputConfigsCount + noOfConfigsAdded); + }); + + it('yarn.resourcemanager.ha__yarn-client', function() { var expectedYarnRmHaValue = 'c6401.ambari.apache.org:8032,c6402.ambari.apache.org:8032'; - expect(yarnRmDetails.value).to.be.eql(expectedYarnRmHaValue); - expect(yarnRmDetails.recommendedValue).to.be.eql(expectedYarnRmHaValue); - expect(yarnRmDetails.displayName).to.be.eql('yarn.resourcemanager.ha'); - expect(yarnRmDetails.description).to.be.eql('Comma separated yarn resourcemanager host addresses with port'); + expect(this.yarnRmDetails.value).to.be.equal(expectedYarnRmHaValue); + expect(this.yarnRmDetails.recommendedValue).to.be.equal(expectedYarnRmHaValue); + expect(this.yarnRmDetails.displayName).to.be.equal('yarn.resourcemanager.ha'); + expect(this.yarnRmDetails.description).to.be.equal('Comma separated yarn resourcemanager host addresses with port'); + }); + it('yarn.resourcemanager.scheduler.ha__yarn-client', function() { var expectedYarnRmSchedulerValue = 'c6401.ambari.apache.org:8030,c6402.ambari.apache.org:8030'; - expect(yarnRmSchedulerDetails.value).to.be.eql(expectedYarnRmSchedulerValue); - expect(yarnRmSchedulerDetails.recommendedValue).to.be.eql(expectedYarnRmSchedulerValue); - expect(yarnRmSchedulerDetails.displayName).to.be.eql('yarn.resourcemanager.scheduler.ha'); - expect(yarnRmSchedulerDetails.description).to.be.eql('Comma separated yarn resourcemanager scheduler addresses with port'); - - var noOfConfigsAdded = 2; - expect(configs.length).to.be.eql(inputConfigsCount + noOfConfigsAdded) ; + expect(this.yarnRmSchedulerDetails.value).to.be.equal(expectedYarnRmSchedulerValue); + expect(this.yarnRmSchedulerDetails.recommendedValue).to.be.equal(expectedYarnRmSchedulerValue); + expect(this.yarnRmSchedulerDetails.displayName).to.be.equal('yarn.resourcemanager.scheduler.ha'); + expect(this.yarnRmSchedulerDetails.description).to.be.equal('Comma separated yarn resourcemanager scheduler addresses with port'); }); }); @@ -1776,20 +1783,43 @@ describe('App.InstallerStep7Controller', function () { } ]; - it('should add three security related configs for HAWQ if Kerberos is enabled', function () { - var originalConfigsLength = configs.length; + beforeEach(function () { + this.originalConfigsLength = configs.length; installerStep7Controller.addHawqConfigsOnKerberizedCluster(configs); + }); + + it('should add three security related configs for HAWQ if Kerberos is enabled', function () { // ensure 3 new configs are added - expect(configs.length - originalConfigsLength).to.be.eql(3); - // check if all three new properties were added - secureProperties.forEach(function (newProperty) { - var newPropertyAdded = configs.findProperty('id', newProperty.name + '__' + newProperty.file); - expect(newPropertyAdded.name).to.be.eql(newProperty.name); - expect(newPropertyAdded.displayName).to.be.eql(newProperty.name); - expect(newPropertyAdded.value).to.be.eql(newProperty.value); - expect(newPropertyAdded.recommendedValue).to.be.eql(newProperty.value); - expect(newPropertyAdded.isOverridable).to.be.eql(newProperty.isOverridable); - expect(newPropertyAdded.isReconfigurable).to.be.eql(newProperty.isReconfigurable); + expect(configs.length - this.originalConfigsLength).to.be.eql(3); + }); + + // check if all three new properties were added + secureProperties.forEach(function (newProperty) { + var id = newProperty.name + '__' + newProperty.file; + describe(id, function () { + + beforeEach(function () { + this.newPropertyAdded = configs.findProperty('id', id); + }); + + it('#name', function () { + expect(this.newPropertyAdded.name).to.be.equal(newProperty.name); + }); + it('#displayName', function () { + expect(this.newPropertyAdded.displayName).to.be.equal(newProperty.name); + }); + it('#value', function () { + expect(this.newPropertyAdded.value).to.be.equal(newProperty.value); + }); + it('#recommendedValue', function () { + expect(this.newPropertyAdded.recommendedValue).to.be.equal(newProperty.value); + }); + it('#isOverridable', function () { + expect(this.newPropertyAdded.isOverridable).to.be.equal(newProperty.isOverridable); + }); + it('#isReconfigurable', function () { + expect(this.newPropertyAdded.isReconfigurable).to.be.equal(newProperty.isReconfigurable); + }); }); }); }); @@ -2320,8 +2350,6 @@ describe('App.InstallerStep7Controller', function () { describe('#addServiceController', function () { - var installedServices = []; - beforeEach(function () { installerStep7Controller.set('wizardController', {name: 'addServiceController'}); this.stub = sinon.stub(App.configsCollection, 'getConfigByName'); http://git-wip-us.apache.org/repos/asf/ambari/blob/c263626e/ambari-web/test/controllers/wizard/step8_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js index 14b7293..62168b6 100644 --- a/ambari-web/test/controllers/wizard/step8_test.js +++ b/ambari-web/test/controllers/wizard/step8_test.js @@ -17,7 +17,6 @@ */ var App = require('app'); -var modelSetup = require('test/init_model_test'); require('utils/ajax/ajax_queue'); require('controllers/main/service/info/configs'); require('controllers/wizard/step8_controller'); @@ -432,10 +431,10 @@ describe('App.WizardStep8Controller', function () { isNotDefaultValue: false }) }); - var configs = Em.A([Em.Object.create({ + var _configs = Em.A([Em.Object.create({ name: 'property' })]); - expect(installerStep8Controller.isConfigsChanged(properties,configs)).to.be.true; + expect(installerStep8Controller.isConfigsChanged(properties, _configs)).to.be.true; }); }); @@ -1186,7 +1185,7 @@ describe('App.WizardStep8Controller', function () { installerStep8Controller.deleteClusters(clusterNames); expect(App.ajax.send.callCount).to.equal(clusterNames.length); clusterNames.forEach(function(n, i) { - expect(App.ajax.send.getCall(i).args[0].data).to.eql({name: n, isLast: i == clusterNames.length - 1}); + expect(App.ajax.send.getCall(i).args[0].data).to.eql({name: n, isLast: i === clusterNames.length - 1}); }); }); @@ -1199,7 +1198,7 @@ describe('App.WizardStep8Controller', function () { describe('#createStormSiteObj', function() { it('should replace quote \'"\' to "\'" for some properties', function() { - var configs = [ + var _configs = [ {filename: 'storm-site.xml', value: ["a", "b"], name: 'storm.zookeeper.servers'} ], expected = { @@ -1209,12 +1208,12 @@ describe('App.WizardStep8Controller', function () { 'storm.zookeeper.servers': '[\'a\',\'b\']' } }; - installerStep8Controller.reopen({configs: configs}); + installerStep8Controller.reopen({configs: _configs}); expect(installerStep8Controller.createStormSiteObj('version1')).to.eql(expected); }); it('should not escape special characters', function() { - var configs = [ + var _configs = [ {filename: 'storm-site.xml', value: "abc\n\t", name: 'nimbus.childopts'}, {filename: 'storm-site.xml', value: "a\nb", name: 'supervisor.childopts'}, {filename: 'storm-site.xml', value: "a\t\tb", name: 'worker.childopts'} @@ -1228,7 +1227,7 @@ describe('App.WizardStep8Controller', function () { 'worker.childopts': 'a\t\tb' } }; - installerStep8Controller.reopen({configs: configs}); + installerStep8Controller.reopen({configs: _configs}); expect(installerStep8Controller.createStormSiteObj('version1')).to.eql(expected); }); }); @@ -1967,7 +1966,7 @@ describe('App.WizardStep8Controller', function () { expect(data.properties['ambari.dispatch.credential.password']).to.equal('pwd'); }); it('custom property is valid', function () { - expect(data.properties['some_p']).to.equal('some_v'); + expect(data.properties.some_p).to.equal('some_v'); }); });
