ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject ambari git commit: AMBARI-15765 Improve config groups loading on wizard (part 2). (ababiichuk)
Date Thu, 07 Apr 2016 16:31:03 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk aabc4d723 -> 016a303bd


AMBARI-15765 Improve config groups loading on wizard (part 2). (ababiichuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/016a303b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/016a303b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/016a303b

Branch: refs/heads/trunk
Commit: 016a303bd8ed3fdcbb543e359a3f8acde87f5059
Parents: aabc4d7
Author: ababiichuk <ababiichuk@hortonworks.com>
Authored: Thu Apr 7 18:20:31 2016 +0300
Committer: ababiichuk <ababiichuk@hortonworks.com>
Committed: Thu Apr 7 19:30:45 2016 +0300

----------------------------------------------------------------------
 .../app/controllers/wizard/step7_controller.js  | 323 +++++------------
 ambari-web/app/utils/ajax/ajax.js               |   4 +
 .../test/controllers/wizard/step7_test.js       | 349 -------------------
 3 files changed, 88 insertions(+), 588 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/016a303b/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 255bced..0520c8f 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -42,7 +42,7 @@ var App = require('app');
  * @property {?object[]} slaveComponentHosts
  */
 
-App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.EnhancedConfigsMixin,
App.ToggleIsRequiredMixin, {
+App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.EnhancedConfigsMixin,
App.ToggleIsRequiredMixin, App.GroupsMappingMixin, {
 
   name: 'wizardStep7Controller',
 
@@ -56,8 +56,6 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
 
   selectedService: null,
 
-  slaveHostToGroup: null,
-
   addMiscTabToPage: true,
 
   /**
@@ -198,8 +196,6 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
    */
   slaveComponentHosts: Em.computed.alias('content.slaveGroupProperties'),
 
-  customData: [],
-
   /**
    * Filter text will be located here
    * @type {string}
@@ -336,194 +332,77 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
   },
 
   /**
-   * Load config groups for installed services
-   * One ajax-request for each service
-   * @param {string[]} servicesNames
-   * @method loadInstalledServicesConfigGroups
+   * load all overrides for all config groups
+   *
+   * @returns {*|$.ajax}
    */
-  loadInstalledServicesConfigGroups: function (servicesNames) {
-    servicesNames.forEach(function (serviceName) {
-      App.ajax.send({
-        name: 'config.tags_and_groups',
-        sender: this,
-        data: {
-          serviceName: serviceName,
-          serviceConfigsDef: App.config.get('preDefinedServiceConfigs').findProperty('serviceName',
serviceName)
-        },
-        success: 'loadServiceTagsSuccess'
-      });
-    }, this);
-  },
-
-  /**
-   * Create site to tag map. Format:
-   * <code>
-   *   {
-   *    site1: tag1,
-   *    site1: tag2,
-   *    site2: tag3
-   *    ...
-   *   }
-   * </code>
-   * @param {object} desired_configs
-   * @param {string[]} sites
-   * @returns {object}
-   * @private
-   * @method _createSiteToTagMap
-   */
-  _createSiteToTagMap: function (desired_configs, sites) {
-    var siteToTagMap = {};
-    for (var site in desired_configs) {
-      if (desired_configs.hasOwnProperty(site)) {
-        if (!!sites[site]) {
-          siteToTagMap[site] = desired_configs[site].tag;
-        }
-      }
-    }
-    return siteToTagMap;
+  loadOverrides: function() {
+    return App.ajax.send({
+      name: 'service.serviceConfigVersions.get.current.not.default',
+      sender: this,
+      success: 'parseOverrides'
+    })
   },
 
   /**
-   * Load config groups success callback
-   * @param {object} data
-   * @param {object} opt
-   * @param {object} params
-   * @method loadServiceTagsSuccess
-   */
-  loadServiceTagsSuccess: function (data, opt, params) {
-    var serviceName = params.serviceName,
-      service = this.get('stepConfigs').findProperty('serviceName', serviceName),
-      defaultConfigGroupHosts = this.get('wizardController.allHosts').mapProperty('hostName'),
-      siteToTagMap = this._createSiteToTagMap(data.Clusters.desired_configs, params.serviceConfigsDef.get('configTypes'));
-    this.set('loadedClusterSiteToTagMap', siteToTagMap);
-
-    //parse loaded config groups
-    var configGroups = [];
-    if (data.config_groups.length) {
-      data.config_groups.forEach(function (item) {
-        item = item.ConfigGroup;
-        if (item.tag === serviceName) {
-          var groupHosts = item.hosts.mapProperty('host_name');
-          configGroups.push({
-            id: App.ServiceConfigGroup.groupId(serviceName, item.group_name),
-            config_group_id: item.id,
-            name: item.group_name,
-            description: item.description,
-            is_default: false,
-            parent_config_group_id: App.ServiceConfigGroup.getParentConfigGroupId(serviceName),
-            service_id: serviceName,
-            service_name: serviceName,
-            hosts: groupHosts,
-            desired_configs: item.desired_configs
-          });
-          groupHosts.forEach(function (host) {
-            defaultConfigGroupHosts = defaultConfigGroupHosts.without(host);
-          }, this);
-        }
-      }, this);
-    }
-
-    var defaultConfigGroup = App.configGroupsMapper.generateDefaultGroup(serviceName, defaultConfigGroupHosts);
-
-    configGroups = configGroups.sortProperty('name');
-    configGroups.unshift(defaultConfigGroup);
-    App.store.loadMany(App.ServiceConfigGroup, configGroups);
-    App.store.commit();
-    service.set('configGroups', App.ServiceConfigGroup.find().filterProperty('serviceName',
serviceName));
+   * add overriden configs to stepConfigs
+   *
+   * @param data
+   */
+  parseOverrides: function(data) {
+    var self = this;
+    data.items.forEach(function(group) {
+      var stepConfig = self.get('stepConfigs').findProperty('serviceName', group.service_name),
+        serviceConfigs = stepConfig.get('configs'),
+        configGroup = App.ServiceConfigGroup.find().filterProperty('serviceName', group.service_name).findProperty('name',
group.group_name);
+
+      var isEditable = self.get('canEdit') && configGroup.get('name') == stepConfig.get('selectedConfigGroup.name');
+
+      group.configurations.forEach(function (config) {
+        for (var prop in config.properties) {
+          var fileName = App.config.getOriginalFileName(config.type);
+          var serviceConfig = serviceConfigs.filterProperty('name', prop).findProperty('filename',
fileName);
+          if (serviceConfig) {
+            var value = App.config.formatPropertyValue(serviceConfig, config.properties[prop]);
+            var isFinal = !!(config.properties_attributes && config.properties_attributes.final
&& config.properties_attributes.final[prop]);
+
+            App.config.createOverride(serviceConfig, {
+              "value": value,
+              "savedValue": value,
+              "isFinal": isFinal,
+              "savedIsFinal": isFinal,
+              "isEditable": isEditable
+            }, configGroup);
 
-    var loadedGroupToOverrideSiteToTagMap = {};
-    configGroups.forEach(function (item) {
-      var groupName = item.name;
-      loadedGroupToOverrideSiteToTagMap[groupName] = {};
-      item.desired_configs.forEach(function (site) {
-        loadedGroupToOverrideSiteToTagMap[groupName][site.type] = site.tag;
-      }, this);
-    }, this);
-    this.set('preSelectedConfigGroup', App.ServiceConfigGroup.find(App.ServiceConfigGroup.getParentConfigGroupId(serviceName)));
-    this.loadServiceConfigGroupOverrides(service.get('configs'), loadedGroupToOverrideSiteToTagMap,
service.get('configGroups'));
-  },
+          } else {
 
-  /**
-   * Get properties from server by type and tag with properties, that belong to group
-   * push them to common {serviceConfigs} and call callback function
-   */
-  loadServiceConfigGroupOverrides: function (serviceConfigs, loadedGroupToOverrideSiteToTagMap,
configGroups) {
-    var configKeyToConfigMap = {};
-    serviceConfigs.forEach(function (item) {
-      if (!configKeyToConfigMap[item.filename]) {
-        configKeyToConfigMap[item.filename] = {};
-      }
-      configKeyToConfigMap[item.filename][item.name] = item;
-    });
-    var typeTagToGroupMap = {};
-    var urlParams = [];
-    for (var group in loadedGroupToOverrideSiteToTagMap) {
-      var overrideTypeTags = loadedGroupToOverrideSiteToTagMap[group];
-      for (var type in overrideTypeTags) {
-        var tag = overrideTypeTags[type];
-        typeTagToGroupMap[type + "///" + tag] = configGroups.findProperty('name', group);
-        urlParams.push('(type=' + type + '&tag=' + tag + ')');
-      }
-    }
-    var params = urlParams.join('|');
-    if (urlParams.length) {
-      App.ajax.send({
-        name: 'config.host_overrides',
-        sender: this,
-        data: {
-          params: params,
-          configKeyToConfigMap: configKeyToConfigMap,
-          typeTagToGroupMap: typeTagToGroupMap,
-          serviceConfigs: serviceConfigs
-        },
-        success: 'loadServiceConfigGroupOverridesSuccess'
-      });
-    } else {
-      this.onLoadOverrides(serviceConfigs);
-    }
-  },
+            serviceConfigs.push(App.config.createCustomGroupConfig({
+              propertyName: prop,
+              filename: fileName,
+              value: config.properties[prop],
+              savedValue: config.properties[prop],
+              isEditable: isEditable
+            }, configGroup));
 
-  loadServiceConfigGroupOverridesSuccess: function (data, opt, params) {
-    data.items.forEach(function (config) {
-      var group = params.typeTagToGroupMap[config.type + "///" + config.tag];
-      var properties = config.properties;
-      for (var prop in properties) {
-        var fileName = App.config.getOriginalFileName(config.type);
-        var serviceConfigProperty = !!params.configKeyToConfigMap[fileName] ? params.configKeyToConfigMap[fileName][prop]
: false;
-        if (serviceConfigProperty) {
-          var hostOverrideValue = App.config.formatPropertyValue(serviceConfigProperty, properties[prop]);
-          var hostOverrideIsFinal = !!(config.properties_attributes && config.properties_attributes.final
&& config.properties_attributes.final[prop]);
-
-          App.config.createOverride(serviceConfigProperty, {
-            "value": hostOverrideValue,
-            "savedValue": hostOverrideValue,
-            "isFinal": hostOverrideIsFinal,
-            "savedIsFinal": hostOverrideIsFinal,
-            "isEditable": false
-          }, group);
-        } else {
-          params.serviceConfigs.push(App.config.createCustomGroupConfig({
-            propertyName: prop,
-            filename: fileName,
-            value: config.properties[prop],
-            savedValue: config.properties[prop]
-          }, group));
+          }
         }
-      }
+      });
     });
-    this.onLoadOverrides(params.serviceConfigs);
+    this.onLoadOverrides();
   },
 
+  onLoadOverrides: function () {
+    this.get('stepConfigs').forEach(function(stepConfig) {
+      stepConfig.set('configGroups', App.ServiceConfigGroup.find().filterProperty('serviceName',
stepConfig.get('serviceName')));
 
-  onLoadOverrides: function (configs) {
-    var serviceName = configs[0].serviceName,
-      service = this.get('stepConfigs').findProperty('serviceName', serviceName);
-    var serviceConfig = App.config.createServiceConfig(serviceName);
-    service.set('selectedConfigGroup', this.get('preSelectedConfigGroup'));
-    this.loadComponentConfigs(service.get('configs'), serviceConfig, service);
-    // override if a property isRequired or not
-    this.overrideConfigIsRequired(service);
-    service.set('configs', serviceConfig.get('configs'));
+      stepConfig.get('configGroups').filterProperty('isDefault', false).forEach(function
(configGroup) {
+        configGroup.set('hash', this.get('wizardController').getConfigGroupHash(configGroup));
+      }, this);
+
+      this.addOverride(stepConfig);
+      // override if a property isRequired or not
+      this.overrideConfigIsRequired(stepConfig);
+    }, this);
   },
 
   /**
@@ -554,41 +433,18 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
   },
 
   /**
-   * Set configs with overrides, recommended defaults to component
-   * @param {Ember.Object[]} configs
-   * @param {Ember.Object} componentConfig
-   * @param {Ember.Object} component
+   * Set configs with overrides, recommended defaults to stepConfig
+   * @param {Ember.Object} stepConfig
    * @method loadComponentConfigs
    */
-  loadComponentConfigs: function (configs, componentConfig, component) {
-    var defaultGroupSelected = component.get('selectedConfigGroup.isDefault');
-
-    configs.forEach(function (serviceConfigProperty) {
-      if (!serviceConfigProperty) return;
-
-      if (Em.isNone(serviceConfigProperty.get('isOverridable'))) {
-        serviceConfigProperty.set('isOverridable', true);
-      }
-      if (!Em.isNone(serviceConfigProperty.get('group'))) {
-        serviceConfigProperty.get('group.properties').pushObject(serviceConfigProperty);
-      }
-      this._updateIsEditableFlagForConfig(serviceConfigProperty, defaultGroupSelected);
-
-      serviceConfigProperty.validate();
-
-    }, this);
-    componentConfig.get('configs').pushObjects(configs);
-    component.get('configGroups').filterProperty('isDefault', false).forEach(function (configGroup)
{
-      configGroup.set('hash', this.get('wizardController').getConfigGroupHash(configGroup));
-    }, this);
+  addOverride: function (stepConfig) {
     var overrideToAdd = this.get('overrideToAdd');
     if (overrideToAdd) {
-      overrideToAdd = componentConfig.get('configs').findProperty('name', overrideToAdd.name);
+      overrideToAdd = stepConfig.get('configs').filterProperty('filename', overrideToAdd.filename)
+        .findProperty('name', overrideToAdd.name);
       if (overrideToAdd) {
-        var group = this.get('selectedService.configGroups').findProperty('name', this.get('selectedConfigGroup.name'));
-        var newSCP = App.config.createOverride(overrideToAdd, {isEditable: true}, group);
-        group.get('properties').pushObject(newSCP);
-        component.set('overrideToAdd', null);
+        App.config.createOverride(overrideToAdd, {isEditable: true}, stepConfig.get('selectedConfigGroup'));
+        this.set('overrideToAdd', null);
       }
     }
   },
@@ -666,10 +522,9 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
     this.set('stepConfigs', serviceConfigs);
     this.checkHostOverrideInstaller();
     this.selectProperService();
-    var self = this;
     var rangerService = App.StackService.find().findProperty('serviceName', 'RANGER');
     if (rangerService && !rangerService.get('isInstalled') && !rangerService.get('isSelected'))
{
-      App.config.removeRangerConfigs(self.get('stepConfigs'));
+      App.config.removeRangerConfigs(this.get('stepConfigs'));
     }
     this.loadConfigRecommendations(null, this.completeConfigLoading.bind(this));
   },
@@ -748,11 +603,16 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
    * @method checkHostOverrideInstaller
    */
   checkHostOverrideInstaller: function () {
-    if (this.get('wizardController.name') !== 'kerberosWizardController') {
-      this.loadConfigGroups(this.get('content.configGroups'));
-    }
-    if (this.get('installedServiceNames').length > 0 && !this.get('wizardController.areInstalledConfigGroupsLoaded'))
{
-      this.loadInstalledServicesConfigGroups(this.get('installedServiceNames'));
+    if (this.get('wizardController.name') !== 'kerberosWizardController' && this.get('content.configGroups.length'))
{
+      this.restoreConfigGroups(this.get('content.configGroups'));
+    } else {
+      if (this.get('installedServiceNames').length > 0 && !this.get('wizardController.areInstalledConfigGroupsLoaded'))
{
+        this.loadConfigGroups(this.get('allSelectedServiceNames')).done(this.loadOverrides.bind(this));
+      } else {
+        App.store.commit();
+        App.configGroupsMapper.map(null, false, this.get('allSelectedServiceNames'));
+        this.onLoadOverrides();
+      }
     }
   },
 
@@ -1165,32 +1025,23 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
    * @param serviceConfigGroups
    * @method loadConfigGroups
    */
-  loadConfigGroups: function (serviceConfigGroups) {
+  restoreConfigGroups: function (serviceConfigGroups) {
     var services = this.get('stepConfigs');
-    var hosts = this.get('wizardController.allHosts').mapProperty('hostName');
 
     services.forEach(function (service) {
       if (service.get('serviceName') === 'MISC') return;
       var serviceRawGroups = serviceConfigGroups.filterProperty('service_name', service.serviceName);
-      var id = App.ServiceConfigGroup.getParentConfigGroupId(service.get('serviceName'));
-      if (!serviceRawGroups.length) {
-        App.store.load(App.ServiceConfigGroup, App.configGroupsMapper.generateDefaultGroup(service.get('serviceName'),
hosts));
-        App.store.commit();
-        service.set('configGroups', [App.ServiceConfigGroup.find(id)]);
-      }
-      else {
+      if (serviceRawGroups.length) {
         App.store.commit();
         App.store.loadMany(App.ServiceConfigGroup, serviceRawGroups);
         App.store.commit();
         serviceRawGroups.forEach(function(item){
           var modelGroup = App.ServiceConfigGroup.find(item.id);
-          var wrappedProperties = [];
-
+          modelGroup.set('properties', []);
           item.properties.forEach(function (propertyData) {
             var overriddenSCP, parentSCP = service.configs.filterProperty('filename', propertyData.filename).findProperty('name',
propertyData.name);
             if (parentSCP) {
-              overriddenSCP = App.ServiceConfigProperty.create(parentSCP);
-              overriddenSCP.set('parentSCP', parentSCP);
+              App.config.createOverride(parentSCP, propertyData, modelGroup)
             } else {
               overriddenSCP = App.config.createCustomGroupConfig({
                 propertyName: propertyData.name,
@@ -1201,12 +1052,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
               }, modelGroup);
               this.get('stepConfigs').findProperty('serviceName', service.serviceName).get('configs').pushObject(overriddenSCP);
             }
-              overriddenSCP.set('isOriginalSCP', false);
-              overriddenSCP.set('group', modelGroup);
-              overriddenSCP.setProperties(propertyData);
-            wrappedProperties.pushObject(App.ServiceConfigProperty.create(overriddenSCP));
           }, this);
-          modelGroup.set('properties', wrappedProperties);
         }, this);
         service.set('configGroups', App.ServiceConfigGroup.find().filterProperty('serviceName',
service.get('serviceName')));
       }
@@ -1271,9 +1117,8 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
     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 = config.get('isReconfigurable') && selectedGroup.get('isDefault');
+    } else {
       isEditable = selectedGroup.get('isDefault');
     }
     if (config.get('group')) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/016a303b/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 4b49976..72fdb00 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -2621,6 +2621,10 @@ var urls = {
     real: '/clusters/{clusterName}/configurations/service_config_versions?service_name.in({serviceNames})&is_current=true&fields=*',
     mock: '/data/configurations/service_versions.json'
   },
+  'service.serviceConfigVersions.get.current.not.default': {
+    real: '/clusters/{clusterName}/configurations/service_config_versions?is_current=true&group_id>0&fields=*',
+    mock: '/data/configurations/service_versions.json'
+  },
   'service.serviceConfigVersions.get.total': {
     real: '/clusters/{clusterName}/configurations/service_config_versions?page_size=1&minimal_response=true',
     mock: '/data/configurations/service_versions_total.json'

http://git-wip-us.apache.org/repos/asf/ambari/blob/016a303b/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index 2cbe42c..c6123e0 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -261,31 +261,6 @@ describe('App.InstallerStep7Controller', function () {
     });
   });
 
-  describe('#_createSiteToTagMap', function () {
-    it('should return filtered map', function () {
-      var desiredConfigs = {
-        site1: {
-          tag: "tag1"
-        },
-        site2: {
-          tag: "tag2"
-        },
-        site3: {
-          tag: "tag3"
-        }
-      };
-      var sites = {
-        site1: true,
-        site3: true
-      };
-      var siteToTagMap = installerStep7Controller._createSiteToTagMap(desiredConfigs,sites);
-      expect(siteToTagMap).to.eql({
-        site1: "tag1",
-        site3: "tag3"
-      });
-    });
-  });
-
   describe('#checkDatabaseConnectionTest', function () {
 
     beforeEach(function () {
@@ -435,15 +410,6 @@ describe('App.InstallerStep7Controller', function () {
     });
   });
 
-  describe('#loadInstalledServicesConfigGroups', function () {
-    it('should do ajax request for each received service name', function () {
-      var serviceNames = ['s1', 's2', 's3'];
-      installerStep7Controller.loadInstalledServicesConfigGroups(serviceNames);
-      var args = testHelpers.filterAjaxRequests('name', 'config.tags_and_groups');
-      expect(args).to.have.property('length').equal(serviceNames.length);
-    });
-  });
-
   describe('#getConfigTags', function () {
     it('should do ajax-request', function () {
       installerStep7Controller.getConfigTags();
@@ -982,84 +948,6 @@ describe('App.InstallerStep7Controller', function () {
 
   });
 
-  describe('#checkHostOverrideInstaller', function () {
-    beforeEach(function () {
-      sinon.stub(installerStep7Controller, 'loadConfigGroups', Em.K);
-      sinon.stub(installerStep7Controller, 'loadInstalledServicesConfigGroups', Em.K);
-      sinon.stub(App, 'get', function (k) {
-        if (k === 'supports.hostOverridesInstaller') return false;
-        return Em.get(App, k);
-      });
-    });
-    afterEach(function () {
-      installerStep7Controller.loadConfigGroups.restore();
-      installerStep7Controller.loadInstalledServicesConfigGroups.restore();
-      App.get.restore();
-    });
-    Em.A([
-        {
-          installedServiceNames: [],
-          m: 'installedServiceNames is empty',
-          e: {
-            loadConfigGroups: true,
-            loadInstalledServicesConfigGroups: false
-          }
-        },
-        {
-          installedServiceNames: ['s1', 's2', 's3'],
-          areInstalledConfigGroupsLoaded: false,
-          m: 'installedServiceNames isn\'t empty, config groups not yet loaded',
-          e: {
-            loadConfigGroups: true,
-            loadInstalledServicesConfigGroups: true
-          }
-        },
-        {
-          installedServiceNames: ['s1', 's2', 's3'],
-          areInstalledConfigGroupsLoaded: true,
-          m: 'installedServiceNames isn\'t empty, config groups already loaded',
-          e: {
-            loadConfigGroups: true,
-            loadInstalledServicesConfigGroups: false
-          }
-        }
-      ]).forEach(function (test) {
-        describe(test.m, function () {
-
-          beforeEach(function () {
-            installerStep7Controller.reopen({
-              installedServiceNames: test.installedServiceNames,
-              wizardController: {
-                areInstalledConfigGroupsLoaded: test.areInstalledConfigGroupsLoaded
-              }
-            });
-            installerStep7Controller.checkHostOverrideInstaller();
-          });
-
-          if (test.e.loadConfigGroups) {
-            it('loadConfigGroups is called once', function () {
-              expect(installerStep7Controller.loadConfigGroups.calledOnce).to.equal(true);
-            });
-          }
-          else {
-            it('loadConfigGroups is not called', function () {
-              expect(installerStep7Controller.loadConfigGroups.called).to.equal(false);
-            });
-          }
-          if (test.e.loadInstalledServicesConfigGroups) {
-            it('loadInstalledServicesConfigGroups is called once', function () {
-              expect(installerStep7Controller.loadInstalledServicesConfigGroups.calledOnce).to.equal(true);
-            });
-          }
-          else {
-            it('loadInstalledServicesConfigGroups is not called', function () {
-              expect(installerStep7Controller.loadInstalledServicesConfigGroups.called).to.equal(false);
-            });
-          }
-        });
-      });
-  });
-
   describe('#loadStep', function () {
     beforeEach(function () {
       installerStep7Controller.reopen({
@@ -2060,143 +1948,6 @@ describe('App.InstallerStep7Controller', function () {
 
   });
 
-  describe('#loadServiceConfigGroupOverrides', function () {
-
-    var serviceConfigs = [
-      {filename: 'f1', name: 'n1'}
-    ];
-
-    var configGroups = [
-      {
-        "name": "Default",
-        "description": "desc",
-        "isDefault": true,
-        "hosts": ['h1', 'h2', 'h3'],
-        "parentConfigGroup": null,
-        "service": {"id": "YARN"},
-        "serviceName": "YARN",
-        "configSiteTags": [],
-        "clusterHosts": []
-      }
-    ];
-
-    var loadedGroupToOverrideSiteToTagMap = {
-      Default: {
-        type1: 'tag1',
-        type2: 'tag2',
-        type3: 'tag3'
-      }
-    };
-
-    beforeEach(function () {
-      installerStep7Controller.loadServiceConfigGroupOverrides(serviceConfigs, loadedGroupToOverrideSiteToTagMap,
configGroups);
-      this.args = testHelpers.findAjaxRequest('name', 'config.host_overrides')[0].data;
-    });
-
-    it('url params are valid', function () {
-      expect(this.args.params).to.be.equal('(type=type1&tag=tag1)|(type=type2&tag=tag2)|(type=type3&tag=tag3)');
-    });
-
-    it('configKeyToConfigMap is valid', function () {
-      var expected = {
-        "f1": {
-          "n1": {
-            "filename": "f1",
-            "name": "n1"
-          }
-        }
-      };
-      expect(this.args.configKeyToConfigMap).to.be.eql(expected);
-    });
-
-    describe('typeTagToGroupMap is valid', function () {
-
-      it('type1///tag1', function () {
-        var expected = {
-          "name": "Default",
-          "description": "desc",
-          "isDefault": true,
-          "hosts": [
-            "h1",
-            "h2",
-            "h3"
-          ],
-          "parentConfigGroup": null,
-          "service": {
-            "id": "YARN"
-          },
-          "serviceName": "YARN",
-          "configSiteTags": [],
-          "clusterHosts": []
-        };
-
-        expect(this.args.typeTagToGroupMap['type1///tag1']).to.be.eql(expected);
-
-      });
-
-      it('type2///tag2', function () {
-        var expected = {
-          "name": "Default",
-          "description": "desc",
-          "isDefault": true,
-          "hosts": [
-            "h1",
-            "h2",
-            "h3"
-          ],
-          "parentConfigGroup": null,
-          "service": {
-            "id": "YARN"
-          },
-          "serviceName": "YARN",
-          "configSiteTags": [],
-          "clusterHosts": []
-        };
-
-        expect(this.args.typeTagToGroupMap['type2///tag2']).to.be.eql(expected);
-
-      });
-
-      it('type3///tag3', function () {
-        var expected = {
-          "name": "Default",
-          "description": "desc",
-          "isDefault": true,
-          "hosts": [
-            "h1",
-            "h2",
-            "h3"
-          ],
-          "parentConfigGroup": null,
-          "service": {
-            "id": "YARN"
-          },
-          "serviceName": "YARN",
-          "configSiteTags": [],
-          "clusterHosts": []
-        };
-
-        expect(this.args.typeTagToGroupMap['type3///tag3']).to.be.eql(expected);
-
-      });
-
-    });
-
-    it('serviceConfigs is valid', function () {
-
-      var expected = [
-        {
-          "filename": "f1",
-          "name": "n1"
-        }
-      ];
-
-      expect(this.args.serviceConfigs).to.be.eql(expected);
-
-    });
-
-  });
-
   describe('#updateHostOverrides', function () {
 
     var configProperty;
@@ -2296,104 +2047,4 @@ describe('App.InstallerStep7Controller', function () {
 
   });
 
-  describe('#loadServiceConfigGroupOverridesSuccess', function () {
-
-    var data = {
-      items: [
-        {
-          type: 'type1',
-          tag: 'tag1',
-          properties: {
-            p1: 'v1',
-            p3: 'v3'
-          },
-          properties_attributes: {
-            final: {
-              p1: true,
-              p3: true
-            }
-          }
-        },
-        {
-          type: 'type2',
-          tag: 'tag1',
-          properties: {
-            p2: 'v2',
-            p4: 'v4'
-          },
-          properties_attributes: {}
-        }
-      ]
-    };
-
-    var params;
-
-    beforeEach(function () {
-      params = {
-        serviceConfigs: [],
-        typeTagToGroupMap: {
-          'type1///tag1': Em.Object.create({
-            name: 't1t1',
-            properties: []
-          }),
-          'type2///tag1': Em.Object.create({
-            name: 't2t1',
-            properties: []
-          })
-        },
-        configKeyToConfigMap: {
-          type1: {},
-          type2: {
-            p4: Em.Object.create({})
-          }
-        }
-      };
-      sinon.stub(installerStep7Controller, 'onLoadOverrides', Em.K);
-      sinon.stub(App.config, 'getOriginalFileName', function (type) {return type;});
-      sinon.stub(App.config, 'formatPropertyValue', function (serviceConfigProperty, originalValue)
{
-        return Em.isNone(originalValue) ? Em.get(serviceConfigProperty, 'value') : originalValue;
-      });
-      installerStep7Controller.loadServiceConfigGroupOverridesSuccess(data, {}, params);
-      this.serviceConfigs = installerStep7Controller.onLoadOverrides.args[0][0];
-    });
-
-    afterEach(function () {
-      installerStep7Controller.onLoadOverrides.restore();
-      App.config.getOriginalFileName.restore();
-      App.config.formatPropertyValue.restore();
-    });
-
-    it('type2/p4 is mapped to the params.configKeyToConfigMap', function () {
-      expect(params).to.have.deep.property('configKeyToConfigMap.type2.p4').that.is.an('object').with.deep.property('overrides');
-    });
-
-    it('type2/p4 has 1 override', function () {
-      expect(params.configKeyToConfigMap.type2.p4.overrides).to.have.property('length').equal(1);
-    });
-
-    it('type2/p4 override is valid', function () {
-      var override = params.configKeyToConfigMap.type2.p4.overrides[0];
-      expect(override.value).to.be.equal('v4');
-      expect(override.group.name).to.be.equal('t2t1');
-      expect(override.isFinal).to.be.false;
-    });
-
-    it('onLoadOverrides is called for 3 configs', function () {
-      expect(this.serviceConfigs).to.have.property('length').equal(3);
-    });
-
-    it('serviceConfigs ids are valid', function () {
-      expect(this.serviceConfigs.mapProperty('id')).to.be.eql(['p1__type1', 'p3__type1',
'p2__type2']);
-    });
-
-    it('serviceConfigs groups are valid', function () {
-      expect(this.serviceConfigs.mapProperty('group.name')).to.be.eql(['t1t1', 't1t1', 't2t1']);
-    });
-
-    it('serviceConfigs filenames are valid', function () {
-      expect(this.serviceConfigs.mapProperty('filename')).to.be.eql(['type1', 'type1', 'type2']);
-    });
-
-  });
-
 });


Mime
View raw message