Repository: ambari Updated Branches: refs/heads/trunk 5e0ad173d -> 7452f7165
AMBARI-15225. Write more UI UT (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7452f716 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7452f716 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7452f716 Branch: refs/heads/trunk Commit: 7452f7165842612d10aff8a9438f535518aa149e Parents: 5e0ad17 Author: Oleg Nechiporenko <onechipore...@apache.org> Authored: Mon Feb 29 17:21:40 2016 +0200 Committer: Oleg Nechiporenko <onechipore...@apache.org> Committed: Mon Feb 29 17:42:09 2016 +0200 ---------------------------------------------------------------------- ambari-web/app/assets/test/tests.js | 5 + .../app/controllers/global/update_controller.js | 49 +++++---- .../app/views/main/service/services/hbase.js | 43 ++++---- .../app/views/main/service/services/hdfs.js | 4 +- .../app/views/main/service/services/storm.js | 5 +- .../test/aliases/computed/formatUnavailable.js | 62 +++++++++++ .../global/update_controller_test.js | 103 +++++++++++++++++++ .../hawq/addStandby/step3_controller_test.js | 54 +++++----- .../nameNode/step3_controller_test.js | 37 +++++++ .../admin/kerberos/step2_controller_test.js | 2 +- .../admin/kerberos/step5_controller_test.js | 44 ++++++++ .../manage_config_groups_controller_test.js | 34 ++++++ .../test/controllers/main/service_test.js | 12 --- ambari-web/test/helpers.js | 2 - ambari-web/test/init_computed_aliases.js | 3 +- ambari-web/test/models/form_test.js | 4 +- .../views/main/service/services/hbase_test.js | 68 ++++++++++++ .../views/main/service/services/hdfs_test.js | 34 ++++++ .../views/main/service/services/storm_test.js | 34 ++++++ .../views/main/service/services/yarn_test.js | 51 +++++++++ 20 files changed, 546 insertions(+), 104 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/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 1954432..a875656 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -60,6 +60,7 @@ var files = [ 'test/controllers/main/admin/kerberos/step2_controller_test', 'test/controllers/main/admin/kerberos/step3_controller_test', 'test/controllers/main/admin/kerberos/step4_controller_test', + 'test/controllers/main/admin/kerberos/step5_controller_test', 'test/controllers/main/admin/kerberos/step6_controller_test', 'test/controllers/main/admin/stack_and_upgrade_controller_test', 'test/controllers/main/admin/serviceAccounts_controller_test', @@ -275,7 +276,11 @@ var files = [ 'test/views/main/service/info/component_list_view_test', 'test/views/main/service/info/metrics/ambari_metrics/regionserver_base_test', 'test/views/main/service/info/metrics/flume/flume_agent_metrics_section_test', + 'test/views/main/service/services/hdfs_test', + 'test/views/main/service/services/hbase_test', 'test/views/main/service/services/ranger_test', + 'test/views/main/service/services/storm_test', + 'test/views/main/service/services/yarn_test', 'test/views/main/service/widgets/create/expression_view_test', 'test/views/main/admin/highAvailability/nameNode/step1_view_test', 'test/views/main/admin/highAvailability/nameNode/step3_view_test', http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/ambari-web/app/controllers/global/update_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js index b1fa1cd..de4523b 100644 --- a/ambari-web/app/controllers/global/update_controller.js +++ b/ambari-web/app/controllers/global/update_controller.js @@ -89,7 +89,7 @@ App.UpdateController = Em.Controller.extend({ }, getUrl: function (testUrl, url) { - return (App.get('testMode')) ? testUrl : App.apiPrefix + '/clusters/' + this.get('clusterName') + url; + return App.get('testMode') ? testUrl : App.apiPrefix + '/clusters/' + this.get('clusterName') + url; }, /** @@ -105,7 +105,7 @@ App.UpdateController = Em.Controller.extend({ if (queryParams) { params = this.computeParameters(queryParams); } - params = (params.length > 0) ? params + "&" : params; + params = params.length > 0 ? params + "&" : params; return prefix + realUrl.replace('<parameters>', params); }, @@ -136,12 +136,9 @@ App.UpdateController = Em.Controller.extend({ break; case 'MATCH': if (Em.isArray(param.value)) { - params += '('; - param.value.forEach(function(v) { - params += param.key + '.matches(' + v + ')' + '|'; - }); - params = params.substring(0, params.length - 1); - params += ')'; + params += '(' + param.value.map(function(v) { + return param.key + '.matches(' + v + ')'; + }).join('|') + ')'; } else { params += param.key + '.matches(' + param.value + ')'; } @@ -235,12 +232,12 @@ App.UpdateController = Em.Controller.extend({ sortProperties = mainHostController.getSortProps(), isHostsLoaded = false; this.get('queryParams').set('Hosts', mainHostController.getQueryParameters(true)); - if (App.router.get('currentState.parentState.name') == 'hosts') { + if (App.router.get('currentState.parentState.name') === 'hosts') { App.updater.updateInterval('updateHost', App.get('contentUpdateInterval')); hostDetailsParams = ''; } else { - if (App.router.get('currentState.parentState.name') == 'hostDetails') { + if (App.router.get('currentState.parentState.name') === 'hostDetails') { hostDetailsFilter = App.router.get('location.lastSetURL').match(/\/hosts\/(.*)\/(summary|configs|alerts|stackVersions|logs)/)[1]; App.updater.updateInterval('updateHost', App.get('componentsUpdateInterval')); //if host details page opened then request info only of one displayed host @@ -263,8 +260,8 @@ App.UpdateController = Em.Controller.extend({ } } - realUrl = realUrl.replace("<stackVersions>", (App.get('supports.stackUpgrade') ? stackVersionInfo : "")); - realUrl = realUrl.replace("<metrics>", (lazyLoadMetrics ? "" : "metrics/disk,metrics/load/load_one,")); + realUrl = realUrl.replace("<stackVersions>", App.get('supports.stackUpgrade') ? stackVersionInfo : ""); + realUrl = realUrl.replace("<metrics>", lazyLoadMetrics ? "" : "metrics/disk,metrics/load/load_one,"); realUrl = realUrl.replace('<hostDetailsParams>', hostDetailsParams); var clientCallback = function (skipCall, queryParams) { @@ -286,7 +283,7 @@ App.UpdateController = Em.Controller.extend({ if (App.get('testMode')) { realUrl = testUrl; } else { - realUrl = self.addParamsToHostsUrl.call(self, queryParams, sortProperties, realUrl); + realUrl = self.addParamsToHostsUrl(queryParams, sortProperties, realUrl); } App.HttpClient.get(realUrl, App.hostsMapper, { @@ -312,7 +309,7 @@ App.UpdateController = Em.Controller.extend({ */ addParamsToHostsUrl: function (queryParams, sortProperties, realUrl) { var paginationProps = this.computeParameters(queryParams.filter(function (param) { - return (this.get('paginationKeys').contains(param.key)); + return this.get('paginationKeys').contains(param.key); }, this)); var sortProps = this.computeParameters(sortProperties); @@ -362,7 +359,7 @@ App.UpdateController = Em.Controller.extend({ var preLoadKeys = this.get('hostsPreLoadKeys'); if (this.get('queryParams.Hosts').length > 0 && this.get('queryParams.Hosts').filter(function (param) { - return (preLoadKeys.contains(param.key)); + return preLoadKeys.contains(param.key); }, this).length > 0) { this.getHostByHostComponents(callback); return true; @@ -394,7 +391,7 @@ App.UpdateController = Em.Controller.extend({ var hostNames = data.items.mapProperty('Hosts.host_name'); var skipCall = hostNames.length === 0; - var itemTotal = parseInt(data.itemTotal); + var itemTotal = parseInt(data.itemTotal, 10); if (!isNaN(itemTotal)) { App.router.set('mainHostController.filteredCount', itemTotal); } @@ -403,7 +400,7 @@ App.UpdateController = Em.Controller.extend({ params.callback(skipCall); } else { queryParams = queryParams.filter(function (param) { - return !(preLoadKeys.contains(param.key)); + return !preLoadKeys.contains(param.key); }); queryParams.push({ @@ -450,8 +447,8 @@ App.UpdateController = Em.Controller.extend({ requestsRunningStatus = this.get('requestsRunningStatus'), conditionalFieldsString = conditionalFields.length > 0 ? ',' + conditionalFields.join(',') : '', testUrl = '/data/dashboard/HDP2/master_components.json', - isFlumeInstalled = App.cache['services'].mapProperty('ServiceInfo.service_name').contains('FLUME'), - isATSInstalled = App.cache['services'].mapProperty('ServiceInfo.service_name').contains('YARN') && isATSPresent, + isFlumeInstalled = App.cache.services.mapProperty('ServiceInfo.service_name').contains('FLUME'), + isATSInstalled = App.cache.services.mapProperty('ServiceInfo.service_name').contains('YARN') && isATSPresent, flumeHandlerParam = isFlumeInstalled ? 'ServiceComponentInfo/component_name=FLUME_HANDLER|' : '', atsHandlerParam = isATSInstalled ? 'ServiceComponentInfo/component_name=APP_TIMELINE_SERVER|' : '', haComponents = App.get('isHaEnabled') ? 'ServiceComponentInfo/component_name=JOURNALNODE|ServiceComponentInfo/component_name=ZKFC|' : '', @@ -473,12 +470,12 @@ App.UpdateController = Em.Controller.extend({ self.set('isUpdated', true); }; - if (!requestsRunningStatus["updateServiceMetric"]) { - requestsRunningStatus["updateServiceMetric"] = true; + if (!requestsRunningStatus.updateServiceMetric) { + requestsRunningStatus.updateServiceMetric = true; App.HttpClient.get(servicesUrl, App.serviceMetricsMapper, { complete: function () { App.set('router.mainServiceItemController.isServicesInfoLoaded', App.get('router.clusterController.isLoaded')); - requestsRunningStatus["updateServiceMetric"] = false; + requestsRunningStatus.updateServiceMetric = false; callback(); } }); @@ -496,12 +493,12 @@ App.UpdateController = Em.Controller.extend({ var metricsKey = 'metrics/'; if (/^2.1/.test(App.get('currentStackVersionNumber'))) { - serviceSpecificParams['STORM'] = 'metrics/api/cluster/summary'; + serviceSpecificParams.STORM = 'metrics/api/cluster/summary'; } else if (/^2.2/.test(App.get('currentStackVersionNumber'))) { - serviceSpecificParams['STORM'] = 'metrics/api/v1/cluster/summary,metrics/api/v1/topology/summary'; + serviceSpecificParams.STORM = 'metrics/api/v1/cluster/summary,metrics/api/v1/topology/summary'; } - App.cache['services'].forEach(function (service) { + App.cache.services.forEach(function (service) { var urlParams = serviceSpecificParams[service.ServiceInfo.service_name]; if (urlParams) { conditionalFields.push(urlParams); @@ -511,7 +508,7 @@ App.UpdateController = Em.Controller.extend({ //first load shouldn't contain metrics in order to make call lighter if (!App.get('router.clusterController.isServiceMetricsLoaded')) { return conditionalFields.filter(function (condition) { - return (condition.indexOf(metricsKey) === -1); + return condition.indexOf(metricsKey) === -1; }); } http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/ambari-web/app/views/main/service/services/hbase.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/services/hbase.js b/ambari-web/app/views/main/service/services/hbase.js index ec48650..24c6175 100644 --- a/ambari-web/app/views/main/service/services/hbase.js +++ b/ambari-web/app/views/main/service/services/hbase.js @@ -17,7 +17,22 @@ var App = require('app'); var date = require('utils/date/date'); -var numberUtils = require('utils/number_utils'); + +function getMasterTime(key) { + var _k = 'service.' + key; + return Em.computed(_k, function () { + var uptime = this.get(_k); + if (uptime && uptime > 0) { + var diff = App.dateTime() - uptime; + if (diff < 0) { + diff = 0; + } + var formatted = date.timingFormat(diff); + return this.t('dashboard.services.uptime').format(formatted); + } + return this.t('services.service.summary.notRunning'); + }); +} App.MainDashboardServiceHbaseView = App.MainDashboardServiceView.extend({ templateName: require('templates/main/service/services/hbase'), @@ -68,31 +83,9 @@ App.MainDashboardServiceHbaseView = App.MainDashboardServiceView.extend({ return this.t('dashboard.services.hbase.averageLoadPerServer').format(avgLoad); }.property("service.averageLoad"), - masterStartedTime: function () { - var uptime = this.get('service').get('masterStartTime'); - if (uptime && uptime > 0) { - var diff = App.dateTime() - uptime; - if (diff < 0) { - diff = 0; - } - var formatted = date.timingFormat(diff); - return this.t('dashboard.services.uptime').format(formatted); - } - return this.t('services.service.summary.notRunning'); - }.property("service.masterStartTime"), + masterStartedTime: getMasterTime('masterStartTime'), - masterActivatedTime: function () { - var uptime = this.get('service').get('masterActiveTime'); - if (uptime && uptime > 0) { - var diff = App.dateTime() - uptime; - if (diff < 0) { - diff = 0; - } - var formatted = date.timingFormat(diff); - return this.t('dashboard.services.uptime').format(formatted); - } - return this.t('services.service.summary.notRunning'); - }.property("service.masterActiveTime"), + masterActivatedTime: getMasterTime('masterActiveTime'), regionServerComponent: Em.Object.create({ componentName: 'HBASE_REGIONSERVER' http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/ambari-web/app/views/main/service/services/hdfs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/services/hdfs.js b/ambari-web/app/views/main/service/services/hdfs.js index fca6457..dea9902 100644 --- a/ambari-web/app/views/main/service/services/hdfs.js +++ b/ambari-web/app/views/main/service/services/hdfs.js @@ -40,11 +40,11 @@ App.MainDashboardServiceHdfsView = App.MainDashboardServiceView.extend({ color: '#0066B3', stroke: '#0066B3', palette: new Rickshaw.Color.Palette({ - scheme: [ 'rgba(0,102,179,0)', 'rgba(0,102,179,1)'].reverse() + scheme: ['rgba(0,102,179,1)', 'rgba(0,102,179,0)'] }), data: function () { var total = this.get('service.capacityTotal') + 0; - var remaining = (this.get('service.capacityRemaining') + 0); + var remaining = this.get('service.capacityRemaining') + 0; var used = total - remaining; return [ used, remaining ]; }.property('service.capacityUsed', 'service.capacityTotal') http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/ambari-web/app/views/main/service/services/storm.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/services/storm.js b/ambari-web/app/views/main/service/services/storm.js index c236193..360a733 100644 --- a/ambari-web/app/views/main/service/services/storm.js +++ b/ambari-web/app/views/main/service/services/storm.js @@ -17,7 +17,6 @@ */ var App = require('app'); -var date = require('utils/date/date'); App.MainDashboardServiceStormView = App.MainDashboardServiceView.extend({ templateName: require('templates/main/service/services/storm'), @@ -27,9 +26,7 @@ App.MainDashboardServiceStormView = App.MainDashboardServiceView.extend({ * this parameter is used to fiter hosts by component name * used in mainHostController.filterByComponent() method */ - filterComponent: function() { - return Em.Object.create({componentName: 'SUPERVISOR'}); - }.property(), + filterComponent: Em.Object.create({componentName: 'SUPERVISOR'}), freeSlotsPercentage: Em.computed.percents('service.freeSlots', 'service.totalSlots'), http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/ambari-web/test/aliases/computed/formatUnavailable.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/aliases/computed/formatUnavailable.js b/ambari-web/test/aliases/computed/formatUnavailable.js new file mode 100644 index 0000000..22a2d94 --- /dev/null +++ b/ambari-web/test/aliases/computed/formatUnavailable.js @@ -0,0 +1,62 @@ +/** + * 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 helpers = App.TestAliases.helpers; + +/** + * + * @param {Em.Object} context + * @param {string} propertyName + * @param {string} dependentKey + */ +App.TestAliases.testAsComputedFormatNa = function (context, propertyName, dependentKey) { + + describe('#' + propertyName + ' as Em.computed.formatUnavailable', function () { + + afterEach(function () { + helpers.smartRestoreGet(context); + }); + + it('has valid dependent keys', function () { + expect(Em.meta(context).descs[propertyName]._dependentKeys).to.eql([dependentKey]); + }); + + it('should be `0` if ' + JSON.stringify(dependentKey) + ' is `0`', function () { + helpers.smartStubGet(context, dependentKey, 0) + .propertyDidChange(context, propertyName); + var value = helpers.smartGet(context, propertyName); + expect(value).to.be.equal(0); + }); + + it('should be `12` if ' + JSON.stringify(dependentKey) + ' is `12`', function () { + helpers.smartStubGet(context, dependentKey, 12) + .propertyDidChange(context, propertyName); + var value = helpers.smartGet(context, propertyName); + expect(value).to.be.equal(12); + }); + + it('should be `n/a` if ' + JSON.stringify(dependentKey) + ' is not number >= 0', function () { + helpers.smartStubGet(context, dependentKey, null) + .propertyDidChange(context, propertyName); + var value = helpers.smartGet(context, propertyName); + expect(value).to.be.equal(Em.I18n.t('services.service.summary.notAvailable')); + }); + + }); + +}; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/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 c0a4760..2c679c6 100644 --- a/ambari-web/test/controllers/global/update_controller_test.js +++ b/ambari-web/test/controllers/global/update_controller_test.js @@ -21,6 +21,7 @@ var App = require('app'); require('utils/updater'); require('controllers/global/update_controller'); var testHelpers = require('test/helpers'); +var c; describe('App.UpdateController', function () { var controller = App.UpdateController.create({ @@ -29,6 +30,10 @@ describe('App.UpdateController', function () { updateServiceMetric: function(){} }); + beforeEach(function () { + c = App.UpdateController.create(); + }); + App.TestAliases.testAsComputedAlias(App.UpdateController.create(), 'clusterName', 'App.router.clusterController.clusterName', 'string'); App.TestAliases.testAsComputedAnd(App.UpdateController.create(), 'updateAlertInstances', ['isWorking', '!App.router.mainAlertInstancesController.isUpdating']); @@ -436,4 +441,102 @@ describe('App.UpdateController', function () { }); + describe('#computeParameters', function () { + + Em.A([ + { + q: [{ + type: 'EQUAL', + key: 'k', + value: [1, 2] + }], + result: 'k.in(1,2)' + }, + { + q: [{ + type: 'MULTIPLE', + key: 'k', + value: [1, 2] + }], + result: 'k.in(1,2)' + }, + { + q: [{ + type: 'EQUAL', + key: 'k', + value: 1 + }], + result: 'k=1' + }, + { + q: [ + { + type: 'LESS', + key: 'k', + value: '1' + } + ], + result: 'k<1' + }, + { + q: [ + { + type: 'MORE', + key: 'k', + value: '1' + } + ], + result: 'k>1' + }, + { + q: [ + { + type: 'SORT', + key: 'k', + value: 'f' + } + ], + result: 'sortBy=k.f' + }, + { + q: [ + { + type: 'MATCH', + key: 'k', + value: 'abc' + } + ], + result: 'k.matches(abc)' + }, + { + q: [ + { + type: 'MATCH', + key: 'k', + value: ['a', 'b', 'c'] + } + ], + result: '(k.matches(a)|k.matches(b)|k.matches(c))' + }, + { + q: [ + {type: 'EQUAL', key: 'k1', value: [1,2]}, + {type: 'EQUAL', key: 'k2', value: 'abc'}, + {type: 'LESS', key: 'k3', value: 1}, + {type: 'MORE', key: 'k4', value: 1}, + {type: 'MATCH', key: 'k5', value: ['a', 'b', 'c']} + ], + result: 'k1.in(1,2)&k2=abc&k3<1&k4>1&(k5.matches(a)|k5.matches(b)|k5.matches(c))' + } + ]).forEach(function (test, index) { + + it('test#' + index, function () { + var result = c.computeParameters(test.q); + expect(result).to.be.equal(test.result); + }); + + }); + + }); + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller_test.js b/ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller_test.js index af1937f..bd6a67a 100644 --- a/ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller_test.js +++ b/ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller_test.js @@ -20,14 +20,22 @@ var App = require('app'); require('controllers/main/admin/highAvailability/hawq/addStandby/step3_controller'); var testHelpers = require('test/helpers'); +function getController() { + return App.AddHawqStandbyWizardStep3Controller.create({ + content: Em.Object.create({}) + }); +} +var controller; + describe('App.AddHawqStandbyWizardStep3Controller', function () { + beforeEach(function () { + controller = getController(); + }); + describe('#isSubmitDisabled', function () { - var controller = App.AddHawqStandbyWizardStep3Controller.create({ - content: Em.Object.create({}) - }), - cases = [ + var cases = [ { isLoaded: false, isSubmitDisabled: true, @@ -51,10 +59,6 @@ describe('App.AddHawqStandbyWizardStep3Controller', function () { describe('#loadConfigTagsSuccessCallback', function () { - var controller = App.AddHawqStandbyWizardStep3Controller.create({ - content: Em.Object.create({}) - }); - it('should send proper ajax request', function () { controller.loadConfigTagsSuccessCallback({ 'Clusters': { @@ -76,10 +80,7 @@ describe('App.AddHawqStandbyWizardStep3Controller', function () { describe('#loadConfigsSuccessCallback', function () { - var controller = App.AddHawqStandbyWizardStep3Controller.create({ - content: Em.Object.create({}) - }), - cases = [ + var cases = [ { 'items': [ { @@ -117,10 +118,6 @@ describe('App.AddHawqStandbyWizardStep3Controller', function () { describe('#loadConfigsSuccessCallback=loadConfigsErrorCallback(we have one callback for both cases)', function () { - var controller = App.AddHawqStandbyWizardStep3Controller.create({ - content: Em.Object.create({}) - }); - beforeEach(function () { sinon.stub(controller, 'setDynamicConfigValues', Em.K); }); @@ -137,7 +134,6 @@ describe('App.AddHawqStandbyWizardStep3Controller', function () { }); - describe('#setDynamicConfigValues', function () { var data = { @@ -151,7 +147,17 @@ describe('App.AddHawqStandbyWizardStep3Controller', function () { ] }; - var controller = App.AddHawqStandbyWizardStep3Controller.create({ + var configs = { + configs: [ + Em.Object.create({ + name: 'hawq_standby_address_host' + }) + ] + }; + + + beforeEach(function () { + controller = App.AddHawqStandbyWizardStep3Controller.create({ content: Em.Object.create({ masterComponentHosts: [ {component: 'HAWQMASTER', hostName: 'h0', isInstalled: true}, @@ -164,17 +170,7 @@ describe('App.AddHawqStandbyWizardStep3Controller', function () { newHawqStandby: 'h1' } }) - }), - configs = { - configs: [ - Em.Object.create({ - name: 'hawq_standby_address_host' - }) - ] - }; - - - beforeEach(function () { + }) controller.setDynamicConfigValues(configs, data); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/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 d4c2e41..ca55a32 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 @@ -18,6 +18,7 @@ var App = require('app'); +var testHelpers = require('test/helpers'); var controller; describe('App.HighAvailabilityWizardStep3Controller', function() { @@ -401,5 +402,41 @@ describe('App.HighAvailabilityWizardStep3Controller', function() { }); + describe('#onLoadConfigsTags', function () { + + var data = {Clusters: {desired_configs: { + 'hdfs-site': {tag: 'v1'}, + 'core-site': {tag: 'v2'}, + 'zoo.cfg': {tag: 'v3'}, + 'hbase-site': {tag: 'v4'}, + 'accumulo-site': {tag: 'v5'}, + 'ams-hbase-site': {tag: 'v6'}, + 'hawq-site': {tag: 'v7'}, + 'hdfs-client': {tag: 'v8'}, + }}}; + + beforeEach(function () { + sinon.stub(App.Service, 'find', function () { + return [ + Em.Object.create({serviceName: 'HBASE'}), + Em.Object.create({serviceName: 'ACCUMULO'}), + Em.Object.create({serviceName: 'AMBARI_METRICS'}), + Em.Object.create({serviceName: 'HAWQ'}) + ]; + }); + controller.onLoadConfigsTags(data); + this.args = testHelpers.findAjaxRequest('name', 'admin.get.all_configurations'); + }); + + afterEach(function () { + App.Service.find.restore(); + }); + + it('urlParams are valid', function () { + expect(this.args[0].data.urlParams).to.be.equal('(type=hdfs-site&tag=v1)|(type=core-site&tag=v2)|(type=zoo.cfg&tag=v3)|(type=hbase-site&tag=v4)|(type=accumulo-site&tag=v5)|(type=ams-hbase-site&tag=v6)|(type=hawq-site&tag=v7)|(type=hdfs-client&tag=v8)'); + }); + + }); + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/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 4cfa51c..beacc63 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 @@ -27,7 +27,7 @@ describe('App.KerberosWizardStep2Controller', function() { App.TestAliases.testAsComputedAlias(getController(), 'isBackBtnDisabled', 'testConnectionInProgress', 'boolean'); - App.TestAliases.testAsComputedAlias(getController(), 'hostNames', 'App.allHostNames'); + App.TestAliases.testAsComputedAlias(getController(), 'hostNames', 'App.allHostNames', 'array'); App.TestAliases.testAsComputedAlias(getController(), 'isConfigsLoaded', 'wizardController.stackConfigsLoaded', 'boolean'); http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/ambari-web/test/controllers/main/admin/kerberos/step5_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/kerberos/step5_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step5_controller_test.js new file mode 100644 index 0000000..d3180e3 --- /dev/null +++ b/ambari-web/test/controllers/main/admin/kerberos/step5_controller_test.js @@ -0,0 +1,44 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); +var c; +describe('App.KerberosWizardStep5Controller', function() { + + beforeEach(function () { + c = App.KerberosWizardStep5Controller.create({}); + }); + + describe('#prepareCSVData', function () { + + it('should split data', function () { + + var data = [ + 'a,b,c', + 'd,e', + '1,2,3,4' + ]; + + var result = c.prepareCSVData(data); + expect(result).to.be.eql([['a', 'b', 'c'], ['d', 'e'], ['1', '2', '3', '4']]) + + }); + + }); + +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/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 119547f..4bd2f44 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 @@ -549,4 +549,38 @@ describe('App.ManageConfigGroupsController', function() { }); }); + + describe('#componentsForFilter', function () { + + beforeEach(function () { + sinon.stub(App.StackServiceComponent, 'find', function () { + return [ + Em.Object.create({ + serviceName: 'HDFS' + }), + Em.Object.create({ + serviceName: 'noHDFS' + }), + Em.Object.create({ + serviceName: 'HDFS' + }) + ]; + }); + c.set('serviceName', 'HDFS'); + }); + + afterEach(function () { + App.StackServiceComponent.find.restore(); + }); + + it('should map components for current service', function () { + expect(c.get('componentsForFilter')).to.have.property('length').equal(2); + }); + + it('no one is selected', function () { + expect(c.get('componentsForFilter').mapProperty('selected')).to.be.eql([false, false]); + }); + + }); + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/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 177aac8..9db4849 100644 --- a/ambari-web/test/controllers/main/service_test.js +++ b/ambari-web/test/controllers/main/service_test.js @@ -214,12 +214,6 @@ describe('App.MainServiceController', function () { expect(r).to.be.null; }); - it('nothing disabled', function() { - var event = {target: {}}, query = 'query'; - mainServiceController.startAllService(event).onPrimary(query); - expect(mainServiceController.allServicesCall.calledWith('STARTED', query)); - }); - }); describe('#stopAllService', function() { @@ -244,12 +238,6 @@ describe('App.MainServiceController', function () { expect(r).to.be.null; }); - it('nothing disabled', function() { - var event = {target: {}}, query = 'query'; - mainServiceController.stopAllService(event).onPrimary(query); - expect(mainServiceController.allServicesCall.calledWith('STARTED', query)); - }); - }); describe('#startStopAllService', function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/ambari-web/test/helpers.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/helpers.js b/ambari-web/test/helpers.js index 1bb65d0..13aef7f 100644 --- a/ambari-web/test/helpers.js +++ b/ambari-web/test/helpers.js @@ -15,8 +15,6 @@ * the License. */ -/*eslint-disable mocha-cleanup/no-assertions-outside-it */ - module.exports = { /** http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/ambari-web/test/init_computed_aliases.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/init_computed_aliases.js b/ambari-web/test/init_computed_aliases.js index 57e0861..c911453 100644 --- a/ambari-web/test/init_computed_aliases.js +++ b/ambari-web/test/init_computed_aliases.js @@ -192,4 +192,5 @@ require('test/aliases/computed/filterBy'); require('test/aliases/computed/findBy'); require('test/aliases/computed/sumBy'); require('test/aliases/computed/and'); -require('test/aliases/computed/or'); \ No newline at end of file +require('test/aliases/computed/or'); +require('test/aliases/computed/formatUnavailable'); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/ambari-web/test/models/form_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/form_test.js b/ambari-web/test/models/form_test.js index 29ca459..2d45ada 100644 --- a/ambari-web/test/models/form_test.js +++ b/ambari-web/test/models/form_test.js @@ -19,7 +19,7 @@ var App = require('app'); require('models/form'); -/*eslint-disable mocha-cleanup/no-assertions-outside-it */ + var form, field, formField, @@ -75,7 +75,7 @@ var form, formField.validate(); expect(formField.get('errorMessage')).to.equal(message); }; -/*eslint-enable mocha-cleanup/no-assertions-outside-it */ + describe('App.Form', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/ambari-web/test/views/main/service/services/hbase_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/service/services/hbase_test.js b/ambari-web/test/views/main/service/services/hbase_test.js new file mode 100644 index 0000000..2d4a4b9 --- /dev/null +++ b/ambari-web/test/views/main/service/services/hbase_test.js @@ -0,0 +1,68 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); +require('/views/main/service/services/hbase'); + +var view; + +function getView() { + return App.MainDashboardServiceHbaseView.create(); +} + +describe('App.MainDashboardServiceHbaseView', function () { + + beforeEach(function () { + view = getView(); + }); + + App.TestAliases.testAsComputedFilterBy(getView(), 'masters', 'service.hostComponents', 'isMaster', true); + + App.TestAliases.testAsComputedFilterBy(getView(), 'passiveMasters', 'masters', 'haStatus', 'false'); + + App.TestAliases.testAsComputedFindBy(getView(), 'activeMaster', 'masters', 'haStatus', 'true'); + + App.TestAliases.testAsComputedCountBasedMessage(getView(), 'regionServesText', 'service.regionServersTotal', '', Em.I18n.t('services.service.summary.viewHost'), Em.I18n.t('services.service.summary.viewHosts')); + + App.TestAliases.testAsComputedCountBasedMessage(getView(), 'phoenixServersText', 'service.phoenixServersTotal', '', Em.I18n.t('services.service.summary.viewHost'), Em.I18n.t('services.service.summary.viewHosts')); + + describe('#averageLoad', function () { + + beforeEach(function () { + view.reopen({service: Em.Object.create()}); + }); + + Em.A([ + { + averageLoad: NaN, + e: Em.I18n.t('dashboard.services.hbase.averageLoadPerServer').format(Em.I18n.t('services.service.summary.notAvailable')) + }, + { + averageLoad: 12, + e: Em.I18n.t('dashboard.services.hbase.averageLoadPerServer').format(12) + } + ]).forEach(function (test, index) { + it('test# ' + (index + 1), function () { + view.set('service.averageLoad', test.averageLoad); + expect(view.get('averageLoad')).to.be.equal(test.e); + }); + }); + + }); + +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/ambari-web/test/views/main/service/services/hdfs_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/service/services/hdfs_test.js b/ambari-web/test/views/main/service/services/hdfs_test.js new file mode 100644 index 0000000..9e6ebb8 --- /dev/null +++ b/ambari-web/test/views/main/service/services/hdfs_test.js @@ -0,0 +1,34 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); +require('/views/main/service/services/hdfs'); + +function getView() { + return App.MainDashboardServiceHdfsView.create(); +} + +describe('App.MainDashboardServiceHdfsView', function () { + + App.TestAliases.testAsComputedAlias(getView(), 'dataNodesDead', 'service.dataNodesInstalled', 'boolean'); + + App.TestAliases.testAsComputedAlias(getView(), 'journalNodesTotal', 'service.journalNodes.length', 'number'); + + App.TestAliases.testAsComputedGt(getView(), 'showJournalNodes', 'service.journalNodes.length', 0); + +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/ambari-web/test/views/main/service/services/storm_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/service/services/storm_test.js b/ambari-web/test/views/main/service/services/storm_test.js new file mode 100644 index 0000000..e659e78 --- /dev/null +++ b/ambari-web/test/views/main/service/services/storm_test.js @@ -0,0 +1,34 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); +require('/views/main/service/services/storm'); + +function getView() { + return App.MainDashboardServiceStormView.create(); +} + +describe('App.MainDashboardServiceStormView', function () { + + App.TestAliases.testAsComputedPercents(getView(), 'freeSlotsPercentage', 'service.freeSlots', 'service.totalSlots'); + + App.TestAliases.testAsComputedAlias(getView(), 'superVisorsLive', 'service.superVisorsStarted'); + + App.TestAliases.testAsComputedAlias(getView(), 'superVisorsTotal', 'service.superVisorsTotal'); + +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/7452f716/ambari-web/test/views/main/service/services/yarn_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/service/services/yarn_test.js b/ambari-web/test/views/main/service/services/yarn_test.js new file mode 100644 index 0000000..b9eee96 --- /dev/null +++ b/ambari-web/test/views/main/service/services/yarn_test.js @@ -0,0 +1,51 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); +require('/views/main/service/services/yarn'); + +function getView() { + return App.MainDashboardServiceYARNView.create(); +} + +describe('App.MainDashboardServiceYARNView', function () { + + App.TestAliases.testAsComputedCountBasedMessage(getView(), 'nodeManagerText', 'service.nodeManagersTotal', '', Em.I18n.t('services.service.summary.viewHost'), Em.I18n.t('services.service.summary.viewHosts')); + + App.TestAliases.testAsComputedGt(getView(), 'hasManyYarnClients', 'service.installedClients', 1); + + App.TestAliases.testAsComputedFormatNa(getView(), '_nmActive', 'service.nodeManagersCountActive'); + App.TestAliases.testAsComputedFormatNa(getView(), '_nmLost', 'service.nodeManagersCountLost'); + App.TestAliases.testAsComputedFormatNa(getView(), '_nmUnhealthy', 'service.nodeManagersCountUnhealthy'); + App.TestAliases.testAsComputedFormatNa(getView(), '_nmRebooted', 'service.nodeManagersCountRebooted'); + App.TestAliases.testAsComputedFormatNa(getView(), '_nmDecom', 'service.nodeManagersCountDecommissioned'); + + App.TestAliases.testAsComputedFormatNa(getView(), '_allocated', 'service.containersAllocated'); + App.TestAliases.testAsComputedFormatNa(getView(), '_pending', 'service.containersPending'); + App.TestAliases.testAsComputedFormatNa(getView(), '_reserved', 'service.containersReserved'); + + App.TestAliases.testAsComputedFormatNa(getView(), '_appsSubmitted', 'service.appsSubmitted'); + App.TestAliases.testAsComputedFormatNa(getView(), '_appsRunning', 'service.appsRunning'); + App.TestAliases.testAsComputedFormatNa(getView(), '_appsPending', 'service.appsPending'); + App.TestAliases.testAsComputedFormatNa(getView(), '_appsCompleted', 'service.appsCompleted'); + App.TestAliases.testAsComputedFormatNa(getView(), '_appsKilled', 'service.appsKilled'); + App.TestAliases.testAsComputedFormatNa(getView(), '_appsFailed', 'service.appsFailed'); + + App.TestAliases.testAsComputedFormatNa(getView(), '_queuesCountFormatted', 'service.queuesCount'); + +}); \ No newline at end of file