AMBARI-11373. [WinTP2] HDPWIN 2.2 HDFS configuration: Error count on the Advanced tab is 3, yet no properties are invalid (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c035bdad Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c035bdad Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c035bdad Branch: refs/heads/trunk Commit: c035bdadd1ccef6428e8083282b3a3fa67ee0e12 Parents: 043357d Author: Alex Antonenko <[email protected]> Authored: Mon May 25 21:26:46 2015 +0300 Committer: Alex Antonenko <[email protected]> Committed: Mon May 25 21:50:02 2015 +0300 ---------------------------------------------------------------------- ambari-web/app/utils/config.js | 19 ++++++++++++++++++- ambari-web/test/utils/config_test.js | 7 +++++++ 2 files changed, 25 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/c035bdad/ambari-web/app/utils/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js index bf84592..a7fd14c 100644 --- a/ambari-web/app/utils/config.js +++ b/ambari-web/app/utils/config.js @@ -76,6 +76,7 @@ App.config = Em.Object.create({ setPreDefinedServiceConfigs: function (isMiscTabToBeAdded) { var configs = this.get('preDefinedSiteProperties'); var services = []; + var self = this; var stackServices = App.StackService.find().filterProperty('id'); // Only include services that has configTypes related to them for service configuration page var servicesWithConfigTypes = stackServices.filter(function (service) { @@ -102,7 +103,15 @@ App.config = Em.Object.create({ } allTabs.forEach(function (service) { - var serviceConfigs = configs.filterProperty('serviceName', service.get('serviceName')); + var configTypes = Em.keys(service.get('configTypes')); + // filter properties by service name and service config types + var serviceConfigs = configs.filterProperty('serviceName', service.get('serviceName')).filter(function(property) { + var propFilename = self.getConfigTagFromFileName(Em.getWithDefault(property, 'filename', '')); + if (propFilename && service.get('serviceName') != 'MISC') { + return configTypes.contains(propFilename); + } + return true; + }); service.set('configs', serviceConfigs); services.push(service); }); @@ -497,12 +506,20 @@ App.config = Em.Object.create({ var preDefinedNames = preDefinedConfigs.mapProperty('name'); var storedNames = storedConfigs.mapProperty('name'); var names = preDefinedNames.concat(storedNames).uniq(); + var configTypes = Em.keys(App.StackService.find().filter(function(service) { + return selectedServiceNames.contains(service.get('serviceName')); + }).mapProperty('configTypes')) + .uniq().compact().filter(function(configType) { return !!configType; }); + names.forEach(function (name) { var storedCfgs = storedConfigs.filterProperty('name', name); var preDefinedCfgs = []; var preDefinedConfig = preDefinedConfigs.filterProperty('name', name); preDefinedConfig.forEach(function (_preDefinedConfig) { if (selectedServiceNames.contains(_preDefinedConfig.serviceName) || _preDefinedConfig.serviceName === 'MISC') { + if (_preDefinedConfig.serviceName != 'MISC' && _preDefinedConfig.filename && !configTypes.contains(_preDefinedConfig.filename)) { + return; + } preDefinedCfgs.push(_preDefinedConfig); } }, this); http://git-wip-us.apache.org/repos/asf/ambari/blob/c035bdad/ambari-web/test/utils/config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/config_test.js b/ambari-web/test/utils/config_test.js index 42d580d..d382a60 100644 --- a/ambari-web/test/utils/config_test.js +++ b/ambari-web/test/utils/config_test.js @@ -472,6 +472,13 @@ describe('App.config', function () { var miscCategory = App.config.get('preDefinedServiceConfigs').findProperty('serviceName', 'MISC'); expect(Em.keys(miscCategory.get('configTypes'))).to.eql(['cluster-env', 'hadoop-env', 'oozie-env']); }); + + it('should not load configs for missed config types', function() { + var hdfsService = App.config.get('preDefinedServiceConfigs').findProperty('serviceName', 'HDFS'); + var rangerRelatedConfigs = hdfsService.get('configs').filterProperty('filename', 'ranger-hdfs-plugin-properties.xml'); + expect(rangerRelatedConfigs.length).to.be.eql(0); + expect(hdfsService.get('configs.length') > 0).to.be.true; + }); }); describe('#isManagedMySQLForHiveAllowed', function () {
