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 2014/07/09 06:29:45 UTC
[2/6] AMBARI-6430. Make new services pluggable to the wizard. (jaimin
via yusaku)
http://git-wip-us.apache.org/repos/asf/ambari/blob/00f8d5c5/ambari-web/app/views/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/item.js b/ambari-web/app/views/main/service/item.js
index 4ee6a64..15d9835 100644
--- a/ambari-web/app/views/main/service/item.js
+++ b/ambari-web/app/views/main/service/item.js
@@ -30,7 +30,7 @@ App.MainServiceItemView = Em.View.extend({
var serviceName = service.get('serviceName');
var disableRefreshConfgis = !service.get('isRestartRequired');
- if (service.get('isClientsOnly')) {
+ if (this.get('controller.isClientsOnlyService')) {
if (serviceName != 'TEZ') {
options.push({action: 'runSmokeTest', cssClass: 'icon-thumbs-up-alt', 'label': Em.I18n.t('services.service.actions.run.smoke')});
}
@@ -84,13 +84,13 @@ App.MainServiceItemView = Em.View.extend({
options.push({action:'turnOnOffPassive', cssClass: 'icon-medkit', context:requestLabel, 'label':passiveLabel , disabled: false});
}
return options;
- }.property('controller.content', 'controller.isStopDisabled'),
+ }.property('controller.content', 'controller.isStopDisabled','controller.isClientsOnlyService'),
isMaintenanceActive: function() {
return this.get('maintenance').length !== 0;
}.property('maintenance'),
- hasConfigTab: function(){
- return this.get("controller.content.isConfigurable");
- }.property('controller.content.isConfigurable'),
+ hasConfigTab: function() {
+ return !App.get('services.noConfigTypes').concat('HCATALOG').contains('controller.content.serviceName');
+ }.property('controller.content.serviceName','App.services.noConfigTypes'),
didInsertElement: function () {
this.get('controller').setStartStopState();
http://git-wip-us.apache.org/repos/asf/ambari/blob/00f8d5c5/ambari-web/app/views/main/service/menu.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/menu.js b/ambari-web/app/views/main/service/menu.js
index de81134..562ddf0 100644
--- a/ambari-web/app/views/main/service/menu.js
+++ b/ambari-web/app/views/main/service/menu.js
@@ -26,7 +26,8 @@ App.MainServiceMenuView = Em.CollectionView.extend({
var items = App.router.get('mainServiceController.content').filter(function(item){
return !this.get('disabledServices').contains(item.get('id'));
}, this);
- return misc.sortByOrder(App.Service.servicesSortOrder, items);
+ var stackServices = App.StackService.find().mapProperty('serviceName');
+ return misc.sortByOrder(stackServices, items);
}.property('App.router.mainServiceController.content', 'App.router.mainServiceController.content.length'),
didInsertElement:function () {
@@ -73,12 +74,16 @@ App.MainServiceMenuView = Em.CollectionView.extend({
return this.get('content.criticalAlertsCount');
}.property('content.criticalAlertsCount'),
+ isConfigurable: function () {
+ return !App.get('services.noConfigTypes').concat('HCATALOG').contains('content.serviceName');
+ }.property('App.services.noConfigTypes','content.serviceName'),
+
link: function() {
var stateName = (['summary','configs'].contains(App.router.get('currentState.name')))
- ? this.get('content.isConfigurable') ? App.router.get('currentState.name') : 'summary'
+ ? this.get('isConfigurable') ? App.router.get('currentState.name') : 'summary'
: 'summary';
return "#/main/services/" + this.get('content.id') + "/" + stateName;
- }.property('App.router.currentState.name', 'parentView.activeServiceId'),
+ }.property('App.router.currentState.name', 'parentView.activeServiceId', 'isConfigurable'),
refreshRestartRequiredMessage: function() {
var restarted, componentsCount, hostsCount, message, tHosts, tComponents;
@@ -115,7 +120,8 @@ App.TopNavServiceMenuView = Em.CollectionView.extend({
var items = App.router.get('mainServiceController.content').filter(function(item){
return !this.get('disabledServices').contains(item.get('id'));
}, this);
- return misc.sortByOrder(App.Service.servicesSortOrder, items);
+ var stackServices = App.StackService.find().mapProperty('serviceName');
+ return misc.sortByOrder(stackServices, items);
}.property('App.router.mainServiceController.content', 'App.router.mainServiceController.content.length'),
didInsertElement:function () {
@@ -160,12 +166,16 @@ App.TopNavServiceMenuView = Em.CollectionView.extend({
return this.get('content.criticalAlertsCount');
}.property('content.criticalAlertsCount'),
+ isConfigurable: function () {
+ return !App.get('services.noConfigTypes').concat('HCATALOG').contains('content.serviceName');
+ }.property('App.services.noConfigTypes','content.serviceName'),
+
link: function() {
var stateName = (['summary','configs'].contains(App.router.get('currentState.name')))
- ? this.get('content.isConfigurable') ? App.router.get('currentState.name') : 'summary'
+ ? this.get('isConfigurable') ? App.router.get('currentState.name') : 'summary'
: 'summary';
return "#/main/services/" + this.get('content.id') + "/" + stateName;
- }.property('App.router.currentState.name', 'parentView.activeServiceId'),
+ }.property('App.router.currentState.name', 'parentView.activeServiceId','isConfigurable'),
refreshRestartRequiredMessage: function() {
var restarted, componentsCount, hostsCount, message, tHosts, tComponents;
http://git-wip-us.apache.org/repos/asf/ambari/blob/00f8d5c5/ambari-web/app/views/main/service/service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/service.js b/ambari-web/app/views/main/service/service.js
index b8b6c42..7f48ac9 100644
--- a/ambari-web/app/views/main/service/service.js
+++ b/ambari-web/app/views/main/service/service.js
@@ -52,7 +52,8 @@ App.MainDashboardServiceHealthView = Em.View.extend({
},
healthStatus: function () {
- if (this.get('service.isClientsOnly')) {
+ var isClientOnlyService = App.get('services.clientOnly').contains(this.get('service.serviceName'));
+ if (isClientOnlyService) {
return 'icon-laptop';
}
if (this.get('service.passiveState') != 'OFF') {
@@ -82,7 +83,7 @@ App.MainDashboardServiceHealthView = Em.View.extend({
}
return 'health-status-' + status;
- }.property('service.healthStatus','service.passiveState','service.isClientsOnly'),
+ }.property('service.healthStatus','service.passiveState','service.serviceName'),
healthStatusClass: function () {
switch (this.get('healthStatus')) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/00f8d5c5/ambari-web/app/views/wizard/step5_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/wizard/step5_view.js b/ambari-web/app/views/wizard/step5_view.js
index 2a5fb34..c78cb4c 100644
--- a/ambari-web/app/views/wizard/step5_view.js
+++ b/ambari-web/app/views/wizard/step5_view.js
@@ -17,6 +17,7 @@
*/
var App = require('app');
+var stringUtils = require('utils/string_utils');
App.WizardStep5View = Em.View.extend({
@@ -33,14 +34,30 @@ App.WizardStep5View = Em.View.extend({
didInsertElement: function () {
this.get('controller').loadStep();
- }
+ this.setCoHostedComponentText();
+ },
+
+ coHostedComponentText: '',
+
+ setCoHostedComponentText: function () {
+ var coHostedComponents = App.StackServiceComponent.find().filterProperty('isOtherComponentCoHosted').filterProperty('stackService.isSelected');
+ var coHostedComponentsText = '';
+ coHostedComponents.forEach(function (serviceComponent, index) {
+ var coHostedComponentsDisplayNames = serviceComponent.get('coHostedComponents').map(function (item) {
+ return App.StackServiceComponent.find().findProperty('componentName', item).get('displayName');
+ });
+ var componentTextArr = [serviceComponent.get('displayName')].concat(coHostedComponentsDisplayNames);
+ coHostedComponents[index] = stringUtils.getFormattedStringFromArray(componentTextArr);
+ coHostedComponentsText += '<br/>' + Em.I18n.t('installer.step5.body.coHostedComponents').format(coHostedComponents[index]);
+ }, this);
+ this.set('coHostedComponentText', coHostedComponentsText);
+ }
});
App.InputHostView = Em.TextField.extend(App.SelectHost, {
attributeBindings: ['disabled'],
-
/**
* Saved typeahead component
* @type {$}
@@ -162,7 +179,7 @@ App.RemoveControlView = Em.View.extend({
* Index for multiple component
* @type {number}
*/
- zId: null,
+ serviceComponentId: null,
/**
* Current component name
@@ -182,6 +199,6 @@ App.RemoveControlView = Em.View.extend({
* @method click
*/
click: function () {
- this.get('controller').removeComponent(this.get('componentName'), this.get("zId"));
+ this.get('controller').removeComponent(this.get('componentName'), this.get("serviceComponentId"));
}
-});
\ No newline at end of file
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/00f8d5c5/ambari-web/app/views/wizard/step6_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/wizard/step6_view.js b/ambari-web/app/views/wizard/step6_view.js
index 39c37aa..c700565 100644
--- a/ambari-web/app/views/wizard/step6_view.js
+++ b/ambari-web/app/views/wizard/step6_view.js
@@ -53,14 +53,9 @@ App.WizardStep6View = App.TableView.extend({
*/
didInsertElement: function () {
var controller = this.get('controller');
- if (controller.get('isMasters')) {
- this.set('label', Em.I18n.t('installer.step6.addHostWizard.body'));
- this.set('title', Em.I18n.t('installer.step5.header'));
- }
- else {
- this.set('title', Em.I18n.t('installer.step6.header'));
- this.setLabel();
- }
+ this.set('title', Em.I18n.t('installer.step6.header'));
+ this.setLabel();
+
App.tooltip($('body'), {selector: '[rel=tooltip]'});
controller.loadStep();
},
@@ -113,8 +108,6 @@ App.WizardStep6HostView = Em.View.extend({
* @method didInsertElement
*/
didInsertElement: function () {
- if(this.get('controller.isMasters')) return;
-
var components = this.get('controller').getMasterComponentsForHost(this.get('host.hostName'));
if (components && components.length > 0) {
components = components.map(function (_component) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/00f8d5c5/ambari-web/test/app_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/app_test.js b/ambari-web/test/app_test.js
index 3b0565b..a5b4d76 100644
--- a/ambari-web/test/app_test.js
+++ b/ambari-web/test/app_test.js
@@ -92,14 +92,15 @@ describe('#App', function() {
var globalProperties = require('data/HDP2/global_properties');
var siteProperties = require('data/HDP2/site_properties');
+
var reviewConfigs = require('data/review_configs');
var disableResult = App.disableComponent(testableComponent);
+
describe('#disableComponent()', function() {
// copy
var _globalProperties = $.extend({}, globalProperties);
var _siteProperties = $.extend({}, siteProperties);
- var _reviewConfigs = JSON.parse(JSON.stringify(reviewConfigs));
describe('result validation', function() {
@@ -139,12 +140,6 @@ describe('#App', function() {
expect(_siteProperties.configProperties.mapProperty('name')).to.not.include.members(expectedInfo.properties.site_properties);
});
- it('should remove review config for component', function() {
- var reviewConfig = _reviewConfigs.findProperty('config_name', 'services')
- .config_value.findProperty('service_name', testableComponent.get('serviceName'))
- .service_components.mapProperty('component_name');
- expect(reviewConfig).to.not.include(expectedInfo.reviewConfigs.component_name);
- });
});
});
@@ -158,13 +153,6 @@ describe('#App', function() {
it('should add site properties of component', function() {
expect(siteProperties.configProperties.mapProperty('name')).to.include.members(expectedInfo.properties.site_properties);
});
-
- it('should add review config for component', function() {
- var reviewConfig = reviewConfigs.findProperty('config_name', 'services')
- .config_value.findProperty('service_name', testableComponent.get('serviceName'))
- .get('service_components').mapProperty('component_name');
- expect(reviewConfig).to.include(expectedInfo.reviewConfigs.component_name);
- });
});
modelSetup.restoreStackVersion(this);
http://git-wip-us.apache.org/repos/asf/ambari/blob/00f8d5c5/ambari-web/test/controllers/main/host/add_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/add_controller_test.js b/ambari-web/test/controllers/main/host/add_controller_test.js
index 6ca3f0d..4bdeae3 100644
--- a/ambari-web/test/controllers/main/host/add_controller_test.js
+++ b/ambari-web/test/controllers/main/host/add_controller_test.js
@@ -119,30 +119,30 @@ describe('App.AddHostController', function () {
{
title: 'Service is not in stack',
services: [
- {
+ Em.Object.create({
serviceName: 'TEST',
isSelected: true
- }
+ })
],
result: []
},
{
title: 'Service does not have any clients',
services: [
- {
+ Em.Object.create({
serviceName: 'GANGLIA',
isSelected: true
- }
+ })
],
result: []
},
{
title: 'StackServiceComponent is empty',
services: [
- {
+ Em.Object.create({
serviceName: 'HDFS',
isSelected: true
- }
+ })
],
result: []
}
@@ -160,10 +160,10 @@ describe('App.AddHostController', function () {
it('HDFS has uninstalled client', function () {
modelSetup.setupStackServiceComponent();
var services = [
- {
+ Em.Object.create({
serviceName: 'HDFS',
isSelected: true
- }
+ })
];
controller.set('content.services', services);
controller.saveClients();
@@ -186,10 +186,10 @@ describe('App.AddHostController', function () {
it('HDFS has installed client', function () {
modelSetup.setupStackServiceComponent();
var services = [
- {
+ Em.Object.create({
serviceName: 'HDFS',
isSelected: true
- }
+ })
];
App.store.load(App.HostComponent, {
id: 'HDFS_CLIENT_host1',
http://git-wip-us.apache.org/repos/asf/ambari/blob/00f8d5c5/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 624af19..058ac57 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -913,6 +913,7 @@ describe('App.MainHostDetailsController', function () {
controller.doDecommissionRegionServer.restore();
controller.doDecommission.restore();
controller.showBackgroundOperationsPopup.restore();
+ controller.doDecommissionRegionServer.restore();
});
it('HDFS service', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/00f8d5c5/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 a1d9ed5..71c417b 100644
--- a/ambari-web/test/controllers/wizard/step4_test.js
+++ b/ambari-web/test/controllers/wizard/step4_test.js
@@ -30,7 +30,7 @@ describe('App.WizardStep4Controller', function () {
var controller = App.WizardStep4Controller.create();
services.forEach(function(serviceName, index){
controller.pushObject(Ember.Object.create({
- 'serviceName':serviceName, 'isSelected': true, 'canBeSelected': true, 'isInstalled': false, 'isDisabled': 'HDFS' === serviceName
+ 'serviceName':serviceName, 'isSelected': true, 'canBeSelected': true, 'isInstalled': false, 'isDisabled': 'HDFS' === serviceName, isDFS: 'HDFS' === serviceName
}));
});
@@ -78,145 +78,14 @@ describe('App.WizardStep4Controller', function () {
});
describe('#selectMinimum()', function () {
- it('should set isSelected false for all not disabled services', function () {
+ it('should set isSelected false for all services', function () {
controller.setEach('isSelected', true);
controller.selectMinimum();
- expect(controller.findProperty('serviceName', 'HDFS').get('isSelected')).to.equal(true);
+ expect(controller.findProperty('serviceName', 'HDFS').get('isSelected')).to.equal(false);
expect(controller.filterProperty('isDisabled', false).everyProperty('isSelected', false)).to.equal(true);
});
});
- describe('#needToAddMapReduce()', function () {
- it('should return true if Pig is selected and MapReduce is not selected', function () {
- controller.setEach('isSelected', false);
- controller.findProperty('serviceName', 'PIG').set('isSelected', true);
- expect(controller.needToAddMapReduce()).to.equal(true);
- });
-
- it('should return true if Oozie is selected and MapReduce is not selected', function () {
- controller.setEach('isSelected', false);
- controller.findProperty('serviceName', 'OOZIE').set('isSelected', true);
- expect(controller.needToAddMapReduce()).to.equal(true);
- });
-
- it('should return true if Hive is selected and MapReduce is not selected', function () {
- controller.setEach('isSelected', false);
- controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
- expect(controller.needToAddMapReduce()).to.equal(true);
- });
-
- it('should return false if MapReduce is selected or Pig, Oozie and Hive are not selected', function () {
- controller.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true);
- expect(controller.needToAddMapReduce()).to.equal(false);
- controller.setEach('isSelected', false);
- expect(controller.needToAddMapReduce()).to.equal(false);
- });
- });
-
- describe('#needToAddYarnMapReduce2()', function () {
- it('should return true if Pig is selected and YARN+MapReduce2 is not selected', function () {
- controller.setEach('isSelected', false);
- controller.findProperty('serviceName', 'PIG').set('isSelected', true);
- expect(controller.needToAddYarnMapReduce2()).to.equal(true);
- });
-
- it('should return true if Oozie is selected and YARN+MapReduce2 is not selected', function () {
- controller.setEach('isSelected', false);
- controller.findProperty('serviceName', 'OOZIE').set('isSelected', true);
- expect(controller.needToAddYarnMapReduce2()).to.equal(true);
- });
-
- it('should return true if Hive is selected and YARN+MapReduce2 is not selected', function () {
- controller.setEach('isSelected', false);
- controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
- expect(controller.needToAddYarnMapReduce2()).to.equal(true);
- });
-
- it('should return false if YARN+MapReduce2 is selected or Pig, Oozie and Hive are not selected', function () {
- controller.findProperty('serviceName', 'YARN').set('isSelected', true);
- expect(controller.needToAddYarnMapReduce2()).to.equal(false);
- controller.setEach('isSelected', false);
- expect(controller.needToAddYarnMapReduce2()).to.equal(false);
- });
- });
-
- describe('#needToAddZooKeeper()', function () {
- beforeEach(function() {
- ajax_send = App.ajax.send;
- App.ajax.send = function() {};
- });
-
- afterEach(function() {
- App.ajax.send = ajax_send;
- });
- var originalStackVersion = App.get('currentStackVersion');
-
- it('should return false if ZOOKEEPER is selected and Hadoop version above 2', function () {
- App.set('currentStackVersion', 'HDP-2.1.1');
- controller.findProperty('serviceName', 'ZOOKEEPER').set('isSelected', true);
- expect(controller.needToAddZooKeeper()).to.equal(false);
- });
- it('should return true if ZOOKEEPER is not selected and Hadoop version above 2', function () {
- controller.findProperty('serviceName', 'ZOOKEEPER').set('isSelected', false);
- expect(controller.needToAddZooKeeper()).to.equal(true);
- });
- it('should return false if none of the HBASE, HIVE, WEBHCAT, STORM is selected and Hadoop version below 2', function () {
- App.set('currentStackVersion', 'HDP-1.3.0');
- expect(controller.needToAddZooKeeper()).to.equal(false);
- });
- it('should return true if HBASE is not selected and Hadoop version below 2', function () {
- controller.findProperty('serviceName', 'HBASE').set('isSelected', true);
- expect(controller.needToAddZooKeeper()).to.equal(true);
- });
- it('should return true if HBASE, HIVE, WEBHCAT, STORM are selected and Hadoop version below 2', function () {
- controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
- controller.findProperty('serviceName', 'WEBHCAT').set('isSelected', true);
- controller.findProperty('serviceName', 'STORM').set('isSelected', true);
- expect(controller.needToAddZooKeeper()).to.equal(true);
- App.set('currentStackVersion', originalStackVersion);
- });
- });
-
- describe('#gangliaOrNagiosNotSelected()', function () {
- it('should return true if Nagios or Ganglia is not selected', function () {
- controller.setEach('isSelected', true);
- controller.findProperty('serviceName', 'NAGIOS').set('isSelected', false);
- expect(controller.gangliaOrNagiosNotSelected()).to.equal(true);
- controller.setEach('isSelected', true);
- controller.findProperty('serviceName', 'GANGLIA').set('isSelected', false);
- expect(controller.gangliaOrNagiosNotSelected()).to.equal(true);
- });
-
- it('should return false if Nagios and Ganglia is selected', function () {
- controller.setEach('isSelected', false);
- controller.findProperty('serviceName', 'GANGLIA').set('isSelected', true);
- controller.findProperty('serviceName', 'NAGIOS').set('isSelected', true);
- expect(controller.gangliaOrNagiosNotSelected()).to.equal(false);
- });
- });
-
- describe('#needToAddTez()', function () {
- it('should return false if YARN is present, but not selected', function () {
- controller.findProperty('serviceName', 'YARN').set('isSelected', false);
- expect(controller.needToAddTez()).to.equal(false);
- });
- it('should return true if YARN is selected', function () {
- controller.findProperty('serviceName', 'YARN').set('isSelected', true);
- expect(controller.needToAddTez()).to.equal(true);
- });
- });
-
- describe('#needToAddOozie()', function () {
- it('should return false if FALCON is present, but not selected', function () {
- controller.findProperty('serviceName', 'FALCON').set('isSelected', false);
- expect(controller.needToAddOozie()).to.equal(false);
- });
- it('should return true if FALCON is selected', function () {
- controller.findProperty('serviceName', 'FALCON').set('isSelected', true);
- expect(controller.needToAddOozie()).to.equal(true);
- });
- });
-
describe('#noDFSs()', function () {
it('should return true if HDFS is not selected and GLUSTERFS is absent', function () {
controller.findProperty('serviceName', 'HDFS').set('isSelected', false);
@@ -228,7 +97,7 @@ describe('App.WizardStep4Controller', function () {
});
it('should return true if HDFS is not selected and GLUSTERFS is not selected, but present', function () {
controller.pushObject(Ember.Object.create({
- 'serviceName':'GLUSTERFS', 'isSelected': false, 'canBeSelected': true, 'isInstalled': false, 'isDisabled': false
+ 'serviceName':'GLUSTERFS', 'isSelected': false, 'canBeSelected': true, 'isInstalled': false, 'isDisabled': false, 'isDFS': true
}));
controller.findProperty('serviceName', 'HDFS').set('isSelected', false);
expect(controller.noDFSs()).to.equal(true);
@@ -256,7 +125,7 @@ describe('App.WizardStep4Controller', function () {
});
});
- describe('#checkDependencies()', function () {
+ describe('#setGroupedServices()', function () {
var testCases = [
{
title: 'should set HCATALOG and WEBHCAT isSelected to true when HIVE is selected',
@@ -327,10 +196,13 @@ describe('App.WizardStep4Controller', function () {
controller.clear();
for(var id in testCase.condition) {
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.checkDependencies();
+ controller.setGroupedServices();
for(var service in testCase.result) {
expect(controller.findProperty('serviceName', service).get('isSelected')).to.equal(testCase.result[service]);
}
@@ -381,6 +253,14 @@ describe('App.WizardStep4Controller', function () {
});
describe('#validateMonitoring', function() {
+ beforeEach(function() {
+ sinon.stub(controller, 'monitoringCheckPopup', Em.K);
+ sinon.stub(App.router, 'send', Em.K);
+ });
+ afterEach(function() {
+ controller.monitoringCheckPopup.restore();
+ App.router.send.restore();
+ });
Em.A([
{
gangliaOrNagiosNotSelected: true,
@@ -398,12 +278,11 @@ describe('App.WizardStep4Controller', function () {
}
]).forEach(function (test) {
it(test.m, function () {
- sinon.stub(controller, 'monitoringCheckPopup', Em.K);
- sinon.stub(App.router, 'send', Em.K);
sinon.stub(controller, 'gangliaOrNagiosNotSelected', function() {
return test.gangliaOrNagiosNotSelected;
});
controller.validateMonitoring();
+ controller.gangliaOrNagiosNotSelected.restore();
if (test.e.monitoringCheckPopup) {
expect(controller.monitoringCheckPopup.calledOnce).to.equal(true);
}
@@ -416,9 +295,6 @@ describe('App.WizardStep4Controller', function () {
else {
expect(App.router.send.called).to.equal(false);
}
- controller.gangliaOrNagiosNotSelected.restore();
- controller.monitoringCheckPopup.restore();
- App.router.send.restore();
});
});
});
@@ -426,9 +302,11 @@ describe('App.WizardStep4Controller', function () {
describe('#submit', function() {
beforeEach(function() {
sinon.stub(controller, 'validateMonitoring', Em.K);
+ sinon.stub(controller, 'setGroupedServices', Em.K);
});
afterEach(function() {
controller.validateMonitoring.restore();
+ controller.setGroupedServices.restore();
});
it('if not isSubmitDisabled shound\'t do nothing', function() {
controller.reopen({isSubmitDisabled: true});
@@ -436,19 +314,20 @@ describe('App.WizardStep4Controller', function () {
expect(controller.validateMonitoring.called).to.equal(false);
});
it('if isSubmitDisabled and not submitChecks should call validateMonitoring', function() {
+ sinon.stub(controller, 'isSubmitChecksFailed', function() { return false; });
controller.reopen({
isSubmitDisabled: false,
submitChecks: []
});
controller.submit();
expect(controller.validateMonitoring.calledOnce).to.equal(true);
+ controller.isSubmitChecksFailed.restore();
});
it('if isSubmitDisabled and some submitChecks true shouldn\'t call validateMonitoring', function() {
controller.reopen({
isSubmitDisabled: false,
submitChecks: [
{
- checkCallback: 'needToAddMapReduce',
popupParams: [
{serviceName: 'MAPREDUCE', selected: true},
'mapreduceCheck'
@@ -456,10 +335,10 @@ describe('App.WizardStep4Controller', function () {
}
]
});
- sinon.stub(controller, 'needToAddMapReduce', function() {return true;});
+ sinon.stub(controller, 'isSubmitChecksFailed', function() { return true; });
controller.submit();
+ controller.isSubmitChecksFailed.restore();
expect(controller.validateMonitoring.called).to.equal(false);
- controller.needToAddMapReduce.restore();
});
it('if isSubmitDisabled and some submitChecks false should call validateMonitoring', function() {
controller.reopen({
@@ -474,10 +353,10 @@ describe('App.WizardStep4Controller', function () {
}
]
});
- sinon.stub(controller, 'needToAddMapReduce', function() {return false;});
+ sinon.stub(controller, 'isSubmitChecksFailed', function() { return false; });
controller.submit();
+ controller.isSubmitChecksFailed.restore();
expect(controller.validateMonitoring.calledOnce).to.equal(true);
- controller.needToAddMapReduce.restore();
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/00f8d5c5/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 d3f5a91..3eb18cb 100644
--- a/ambari-web/test/controllers/wizard/step5_test.js
+++ b/ambari-web/test/controllers/wizard/step5_test.js
@@ -19,212 +19,85 @@
var Ember = require('ember');
var App = require('app');
require('controllers/wizard/step5_controller');
+var modelSetup = require('test/init_model_test');
+require('utils/ajax/ajax');
var c;
describe('App.WizardStep5Controller', function () {
- beforeEach(function() {
+ beforeEach(function () {
c = App.WizardStep5Controller.create();
});
var controller = App.WizardStep5Controller.create();
controller.set('content', {});
var cpu = 2, memory = 4;
- var schemes = Em.A([
- {'description': 'empty condition'},
- {
- 'description': 'second host if amount more than 1',
- "else": 1
- },
- {
- 'description': 'first host if amount less than 3, third host if amount less than 6, fourth host if amount more than 5',
- "3": 0,
- "6": 2,
- "else": 3
- },
- {
- 'description': 'second host if amount less than 3, second host if amount less than 6, third host if amount less than 31, sixth host if amount more than 30',
- "3": 1,
- "6": 1,
- "31": 2,
- "else": 5
- }
- ]);
-
- var test_config = [
- {
- title: '1 host',
- hosts: ['host0'],
- equals: [0, 0, 0, 0]
- },
- {
- title: '2 hosts',
- hosts: ['host0', 'host1'],
- equals: [0, 1, 0, 1]
- },
- {
- title: '3 hosts',
- hosts: ['host0', 'host1', 'host2'],
- equals: [0, 1, 2, 1]
- },
- {
- title: '5 hosts',
- hosts: ['host0', 'host1', 'host2', 'host3', 'host4'],
- equals: [0, 1, 2, 1]
- },
- {
- title: '6 hosts',
- hosts: ['host0', 'host1', 'host2', 'host3', 'host4', 'host6'],
- equals: [0, 1, 3, 2]
- },
- {
- title: '10 hosts',
- hosts: ['host0', 'host1', 'host2', 'host3', 'host4', 'host5', 'host6', 'host7', 'host8', 'host9'],
- equals: [0, 1, 3, 2]
- },
- {
- title: '31 hosts',
- hosts: ['host0', 'host1', 'host2', 'host3', 'host4', 'host5', 'host6', 'host7', 'host8', 'host9', 'host10', 'host11', 'host12', 'host13', 'host14', 'host15', 'host16', 'host17', 'host18', 'host19', 'host20', 'host21', 'host22', 'host23', 'host24', 'host25', 'host26', 'host27', 'host28', 'host29', 'host30'],
- equals: [0, 1, 3, 5]
- }
- ];
-
- schemes.forEach(function(scheme, index) {
- describe('#getHostForComponent() condition: ' + scheme.description, function() {
-
- delete scheme['description'];
+ describe('#getHostForComponent()', function () {
+ before(function () {
+ modelSetup.setupStackServiceComponent();
+ });
- test_config.forEach(function(test) {
- it(test.title, function () {
- controller.get('hosts').clear();
- test.hosts.forEach(function(_host) {
- controller.get('hosts').pushObject(Em.Object.create({
- host_name: _host,
- cpu: cpu,
- memory: memory
- }));
- });
- expect(controller.getHostForComponent(test.hosts.length, scheme).host_name).to.equal(test.hosts[test.equals[index]]);
+ var componentHostsGenerator = function (componentName, hosts) {
+ it('test hosts input valid', function () {
+ expect(hosts.length).to.eql(5);
});
+ return {
+ componentName: componentName,
+ expectedLocation: hosts
+ };
+ },
+ hostsCount = [1, 3, 6, 10, 31],
+ tests = [
+ componentHostsGenerator('NAMENODE', ['host0', 'host0', 'host0', 'host0', 'host0']),
+ componentHostsGenerator('SECONDARY_NAMENODE', ['host0', 'host1', 'host1', 'host1', 'host1']),
+ componentHostsGenerator('HBASE_MASTER', ['host0', 'host0', 'host2', 'host2', 'host3']),
+ componentHostsGenerator('JOBTRACKER', ['host0', 'host1', 'host1', 'host1', 'host2']),
+ componentHostsGenerator('OOZIE_SERVER', ['host0', 'host1', 'host2', 'host2', 'host3']),
+ componentHostsGenerator('HIVE_SERVER', ['host0', 'host1', 'host2', 'host2', 'host4']),
+ componentHostsGenerator('STORM_UI_SERVER', ['host0', 'host0', 'host0', 'host0', 'host0'])
+ ],
+ testMessage = 'should locate `{0}` to `{1}` with {2} node cluster';
+
+ tests.forEach(function (test) {
+ var componentName = test.componentName;
+ hostsCount.forEach(function (count, index) {
+ it(testMessage.format(componentName, test.expectedLocation[index], count), function () {
+ var hosts = Array.apply(null, Array(count)).map(function (_, i) {
+ return 'host' + i;
+ });
+ expect(controller.getHostForComponent(test.componentName, hosts)).to.eql(test.expectedLocation[index]);
+ })
});
});
- });
-
- describe('#getZooKeeperServer', function() {
- it('should be array with three host names if hosts number more than three', function() {
- var hosts = [
- {host_name: 'host1'},
- {host_name: 'host2'},
- {host_name: 'host3'}
- ];
-
- controller.set('hosts', hosts);
- expect(controller.getZooKeeperServer(hosts.length)).to.eql(['host1', 'host2', 'host3']);
- });
-
- it('should be array with one host names if hosts number less than three', function() {
- var hosts = [
- {host_name: 'host1'},
- {host_name: 'host2'}
- ];
- controller.set('hosts', hosts);
- expect(controller.getZooKeeperServer(hosts.length)).to.eql(['host1']);
+ after(function () {
+ modelSetup.cleanStackServiceComponent();
});
});
- describe('#getServerHost', function() {
- it('should be host name if one host ', function() {
- var hosts = [
- {host_name: 'host1'}
- ];
-
- controller.set('hosts', hosts);
- expect(controller.getServerHost(hosts.length)).to.eql('host1');
- });
-
- it('should be host name if hosts number more than one', function() {
- var hosts = [
- {host_name: 'host1'},
- {host_name: 'host2'}
- ];
-
- controller.set('hosts', hosts);
- expect(controller.getServerHost(hosts.length)).to.eql('host1');
- });
-
- it('should be host name different from localhost if hosts number more than one', function() {
- var hosts = [
- {host_name: location.hostname},
- {host_name: 'host2'}
- ];
- //first host_name is empty string, because of location.hostname = "" in console,
- //to implement current test case
-
- controller.set('hosts', hosts);
- expect(controller.getServerHost(hosts.length)).to.eql('host2');
- });
- });
-
-
controller.set('content', {});
- describe('#isReassignWizard', function() {
- it('true if content.controllerName is reassignMasterController', function() {
+ describe('#isReassignWizard', function () {
+ it('true if content.controllerName is reassignMasterController', function () {
controller.set('content.controllerName', 'reassignMasterController');
expect(controller.get('isReassignWizard')).to.equal(true);
});
- it('false if content.controllerName is not reassignMasterController', function() {
+ it('false if content.controllerName is not reassignMasterController', function () {
controller.set('content.controllerName', 'mainController');
expect(controller.get('isReassignWizard')).to.equal(false);
});
});
- describe('#isAddServiceWizard', function() {
- it('true if content.controllerName is addServiceController', function() {
+ describe('#isAddServiceWizard', function () {
+ it('true if content.controllerName is addServiceController', function () {
controller.set('content.controllerName', 'addServiceController');
expect(controller.get('isAddServiceWizard')).to.equal(true);
});
- it('false if content.controllerName is not addServiceController', function() {
+ it('false if content.controllerName is not addServiceController', function () {
controller.set('content.controllerName', 'mainController');
expect(controller.get('isAddServiceWizard')).to.equal(false);
});
});
- describe('#isReassignHive', function() {
-
- var tests = Em.A([
- {
- servicesMasters: Em.A([{component_name: 'HIVE_SERVER'}]),
- controllerName: 'reassignMasterController',
- e: true
- },
- {
- servicesMasters: Em.A([{component_name: 'HIVE_SERVER'}]),
- controllerName: 'addServiceController',
- e: false
- },
- {
- servicesMasters: Em.A([{component_name: 'ZOOKEEPER_SERVER'}]),
- controllerName: 'reassignMasterController',
- e: false
- },
- {
- servicesMasters: Em.A([{component_name: 'ZOOKEEPER_SERVER'}]),
- controllerName: 'addServiceController',
- e: false
- }
- ]);
-
- tests.forEach(function(test) {
- it(test.controllerName + ' ' + test.servicesMasters.mapProperty('component_name').join(','), function() {
- controller.set('content.controllerName', test.controllerName);
- controller.set('servicesMasters', test.servicesMasters);
- expect(controller.get('isReassignHive')).to.equal(test.e);
- });
- });
-
- });
-
- describe('#sortHosts', function() {
+ describe('#sortHosts', function () {
var tests = Em.A([
{
@@ -235,7 +108,7 @@ describe('App.WizardStep5Controller', function () {
Em.Object.create({memory: 1, cpu: 1, host_name: 'host4', id: 4})
],
m: 'memory',
- e: [1,2,3,4]
+ e: [1, 2, 3, 4]
},
{
hosts: [
@@ -245,7 +118,7 @@ describe('App.WizardStep5Controller', function () {
Em.Object.create({memory: 1, cpu: 1, host_name: 'host4', id: 4})
],
m: 'cpu',
- e: [1,2,3,4]
+ e: [1, 2, 3, 4]
},
{
hosts: [
@@ -255,7 +128,7 @@ describe('App.WizardStep5Controller', function () {
Em.Object.create({memory: 1, cpu: 1, host_name: 'host1', id: 4})
],
m: 'host_name',
- e: [4,2,3,1]
+ e: [4, 2, 3, 1]
},
{
hosts: [
@@ -265,12 +138,12 @@ describe('App.WizardStep5Controller', function () {
Em.Object.create({memory: 1, cpu: 1, host_name: 'host2', id: 4})
],
m: 'mix',
- e: [1,2,4,3]
+ e: [1, 2, 4, 3]
}
]);
- tests.forEach(function(test) {
- it(test.m, function() {
+ tests.forEach(function (test) {
+ it(test.m, function () {
var hosts = Em.copy(test.hosts);
controller.sortHosts(hosts);
expect(Em.A(hosts).mapProperty('id')).to.eql(test.e);
@@ -279,7 +152,7 @@ describe('App.WizardStep5Controller', function () {
});
- describe('#renderHostInfo', function() {
+ describe('#renderHostInfo', function () {
var tests = Em.A([
{
@@ -334,8 +207,8 @@ describe('App.WizardStep5Controller', function () {
}
]);
- tests.forEach(function(test) {
- it(test.m, function() {
+ tests.forEach(function (test) {
+ it(test.m, function () {
controller.set('content', {hosts: test.hosts});
controller.renderHostInfo();
var r = controller.get('hosts');
@@ -345,49 +218,16 @@ describe('App.WizardStep5Controller', function () {
});
- describe('#hasHiveServer', function() {
-
- var tests = Em.A([
- {
- selectedServicesMasters: Em.A([{component_name: 'HIVE_SERVER'}]),
- controllerName: 'reassignMasterController',
- e: false
- },
- {
- selectedServicesMasters: Em.A([{component_name: 'HIVE_SERVER'}]),
- controllerName: 'addServiceController',
- e: true
- },
- {
- selectedServicesMasters: Em.A([{component_name: 'ANOTHER'}]),
- controllerName: 'addServiceController',
- e: false
- },
- {
- selectedServicesMasters: Em.A([{component_name: 'ANOTHER'}]),
- controllerName: 'reassignMasterController',
- e: false
- }
- ]);
-
- tests.forEach(function(test) {
- it(test.controllerName + ' ' + test.selectedServicesMasters.mapProperty('component_name').join(','), function() {
- controller.set('content.controllerName', test.controllerName);
- controller.set('selectedServicesMasters', test.selectedServicesMasters);
- expect(controller.get('hasHiveServer')).to.equal(test.e);
+ describe('#selectHost', function () {
+ before(function () {
+ modelSetup.setupStackServiceComponent();
+ App.store.load(App.StackServiceComponent, {
+ id: 'KERBEROS_SERVER',
+ component_name: 'KERBEROS_SERVER'
});
});
- });
-
- describe('#selectHost', function() {
-
var tests = Em.A([
- {componentName: 'KERBEROS_SERVER', hostsCount: 1, e: 'host1'},
- {componentName: 'KERBEROS_SERVER', hostsCount: 3, e: 'host2'},
- {componentName: 'KERBEROS_SERVER', hostsCount: 6, e: 'host4'},
- {componentName: 'KERBEROS_SERVER', hostsCount: 31, e: 'host6'},
- {componentName: 'KERBEROS_SERVER', hostsCount: 32, e: 'host6'},
{componentName: 'NAMENODE', hostsCount: 1, e: 'host1'},
{componentName: 'NAMENODE', hostsCount: 2, e: 'host1'},
{componentName: 'SECONDARY_NAMENODE', hostsCount: 1, e: 'host1'},
@@ -444,27 +284,22 @@ describe('App.WizardStep5Controller', function () {
{componentName: 'FALCON_SERVER', hostsCount: 32, e: 'host4'}
]);
- tests.forEach(function(test) {
- it(test.componentName + ' ' + test.hostsCount, function() {
- controller.set('hosts', d3.range(1, test.hostsCount + 1).map(function(i) { return {host_name: 'host' + i.toString()};}));
+ tests.forEach(function (test) {
+ it(test.componentName + ' ' + test.hostsCount, function () {
+ controller.set('hosts', d3.range(1, test.hostsCount + 1).map(function (i) {
+ return {host_name: 'host' + i.toString()};
+ }));
expect(controller.selectHost(test.componentName)).to.eql(test.e);
});
});
- describe('getServerHost should be called for', function() {
- Em.A(['STORM_UI_SERVER','DRPC_SERVER','STORM_REST_API','NIMBUS','GANGLIA_SERVER','NAGIOS_SERVER','HUE_SERVER']).forEach(function(componentName) {
- it(componentName, function() {
- sinon.spy(controller, 'getServerHost');
- controller.selectHost(componentName);
- expect(controller.getServerHost.calledOnce).to.equal(true);
- controller.getServerHost.restore();
- });
- });
+ after(function () {
+ modelSetup.cleanStackServiceComponent();
});
});
- describe('#last', function() {
+ describe('#last', function () {
var tests = Em.A([
{
@@ -489,8 +324,8 @@ describe('App.WizardStep5Controller', function () {
}
]);
- tests.forEach(function(test) {
- it(test.m, function() {
+ tests.forEach(function (test) {
+ it(test.m, function () {
controller.set('selectedServicesMasters', test.selectedServicesMasters);
if (!Em.isNone(test.e)) {
expect(controller.last(test.c).indx).to.equal(test.e);
@@ -503,37 +338,43 @@ describe('App.WizardStep5Controller', function () {
});
- describe('#isSubmitDisabled', function() {
- it('should be false if it\'s not a isReassignWizard', function() {
+ describe('#isSubmitDisabled', function () {
+ it('should be false if it\'s not a isReassignWizard', function () {
c.set('controllerName', 'addServiceController');
expect(c.get('isSubmitDisabled')).to.equal(false);
});
});
- describe('#remainingHosts', function() {
- it('should show count of hosts without masters', function() {
- c.reopen({masterHostMapping: [{}]});
- c.set('hosts', [{},{},{}]);
+ describe('#remainingHosts', function () {
+ it('should show count of hosts without masters', function () {
+ c.reopen({masterHostMapping: [
+ {}
+ ]});
+ c.set('hosts', [
+ {},
+ {},
+ {}
+ ]);
expect(c.get('remainingHosts')).to.equal(2);
});
});
- describe('#clearStep', function() {
+ describe('#clearStep', function () {
var tests = Em.A([
{p: 'hosts'},
{p: 'selectedServicesMasters'},
{p: 'servicesMasters'}
]);
- tests.forEach(function(test) {
- it('should cleanup ' + test.p, function() {
- c.set(test.p, [Em.Object.create({}),Em.Object.create({})]);
+ tests.forEach(function (test) {
+ it('should cleanup ' + test.p, function () {
+ c.set(test.p, [Em.Object.create({}), Em.Object.create({})]);
c.clearStep();
expect(c.get(test.p).length).to.equal(0);
});
});
});
- describe('#updateComponent', function() {
+ describe('#updateComponent', function () {
var tests = Em.A([
{
componentName: 'HBASE_SERVER',
@@ -612,30 +453,37 @@ describe('App.WizardStep5Controller', function () {
}
]);
- tests.forEach(function(test) {
- it(test.m, function() {
+ tests.forEach(function (test) {
+ it(test.m, function () {
+ sinon.stub(App.StackService, 'find', function () {
+ return test.services;
+ });
c.reopen({
content: Em.Object.create({
- services: test.services,
controllerName: test.controllerName
}),
- selectedServicesMasters: test.selectedServicesMasters
+ selectedServicesMasters: test.selectedServicesMasters,
+ hosts: test.hosts
});
c.updateComponent(test.componentName);
- Em.keys(test.e).forEach(function(k) {
+ App.StackService.find.restore();
+ Em.keys(test.e).forEach(function (k) {
expect(c.last(test.componentName).get(k)).to.equal(test.e[k]);
});
+
});
});
});
- describe('#renderComponents', function() {
+ describe('#renderComponents', function () {
var tests = Em.A([
{
masterComponents: Em.A([
{component_name: 'ZOOKEEPER_SERVER'}
]),
- services: Em.A([]),
+ services: Em.A([
+ Em.Object.create({serviceName: 'ZOOKEEPER', isInstalled: false, isSelected: true})
+ ]),
controllerName: 'reassignMasterController',
m: 'One component',
isHaEnabled: false,
@@ -645,24 +493,24 @@ describe('App.WizardStep5Controller', function () {
servicesMasters: ['ZOOKEEPER_SERVER'],
showRemoveControl: [false],
isInstalled: [false],
- zId: [1]
+ serviceComponentId: [1]
}
},
{
masterComponents: Em.A([
- {component_name: 'ZOOKEEPER_SERVER'},
- {component_name: 'SECONDARY_NAMENODE'}
+ {component_name: 'ZOOKEEPER_SERVER'}
+ ]),
+ services: Em.A([
+ Em.Object.create({serviceName: 'ZOOKEEPER', isInstalled: false, isSelected: true})
]),
- services: Em.A([]),
controllerName: 'addServiceController',
- m: 'One component',
- isHaEnabled: true,
+ m: 'One component, service is not installed',
component_name: 'ZOOKEEPER_SERVER',
e: {
selectedServicesMasters: ['ZOOKEEPER_SERVER'],
servicesMasters: ['ZOOKEEPER_SERVER'],
showRemoveControl: [false],
- zId: [1]
+ serviceComponentId: [1]
}
},
{
@@ -671,17 +519,16 @@ describe('App.WizardStep5Controller', function () {
{component_name: 'ZOOKEEPER_SERVER'}
]),
services: Em.A([
- Em.Object.create({serviceName:'ZOOKEEPER', isInstalled: true})
+ Em.Object.create({serviceName: 'ZOOKEEPER', isInstalled: true})
]),
controllerName: 'addServiceController',
m: 'Two components, but service is installed',
- isHaEnabled: false,
component_name: 'ZOOKEEPER_SERVER',
e: {
selectedServicesMasters: ['ZOOKEEPER_SERVER', 'ZOOKEEPER_SERVER'],
servicesMasters: ['ZOOKEEPER_SERVER', 'ZOOKEEPER_SERVER'],
showRemoveControl: [false, false],
- zId: [1, 2]
+ serviceComponentId: [1, 2]
}
},
{
@@ -691,24 +538,28 @@ describe('App.WizardStep5Controller', function () {
{component_name: 'NAMENODE'}
]),
services: Em.A([
+ Em.Object.create({serviceName: 'ZOOKEEPER', isInstalled: false, isSelected: true})
]),
controllerName: 'addServiceController',
- m: 'Two components, but service is installed',
- isHaEnabled: false,
+ m: 'Two components, but service is not installed',
component_name: 'ZOOKEEPER_SERVER',
e: {
selectedServicesMasters: ['ZOOKEEPER_SERVER', 'ZOOKEEPER_SERVER', 'NAMENODE'],
servicesMasters: ['ZOOKEEPER_SERVER', 'ZOOKEEPER_SERVER', 'NAMENODE'],
showRemoveControl: [true, true, undefined],
- zId: [1, 2, 1]
+ serviceComponentId: [1, 2, undefined]
}
}
]);
- tests.forEach(function(test) {
- beforeEach(function() {
+ tests.forEach(function (test) {
+ beforeEach(function () {
App.reopen({isHaEnabled: test.isHaEnabled});
});
- it(test.m, function() {
+ it(test.m, function () {
+ modelSetup.setupStackServiceComponent();
+ sinon.stub(App.StackService, 'find', function () {
+ return test.services;
+ });
App.set('isHaEnabled', test.isHaEnabled);
c.reopen({
content: Em.Object.create({
@@ -718,10 +569,12 @@ describe('App.WizardStep5Controller', function () {
})
});
c.renderComponents(test.masterComponents);
+ App.StackService.find.restore();
+ modelSetup.cleanStackServiceComponent();
expect(c.get('selectedServicesMasters').mapProperty('component_name')).to.eql(test.e.selectedServicesMasters);
expect(c.get('servicesMasters').mapProperty('component_name')).to.eql(test.e.servicesMasters);
expect(c.get('selectedServicesMasters').mapProperty('showRemoveControl')).to.eql(test.e.showRemoveControl);
- expect(c.get('selectedServicesMasters').mapProperty('zId')).to.eql(test.e.zId);
+ expect(c.get('selectedServicesMasters').mapProperty('serviceComponentId')).to.eql(test.e.serviceComponentId);
if (c.get('isReasignController')) {
expect(c.get('servicesMasters').mapProperty('isInstalled')).to.eql(test.e.isInstalled);
}
@@ -729,133 +582,82 @@ describe('App.WizardStep5Controller', function () {
});
});
- describe('#updateHiveCoHosts', function() {
- var tests = Em.A([
- {
- selectedServicesMasters: Em.A([
- Em.Object.create({component_name: 'HIVE_SERVER', selectedHost: 'h1'}),
- Em.Object.create({component_name: 'HIVE_METASTORE', selectedHost: 'h2'}),
- Em.Object.create({component_name: 'WEBHCAT_SERVER', selectedHost: 'h3'})
- ]),
- servicesMasters: Em.A([
- Em.Object.create({component_name: 'HIVE_SERVER', selectedHost: 'h1'})
- ]),
- isReassignHive: false,
- m: 'should set new host for both',
- e: ['h1','h1','h1']
- },
- {
- selectedServicesMasters: Em.A([
- Em.Object.create({component_name: 'HIVE_SERVER', selectedHost: 'h1'}),
- Em.Object.create({component_name: 'HIVE_METASTORE', selectedHost: 'h2'}),
- Em.Object.create({component_name: 'WEBHCAT_SERVER', selectedHost: 'h3'})
- ]),
- servicesMasters: Em.A([
- Em.Object.create({component_name: 'HIVE_METASTORE', selectedHost: 'h1'})
- ]),
- isReassignHive: false,
- m: 'should set new host for WEBHCAT_SERVER',
- e: ['h1','h2','h1']
- },
- {
- selectedServicesMasters: Em.A([
- Em.Object.create({component_name: 'HIVE_METASTORE', selectedHost: 'h2'}),
- Em.Object.create({component_name: 'WEBHCAT_SERVER', selectedHost: 'h3'})
- ]),
- servicesMasters: Em.A([
- Em.Object.create({component_name: 'HIVE_METASTORE', selectedHost: 'h1'})
- ]),
- isReassignHive: false,
- m: 'missing HIVE_SERVER',
- e: ['h2','h3']
- }
- ]);
-
- tests.forEach(function(test) {
- it(test.m, function() {
- c.set('selectedServicesMasters', test.selectedServicesMasters);
- c.set('servicesMasters', test.servicesMasters);
- c.reopen({isReassignHive: test.isReassignHive});
- c.updateHiveCoHosts();
- expect(c.get('selectedServicesMasters').mapProperty('selectedHost')).to.eql(test.e);
- });
- });
-
- });
-
- describe('#assignHostToMaster', function() {
+ describe('#assignHostToMaster', function () {
var tests = Em.A([
- {
- componentName: 'c1',
- selectedHost: 'h2',
- zId: '1',
- e: {
- indx: 0
- }
- },
- {
- componentName: 'c2',
- selectedHost: 'h3',
- zId: '2',
- e: {
- indx: 3
- }
- },
- {
- componentName: 'c3',
- selectedHost: 'h1',
- e: {
- indx: 2
- }
- },
- {
- componentName: 'c2',
- selectedHost: 'h4',
- e: {
- indx: 1
+ {
+ componentName: 'c1',
+ selectedHost: 'h2',
+ serviceComponentId: '1',
+ e: {
+ indx: 0
+ }
+ },
+ {
+ componentName: 'c2',
+ selectedHost: 'h3',
+ serviceComponentId: '2',
+ e: {
+ indx: 3
+ }
+ },
+ {
+ componentName: 'c3',
+ selectedHost: 'h1',
+ e: {
+ indx: 2
+ }
+ },
+ {
+ componentName: 'c2',
+ selectedHost: 'h4',
+ e: {
+ indx: 1
+ }
}
- }
- ]),
- selectedServicesMasters = Em.A([
- Em.Object.create({component_name: 'c1', zId: '1', selectedHost: 'h1'}),
- Em.Object.create({component_name: 'c2', zId: '1', selectedHost: 'h1'}),
- Em.Object.create({component_name: 'c3', zId: '1', selectedHost: 'h3'}),
- Em.Object.create({component_name: 'c2', zId: '2', selectedHost: 'h2'})
- ]);
+ ]),
+ selectedServicesMasters = Em.A([
+ Em.Object.create({component_name: 'c1', serviceComponentId: '1', selectedHost: 'h1'}),
+ Em.Object.create({component_name: 'c2', serviceComponentId: '1', selectedHost: 'h1'}),
+ Em.Object.create({component_name: 'c3', serviceComponentId: '1', selectedHost: 'h3'}),
+ Em.Object.create({component_name: 'c2', serviceComponentId: '2', selectedHost: 'h2'})
+ ]);
- tests.forEach(function(test) {
- it(test.componentName + ' ' + test.selectedHost + ' ' + test.zId, function() {
+ tests.forEach(function (test) {
+ it(test.componentName + ' ' + test.selectedHost + ' ' + test.serviceComponentId, function () {
c.set('selectedServicesMasters', selectedServicesMasters);
- c.assignHostToMaster(test.componentName, test.selectedHost, test.zId);
+ c.assignHostToMaster(test.componentName, test.selectedHost, test.serviceComponentId);
expect(c.get('selectedServicesMasters').objectAt(test.e.indx).get('selectedHost')).to.equal(test.selectedHost);
})
});
});
- describe('#submit', function() {
- beforeEach(function() {
+ describe('#submit', function () {
+ beforeEach(function () {
+ if (!App.router) {
+ App.router = Em.Object.create({send: Em.K});
+ }
sinon.spy(App.router, 'send');
});
- afterEach(function() {
+ afterEach(function () {
App.router.send.restore();
});
- it('should go next if not isSubmitDisabled', function() {
+ it('should go next if not isSubmitDisabled', function () {
c.reopen({isSubmitDisabled: false});
c.submit();
expect(App.router.send.calledWith('next')).to.equal(true);
});
- it('shouldn\'t go next if isSubmitDisabled', function() {
+ it('shouldn\'t go next if isSubmitDisabled', function () {
c.reopen({isSubmitDisabled: true});
c.submit();
expect(App.router.send.called).to.equal(false);
});
});
- describe('#removeComponent', function() {
+ describe('#removeComponent', function () {
var tests = Em.A([
{
componentName: 'c1',
- zId: 1,
+ serviceComponentId: 1,
selectedServicesMasters: Em.A([]),
hosts: [],
m: 'empty selectedServicesMasters',
@@ -863,9 +665,9 @@ describe('App.WizardStep5Controller', function () {
},
{
componentName: 'ZOOKEPEER_SERVER',
- zId: 1,
+ serviceComponentId: 1,
selectedServicesMasters: Em.A([
- Em.Object.create({zId: 1, component_name: 'HBASE_SERVER'})
+ Em.Object.create({serviceComponentId: 1, component_name: 'HBASE_SERVER'})
]),
hosts: [],
m: 'no such components',
@@ -873,9 +675,9 @@ describe('App.WizardStep5Controller', function () {
},
{
componentName: 'ZOOKEPEER_SERVER',
- zId: 1,
+ serviceComponentId: 1,
selectedServicesMasters: Em.A([
- Em.Object.create({zId: 1, component_name: 'ZOOKEPEER_SERVER'})
+ Em.Object.create({serviceComponentId: 1, component_name: 'ZOOKEPEER_SERVER'})
]),
hosts: [],
m: 'component is only 1',
@@ -883,12 +685,15 @@ describe('App.WizardStep5Controller', function () {
},
{
componentName: 'ZOOKEPEER_SERVER',
- zId: 2,
+ serviceComponentId: 2,
selectedServicesMasters: Em.A([
- Em.Object.create({zId: 1, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
- Em.Object.create({zId: 2, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false})
+ Em.Object.create({serviceComponentId: 1, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
+ Em.Object.create({serviceComponentId: 2, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false})
]),
- hosts: [{},{}],
+ hosts: [
+ {},
+ {}
+ ],
m: 'two components, add allowed, remove not allowed',
e: true,
showAddControl: true,
@@ -896,12 +701,14 @@ describe('App.WizardStep5Controller', function () {
},
{
componentName: 'ZOOKEPEER_SERVER',
- zId: 2,
+ serviceComponentId: 2,
selectedServicesMasters: Em.A([
- Em.Object.create({zId: 1, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
- Em.Object.create({zId: 2, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false})
+ Em.Object.create({serviceComponentId: 1, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
+ Em.Object.create({serviceComponentId: 2, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false})
]),
- hosts: [{}],
+ hosts: [
+ {}
+ ],
m: 'two components, add not allowed, remove not allowed',
e: true,
showAddControl: false,
@@ -909,13 +716,16 @@ describe('App.WizardStep5Controller', function () {
},
{
componentName: 'ZOOKEPEER_SERVER',
- zId: 2,
+ serviceComponentId: 2,
selectedServicesMasters: Em.A([
- Em.Object.create({zId: 1, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
- Em.Object.create({zId: 2, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
- Em.Object.create({zId: 3, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: true})
+ Em.Object.create({serviceComponentId: 1, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
+ Em.Object.create({serviceComponentId: 2, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
+ Em.Object.create({serviceComponentId: 3, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: true})
]),
- hosts: [{},{}],
+ hosts: [
+ {},
+ {}
+ ],
m: 'three components, add not allowed, remove allowed',
e: true,
showAddControl: false,
@@ -923,25 +733,29 @@ describe('App.WizardStep5Controller', function () {
},
{
componentName: 'ZOOKEPEER_SERVER',
- zId: 2,
+ serviceComponentId: 2,
selectedServicesMasters: Em.A([
- Em.Object.create({zId: 1, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
- Em.Object.create({zId: 2, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
- Em.Object.create({zId: 3, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: true})
+ Em.Object.create({serviceComponentId: 1, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
+ Em.Object.create({serviceComponentId: 2, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
+ Em.Object.create({serviceComponentId: 3, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: true})
]),
- hosts: [{},{}, {}],
+ hosts: [
+ {},
+ {},
+ {}
+ ],
m: 'three components, add allowed, remove allowed',
e: true,
showAddControl: true,
showRemoveControl: true
}
]);
- tests.forEach(function(test) {
- it(test.m, function() {
+ tests.forEach(function (test) {
+ it(test.m, function () {
c.set('selectedServicesMasters', test.selectedServicesMasters);
c.set('hosts', test.hosts);
- expect(c.removeComponent(test.componentName, test.zId)).to.equal(test.e);
- if(test.e) {
+ expect(c.removeComponent(test.componentName, test.serviceComponentId)).to.equal(test.e);
+ if (test.e) {
expect(c.get('selectedServicesMasters.lastObject.showRemoveControl')).to.equal(test.showRemoveControl);
expect(c.get('selectedServicesMasters.lastObject.showAddControl')).to.equal(test.showAddControl);
}
@@ -949,7 +763,7 @@ describe('App.WizardStep5Controller', function () {
});
});
- describe('#addComponent', function() {
+ describe('#addComponent', function () {
var tests = Em.A([
{
componentName: 'c1',
@@ -961,7 +775,7 @@ describe('App.WizardStep5Controller', function () {
{
componentName: 'ZOOKEPEER_SERVER',
selectedServicesMasters: Em.A([
- Em.Object.create({zId: 1, component_name: 'HBASE_SERVER'})
+ Em.Object.create({serviceComponentId: 1, component_name: 'HBASE_SERVER'})
]),
hosts: [],
m: 'no such components',
@@ -970,7 +784,7 @@ describe('App.WizardStep5Controller', function () {
{
componentName: 'ZOOKEPEER_SERVER',
selectedServicesMasters: Em.A([
- Em.Object.create({zId: 1, component_name: 'ZOOKEPEER_SERVER'})
+ Em.Object.create({serviceComponentId: 1, component_name: 'ZOOKEPEER_SERVER'})
]),
hosts: [],
m: 'one component, 0 hosts',
@@ -979,8 +793,8 @@ describe('App.WizardStep5Controller', function () {
{
componentName: 'ZOOKEPEER_SERVER',
selectedServicesMasters: Em.A([
- Em.Object.create({zId: 1, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
- Em.Object.create({zId: 2, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false})
+ Em.Object.create({serviceComponentId: 1, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
+ Em.Object.create({serviceComponentId: 2, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false})
]),
hosts: [Em.Object.create({}), Em.Object.create({})],
m: 'two components, two hosts',
@@ -989,16 +803,16 @@ describe('App.WizardStep5Controller', function () {
{
componentName: 'ZOOKEPEER_SERVER',
selectedServicesMasters: Em.A([
- Em.Object.create({zId: 1, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
- Em.Object.create({zId: 2, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false})
+ Em.Object.create({serviceComponentId: 1, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false}),
+ Em.Object.create({serviceComponentId: 2, component_name: 'ZOOKEPEER_SERVER', showAddControl: false, showRemoveControl: false})
]),
hosts: [Em.Object.create({}), Em.Object.create({}), Em.Object.create({})],
m: 'two components, 3 hosts',
e: true
}
]);
- tests.forEach(function(test) {
- it(test.m, function() {
+ tests.forEach(function (test) {
+ it(test.m, function () {
c.set('selectedServicesMasters', test.selectedServicesMasters);
c.set('hosts', test.hosts);
expect(c.addComponent(test.componentName)).to.equal(test.e);
@@ -1006,28 +820,28 @@ describe('App.WizardStep5Controller', function () {
});
});
- describe('#loadStep', function() {
+ describe('#loadStep', function () {
var methods = Em.A(['clearStep', 'renderHostInfo', 'renderComponents', 'loadComponents']);
- describe('should call several methods', function() {
- beforeEach(function() {
- methods.forEach(function(m) {
+ describe('should call several methods', function () {
+ beforeEach(function () {
+ methods.forEach(function (m) {
sinon.spy(c, m);
});
c.reopen({content: {services: Em.A([])}});
});
- afterEach(function() {
- methods.forEach(function(m) {
+ afterEach(function () {
+ methods.forEach(function (m) {
c[m].restore();
});
});
- methods.forEach(function(m) {
- it(m, function() {
+ methods.forEach(function (m) {
+ it(m, function () {
c.loadStep();
expect(c[m].calledOnce).to.equal(true);
});
});
});
- it('should update HBASE if App.supports.multipleHBaseMasters is true', function() {
+ it('should update HBASE if App.supports.multipleHBaseMasters is true', function () {
App.set('supports.multipleHBaseMasters', true);
sinon.spy(c, 'updateComponent');
c.reopen({content: {services: Em.A([])}});
@@ -1037,34 +851,34 @@ describe('App.WizardStep5Controller', function () {
});
});
- describe('#title', function() {
- it('should be custom title for reassignMasterController', function() {
+ describe('#title', function () {
+ it('should be custom title for reassignMasterController', function () {
c.set('content', {controllerName: 'reassignMasterController'});
expect(c.get('title')).to.equal(Em.I18n.t('installer.step5.reassign.header'));
});
- it('should be default for other', function() {
+ it('should be default for other', function () {
c.set('content', {controllerName: 'notReassignMasterController'});
expect(c.get('title')).to.equal(Em.I18n.t('installer.step5.header'));
});
});
- describe('#isSubmitDisabled', function() {
- it('should be false if no isReassignWizard', function() {
+ describe('#isSubmitDisabled', function () {
+ it('should be false if no isReassignWizard', function () {
c.reopen({isReassignWizard: false});
expect(c.get('isSubmitDisabled')).to.equal(false);
});
- it('should be true if isReassignWizard', function() {
+ it('should be true if isReassignWizard', function () {
var hostComponents = Em.A([
Em.Object.create({componentName: 'c1', host: Em.Object.create({hostName: 'h1'})}),
Em.Object.create({componentName: 'c1', host: Em.Object.create({hostName: 'h2'})})
]);
- sinon.stub(App.HostComponent, 'find', function() {
+ sinon.stub(App.HostComponent, 'find', function () {
return hostComponents;
});
c.reopen({
isReassignWizard: true,
- content:{
- reassign:{
+ content: {
+ reassign: {
component_name: 'c1'
}
},
@@ -1078,19 +892,19 @@ describe('App.WizardStep5Controller', function () {
App.HostComponent.find.restore();
});
- it('should be false if isReassignWizard', function() {
+ it('should be false if isReassignWizard', function () {
var hostComponents = Em.A([
Em.Object.create({componentName: 'c1', host: Em.Object.create({hostName: 'h1'})}),
Em.Object.create({componentName: 'c1', host: Em.Object.create({hostName: 'h2'})}),
Em.Object.create({componentName: 'c1', host: Em.Object.create({hostName: 'h3'})})
]);
- sinon.stub(App.HostComponent, 'find', function() {
+ sinon.stub(App.HostComponent, 'find', function () {
return hostComponents;
});
c.reopen({
isReassignWizard: true,
- content:{
- reassign:{
+ content: {
+ reassign: {
component_name: 'c1'
}
},
@@ -1105,7 +919,7 @@ describe('App.WizardStep5Controller', function () {
});
- describe('#masterHostMapping', function() {
+ describe('#masterHostMapping', function () {
Em.A([
{
selectedServicesMasters: [
@@ -1119,8 +933,13 @@ describe('App.WizardStep5Controller', function () {
],
m: 'Two hosts',
e: [
- {host_name: 'h1', hostInfo: {}, masterServices: [{}, {}]},
- {host_name: 'h2', hostInfo: {}, masterServices: [{}]}
+ {host_name: 'h1', hostInfo: {}, masterServices: [
+ {},
+ {}
+ ]},
+ {host_name: 'h2', hostInfo: {}, masterServices: [
+ {}
+ ]}
]
},
{
@@ -1139,7 +958,10 @@ describe('App.WizardStep5Controller', function () {
],
m: 'One host',
e: [
- {host_name: 'h1', hostInfo: {}, masterServices: [{}, {}]}
+ {host_name: 'h1', hostInfo: {}, masterServices: [
+ {},
+ {}
+ ]}
]
}
]).forEach(function (test) {
@@ -1150,7 +972,7 @@ describe('App.WizardStep5Controller', function () {
});
var result = c.get('masterHostMapping');
expect(result.length).to.equal(test.e.length);
- result.forEach(function(r, i) {
+ result.forEach(function (r, i) {
expect(r.get('host_name')).to.equal(test.e[i].host_name);
expect(r.get('masterServices.length')).to.equal(test.e[i].masterServices.length);
expect(r.get('hostInfo')).to.be.an.object;
@@ -1159,7 +981,7 @@ describe('App.WizardStep5Controller', function () {
});
});
- describe('#loadComponents', function() {
+ describe('#loadComponents', function () {
Em.A([
{
services: [
@@ -1218,8 +1040,7 @@ describe('App.WizardStep5Controller', function () {
display_name: 'c1d',
selectedHost: 'h3',
isInstalled: false,
- serviceId: 's1',
- isHiveCoHost: false
+ serviceId: 's1'
}
},
{
@@ -1239,8 +1060,7 @@ describe('App.WizardStep5Controller', function () {
display_name: 'c1d',
selectedHost: 'h3',
isInstalled: false,
- serviceId: 's1',
- isHiveCoHost: false
+ serviceId: 's1'
}
},
{
@@ -1260,8 +1080,7 @@ describe('App.WizardStep5Controller', function () {
display_name: 'c1d',
selectedHost: 'h2',
isInstalled: true,
- serviceId: 's1',
- isHiveCoHost: false
+ serviceId: 's1'
}
},
{
@@ -1281,76 +1100,34 @@ describe('App.WizardStep5Controller', function () {
display_name: 'c1d',
selectedHost: 'h2',
isInstalled: true,
- serviceId: 's1',
- isHiveCoHost: false
+ serviceId: 's1'
}
}
]).forEach(function (test) {
- it(test.m, function() {
+ it(test.m, function () {
c.reopen({
content: {
- services: test.services,
masterComponentHosts: test.masterComponentHosts
}
});
- sinon.stub(App.StackServiceComponent, 'find', function() {
+ sinon.stub(App.StackService, 'find', function () {
+ return test.services;
+ });
+ sinon.stub(App.StackServiceComponent, 'find', function () {
return test.masterComponents;
});
- sinon.stub(c, 'selectHost', function() {
+ sinon.stub(c, 'selectHost', function () {
return test.selectHost;
});
var r = c.loadComponents();
+ App.StackService.find.restore();
App.StackServiceComponent.find.restore();
c.selectHost.restore();
expect(r.length).to.equal(1);
- Em.keys(test.e).forEach(function(k) {
+ Em.keys(test.e).forEach(function (k) {
expect(r[0][k]).to.equal(test.e[k]);
});
});
});
});
-
- describe('#_isHiveCoHost', function() {
- Em.A([
- {
- componentName: 'HIVE_METASTORE',
- isReassignWizard: false,
- e: true
- },
- {
- componentName: 'WEBHCAT_SERVER',
- isReassignWizard: false,
- e: true
- },
- {
- componentName: 'HIVE_METASTORE',
- isReassignWizard: true,
- e: false
- },
- {
- componentName: 'WEBHCAT_SERVER',
- isReassignWizard: true,
- e: false
- },
- {
- componentName: 'C1',
- isReassignWizard: false,
- e: false
- },
- {
- componentName: 'C1',
- isReassignWizard: true,
- e: false
- }
- ]).forEach(function (test) {
- it(test.componentName.toString() + ' ' + test.isReassignWizard.toString(), function () {
- c.reopen({
- isReassignWizard: test.isReassignWizard
- });
- var r = c._isHiveCoHost(test.componentName);
- expect(r).to.equal(test.e);
- });
- });
- });
-
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/00f8d5c5/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 536503f..7b28e1f 100644
--- a/ambari-web/test/controllers/wizard/step6_test.js
+++ b/ambari-web/test/controllers/wizard/step6_test.js
@@ -56,9 +56,6 @@ describe('App.WizardStep6Controller', function () {
masterComponentHosts: {},
services: services
});
- sinon.stub(controller, 'getComponentDisplayName', function (c) {
- return App.format.components[c];
- });
var h = {}, m = [];
Em.A(['host0', 'host1', 'host2', 'host3']).forEach(function (hostName) {
@@ -77,9 +74,6 @@ describe('App.WizardStep6Controller', function () {
});
- afterEach(function () {
- controller.getComponentDisplayName.restore();
- });
describe('#loadStep', function () {
Em.A([
http://git-wip-us.apache.org/repos/asf/ambari/blob/00f8d5c5/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 aa147d4..7a329e5 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -17,6 +17,7 @@
*/
var App = require('app');
+var modelSetup = require('test/init_model_test');
require('utils/ajax/ajax_queue');
require('controllers/main/admin/security');
require('controllers/main/service/info/configs');
@@ -487,6 +488,158 @@ describe('App.WizardStep8Controller', function () {
});
});
+ describe('#loadServices()', function() {
+ var serviceComponentGenerator = function(componentName, displayName, componentValue) {
+ return Em.Object.create({
+ component_name: componentName,
+ display_name: displayName,
+ component_value: componentValue
+ })
+ };
+
+ var slaveComponentGenerator = function(componentName, hosts) {
+ return Em.Object.create({
+ componentName: componentName,
+ hosts: hosts.map(function(host) { return {'hostName' : host } })
+ });
+ };
+ var masterComponentGenerator = function(componentName, hostName) {
+ return Em.Object.create({
+ component: componentName,
+ hostName: hostName
+ });
+ };
+
+ var serviceConfigGenerator = function(name, value) {
+ return Em.Object.create({
+ name: name,
+ value: value
+ });
+ }
+ before(function() {
+ modelSetup.setupStackServiceComponent();
+ var services = ['HDFS', 'YARN', 'TEZ', 'NAGIOS', 'GANGLIA','OOZIE'];
+ this.controller = App.WizardStep8Controller.create({
+ content: {
+ services: App.StackService.find().setEach('isSelected', true).setEach('isInstalled', false).filterProperty('stackVersion', '2.1').filter(function(service) {
+ return services.contains(service.get('serviceName'));
+ }),
+ slaveComponentHosts: Em.A([
+ slaveComponentGenerator('DATANODE', ['h1','h2']),
+ slaveComponentGenerator('NODEMANAGER', ['h1']),
+ slaveComponentGenerator('CLIENT', ['h1'])
+ ]),
+ masterComponentHosts: Em.A([
+ masterComponentGenerator('NAMENODE', 'h1'),
+ masterComponentGenerator('SECONDARY_NAMENODE', 'h2'),
+ masterComponentGenerator('APP_TIMELINE_SERVER', 'h1'),
+ masterComponentGenerator('RESOURCEMANAGER', 'h1'),
+ masterComponentGenerator('NAGIOS_SERVER', 'h1'),
+ masterComponentGenerator('GANGLIA_SERVER', 'h2'),
+ masterComponentGenerator('OOZIE_SERVER', 'h2')
+ ]),
+ serviceConfigProperties: Em.A([
+ serviceConfigGenerator('nagios_web_login', 'admin'),
+ serviceConfigGenerator('nagios_contact', 'admin@admin.com'),
+ serviceConfigGenerator('oozie_database', 'New Derby Database'),
+ serviceConfigGenerator('oozie_derby_database', '')
+ ])
+ }
+ });
+ var _this = this;
+ this.controller.reopen({
+ wizardController: {
+ getDBProperty: function() {
+ return _this.controller.get('content.serviceConfigProperties')
+ }
+ }
+ });
+ this.controller.loadServices();
+ });
+
+ var tests = [
+ {
+ service_name: 'HDFS',
+ display_name: 'HDFS',
+ service_components: Em.A([
+ serviceComponentGenerator('NAMENODE', 'NameNode', 'h1'),
+ serviceComponentGenerator('DATANODE', 'DataNode', '2 hosts'),
+ serviceComponentGenerator('SECONDARY_NAMENODE', 'SNameNode', 'h2')
+ ])
+ },
+ {
+ service_name: 'YARN',
+ display_name: 'YARN + MapReduce2',
+ service_components: Em.A([
+ serviceComponentGenerator('RESOURCEMANAGER', 'ResourceManager', 'h1'),
+ serviceComponentGenerator('NODEMANAGER', 'NodeManager', '1 host'),
+ serviceComponentGenerator('APP_TIMELINE_SERVER', 'App Timeline Server', 'h1')
+ ])
+ },
+ {
+ service_name: 'TEZ',
+ display_name: 'Tez',
+ service_components: Em.A([
+ serviceComponentGenerator('CLIENT', 'Clients', '1 host')
+ ])
+ },
+ {
+ service_name: 'NAGIOS',
+ display_name: 'Nagios',
+ service_components: Em.A([
+ serviceComponentGenerator('NAGIOS_SERVER', 'Server', 'h1'),
+ serviceComponentGenerator('Custom', 'Administrator', 'admin / (admin@admin.com)')
+ ])
+ },
+ {
+ service_name: 'GANGLIA',
+ display_name: 'Ganglia',
+ service_components: Em.A([
+ serviceComponentGenerator('GANGLIA_SERVER', 'Server', 'h2')
+ ])
+ },
+ {
+ service_name: 'OOZIE',
+ display_name: 'Oozie',
+ service_components: Em.A([
+ serviceComponentGenerator('OOZIE_SERVER', 'Server', 'h2'),
+ serviceComponentGenerator('Custom', 'Database', ' (New Derby Database)')
+ ])
+ }
+ ];
+
+ tests.forEach(function(test) {
+ describe('Load review for `' + test.service_name + '` service', function(){
+ it('{0} service should be displayed as {1}'.format(test.service_name, test.display_name), function() {
+ expect(this.controller.get('services').findProperty('service_name', test.service_name).get('display_name')).to.eql(test.display_name);
+ });
+ it('{0}: all components present'.format(test.service_name), function() {
+ var serviceObj = this.controller.get('services').findProperty('service_name', test.service_name);
+ expect(test.service_components.length).to.be.eql(serviceObj.get('service_components.length'));
+ });
+ test.service_components.forEach(function(serviceComponent) {
+ var testMessage = '`{0}` component present with `{1}` value and displayed as `{2}`';
+ it(testMessage.format(serviceComponent.get('component_name'), serviceComponent.get('component_value'), serviceComponent.get('display_name')), function() {
+ var serviceObj = this.controller.get('services').findProperty('service_name', test.service_name);
+ var component;
+ if (serviceComponent.get('component_name') === 'Custom') {
+ component = serviceObj.get('service_components').findProperty('display_name', serviceComponent.get('display_name'));
+ } else
+ component = serviceObj.get('service_components').findProperty('component_name', serviceComponent.get('component_name'));
+ if (serviceComponent.get('component_name') !== 'Custom')
+ expect(component.get('component_name')).to.eql(serviceComponent.get('component_name'));
+ expect(component.get('component_value')).to.eql(serviceComponent.get('component_value'));
+ expect(component.get('display_name')).to.eql(serviceComponent.get('display_name'));
+ });
+ });
+ })
+ });
+
+ after(function() {
+ modelSetup.cleanStackServiceComponent();
+ });
+ });
+
describe('#removeHiveConfigs', function () {
Em.A([
{
http://git-wip-us.apache.org/repos/asf/ambari/blob/00f8d5c5/ambari-web/test/controllers/wizard/step9_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step9_test.js b/ambari-web/test/controllers/wizard/step9_test.js
index b7972fe..b9c57e0 100644
--- a/ambari-web/test/controllers/wizard/step9_test.js
+++ b/ambari-web/test/controllers/wizard/step9_test.js
@@ -23,6 +23,8 @@ require('models/stack_service_component');
require('models/hosts');
require('controllers/wizard/step9_controller');
require('utils/helper');
+require('utils/ajax/ajax');
+
var modelSetup = require('test/init_model_test');
var c, obj;
describe('App.InstallerStep9Controller', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/00f8d5c5/ambari-web/test/init_model_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/init_model_test.js b/ambari-web/test/init_model_test.js
index 3ed3b06..1b4b183 100644
--- a/ambari-web/test/init_model_test.js
+++ b/ambari-web/test/init_model_test.js
@@ -19,21 +19,15 @@
var App = require('app');
require('models/stack_service_component');
require('mappers/server_data_mapper');
-require('mappers/stack_service_component_mapper');
+require('mappers/stack_service_mapper');
module.exports = {
setupStackServiceComponent: function() {
/**
- * initialization of App.StackServiceComponent model
+ * initialization of App.StackServiceComponent and App.StackService models
* @type {*}
*/
- var data = {items: Em.A([])};
- require('test/service_components').items.forEach(function(i) {
- i.serviceComponents.forEach(function(sc) {
- data.items.pushObject(sc.StackServiceComponents);
- });
- });
- App.stackServiceComponentMapper.map(data);
+ App.stackServiceMapper.map(require('test/service_components'));
},
cleanStackServiceComponent: function(){
App.StackServiceComponent.find().set('content',[]);