Repository: ambari Updated Branches: refs/heads/branch-1.7.0 69d0f1a3d -> 99c64cdbf
http://git-wip-us.apache.org/repos/asf/ambari/blob/99c64cdb/ambari-web/app/utils/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js index b31c5ad..cd5b094 100644 --- a/ambari-web/app/utils/config.js +++ b/ambari-web/app/utils/config.js @@ -92,13 +92,18 @@ App.config = Em.Object.create({ }.property('App.isHadoop2Stack'), preDefinedSiteProperties: function () { + var sitePropertiesForCurrentStack = this.preDefinedConfigFile('site_properties'); + if (sitePropertiesForCurrentStack) { + return sitePropertiesForCurrentStack.configProperties; + } + if (App.get('isHadoop22Stack')) { return require('data/HDP2.2/site_properties').configProperties; } else if (App.get('isHadoop2Stack')) { return require('data/HDP2/site_properties').configProperties; } return require('data/site_properties').configProperties; - }.property('App.isHadoop2Stack', 'App.isHadoop22Stack'), + }.property('App.isHadoop2Stack', 'App.isHadoop22Stack', 'App.currentStackName'), preDefinedCustomConfigs: function () { if (App.get('isHadoop2Stack')) { @@ -107,6 +112,13 @@ App.config = Em.Object.create({ return require('data/custom_configs'); }.property('App.isHadoop2Stack'), + preDefinedConfigFile: function(file) { + try { + return require('data/{0}/{1}'.format(App.get('currentStackName'), file)); + } catch(err) { + // the file doesn't exist, which might be expected. + } + }, //categories which contain custom configs categoriesWithCustom: ['CapacityScheduler'], @@ -118,32 +130,34 @@ App.config = Em.Object.create({ createContentProperties: function (configs) { var services = App.StackService.find(); var contentProperties = []; - services.forEach(function (service) { - if (service.get('configTypes')) { - Object.keys(service.get('configTypes')).forEach(function (type) { - var contentProperty = configs.filterProperty('filename', type + '.xml').someProperty('name', 'content'); - if (contentProperty && (type.endsWith('-log4j') || type.endsWith('-env'))) { - var property = { - "id": "site property", - "name": "content", - "displayName": type.endsWith('-env') ? type + ' template' : "content", - "value": "", - "defaultValue": "", - "description": type + " properties", - "displayType": "content", - "isOverridable": true, - "isRequired": false, - "isVisible": true, - "showLabel": type.endsWith('-env'), - "serviceName": service.get('serviceName'), - "filename": type + '.xml', - "category": "Advanced " + type - }; - contentProperties.pushObject(property); - } - }, this); - } - }, this); + if (configs) { + services.forEach(function (service) { + if (service.get('configTypes')) { + Object.keys(service.get('configTypes')).forEach(function (type) { + var contentProperty = configs.filterProperty('filename', type + '.xml').someProperty('name', 'content'); + if (contentProperty && (type.endsWith('-log4j') || type.endsWith('-env'))) { + var property = { + "id": "site property", + "name": "content", + "displayName": type.endsWith('-env') ? type + ' template' : "content", + "value": "", + "defaultValue": "", + "description": type + " properties", + "displayType": "content", + "isOverridable": true, + "isRequired": false, + "isVisible": true, + "showLabel": type.endsWith('-env'), + "serviceName": service.get('serviceName'), + "filename": type + '.xml', + "category": "Advanced " + type + }; + contentProperties.pushObject(property); + } + }, this); + } + }, this); + } return contentProperties; }, http://git-wip-us.apache.org/repos/asf/ambari/blob/99c64cdb/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 528be46..b04a404 100644 --- a/ambari-web/test/utils/config_test.js +++ b/ambari-web/test/utils/config_test.js @@ -421,4 +421,52 @@ describe('App.config', function () { expect(ServiceConfig.get('configCategories.length')).to.eql(1); }); }); + + describe('#preDefinedConfigFile', function() { + before(function() { + setups.setupStackVersion(this, 'BIGTOP-0.8'); + }); + + it('bigtop site properties should be ok.', function() { + var bigtopSiteProperties = App.config.preDefinedConfigFile('site_properties'); + expect(bigtopSiteProperties).to.be.ok; + }); + + it('a non-existing file should not be ok.', function () { + var notExistingSiteProperty = App.config.preDefinedConfigFile('notExisting'); + expect(notExistingSiteProperty).to.not.be.ok; + }); + + after(function() { + setups.restoreStackVersion(this); + }); + }); + + describe('#preDefinedSiteProperties-bigtop', function () { + before(function() { + setups.setupStackVersion(this, 'BIGTOP-0.8'); + }); + + it('bigtop should use New PostgreSQL Database as its default hive metastore database', function () { + expect(App.config.get('preDefinedSiteProperties').findProperty('defaultValue', 'New PostgreSQL Database')).to.be.ok; + }); + + after(function() { + setups.restoreStackVersion(this); + }); + }); + + describe('#preDefinedSiteProperties-hdp2', function () { + before(function() { + setups.setupStackVersion(this, 'HDP-2.0'); + }); + + it('HDP2 should use New MySQL Database as its default hive metastore database', function () { + expect(App.config.get('preDefinedSiteProperties').findProperty('defaultValue', 'New MySQL Database')).to.be.ok; + }); + + after(function() { + setups.restoreStackVersion(this); + }); + }); });