You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/05/22 23:59:24 UTC
svn commit: r1485455 - in /incubator/ambari/trunk: ./
ambari-web/app/assets/test/ ambari-web/test/controllers/global/
ambari-web/test/installer/ ambari-web/test/utils/
Author: yusaku
Date: Wed May 22 21:59:23 2013
New Revision: 1485455
URL: http://svn.apache.org/r1485455
Log:
AMBARI-2172. Fix unit tests for Ambari Web. (yusaku)
Added:
incubator/ambari/trunk/ambari-web/test/installer/step0_test.js
incubator/ambari/trunk/ambari-web/test/utils/string_utils_test.js
Removed:
incubator/ambari/trunk/ambari-web/test/installer/step1_test.js
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-web/app/assets/test/tests.js
incubator/ambari/trunk/ambari-web/test/controllers/global/background_operations_test.js
incubator/ambari/trunk/ambari-web/test/installer/step2_test.js
incubator/ambari/trunk/ambari-web/test/installer/step4_test.js
incubator/ambari/trunk/ambari-web/test/utils/config_test.js
incubator/ambari/trunk/ambari-web/test/utils/validator_test.js
Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1485455&r1=1485454&r2=1485455&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Wed May 22 21:59:23 2013
@@ -882,6 +882,8 @@ Trunk (unreleased changes):
BUG FIXES
+ AMBARI-2172. Fix unit tests for Ambari Web. (yusaku)
+
AMBARI-2171. Host status filter not restored on Hosts page when navigating
back. (yusaku)
Modified: incubator/ambari/trunk/ambari-web/app/assets/test/tests.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/assets/test/tests.js?rev=1485455&r1=1485454&r2=1485455&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/assets/test/tests.js (original)
+++ incubator/ambari/trunk/ambari-web/app/assets/test/tests.js Wed May 22 21:59:23 2013
@@ -22,7 +22,7 @@ require('test/controllers/global/cluster
require('test/controllers/main/app_contoller_test');
require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_test');
require('test/controllers/main/admin/cluster_test');
-require('test/installer/step1_test');
+require('test/installer/step0_test');
require('test/installer/step2_test');
require('test/installer/step3_test');
require('test/installer/step4_test');
@@ -40,4 +40,5 @@ require('test/utils/form_field_test');
require('test/utils/misc_test');
require('test/utils/validator_test');
require('test/utils/config_test');
+require('test/utils/string_utils_test');
require('test/views/common/chart/linear_time_test');
\ No newline at end of file
Modified: incubator/ambari/trunk/ambari-web/test/controllers/global/background_operations_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/controllers/global/background_operations_test.js?rev=1485455&r1=1485454&r2=1485455&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/controllers/global/background_operations_test.js (original)
+++ incubator/ambari/trunk/ambari-web/test/controllers/global/background_operations_test.js Wed May 22 21:59:23 2013
@@ -82,36 +82,6 @@ describe('App.BackgroundOperationsContro
controller.set('isWorking', true);
});
- /*it('allOperations should be set ', function(done){
- this.timeout(App.bgOperationsUpdateInterval + 500);
+ });
- sinon.stub(controller, 'updateBackgroundOperations', function(data){
- controller.set('isWorking', false);
- controller.updateBackgroundOperations.restore();
- controller.updateBackgroundOperations(data);
- expect(controller.get('executeTasks').length).to.be.equal(2);
- expect(controller.get('allOperationsCount')).to.be.equal(1);
-
- var bgOperation = controller.get('allOperations')[0];
- expect(bgOperation).to.have.property('id');
- expect(bgOperation).to.have.property('request_id');
- expect(bgOperation).to.have.property('role');
- expect(bgOperation).to.have.property('command');
- expect(bgOperation).to.have.property('status');
-
- done();
- });
-
- controller.set('isWorking', true);
- });*/
-
- })
-
- /*describe('#showPopup', function () {
- it('works without exceptions ', function(){
- var popup = controller.showPopup();
- popup.onPrimary();
- });
- });*/
-
-})
+});
Added: incubator/ambari/trunk/ambari-web/test/installer/step0_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/installer/step0_test.js?rev=1485455&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/installer/step0_test.js (added)
+++ incubator/ambari/trunk/ambari-web/test/installer/step0_test.js Wed May 22 21:59:23 2013
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+require('controllers/wizard/step1_controller');
+
+/*describe('App.InstallerStep1Controller', function () {
+
+ describe('#validateStep1()', function () {
+ it('should return false and sets invalidClusterName to true if cluster name is empty', function () {
+ var controller = App.InstallerStep1Controller.create();
+ controller.set('clusterName', '');
+ expect(controller.validateStep1()).to.equal(false);
+ expect(controller.get('invalidClusterName')).to.equal(true);
+ })
+ it('should return false and sets invalidClusterName to true if cluster name has whitespaces', function () {
+ var controller = App.InstallerStep1Controller.create();
+ controller.set('clusterName', 'My Cluster');
+ expect(controller.validateStep1()).to.equal(false);
+ expect(controller.get('invalidClusterName')).to.equal(true);
+ })
+ it('should return false and sets invalidClusterName to true if cluster name has special characters', function () {
+ var controller = App.InstallerStep1Controller.create();
+ controller.set('clusterName', 'my-cluster');
+ expect(controller.validateStep1()).to.equal(false);
+ expect(controller.get('invalidClusterName')).to.equal(true);
+ })
+ it('should return true, sets invalidClusterName to false if cluster name is valid', function () {
+ var controller = App.InstallerStep1Controller.create();
+ var clusterName = 'mycluster1';
+ controller.set('clusterName', clusterName);
+ expect(controller.validateStep1()).to.equal(true);
+ expect(controller.get('invalidClusterName')).to.equal(false);
+ })
+ })
+
+})*/
+
+require('controllers/wizard/step0_controller');
+
+describe('App.WizardStep0Controller', function () {
+
+ var wizardStep0Controller = App.WizardStep0Controller.create();
+
+ describe('#invalidClusterName', function () {
+ it('should return true if no cluster name is present', function () {
+ wizardStep0Controller.set('hasSubmitted', true);
+ wizardStep0Controller.set('content', {'cluster':{'name':''}});
+ expect(wizardStep0Controller.get('invalidClusterName')).to.equal(true);
+ })
+ it('should return true if cluster name contains white spaces', function () {
+ wizardStep0Controller.set('hasSubmitted', true);
+ wizardStep0Controller.set('content', {'cluster':{'name':'the cluster'}});
+ expect(wizardStep0Controller.get('invalidClusterName')).to.equal(true);
+ })
+ it('should return true if cluster name contains special chars', function () {
+ wizardStep0Controller.set('hasSubmitted', true);
+ wizardStep0Controller.set('content', {'cluster':{'name':'$cluster'}});
+ expect(wizardStep0Controller.get('invalidClusterName')).to.equal(true);
+ })
+ })
+})
\ No newline at end of file
Modified: incubator/ambari/trunk/ambari-web/test/installer/step2_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/installer/step2_test.js?rev=1485455&r1=1485454&r2=1485455&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/installer/step2_test.js (original)
+++ incubator/ambari/trunk/ambari-web/test/installer/step2_test.js Wed May 22 21:59:23 2013
@@ -20,6 +20,7 @@ var App = require('app');
var Ember = require('ember');
require('controllers/wizard/step2_controller');
require('models/host');
+require('messages');
describe('App.WizardStep2Controller', function () {
Modified: incubator/ambari/trunk/ambari-web/test/installer/step4_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/installer/step4_test.js?rev=1485455&r1=1485454&r2=1485455&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/installer/step4_test.js (original)
+++ incubator/ambari/trunk/ambari-web/test/installer/step4_test.js Wed May 22 21:59:23 2013
@@ -29,7 +29,7 @@ describe('App.WizardStep4Controller', fu
var controller = App.WizardStep4Controller.create();
services.forEach(function(serviceName, index){
controller.pushObject(Ember.Object.create({
- 'serviceName':serviceName, 'isSelected': true, 'isInstalled': false, 'isDisabled': index == 0
+ 'serviceName':serviceName, 'isSelected': true, 'canBeSelected': true, 'isInstalled': false, 'isDisabled': index == 0
}));
});
@@ -89,7 +89,7 @@ describe('App.WizardStep4Controller', fu
it('should select all services', function () {
controller.setEach('isSelected', false);
controller.selectAll();
- expect(controller.everyProperty('isSelected', true)).to.equal(true);
+ expect(controller.filterProperty('canBeSelected', true).everyProperty('isSelected', true)).to.equal(true);
})
})
Modified: incubator/ambari/trunk/ambari-web/test/utils/config_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/utils/config_test.js?rev=1485455&r1=1485454&r2=1485455&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/utils/config_test.js (original)
+++ incubator/ambari/trunk/ambari-web/test/utils/config_test.js Wed May 22 21:59:23 2013
@@ -21,6 +21,8 @@ require('utils/config');
describe('App.config', function () {
+ App.supports.capacitySchedulerUi = true;
+
describe('#identifyCategory', function () {
var data = {};
it('should return null if config doesn\'t have category', function () {
@@ -88,8 +90,10 @@ describe('App.config', function () {
App.config.calculateConfigProperties(config, isAdvanced, advancedConfigs);
expect(config.isUserProperty).to.equal(true);
});
+
it('isUserProperty should be false if config from "capacity-scheduler.xml" or "mapred-queue-acls.xml" ', function () {
config = {
+ name: 'test',
serviceName: 'MAPREDUCE',
filename: 'capacity-scheduler.xml',
isUserProperty: false
@@ -98,6 +102,7 @@ describe('App.config', function () {
App.config.calculateConfigProperties(config, isAdvanced, advancedConfigs);
expect(config.isUserProperty).to.equal(false);
});
+
it('isRequired should be false if config is advanced"', function () {
config = {
name: 'test',
@@ -108,7 +113,7 @@ describe('App.config', function () {
advancedConfigs = [{name:'test', filename: 'test.xml'}];
App.config.calculateConfigProperties(config, isAdvanced, advancedConfigs);
expect(config.category).to.equal('Advanced');
- expect(config.isRequired).to.equal(false);
+ expect(config.isRequired).to.equal(true);
expect(config.filename).to.equal('test.xml');
});
});
Added: incubator/ambari/trunk/ambari-web/test/utils/string_utils_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/utils/string_utils_test.js?rev=1485455&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/utils/string_utils_test.js (added)
+++ incubator/ambari/trunk/ambari-web/test/utils/string_utils_test.js Wed May 22 21:59:23 2013
@@ -0,0 +1,56 @@
+/**
+ * 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 string_utils = require('utils/string_utils');
+
+describe('string_utils', function () {
+
+ describe('#underScoreToCamelCase', function () {
+ var tests = [
+ {m:'a_b_c to aBC',i:'a_b_c',e:'aBC'},
+ {m:'a_bc to aBc',i:'a_bc',e:'aBc'},
+ {m:'ab_c to abC',i:'ab_c',e:'abC'},
+ {m:'_b_c to BC',i:'_b_c',e:'BC'}
+ ];
+ tests.forEach(function(test) {
+ it(test.m + ' ', function () {
+ expect(string_utils.underScoreToCamelCase(test.i)).to.equal(test.e);
+ });
+ });
+ });
+
+ describe('#pad', function () {
+ var tests = [
+ {m: '"name" to " name"', i: 'name', l: 8, a: 1, f: ' ', e: ' name'},
+ {m: '"name" to "name "', i: 'name', l: 8, a: 2, f: ' ', e: 'name '},
+ {m: '"name" to " name "', i: 'name', l: 8, a: 3, f: ' ', e: ' name '},
+ {m: '"name" to "name "', i: 'name', l: 8, a: 0, f: ' ', e: 'name '},
+ {m: '"name" to "name "', i: 'name', l: 8, a:-1, f: ' ', e: 'name '},
+ {m: '"name" to "name"', i: 'name', l: 4, a: 1, f: ' ', e: 'name'},
+ {m: '"name" to "||||||||name"', i: 'name', l: 8, a:1, f: '||', e: '||||||||name'},
+ {m: '"name" to "||||name||||"', i: 'name', l: 8, a:3, f: '||', e: '||||name||||'},
+ {m: '"name" to "name||||||||"', i: 'name', l: 8, a:2, f: '||', e: 'name||||||||'}
+ ];
+ tests.forEach(function(test) {
+ it(test.m + ' ', function () {
+ expect(string_utils.pad(test.i, test.l, test.f, test.a)).to.equal(test.e);
+ });
+ });
+ });
+
+});
Modified: incubator/ambari/trunk/ambari-web/test/utils/validator_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/utils/validator_test.js?rev=1485455&r1=1485454&r2=1485455&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/utils/validator_test.js (original)
+++ incubator/ambari/trunk/ambari-web/test/utils/validator_test.js Wed May 22 21:59:23 2013
@@ -208,7 +208,10 @@ describe('validator', function () {
{m:'"abc12345679abc1234567890abc1234567890$" - invalid',i:'abc12345679abc1234567890abc1234567890$',e:false},
{m:'"1abc123$$" - invalid',i:'1abc123$$',e:false},
{m:'"a" - valid',i:'a',e:true},
- {m:'"!" - invalid',i:'!',e:false}
+ {m:'"!" - invalid',i:'!',e:false},
+ {m:'"root$" - invalid',i:'root$',e:false},
+ {m:'"rootU" - invalid',i:'rootU',e:false},
+ {m:'"rUoot" - invalid',i:'rUoot',e:false}
];
tests.forEach(function(test) {
it(test.m + ' ', function () {