You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2014/05/06 14:36:59 UTC
git commit: AMBARI-5679. Unit tests for steps 7 (with refactor).
(onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk c867591fa -> f475fc0b8
AMBARI-5679. Unit tests for steps 7 (with refactor). (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f475fc0b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f475fc0b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f475fc0b
Branch: refs/heads/trunk
Commit: f475fc0b8c038a5607c81988dcf9bb11f3aa5c8a
Parents: c867591
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Tue May 6 15:33:22 2014 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Tue May 6 15:33:22 2014 +0300
----------------------------------------------------------------------
.../app/controllers/wizard/step7_controller.js | 412 +++++--
ambari-web/app/templates/wizard/step7.hbs | 30 +-
.../wizard/step7_custom_config_error.hbs | 38 -
ambari-web/test/installer/step7_test.js | 1078 +++++++++++++++++-
4 files changed, 1379 insertions(+), 179 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/f475fc0b/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index 51b7f41..30b72ac 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -32,7 +32,11 @@ App.WizardStep7Controller = Em.Controller.extend({
name: 'wizardStep7Controller',
- stepConfigs: [], //contains all field properties that are viewed in this step
+ /**
+ * Contains all field properties that are viewed in this step
+ * @type {object[]}
+ */
+ stepConfigs: [],
selectedService: null,
@@ -40,42 +44,88 @@ App.WizardStep7Controller = Em.Controller.extend({
secureConfigs: require('data/secure_mapping'),
- miscModalVisible: false, //If miscConfigChange Modal is shown
+ /**
+ * If miscConfigChange Modal is shown
+ * @type {bool}
+ */
+ miscModalVisible: false,
gangliaAvailableSpace: null,
+ /**
+ * @type {string}
+ */
gangliaMoutDir:'/',
overrideToAdd: null,
+ /**
+ * Is installer controller used
+ * @type {bool}
+ */
isInstaller: true,
+ /**
+ * List of config groups
+ * @type {object[]}
+ */
configGroups: [],
+ /**
+ * List of config group to be deleted
+ * @type {object[]}
+ */
groupsToDelete: [],
+ /**
+ * Currently selected config group
+ * @type {object}
+ */
selectedConfigGroup: null,
+
/**
- * config tags of actually installed services
+ * Config tags of actually installed services
+ * @type {array}
*/
serviceConfigTags: [],
serviceConfigsData: require('data/service_configs'),
+ /**
+ * Are advanced configs loaded
+ * @type {bool}
+ */
isAdvancedConfigLoaded: true,
+ /**
+ * Should Next-button be disabled
+ * @type {bool}
+ */
isSubmitDisabled: function () {
return (!this.stepConfigs.filterProperty('showConfig', true).everyProperty('errorCount', 0) || this.get("miscModalVisible"));
}.property('stepConfigs.@each.errorCount', 'miscModalVisible'),
+ /**
+ * List of selected to install service names
+ * @type {string[]}
+ */
selectedServiceNames: function () {
return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).mapProperty('serviceName');
}.property('content.services').cacheable(),
+ /**
+ * List of installed and selected to install service names
+ * @type {string[]}
+ */
allSelectedServiceNames: function () {
return this.get('content.services').filterProperty('isSelected').mapProperty('serviceName');
}.property('content.services').cacheable(),
+ /**
+ * List of installed service names
+ * Sqoop and HCatalog are excluded if not installer wizard running
+ * @type {string[]}
+ */
installedServiceNames: function () {
var serviceNames = this.get('content.services').filterProperty('isInstalled').mapProperty('serviceName');
if(this.get('content.controllerName') !== 'installerController') {
@@ -84,24 +134,67 @@ App.WizardStep7Controller = Em.Controller.extend({
return serviceNames;
}.property('content.services').cacheable(),
+ /**
+ * List of master components
+ * @type {Ember.Enumerable}
+ */
masterComponentHosts: function () {
return this.get('content.masterComponentHosts');
}.property('content.masterComponentHosts'),
+ /**
+ * List of slave components
+ * @type {Ember.Enumerable}
+ */
slaveComponentHosts: function () {
return this.get('content.slaveGroupProperties');
}.property('content.slaveGroupProperties', 'content.slaveComponentHosts'),
customData: [],
+ /**
+ * Filter text will be located here
+ * @type {string}
+ */
+ filter: '',
+
+ /**
+ * Dropdown menu items in filter combobox
+ * @type {Ember.Object[]}
+ */
+ filterColumns: function () {
+ var result = [];
+ for (var i = 1; i < 2; i++) {
+ result.push(Em.Object.create({
+ name: this.t('common.combobox.dropdown.' + i),
+ selected: false
+ }));
+ }
+ return result;
+ }.property(),
+
+ /**
+ * Clear controller's properties:
+ * <ul>
+ * <li>serviceConfigTags</li>
+ * <li>stepConfigs</li>
+ * <li>filter</li>
+ * </ul>
+ * and desect all <code>filterColumns</code>
+ * @method clearStep
+ */
clearStep: function () {
this.get('serviceConfigTags').clear();
this.get('stepConfigs').clear();
this.set('filter', '');
this.get('filterColumns').setEach('selected', false);
},
+
/**
- * Load config groups for installed services
+ * Load config groups for installed services
+ * One ajax-request for each service
+ * @param {string[]} servicesNames
+ * @method loadInstalledServicesConfigGroups
*/
loadInstalledServicesConfigGroups: function (servicesNames) {
servicesNames.forEach(function(serviceName) {
@@ -119,6 +212,10 @@ App.WizardStep7Controller = Em.Controller.extend({
/**
* Load config groups success callback
+ * @param {object} data
+ * @param {object} opt
+ * @param {object} params
+ * @method loadServiceTagsSuccess
*/
loadServiceTagsSuccess: function (data, opt, params) {
var serviceConfigsDef = params.serviceConfigsDef;
@@ -208,6 +305,13 @@ App.WizardStep7Controller = Em.Controller.extend({
service.set('configs', serviceConfig.get('configs'));
},
+ /**
+ *
+ * @param {Ember.Object[]} configs
+ * @param {Ember.Object} componentConfig
+ * @param {Ember.Object} component
+ * @method loadComponentConfigs
+ */
loadComponentConfigs: function (configs, componentConfig, component) {
var localDB = App.router.get('mainServiceInfoConfigsController').getInfoForDefaults();
var recommendedDefaults = {};
@@ -227,7 +331,6 @@ App.WizardStep7Controller = Em.Controller.extend({
s.configsValidator.set('recommendedDefaults', recommendedDefaults);
}
configs.forEach(function (serviceConfigProperty) {
- console.log("config", serviceConfigProperty);
if (!serviceConfigProperty) return;
var overrides = serviceConfigProperty.get('overrides');
// we will populate the override properties below
@@ -257,7 +360,6 @@ App.WizardStep7Controller = Em.Controller.extend({
}
}
}
- console.log("config result", serviceConfigProperty);
} else {
serviceConfigProperty.set('isVisible', false);
}
@@ -278,14 +380,13 @@ App.WizardStep7Controller = Em.Controller.extend({
}
var parentOverridesArray = serviceConfigProperty.get('overrides');
if (parentOverridesArray == null) {
- parentOverridesArray = Ember.A([]);
+ parentOverridesArray = Em.A([]);
serviceConfigProperty.set('overrides', parentOverridesArray);
}
serviceConfigProperty.get('overrides').pushObject(newSCP);
- console.debug("createOverrideProperty(): Added:", newSCP, " to main-property:", serviceConfigProperty)
}, this);
} else {
- serviceConfigProperty.set('overrides', Ember.A([]));
+ serviceConfigProperty.set('overrides', Em.A([]));
}
if (App.get('isAdmin')) {
if(defaultGroupSelected && !this.get('isHostsConfigsPage')){
@@ -308,10 +409,11 @@ App.WizardStep7Controller = Em.Controller.extend({
}
}
},
+
/**
* Resolve dependency between configs.
* @param serviceName {String}
- * @param configs {Mixed}
+ * @param configs {Ember.Enumerable}
*/
resolveServiceDependencyConfigs: function (serviceName, configs) {
switch (serviceName) {
@@ -323,6 +425,12 @@ App.WizardStep7Controller = Em.Controller.extend({
}
},
+ /**
+ * Update some Storm configs
+ * If Ganglia is selected to install or already installed, Ganglia host should be added to configs
+ * @param {Ember.Enumerable} configs
+ * @method resolveStormConfigs
+ */
resolveStormConfigs: function(configs) {
var dependentConfigs, gangliaServerHost;
dependentConfigs = ['nimbus.childopts', 'supervisor.childopts', 'worker.childopts'];
@@ -341,6 +449,7 @@ App.WizardStep7Controller = Em.Controller.extend({
/**
* On load function
+ * @method loadStep
*/
loadStep: function () {
console.log("TRACE: Loading step7: Configure Services");
@@ -353,21 +462,22 @@ App.WizardStep7Controller = Em.Controller.extend({
//STEP 2: Load on-site configs by service from local DB
var storedConfigs = this.get('content.serviceConfigProperties');
//STEP 3: Merge pre-defined configs with loaded on-site configs
- var configs = App.config.mergePreDefinedWithStored(storedConfigs, advancedConfigs, this.get('selectedServiceNames').concat(this.get('installedServiceNames')));
+ var configs = App.config.mergePreDefinedWithStored(
+ storedConfigs,
+ advancedConfigs,
+ this.get('selectedServiceNames').concat(this.get('installedServiceNames'))
+ );
//STEP 4: Add advanced configs
App.config.addAdvancedConfigs(configs, advancedConfigs);
//STEP 5: Add custom configs
App.config.addCustomConfigs(configs);
//put properties from capacity-scheduler.xml into one config with textarea view
- if (this.get('allSelectedServiceNames').contains('YARN') && !App.supports.capacitySchedulerUi) {
+ if (this.get('allSelectedServiceNames').contains('YARN') && !App.get('supports.capacitySchedulerUi')) {
configs = App.config.fileConfigsIntoTextarea(configs, 'capacity-scheduler.xml');
}
+
this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []);
- var localDB = {
- hosts: this.get('wizardController').getDBProperty('hosts'),
- masterComponentHosts: this.get('wizardController').getDBProperty('masterComponentHosts'),
- slaveComponentHosts: this.get('wizardController').getDBProperty('slaveComponentHosts')
- };
+
if (this.get('wizardController.name') === 'addServiceController') {
this.getConfigTags();
this.setInstalledServiceConfigs(this.get('serviceConfigTags'), configs);
@@ -376,6 +486,44 @@ App.WizardStep7Controller = Em.Controller.extend({
this.resolveServiceDependencyConfigs('STORM', configs);
}
//STEP 6: Distribute configs by service and wrap each one in App.ServiceConfigProperty (configs -> serviceConfigs)
+ this.setStepConfigs(configs, storedConfigs);
+
+ this.checkHostOverrideInstaller();
+ this.activateSpecialConfigs();
+ this.selectProperService();
+ if (this.get('content.skipConfigStep')) {
+ App.router.send('next');
+ }
+ },
+
+ /**
+ * If <code>App.supports.hostOverridesInstaller</code> is enabled should load config groups
+ * and (if some services are already installed) load config groups for installed services
+ * @method checkHostOverrideInstaller
+ */
+ checkHostOverrideInstaller: function() {
+ if (App.get('supports.hostOverridesInstaller')) {
+ this.loadConfigGroups(this.get('content.configGroups'));
+ if (this.get('installedServiceNames').length > 0) {
+ this.loadInstalledServicesConfigGroups(this.get('installedServiceNames'));
+ }
+ }
+ },
+
+ /**
+ * Set init <code>stepConfigs</code> value
+ * Set <code>selected</code> for addable services if addServiceController is used
+ * Remove SNameNode if HA is enabled (and if addServiceController is used)
+ * @param {Ember.Object[]} configs
+ * @param {Ember.Object[]} storedConfigs
+ * @method setStepConfigs
+ */
+ setStepConfigs: function(configs, storedConfigs) {
+ var localDB = {
+ hosts: this.get('wizardController').getDBProperty('hosts'),
+ masterComponentHosts: this.get('wizardController').getDBProperty('masterComponentHosts'),
+ slaveComponentHosts: this.get('wizardController').getDBProperty('slaveComponentHosts')
+ };
var serviceConfigs = App.config.renderConfigs(configs, storedConfigs, this.get('allSelectedServiceNames'), this.get('installedServiceNames'), localDB);
if (this.get('wizardController.name') === 'addServiceController') {
serviceConfigs.setEach('showConfig', true);
@@ -387,41 +535,52 @@ App.WizardStep7Controller = Em.Controller.extend({
// Remove SNameNode if HA is enabled
if (App.get('isHaEnabled')) {
- configs = serviceConfigs.findProperty('serviceName', 'HDFS').configs;
- var removedConfigs = configs.filterProperty('category', 'SNameNode');
+ var c = serviceConfigs.findProperty('serviceName', 'HDFS').configs;
+ var removedConfigs = c.filterProperty('category', 'SNameNode');
removedConfigs.map(function(config) {
- configs = configs.without(config);
+ c = c.without(config);
});
- serviceConfigs.findProperty('serviceName', 'HDFS').configs = configs;
+ serviceConfigs.findProperty('serviceName', 'HDFS').configs = c;
}
}
this.set('stepConfigs', serviceConfigs);
- if (App.supports.hostOverridesInstaller) {
- this.loadConfigGroups(this.get('content.configGroups'));
- if (this.get('installedServiceNames').length > 0)
- this.loadInstalledServicesConfigGroups(this.get('installedServiceNames'));
- }
- this.activateSpecialConfigs();
+ },
+
+ /**
+ * Select first addable service for <code>addServiceWizard</code>
+ * Select first service at all in other cases
+ * @method selectProperService
+ */
+ selectProperService: function() {
if (this.get('wizardController.name') === 'addServiceController') {
this.set('selectedService', this.get('stepConfigs').filterProperty('selected', true).get('firstObject'));
}
else {
this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0));
}
- if (this.get('content.skipConfigStep')) {
- App.router.send('next');
- }
},
+
+ /**
+ * Load config tags
+ * @return {$.ajax|null}
+ * @method getConfigTags
+ */
getConfigTags: function() {
- App.ajax.send({
+ return App.ajax.send({
name: 'config.tags.sync',
sender: this,
success: 'getConfigTagsSuccess'
});
},
- getConfigTagsSuccess: function (data, opt, params) {
+ /**
+ * Success callback for config tags request
+ * Updates <code>serviceConfigTags</code> with tags received from server
+ * @param {object} data
+ * @method getConfigTagsSuccess
+ */
+ getConfigTagsSuccess: function (data) {
var installedServiceSites = [];
this.get('serviceConfigsData').filter(function (service) {
if (this.get('installedServiceNames').contains(service.serviceName)){
@@ -446,6 +605,7 @@ App.WizardStep7Controller = Em.Controller.extend({
* set configs actual values from server
* @param serviceConfigTags
* @param configs
+ * @method setInstalledServiceConfigs
*/
setInstalledServiceConfigs: function (serviceConfigTags, configs) {
var configsMap = {};
@@ -463,6 +623,12 @@ App.WizardStep7Controller = Em.Controller.extend({
})
},
+ /**
+ * Add group ids to <code>groupsToDelete</code>
+ * Also save <code>groupsToDelete</code> to local storage
+ * @param {Ember.Object[]} groups
+ * @method setGroupsToDelete
+ */
setGroupsToDelete: function(groups) {
var groupsToDelete = this.get('groupsToDelete');
groups.forEach(function(group) {
@@ -473,6 +639,13 @@ App.WizardStep7Controller = Em.Controller.extend({
});
this.get('wizardController').setDBProperty('groupsToDelete', groupsToDelete);
},
+
+ /**
+ * Update <code>configGroups</code> with selected service configGroups
+ * Also set default group to first position
+ * Update <code>selectedConfigGroup</code> with new default group
+ * @method selectedServiceObserver
+ */
selectedServiceObserver: function () {
if (App.supports.hostOverridesInstaller && this.get('selectedService') && (this.get('selectedService.serviceName') !== 'MISC')) {
var serviceGroups = this.get('selectedService.configGroups');
@@ -486,9 +659,11 @@ App.WizardStep7Controller = Em.Controller.extend({
this.set('selectedConfigGroup', serviceGroups.findProperty('isDefault'));
}
}.observes('selectedService.configGroups.@each'),
+
/**
* load default groups for each service in case of initial load
* @param serviceConfigGroups
+ * @method loadConfigGroups
*/
loadConfigGroups: function (serviceConfigGroups) {
var services = this.get('stepConfigs');
@@ -509,7 +684,8 @@ App.WizardStep7Controller = Em.Controller.extend({
serviceName: service.serviceName
})
]);
- } else {
+ }
+ else {
var defaultGroup = App.ConfigGroup.create(serviceRawGroups.findProperty('isDefault'));
var serviceGroups = service.get('configGroups');
serviceRawGroups.filterProperty('isDefault', false).forEach(function (configGroup) {
@@ -529,51 +705,100 @@ App.WizardStep7Controller = Em.Controller.extend({
});
},
+ /**
+ * Click-handler on config-group to make it selected
+ * @param {object} event
+ * @method selectConfigGroup
+ */
selectConfigGroup: function (event) {
this.set('selectedConfigGroup', event.context);
},
/**
- * rebuild list of configs switch of config group:
+ * Rebuild list of configs switch of config group:
* on default - display all configs from default group and configs from non-default groups as disabled
* on non-default - display all from default group as disabled and configs from selected non-default group
+ * @method switchConfigGroupConfigs
*/
switchConfigGroupConfigs: function () {
- var serviceConfigs = this.get('selectedService.configs');
- var selectedGroup = this.get('selectedConfigGroup');
- var overrideToAdd = this.get('overrideToAdd');
- var isServiceInstalled = this.get('installedServiceNames').contains(this.get('selectedService.serviceName'));
+ var serviceConfigs = this.get('selectedService.configs'),
+ selectedGroup = this.get('selectedConfigGroup'),
+ overrideToAdd = this.get('overrideToAdd'),
+ overrides = [];
if(!selectedGroup) return;
- var displayedConfigGroups = (selectedGroup.get('isDefault')) ?
- this.get('selectedService.configGroups').filterProperty('isDefault', false) :
- [this.get('selectedConfigGroup')];
- var overrides = [];
+ var displayedConfigGroups = this._getDisplayedConfigGroups();
displayedConfigGroups.forEach(function (group) {
overrides.pushObjects(group.get('properties'));
});
serviceConfigs.forEach(function (config) {
- var configOverrides = overrides.filterProperty('name', config.get('name'));
- var isEditable = config.get('isEditable');
- if (isServiceInstalled) {
- isEditable = (!isEditable && !config.get('isReconfigurable')) ? false : selectedGroup.get('isDefault');
- } else {
- isEditable = selectedGroup.get('isDefault');
- }
- config.set('isEditable', isEditable);
- if (overrideToAdd && overrideToAdd.get('name') === config.get('name')) {
- configOverrides.push(this.addOverrideProperty(config));
- this.set('overrideToAdd', null);
- }
- configOverrides.setEach('isEditable', !selectedGroup.get('isDefault'));
- configOverrides.setEach('parentSCP', config);
- config.set('overrides', configOverrides);
+ this._setEditableValue(config);
+ this._setOverrides(config, overrides);
}, this);
}.observes('selectedConfigGroup'),
+
+ /**
+ * Get list of config groups to display
+ * Returns empty array if no <code>selectedConfigGroup</code>
+ * @return {Array}
+ * @method _getDisplayedConfigGroups
+ */
+ _getDisplayedConfigGroups: function() {
+ var selectedGroup = this.get('selectedConfigGroup');
+ if (!selectedGroup) return [];
+ return (selectedGroup.get('isDefault')) ?
+ this.get('selectedService.configGroups').filterProperty('isDefault', false) :
+ [this.get('selectedConfigGroup')];
+ },
+
+ /**
+ * Set <code>isEditable</code> property to <code>config</code>
+ * @param {Ember.Object} config
+ * @return {Ember.Object} updated config-object
+ * @method _setEditableValue
+ */
+ _setEditableValue: function(config) {
+ var selectedGroup = this.get('selectedConfigGroup');
+ if (!selectedGroup) return config;
+ var isEditable = config.get('isEditable'),
+ isServiceInstalled = this.get('installedServiceNames').contains(this.get('selectedService.serviceName'));
+ if (isServiceInstalled) {
+ isEditable = (!isEditable && !config.get('isReconfigurable')) ? false : selectedGroup.get('isDefault');
+ }
+ else {
+ isEditable = selectedGroup.get('isDefault');
+ }
+ config.set('isEditable', isEditable);
+ return config;
+ },
+
+ /**
+ * Set <code>overrides</code> property to <code>config</code>
+ * @param {Ember.Object} config
+ * @param {Ember.Enumerable} overrides
+ * @returns {Ember.Object}
+ * @method _setOverrides
+ */
+ _setOverrides: function(config, overrides) {
+ var selectedGroup = this.get('selectedConfigGroup'),
+ overrideToAdd = this.get('overrideToAdd'),
+ configOverrides = overrides.filterProperty('name', config.get('name'));
+ if (!selectedGroup) return config;
+ if (overrideToAdd && overrideToAdd.get('name') === config.get('name')) {
+ configOverrides.push(this.addOverrideProperty(config));
+ this.set('overrideToAdd', null);
+ }
+ configOverrides.setEach('isEditable', !selectedGroup.get('isDefault'));
+ configOverrides.setEach('parentSCP', config);
+ config.set('overrides', configOverrides);
+ return config;
+ },
+
/**
* create overriden property and push it into Config group
- * @param serviceConfigProperty
- * @return {*}
+ * @param {App.ServiceConfigProperty} serviceConfigProperty
+ * @return {App.ServiceConfigProperty}
+ * @method addOverrideProperty
*/
addOverrideProperty: function (serviceConfigProperty) {
var overrides = serviceConfigProperty.get('overrides') || [];
@@ -589,79 +814,30 @@ App.WizardStep7Controller = Em.Controller.extend({
return newSCP;
},
+ /**
+ * @method manageConfigurationGroup
+ */
manageConfigurationGroup: function () {
App.router.get('mainServiceInfoConfigsController').manageConfigurationGroups(this);
},
- /**
- * Filter text will be located here
- */
- filter: '',
/**
- * Dropdown menu items in filter combobox
- */
- filterColumns: function () {
- var result = [];
- for (var i = 1; i < 2; i++) {
- result.push(Ember.Object.create({
- name: this.t('common.combobox.dropdown.' + i),
- selected: false
- }));
- }
- return result;
- }.property(),
- /**
- * make some configs visible depending on active services
+ * Make some configs visible depending on active services
+ * @method activateSpecialConfigs
*/
activateSpecialConfigs: function () {
var miscConfigs = this.get('stepConfigs').findProperty('serviceName', 'MISC').configs;
miscConfigs = App.config.miscConfigVisibleProperty(miscConfigs, this.get('selectedServiceNames'));
},
+ /**
+ * Click-handler on Next button
+ * @method submit
+ */
submit: function () {
if (!this.get('isSubmitDisabled')) {
App.router.send('next');
}
- },
-
- /**
- * Provides service component name and display-name information for
- * the current selected service.
- */
- getCurrentServiceComponents: function () {
- var selectedServiceName = this.get('selectedService.serviceName');
- var masterComponents = this.get('content.masterComponentHosts');
- var slaveComponents = this.get('content.slaveComponentHosts');
- var scMaps = App.StackServiceComponent.find();
-
- var validComponents = Ember.A([]);
- var seenComponents = {};
- masterComponents.forEach(function(component){
- var cn = component.component;
- var cdn = component.display_name;
- if(component.serviceId===selectedServiceName && !seenComponents[cn]){
- validComponents.pushObject(Ember.Object.create({
- componentName: cn,
- displayName: cdn,
- selected: false
- }));
- seenComponents[cn] = cn;
- }
- });
- slaveComponents.forEach(function(component){
- var cn = component.componentName;
- var cdn = component.displayName;
- var componentDef = scMaps.findProperty('componentName', cn);
- if(!!componentDef && selectedServiceName===componentDef.get('serviceName') && !seenComponents[cn]){
- validComponents.pushObject(Ember.Object.create({
- componentName: cn,
- displayName: cdn,
- selected: false
- }));
- seenComponents[cn] = cn;
- }
- });
- return validComponents;
- }.property('content')
+ }
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/f475fc0b/ambari-web/app/templates/wizard/step7.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/wizard/step7.hbs b/ambari-web/app/templates/wizard/step7.hbs
index b10434f..eb4fb76 100644
--- a/ambari-web/app/templates/wizard/step7.hbs
+++ b/ambari-web/app/templates/wizard/step7.hbs
@@ -17,24 +17,22 @@
}}
<div id="serviceConfig">
- <h2>{{t installer.step7.header}}</h2>
+ <h2>{{t installer.step7.header}}</h2>
- <div class="alert alert-info">
- {{t installer.step7.body}}
- </div>
+ <div class="alert alert-info">
+ {{t installer.step7.body}}
+ </div>
- {{#if isAdvancedConfigLoaded}}
- {{view App.ServicesConfigView}}
- {{else}}
- <div class="spinner"></div>
- {{/if}}
+ {{#if isAdvancedConfigLoaded}}
+ {{view App.ServicesConfigView}}
+ {{else}}
+ <div class="spinner"></div>
+ {{/if}}
- <div class="btn-area">
- <a class="btn" {{action back}}>← {{t common.back}}</a>
-
- <a
- class="btn btn-success pull-right" {{bindAttr disabled="isSubmitDisabled"}}
- {{action submit target="controller"}}>{{t common.next}} →</a>
- </div>
+ <div class="btn-area">
+ <a class="btn" {{action back}}>← {{t common.back}}</a>
+ <a class="btn btn-success pull-right" {{bindAttr disabled="isSubmitDisabled"}}
+ {{action submit target="controller"}}>{{t common.next}} →</a>
+ </div>
</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/f475fc0b/ambari-web/app/templates/wizard/step7_custom_config_error.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/wizard/step7_custom_config_error.hbs b/ambari-web/app/templates/wizard/step7_custom_config_error.hbs
deleted file mode 100644
index 085070c..0000000
--- a/ambari-web/app/templates/wizard/step7_custom_config_error.hbs
+++ /dev/null
@@ -1,38 +0,0 @@
-{{!
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-}}
-
-<h5>{{view.message}}</h5>
-<br />
-<div class="pre-scrollable" style="max-height: 250px;">
- <ul>
- {{#each val in view.customConfig}}
- {{#if val.siteProperties}}
- <li>
- {{val.serviceName}}
- <ul>
- {{#each item in val.siteProperties}}
- <li>
- {{item.displayMsg}}
- </li>
- {{/each}}
- </ul>
- </li>
- {{/if}}
- {{/each}}
- </ul>
-</div>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/f475fc0b/ambari-web/test/installer/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/installer/step7_test.js b/ambari-web/test/installer/step7_test.js
index c1e4161..52e00dd 100644
--- a/ambari-web/test/installer/step7_test.js
+++ b/ambari-web/test/installer/step7_test.js
@@ -18,13 +18,19 @@
var App = require('app');
var numberUtils = require('utils/number_utils');
+require('mixins/common/localStorage');
+require('models/config_group');
require('controllers/wizard/step7_controller');
var installerStep7Controller;
describe('App.InstallerStep7Controller', function () {
- describe('#installedServiceNames', function() {
+ beforeEach(function () {
+ installerStep7Controller = App.WizardStep7Controller.create();
+ });
+
+ describe('#installedServiceNames', function () {
var tests = Em.A([
{
@@ -101,11 +107,9 @@ describe('App.InstallerStep7Controller', function () {
}
]);
- tests.forEach(function(test) {
- it(test.m, function() {
- installerStep7Controller = App.WizardStep7Controller.create({
- content: test.content
- });
+ tests.forEach(function (test) {
+ it(test.m, function () {
+ installerStep7Controller.set('content', test.content);
expect(installerStep7Controller.get('installedServiceNames')).to.include.members(test.e);
expect(test.e).to.include.members(installerStep7Controller.get('installedServiceNames'));
});
@@ -113,4 +117,1064 @@ describe('App.InstallerStep7Controller', function () {
});
-});
+ describe('#isSubmitDisabled', function () {
+ it('should be true if miscModalVisible', function () {
+ installerStep7Controller.reopen({miscModalVisible: true});
+ expect(installerStep7Controller.get('isSubmitDisabled')).to.equal(true);
+ });
+ it('should be true if some of stepConfigs has errors', function () {
+ installerStep7Controller.reopen({
+ miscModalVisible: false,
+ stepConfigs: [
+ {
+ showConfig: true,
+ errorCount: 1
+ }
+ ]
+ });
+ expect(installerStep7Controller.get('isSubmitDisabled')).to.equal(true);
+ });
+ it('should be false if all of stepConfigs don\'t have errors and miscModalVisible is false', function () {
+ installerStep7Controller.reopen({
+ miscModalVisible: false,
+ stepConfigs: [
+ {
+ showConfig: true,
+ errorCount: 0
+ }
+ ]
+ });
+ expect(installerStep7Controller.get('isSubmitDisabled')).to.equal(false);
+ });
+ });
+
+ describe('#selectedServiceNames', function () {
+ it('should use content.services as source of data', function () {
+ installerStep7Controller.set('content', {
+ services: [
+ {isSelected: true, isInstalled: false, serviceName: 's1'},
+ {isSelected: false, isInstalled: false, serviceName: 's2'},
+ {isSelected: true, isInstalled: true, serviceName: 's3'},
+ {isSelected: false, isInstalled: false, serviceName: 's4'},
+ {isSelected: true, isInstalled: false, serviceName: 's5'},
+ {isSelected: false, isInstalled: false, serviceName: 's6'},
+ {isSelected: true, isInstalled: true, serviceName: 's7'},
+ {isSelected: false, isInstalled: false, serviceName: 's8'}
+ ]
+ });
+ var expected = ['s1', 's5'];
+ expect(installerStep7Controller.get('selectedServiceNames')).to.eql(expected);
+ });
+ });
+
+ describe('#allSelectedServiceNames', function () {
+ it('should use content.services as source of data', function () {
+ installerStep7Controller.set('content', {
+ services: [
+ {isSelected: true, isInstalled: false, serviceName: 's1'},
+ {isSelected: false, isInstalled: false, serviceName: 's2'},
+ {isSelected: true, isInstalled: true, serviceName: 's3'},
+ {isSelected: false, isInstalled: false, serviceName: 's4'},
+ {isSelected: true, isInstalled: false, serviceName: 's5'},
+ {isSelected: false, isInstalled: false, serviceName: 's6'},
+ {isSelected: true, isInstalled: true, serviceName: 's7'},
+ {isSelected: false, isInstalled: false, serviceName: 's8'}
+ ]
+ });
+ var expected = ['s1', 's3', 's5', 's7'];
+ expect(installerStep7Controller.get('allSelectedServiceNames')).to.eql(expected);
+ });
+ });
+
+ describe('#masterComponentHosts', function () {
+ it('should be equal to content.masterComponentHosts', function () {
+ var masterComponentHosts = [
+ {},
+ {},
+ {}
+ ];
+ installerStep7Controller.reopen({content: {masterComponentHosts: masterComponentHosts}});
+ expect(installerStep7Controller.get('masterComponentHosts')).to.eql(masterComponentHosts);
+ });
+ });
+
+ describe('#slaveComponentHosts', function () {
+ it('should be equal to content.slaveGroupProperties', function () {
+ var slaveGroupProperties = [
+ {},
+ {},
+ {}
+ ];
+ installerStep7Controller.reopen({content: {slaveGroupProperties: slaveGroupProperties}});
+ expect(installerStep7Controller.get('slaveComponentHosts')).to.eql(slaveGroupProperties);
+ });
+ });
+
+ describe('#clearStep', function () {
+ it('should clear serviceConfigTags', function () {
+ installerStep7Controller.set('serviceConfigTags', [
+ {},
+ {}
+ ]);
+ installerStep7Controller.clearStep();
+ expect(installerStep7Controller.get('serviceConfigTags.length')).to.equal(0);
+ });
+ it('should clear stepConfigs', function () {
+ installerStep7Controller.set('stepConfigs', [
+ {},
+ {}
+ ]);
+ installerStep7Controller.clearStep();
+ expect(installerStep7Controller.get('stepConfigs.length')).to.equal(0);
+ });
+ it('should clear filter', function () {
+ installerStep7Controller.set('filter', 'filter');
+ installerStep7Controller.clearStep();
+ expect(installerStep7Controller.get('filter')).to.equal('');
+ });
+ it('should set for each filterColumns "selected" false', function () {
+ installerStep7Controller.set('filterColumns', [
+ {selected: true},
+ {selected: false},
+ {selected: true}
+ ]);
+ installerStep7Controller.clearStep();
+ expect(installerStep7Controller.get('filterColumns').everyProperty('selected', false)).to.equal(true);
+ });
+ });
+
+ describe('#loadInstalledServicesConfigGroups', function () {
+ before(function () {
+ sinon.stub(App.ajax, 'send', Em.K);
+ });
+ after(function () {
+ App.ajax.send.restore();
+ });
+ it('should do ajax request for each received service name', function () {
+ var serviceNames = ['s1', 's2', 's3'];
+ installerStep7Controller.loadInstalledServicesConfigGroups(serviceNames);
+ expect(App.ajax.send.callCount).to.equal(serviceNames.length);
+ });
+ });
+
+ describe('#getConfigTags', function () {
+ before(function () {
+ sinon.stub(App.ajax, 'send', Em.K);
+ });
+ after(function () {
+ App.ajax.send.restore();
+ });
+ it('should do ajax-request', function () {
+ installerStep7Controller.getConfigTags();
+ expect(App.ajax.send.calledOnce).to.equal(true);
+ });
+ });
+
+ describe('#setGroupsToDelete', function () {
+ beforeEach(function () {
+ installerStep7Controller.set('wizardController', Em.Object.create(App.LocalStorage, {name: 'tdk'}));
+ });
+ it('should add new groups to groupsToDelete', function () {
+ var groupsToDelete = [
+ {id: '1'},
+ {id: '2'}
+ ],
+ groups = [
+ Em.Object.create({id: '3'}),
+ Em.Object.create(),
+ Em.Object.create({id: '5'})
+ ],
+ expected = [
+ {id: "1"},
+ {id: "2"},
+ {id: "3"},
+ {id: "5"}
+ ];
+ installerStep7Controller.set('groupsToDelete', groupsToDelete);
+ installerStep7Controller.setGroupsToDelete(groups);
+ expect(installerStep7Controller.get('groupsToDelete')).to.eql(expected);
+ expect(installerStep7Controller.get('wizardController').getDBProperty('groupsToDelete')).to.eql(expected);
+ });
+ });
+
+ describe('#selectConfigGroup', function () {
+ beforeEach(function () {
+ installerStep7Controller.reopen({content: {services: []}});
+ sinon.stub(installerStep7Controller, 'switchConfigGroupConfigs', Em.K);
+ });
+ afterEach(function () {
+ installerStep7Controller.switchConfigGroupConfigs.restore();
+ });
+ it('should set selectedConfigGroup', function () {
+ var group = {':': []};
+ installerStep7Controller.selectConfigGroup({context: group});
+ expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(group);
+ });
+ });
+
+ describe('#submit', function () {
+ beforeEach(function () {
+ sinon.stub(App.router, 'send', Em.K);
+ });
+ afterEach(function () {
+ App.router.send.restore();
+ });
+ it('should proceed if submit is not disabled', function () {
+ installerStep7Controller.reopen({isSubmitDisabled: false});
+ installerStep7Controller.submit();
+ expect(App.router.send.calledOnce).to.equal(true);
+ });
+ it('should not proceed if submit is disabled', function () {
+ installerStep7Controller.reopen({isSubmitDisabled: true});
+ installerStep7Controller.submit();
+ expect(App.router.send.called).to.equal(false);
+ });
+ });
+
+ describe('#addOverrideProperty', function () {
+ it('should add override property', function () {
+ var groupName = 'groupName',
+ selectedService = {configGroups: [Em.Object.create({name: groupName, properties: []})]},
+ selectedConfigGroup = {name: groupName},
+ serviceConfigProperty = Em.Object.create({overrides: []}),
+ expected = Em.Object.create({
+ value: '',
+ isOriginalSCP: false,
+ isEditable: true
+ });
+ installerStep7Controller.reopen({selectedService: selectedService, selectedConfigGroup: selectedConfigGroup});
+ var newSCP = installerStep7Controller.addOverrideProperty(serviceConfigProperty);
+ Em.keys(expected).forEach(function (k) {
+ expect(newSCP.get(k)).to.equal(expected.get(k));
+ });
+ var group = installerStep7Controller.get('selectedService.configGroups').findProperty('name', groupName);
+ expect(newSCP.get('group')).to.eql(group);
+ expect(newSCP.get('parentSCP')).to.eql(serviceConfigProperty);
+ expect(group.get('properties.length')).to.equal(1);
+ });
+ });
+
+ describe('#getConfigTagsSuccess', function () {
+ it('should update serviceConfigTags', function () {
+ var installedServiceNames = ['s1', 's2'],
+ serviceConfigsData = [
+ {serviceName: 's1', sites: ['s1-site', 's1-log']},
+ {serviceName: 's2', sites: ['s2-site', 'core-site']},
+ {serviceName: 's3', sites: ['s3-site']}
+ ],
+ data = {
+ Clusters: {
+ desired_configs: {
+ "core-site": {
+ "user": "admin",
+ "tag": "version1398780546992"
+ },
+ "global": {
+ "user": "admin",
+ "tag": "version1398780546992"
+ },
+ "s1-site": {
+ "user": "admin",
+ "tag": "version1"
+ },
+ "s1-log": {
+ "user": "admin",
+ "tag": "version1"
+ },
+ "s2-site": {
+ "user": "admin",
+ "tag": "version1"
+ },
+ "s3-site": {
+ "user": "admin",
+ "tag": "version1"
+ }
+ }
+ }
+ },
+ serviceConfigTags = [
+ {siteName: 'core-site', tagName: 'version1398780546992', newTagName: null},
+ {siteName: 's1-site', tagName: 'version1', newTagName: null},
+ {siteName: 's1-log', tagName: 'version1', newTagName: null},
+ {siteName: 's2-site', tagName: 'version1', newTagName: null}
+ ];
+ installerStep7Controller.reopen({serviceConfigsData: serviceConfigsData, installedServiceNames: installedServiceNames});
+ installerStep7Controller.getConfigTagsSuccess(data);
+ expect(installerStep7Controller.get('serviceConfigTags')).to.eql(serviceConfigTags);
+ });
+ });
+
+ describe('#resolveStormConfigs', function () {
+ beforeEach(function () {
+ installerStep7Controller.reopen({
+ content: {services: []},
+ wizardController: Em.Object.create({
+ getDBProperty: function () {
+ return [
+ {component: 'GANGLIA_SERVER', hostName: 'h1'}
+ ];
+ }
+ })
+ });
+ });
+ it('shouldn\'t do nothing if Ganglia and Storm are installed', function () {
+ var installedServiceNames = ['GANGLIA', 'STORM'],
+ configs = [
+ {name: 'nimbus.childopts', value: '.jar=host=', defaultValue: ''},
+ {name: 'supervisor.childopts', value: '.jar=host=', defaultValue: ''},
+ {name: 'worker.childopts', value: '.jar=host=', defaultValue: ''}
+ ],
+ expected = [
+ {name: 'nimbus.childopts', value: '.jar=host=', defaultValue: ''},
+ {name: 'supervisor.childopts', value: '.jar=host=', defaultValue: ''},
+ {name: 'worker.childopts', value: '.jar=host=', defaultValue: ''}
+ ];
+ installerStep7Controller.reopen({installedServiceNames: installedServiceNames});
+ installerStep7Controller.resolveStormConfigs(configs);
+ expect(configs).to.eql(expected);
+ });
+ it('shouldn\'t do nothing if Ganglia is in allSelectedServiceNames', function () {
+ var allSelectedServiceNames = ['GANGLIA'],
+ configs = [
+ {name: 'nimbus.childopts', value: '.jar=host=', defaultValue: ''},
+ {name: 'supervisor.childopts', value: '.jar=host=', defaultValue: ''},
+ {name: 'worker.childopts', value: '.jar=host=', defaultValue: ''}
+ ],
+ expected = [
+ {name: 'nimbus.childopts', value: '.jar=host=h1', defaultValue: '.jar=host=h1', forceUpdate: true},
+ {name: 'supervisor.childopts', value: '.jar=host=h1', defaultValue: '.jar=host=h1', forceUpdate: true},
+ {name: 'worker.childopts', value: '.jar=host=h1', defaultValue: '.jar=host=h1', forceUpdate: true}
+ ];
+ installerStep7Controller.reopen({allSelectedServiceNames: allSelectedServiceNames});
+ installerStep7Controller.resolveStormConfigs(configs);
+ Em.keys(expected[0]).forEach(function (k) {
+ expect(configs.mapProperty(k)).to.eql(expected.mapProperty(k));
+ });
+ });
+ it('shouldn\'t do nothing if Ganglia is in installedServiceNames', function () {
+ var installedServiceNames = ['GANGLIA'],
+ configs = [
+ {name: 'nimbus.childopts', value: '.jar=host=', defaultValue: ''},
+ {name: 'supervisor.childopts', value: '.jar=host=', defaultValue: ''},
+ {name: 'worker.childopts', value: '.jar=host=', defaultValue: ''}
+ ],
+ expected = [
+ {name: 'nimbus.childopts', value: '.jar=host=h1', defaultValue: '.jar=host=h1', forceUpdate: true},
+ {name: 'supervisor.childopts', value: '.jar=host=h1', defaultValue: '.jar=host=h1', forceUpdate: true},
+ {name: 'worker.childopts', value: '.jar=host=h1', defaultValue: '.jar=host=h1', forceUpdate: true}
+ ];
+ installerStep7Controller.reopen({installedServiceNames: installedServiceNames});
+ installerStep7Controller.resolveStormConfigs(configs);
+ Em.keys(expected[0]).forEach(function (k) {
+ expect(configs.mapProperty(k)).to.eql(expected.mapProperty(k));
+ });
+ });
+ });
+
+ describe('#resolveServiceDependencyConfigs', function () {
+ beforeEach(function () {
+ sinon.stub(installerStep7Controller, 'resolveStormConfigs', Em.K);
+ });
+ afterEach(function () {
+ installerStep7Controller.resolveStormConfigs.restore();
+ });
+ it('should call resolveStormConfigs if serviceName is STORM', function () {
+ var serviceName = 'STORM', configs = [
+ {},
+ {},
+ {}
+ ];
+ installerStep7Controller.resolveServiceDependencyConfigs(serviceName, configs);
+ expect(installerStep7Controller.resolveStormConfigs.calledWith(configs)).to.equal(true);
+ });
+ });
+
+ describe('#selectedServiceObserver', function () {
+ beforeEach(function () {
+ installerStep7Controller.reopen({content: {services: []}});
+ sinon.stub(installerStep7Controller, 'switchConfigGroupConfigs', Em.K);
+ });
+ afterEach(function () {
+ installerStep7Controller.switchConfigGroupConfigs.restore();
+ });
+ it('shouldn\'t do nothing if App.supports.hostOverridesInstaller is false', function () {
+ App.set('supports.hostOverridesInstaller', false);
+ var configGroups = [
+ {},
+ {}
+ ],
+ selectedConfigGroup = {};
+ installerStep7Controller.reopen({configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
+ installerStep7Controller.selectedServiceObserver();
+ expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
+ expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
+ });
+ it('shouldn\'t do nothing if selectedService is null', function () {
+ App.set('supports.hostOverridesInstaller', true);
+ var configGroups = [
+ {},
+ {}
+ ],
+ selectedConfigGroup = {};
+ installerStep7Controller.reopen({selectedService: null, configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
+ installerStep7Controller.selectedServiceObserver();
+ expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
+ expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
+ });
+ it('shouldn\'t do nothing if selectedService.serviceName is MISC', function () {
+ App.set('supports.hostOverridesInstaller', true);
+ var configGroups = [
+ {},
+ {}
+ ],
+ selectedConfigGroup = {};
+ installerStep7Controller.reopen({selectedService: {serviceName: 'MISC'}, configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
+ installerStep7Controller.selectedServiceObserver();
+ expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
+ expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
+ });
+ it('should update configGroups and selectedConfigGroup', function () {
+ App.set('supports.hostOverridesInstaller', true);
+ var defaultGroup = {isDefault: true, n: 'n2'},
+ configGroups = [
+ {isDefault: false, n: 'n1'},
+ defaultGroup,
+ {n: 'n3'}
+ ],
+ selectedConfigGroup = {};
+ installerStep7Controller.reopen({selectedService: {serviceName: 's1', configGroups: configGroups}});
+ installerStep7Controller.selectedServiceObserver();
+ expect(installerStep7Controller.get('configGroups').mapProperty('n')).to.eql(['n2', 'n1', 'n3']);
+ expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(defaultGroup);
+ });
+ });
+
+ describe('#loadConfigGroups', function () {
+ beforeEach(function () {
+ installerStep7Controller.reopen({
+ wizardController: Em.Object.create({
+ allHosts: [
+ {hostName: 'h1'},
+ {hostName: 'h2'},
+ {hostName: 'h3'}
+ ]
+ })
+ });
+ });
+ it('shouldn\'t do nothing if only MISC available', function () {
+ var configGroups = [
+ {}
+ ];
+ installerStep7Controller.reopen({
+ stepConfigs: [Em.Object.create({serviceName: 'MISC', configGroups: configGroups})]
+ });
+ installerStep7Controller.loadConfigGroups([]);
+ expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups')).to.eql(configGroups);
+ });
+ it('should set configGroups for service if they don\'t exist', function () {
+ var configGroups = [],
+ serviceName = 'HDFS',
+ serviceConfigGroups = [
+ {service: {id: 's1'}}
+ ];
+ installerStep7Controller.reopen({
+ stepConfigs: [Em.Object.create({serviceName: serviceName, configGroups: configGroups})]
+ });
+ installerStep7Controller.loadConfigGroups(serviceConfigGroups);
+ expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups.length')).to.equal(1);
+ var group = installerStep7Controller.get('stepConfigs.firstObject.configGroups.firstObject');
+ expect(group.get('name')).to.equal(serviceName + ' Default');
+ expect(group.get('description').contains(serviceName)).to.equal(true);
+ expect(group.get('isDefault')).to.equal(true);
+ expect(group.get('hosts')).to.eql(['h1', 'h2', 'h3']);
+ expect(group.get('service.id')).to.equal(serviceName);
+ expect(group.get('serviceName')).to.equal(serviceName);
+ });
+ it('should update configGroups for service (only default group)', function () {
+ var configGroups = [],
+ serviceName = 'HDFS',
+ serviceConfigGroups = [
+ {service: {id: 'HDFS'}, isDefault: true, n: 'n1'}
+ ];
+ installerStep7Controller.reopen({
+ stepConfigs: [Em.Object.create({serviceName: serviceName, configGroups: configGroups})]
+ });
+ installerStep7Controller.loadConfigGroups(serviceConfigGroups);
+ expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault').get('n')).to.equal('n1');
+ });
+ it('should update configGroups for service', function () {
+ var configGroups = [],
+ serviceName = 'HDFS',
+ serviceConfigGroups = [
+ {service: {id: 'HDFS'}, properties: [
+ {},
+ {}
+ ], isDefault: true, n: 'n1'},
+ {service: {id: 'HDFS'}, properties: [
+ {},
+ {}
+ ], isDefault: false, n: 'n2'}
+ ];
+ installerStep7Controller.reopen({
+ stepConfigs: [Em.Object.create({serviceName: serviceName, configGroups: configGroups})]
+ });
+ installerStep7Controller.loadConfigGroups(serviceConfigGroups);
+ expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups.length')).to.equal(2);
+ expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault').get('n')).to.equal('n1');
+ expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault', false).get('properties').everyProperty('group.n', 'n2')).to.equal(true);
+ expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault', false).get('parentConfigGroup.n')).to.equal('n1');
+ });
+ });
+
+ describe('#_getDisplayedConfigGroups', function () {
+ it('should return [] if no selected group', function () {
+ installerStep7Controller.reopen({
+ content: {services: []},
+ selectedConfigGroup: null
+ });
+ expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([]);
+ });
+ it('should return default config group if another selected', function () {
+ var defaultGroup = Em.Object.create({isDefault: false});
+ installerStep7Controller.reopen({
+ content: {services: []},
+ selectedConfigGroup: defaultGroup
+ });
+ expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([defaultGroup]);
+ });
+ it('should return other groups if default selected', function () {
+ var defaultGroup = Em.Object.create({isDefault: true}),
+ cfgG = Em.Object.create({isDefault: true}),
+ configGroups = Em.A([
+ Em.Object.create({isDefault: false}),
+ Em.Object.create({isDefault: false}),
+ cfgG,
+ Em.Object.create({isDefault: false})
+ ]);
+ installerStep7Controller.reopen({
+ content: {services: []},
+ selectedConfigGroup: defaultGroup,
+ selectedService: {configGroups: configGroups}
+ });
+ expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql(configGroups.without(cfgG));
+ });
+ });
+
+ describe('#_setEditableValue', function () {
+ it('shouldn\'t update config if no selectedConfigGroup', function () {
+ installerStep7Controller.reopen({
+ selectedConfigGroup: null
+ });
+ var config = Em.Object.create({isEditable: null});
+ var updatedConfig = installerStep7Controller._setEditableValue(config);
+ expect(updatedConfig.get('isEditable')).to.be.null;
+ });
+ it('should set isEditable equal to selectedGroup.isDefault if service not installed', function () {
+ var isDefault = true;
+ installerStep7Controller.reopen({
+ installedServiceNames: [],
+ selectedService: {serviceName: 'abc'},
+ selectedConfigGroup: Em.Object.create({isDefault: isDefault})
+ });
+ var config = Em.Object.create({isEditable: null});
+ var updatedConfig = installerStep7Controller._setEditableValue(config);
+ expect(updatedConfig.get('isEditable')).to.equal(isDefault);
+ installerStep7Controller.toggleProperty('selectedConfigGroup.isDefault');
+ updatedConfig = installerStep7Controller._setEditableValue(config);
+ expect(updatedConfig.get('isEditable')).to.equal(!isDefault);
+ });
+ Em.A([
+ {
+ isEditable: false,
+ isReconfigurable: false,
+ isDefault: true,
+ e: false
+ },
+ {
+ isEditable: true,
+ isReconfigurable: true,
+ isDefault: true,
+ e: true
+ },
+ {
+ isEditable: false,
+ isReconfigurable: true,
+ isDefault: false,
+ e: false
+ },
+ {
+ isEditable: true,
+ isReconfigurable: false,
+ isDefault: false,
+ e: false
+ }
+ ]).forEach(function (test) {
+ it('service installed, isEditable = ' + test.isEditable.toString() + ', isReconfigurable = ' + test.isReconfigurable.toString(), function () {
+ var config = Em.Object.create({
+ isReconfigurable: test.isReconfigurable,
+ isEditable: test.isEditable
+ });
+ installerStep7Controller.reopen({
+ installedServiceNames: Em.A(['a']),
+ selectedService: Em.Object.create({serviceName: 'a'}),
+ selectedConfigGroup: Em.Object.create({isDefault: test.isDefault})
+ });
+ var updateConfig = installerStep7Controller._setEditableValue(config);
+ expect(updateConfig.get('isEditable')).to.equal(test.e);
+ });
+ });
+ });
+
+ describe('#_setOverrides', function () {
+ it('shouldn\'t update config if no selectedConfigGroup', function () {
+ installerStep7Controller.reopen({
+ selectedConfigGroup: null
+ });
+ var config = Em.Object.create({overrides: null});
+ var updatedConfig = installerStep7Controller._setOverrides(config, []);
+ expect(updatedConfig.get('overrides')).to.be.null;
+ });
+ it('no overrideToAdd', function () {
+ var isDefault = true,
+ name = 'n1',
+ config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
+ overrides = Em.A([
+ Em.Object.create({name: name, value: 'v1'}),
+ Em.Object.create({name: name, value: 'v2'}),
+ Em.Object.create({name: 'n2', value: 'v3'})
+ ]);
+ installerStep7Controller.reopen({
+ overrideToAdd: null,
+ selectedConfigGroup: Em.Object.create({
+ isDefault: isDefault
+ })
+ });
+ var updatedConfig = installerStep7Controller._setOverrides(config, overrides);
+ expect(updatedConfig.get('overrides.length')).to.equal(2);
+ expect(updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
+ expect(updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
+ });
+ it('overrideToAdd exists', function () {
+ var isDefault = true,
+ name = 'n1',
+ config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
+ overrides = Em.A([
+ Em.Object.create({name: name, value: 'v1'}),
+ Em.Object.create({name: name, value: 'v2'}),
+ Em.Object.create({name: 'n2', value: 'v3'})
+ ]);
+ installerStep7Controller.reopen({
+ overrideToAdd: Em.Object.create({name: name}),
+ selectedService: {configGroups: [Em.Object.create({name: 'n', properties: []})]},
+ selectedConfigGroup: Em.Object.create({
+ isDefault: isDefault,
+ name: 'n'
+ })
+ });
+ var updatedConfig = installerStep7Controller._setOverrides(config, overrides);
+ expect(updatedConfig.get('overrides.length')).to.equal(3);
+ expect(updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
+ expect(updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
+ });
+ });
+
+ describe('#switchConfigGroupConfigs', function () {
+ it('if selectedConfigGroup is null, serviceConfigs shouldn\'t be changed', function () {
+ installerStep7Controller.reopen({
+ selectedConfigGroup: null,
+ content: {services: []},
+ serviceConfigs: {configs: [
+ {overrides: []},
+ {overrides: []}
+ ]}
+ });
+ installerStep7Controller.switchConfigGroupConfigs();
+ expect(installerStep7Controller.get('serviceConfigs.configs').everyProperty('overrides.length', 0)).to.equal(true);
+ });
+ it('should set configs for serviceConfigs', function () {
+ var configGroups = [
+ Em.Object.create({
+ properties: [
+ {name: 'g1', value: 'v1'},
+ {name: 'g2', value: 'v2'}
+ ]
+ })
+ ];
+ sinon.stub(installerStep7Controller, '_getDisplayedConfigGroups', function () {
+ return configGroups;
+ });
+ sinon.stub(installerStep7Controller, '_setEditableValue', function (config) {
+ config.set('isEditable', true);
+ return config;
+ });
+ installerStep7Controller.reopen({
+ selectedConfigGroup: Em.Object.create({isDefault: true, name: 'g1'}),
+ content: {services: []},
+ selectedService: {configs: Em.A([Em.Object.create({name: 'g1', overrides: [], properties: []}), Em.Object.create({name: 'g2', overrides: []})])},
+ serviceConfigs: {configs: [Em.Object.create({name: 'g1'})]}
+ });
+ installerStep7Controller.switchConfigGroupConfigs();
+ var configs = installerStep7Controller.get('selectedService.configs');
+ expect(configs.findProperty('name', 'g1').get('overrides').length).to.equal(1);
+ expect(configs.findProperty('name', 'g2').get('overrides').length).to.equal(1);
+ expect(configs.everyProperty('isEditable', true)).to.equal(true);
+ installerStep7Controller._getDisplayedConfigGroups.restore();
+ installerStep7Controller._setEditableValue.restore();
+ });
+ });
+
+ describe('#selectProperService', function () {
+ Em.A([
+ {
+ name: 'addServiceController',
+ stepConfigs: [
+ {selected: false, name: 'n1'},
+ {selected: true, name: 'n2'},
+ {selected: true, name: 'n3'}
+ ],
+ e: 'n2'
+ },
+ {
+ name: 'installerController',
+ stepConfigs: [
+ {showConfig: false, name: 'n1'},
+ {showConfig: false, name: 'n2'},
+ {showConfig: true, name: 'n3'}
+ ],
+ e: 'n3'
+ }
+ ]).forEach(function (test) {
+ it(test.name, function () {
+ sinon.stub(installerStep7Controller, 'selectedServiceObserver', Em.K);
+ installerStep7Controller.reopen({
+ wizardController: Em.Object.create({
+ name: test.name
+ }),
+ stepConfigs: test.stepConfigs
+ });
+ installerStep7Controller.selectProperService();
+ expect(installerStep7Controller.get('selectedService.name')).to.equal(test.e);
+ installerStep7Controller.selectedServiceObserver.restore();
+ });
+ });
+ });
+
+ describe('#setStepConfigs', function () {
+ beforeEach(function () {
+ installerStep7Controller.reopen({
+ content: {services: []},
+ wizardController: Em.Object.create({
+ getDBProperty: function (key) {
+ return this.get(key);
+ }
+ })
+ });
+ });
+ afterEach(function() {
+ App.config.renderConfigs.restore();
+ });
+ it('if wizard isn\'t addService, should set output of App.config.renderConfigs', function () {
+ var serviceConfigs = Em.A([
+ {},
+ {}
+ ]);
+ sinon.stub(App.config, 'renderConfigs', function () {
+ return serviceConfigs;
+ });
+ installerStep7Controller.set('wizardController.name', 'installerController');
+ installerStep7Controller.setStepConfigs([], []);
+ expect(installerStep7Controller.get('stepConfigs')).to.eql(serviceConfigs);
+ });
+ it('addServiceWizard used', function () {
+ var serviceConfigs = Em.A([Em.Object.create({serviceName: 's1'}), Em.Object.create({serviceName: 's2'})]);
+ installerStep7Controller.set('wizardController.name', 'addServiceController');
+ installerStep7Controller.reopen({selectedServiceNames: ['s2']});
+ sinon.stub(App.config, 'renderConfigs', function () {
+ return serviceConfigs;
+ });
+ installerStep7Controller.setStepConfigs([], []);
+ expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
+ expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 's2').get('selected')).to.equal(true);
+ });
+ it('addServiceWizard used, HA enabled', function () {
+ sinon.stub(App, 'get', function(k) {
+ if(k === 'isHaEnabled') {
+ return true;
+ }
+ return Em.get(App, k);
+ });
+ var serviceConfigs = Em.A([
+ Em.Object.create({
+ serviceName: 'HDFS',
+ configs: [
+ {category: 'SNameNode'},
+ {category: 'SNameNode'},
+ {category: 'NameNode'},
+ {category: 'NameNode'},
+ {category: 'SNameNode'}
+ ]
+ }),
+ Em.Object.create({serviceName: 's2'})]
+ );
+ installerStep7Controller.set('wizardController.name', 'addServiceController');
+ installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
+ sinon.stub(App.config, 'renderConfigs', function () {
+ return serviceConfigs;
+ });
+ installerStep7Controller.setStepConfigs([], []);
+ expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
+ expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('selected')).to.equal(true);
+ expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
+ App.get.restore();
+ });
+ });
+
+ describe('#checkHostOverrideInstaller', function() {
+ beforeEach(function() {
+ sinon.stub(installerStep7Controller, 'loadConfigGroups', Em.K);
+ sinon.stub(installerStep7Controller, 'loadInstalledServicesConfigGroups', Em.K);
+ });
+ afterEach(function() {
+ installerStep7Controller.loadConfigGroups.restore();
+ installerStep7Controller.loadInstalledServicesConfigGroups.restore();
+ App.get.restore();
+ });
+ Em.A([
+ {
+ hostOverridesInstaller: false,
+ installedServiceNames: [],
+ m: 'hostOverridesInstaller is false, installedServiceNames is empty',
+ e: {
+ loadConfigGroups: false,
+ loadInstalledServicesConfigGroups: false
+ }
+ },
+ {
+ hostOverridesInstaller: false,
+ installedServiceNames: ['s1', 's2'],
+ m: 'hostOverridesInstaller is false, installedServiceNames is n\'t empty',
+ e: {
+ loadConfigGroups: false,
+ loadInstalledServicesConfigGroups: false
+ }
+ },
+ {
+ hostOverridesInstaller: true,
+ installedServiceNames: [],
+ m: 'hostOverridesInstaller is true, installedServiceNames is empty',
+ e: {
+ loadConfigGroups: true,
+ loadInstalledServicesConfigGroups: false
+ }
+ },
+ {
+ hostOverridesInstaller: true,
+ installedServiceNames: ['s1', 's2', 's3'],
+ m: 'hostOverridesInstaller is true, installedServiceNames isn\'t empty',
+ e: {
+ loadConfigGroups: true,
+ loadInstalledServicesConfigGroups: true
+ }
+ }
+ ]).forEach(function(test) {
+ it(test.m, function() {
+ sinon.stub(App, 'get', function(k) {
+ if (k === 'supports.hostOverridesInstaller') return test.hostOverridesInstaller;
+ return Em.get(App, k);
+ });
+ installerStep7Controller.reopen({installedServiceNames: test.installedServiceNames});
+ installerStep7Controller.checkHostOverrideInstaller();
+ if (test.e.loadConfigGroups) {
+ expect(installerStep7Controller.loadConfigGroups.calledOnce).to.equal(true);
+ }
+ else {
+ expect(installerStep7Controller.loadConfigGroups.called).to.equal(false);
+ }
+ if (test.e.loadInstalledServicesConfigGroups) {
+ expect(installerStep7Controller.loadInstalledServicesConfigGroups.calledOnce).to.equal(true);
+ }
+ else {
+ expect(installerStep7Controller.loadInstalledServicesConfigGroups.called).to.equal(false);
+ }
+ });
+ });
+ });
+
+ describe('#loadStep', function() {
+ beforeEach(function() {
+ installerStep7Controller.reopen({
+ content: {services: []},
+ wizardController: Em.Object.create({
+ getDBProperty: function(k) {return this.get(k);}
+ })
+ });
+ sinon.stub(App.config, 'mergePreDefinedWithStored', Em.K);
+ sinon.stub(App.config, 'addAdvancedConfigs', Em.K);
+ sinon.stub(App.config, 'addCustomConfigs', Em.K);
+ sinon.stub(App.config, 'fileConfigsIntoTextarea', Em.K);
+ sinon.stub(installerStep7Controller, 'clearStep', Em.K);
+ sinon.stub(installerStep7Controller, 'getConfigTags', Em.K);
+ sinon.stub(installerStep7Controller, 'setInstalledServiceConfigs', Em.K);
+ sinon.stub(installerStep7Controller, 'resolveServiceDependencyConfigs', Em.K);
+ sinon.stub(installerStep7Controller, 'setStepConfigs', Em.K);
+ sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
+ sinon.stub(installerStep7Controller, 'activateSpecialConfigs', Em.K);
+ sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
+ sinon.stub(App.router, 'send', Em.K);
+ });
+ afterEach(function() {
+ App.config.mergePreDefinedWithStored.restore();
+ App.config.addAdvancedConfigs.restore();
+ App.config.addCustomConfigs.restore();
+ App.config.fileConfigsIntoTextarea.restore();
+ installerStep7Controller.clearStep.restore();
+ installerStep7Controller.getConfigTags.restore();
+ installerStep7Controller.setInstalledServiceConfigs.restore();
+ installerStep7Controller.resolveServiceDependencyConfigs.restore();
+ installerStep7Controller.setStepConfigs.restore();
+ installerStep7Controller.checkHostOverrideInstaller.restore();
+ installerStep7Controller.activateSpecialConfigs.restore();
+ installerStep7Controller.selectProperService.restore();
+ App.router.send.restore();
+ });
+ it('should call clearStep', function() {
+ installerStep7Controller.loadStep();
+ expect(installerStep7Controller.clearStep.calledOnce).to.equal(true);
+ });
+ it('shouldn\'t do nothing if isAdvancedConfigLoaded is false', function() {
+ installerStep7Controller.set('isAdvancedConfigLoaded', false);
+ installerStep7Controller.loadStep();
+ expect(installerStep7Controller.clearStep.called).to.equal(false);
+ });
+ it('should use App.config to map configs', function() {
+ installerStep7Controller.loadStep();
+ expect(App.config.mergePreDefinedWithStored.calledOnce).to.equal(true);
+ expect(App.config.addAdvancedConfigs.calledOnce).to.equal(true);
+ expect(App.config.addCustomConfigs.calledOnce).to.equal(true);
+ });
+ Em.A([
+ {
+ allSelectedServiceNames: ['YARN'],
+ capacitySchedulerUi: false,
+ e: true
+ },
+ {
+ allSelectedServiceNames: ['YARN'],
+ capacitySchedulerUi: true,
+ e: false
+ },
+ {
+ allSelectedServiceNames: ['HDFS'],
+ capacitySchedulerUi: false,
+ e: false
+ },
+ {
+ allSelectedServiceNames: ['HDFS'],
+ capacitySchedulerUi: true,
+ e: false
+ }
+ ]).forEach(function (test) {
+ it('allSelectedServiceNames = ' + JSON.stringify(test.allSelectedServiceNames) + ', capacitySchedulerUi = ' + test.capacitySchedulerUi.toString(), function () {
+ sinon.stub(App, 'get', function(k) {
+ if (k === 'supports.capacitySchedulerUi') return test.capacitySchedulerUi;
+ return Em.get(App, k);
+ });
+ installerStep7Controller.reopen({allSelectedServiceNames: test.allSelectedServiceNames});
+ installerStep7Controller.loadStep();
+ if (test.e) {
+ expect(App.config.fileConfigsIntoTextarea.calledOnce).to.equal(true);
+ }
+ else {
+ expect(App.config.fileConfigsIntoTextarea.called).to.equal(false);
+ }
+ App.get.restore();
+ });
+ });
+ it('should call getConfigTags, setInstalledServiceConfigs for addServiceController', function() {
+ installerStep7Controller.set('wizardController.name', 'addServiceController');
+ installerStep7Controller.loadStep();
+ expect(installerStep7Controller.getConfigTags.calledOnce).to.equal(true);
+ expect(installerStep7Controller.setInstalledServiceConfigs.calledOnce).to.equal(true);
+ });
+ Em.A([
+ {
+ allSelectedServiceNames: ['STORM'],
+ installedServiceNames: ['STORM'],
+ m: 'allSelectedServiceNames contains STORM, installedServiceNames contains STORM',
+ e: true
+ },
+ {
+ allSelectedServiceNames: [],
+ installedServiceNames: ['STORM'],
+ m: 'allSelectedServiceNames doesn\'t contain STORM, installedServiceNames contains STORM',
+ e: true
+ },
+ {
+ allSelectedServiceNames: ['STORM'],
+ installedServiceNames: [],
+ m: 'allSelectedServiceNames contains STORM, installedServiceNames doesn\'t contain STORM',
+ e: true
+ },
+ {
+ allSelectedServiceNames: [],
+ installedServiceNames: [],
+ m: 'allSelectedServiceNames doesn\'t contain STORM, installedServiceNames doesn\'t contain STORM',
+ e: false
+ }
+ ]).forEach(function(test) {
+ it(test.m, function() {
+ installerStep7Controller.reopen({
+ allSelectedServiceNames: test.allSelectedServiceNames,
+ installedServiceNames: test.installedServiceNames
+ });
+ installerStep7Controller.loadStep();
+ if (test.e) {
+ expect(installerStep7Controller.resolveServiceDependencyConfigs.calledOnce).to.equal(true);
+ }
+ else {
+ expect(installerStep7Controller.resolveServiceDependencyConfigs.called).to.equal(false);
+ }
+ });
+ });
+ it('should call setStepConfigs', function() {
+ installerStep7Controller.loadStep();
+ expect(installerStep7Controller.setStepConfigs.calledOnce).to.equal(true);
+ });
+ it('should call checkHostOverrideInstaller', function() {
+ installerStep7Controller.loadStep();
+ expect(installerStep7Controller.checkHostOverrideInstaller.calledOnce).to.equal(true);
+ });
+ it('should call activateSpecialConfigs', function() {
+ installerStep7Controller.loadStep();
+ expect(installerStep7Controller.activateSpecialConfigs.calledOnce).to.equal(true);
+ });
+ it('should call selectProperService', function() {
+ installerStep7Controller.loadStep();
+ expect(installerStep7Controller.selectProperService.calledOnce).to.equal(true);
+ });
+ Em.A([
+ {
+ m: 'should skip config step',
+ skipConfigStep: true,
+ e: true
+ },
+ {
+ m: 'shouldn\'t skip config step',
+ skipConfigStep: false,
+ e: false
+ }
+ ]).forEach(function(test) {
+ it(test.m, function() {
+ installerStep7Controller.set('content.skipConfigStep', test.skipConfigStep);
+ installerStep7Controller.loadStep();
+ if (test.e) {
+ expect(App.router.send.calledWith('next')).to.equal(true);
+ }
+ else {
+ expect(App.router.send.called).to.equal(false);
+ }
+ });
+ });
+ });
+
+});
\ No newline at end of file