12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232 |
- /**
- * 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.
- */
- var App = require('app');
- require('config');
- require('utils/config');
- require('models/service/hdfs');
- var setups = require('test/init_model_test');
- var modelSetup = setups.configs;
- describe('App.config', function () {
- var loadServiceSpecificConfigs = function(context, serviceName) {
- context.configGroups = modelSetup.setupConfigGroupsObject(serviceName);
- context.advancedConfigs = modelSetup.setupAdvancedConfigsObject();
- context.tags = modelSetup.setupServiceConfigTagsObject(serviceName);
- context.result = App.config.mergePreDefinedWithLoaded(context.configGroups, context.advancedConfigs, context.tags, App.Service.find().findProperty('id', serviceName).get('serviceName'));
- };
- var loadAllServicesConfigs = function(context, serviceNames) {
- context.configGroups = modelSetup.setupConfigGroupsObject();
- };
- var loadServiceModelsData = function(serviceNames) {
- serviceNames.forEach(function(serviceName) {
- App.store.load(App.Service, {
- id: serviceName,
- service_name: serviceName
- });
- });
- };
- var setupContentForMergeWithStored = function(context) {
- loadServiceModelsData(context.installedServiceNames);
- loadAllServicesConfigs(context);
- setups.setupStackVersion(this, 'HDP-2.1');
- context.result = App.config.mergePreDefinedWithStored(context.storedConfigs, modelSetup.setupAdvancedConfigsObject(), context.installedServiceNames);
- };
- var removeServiceModelData = function(serviceIds) {
- serviceIds.forEach(function(serviceId) {
- var record = App.Service.find(serviceId);
- record.deleteRecord();
- record.get('stateManager').transitionTo('loading');
- });
- };
- describe('#handleSpecialProperties', function () {
- var config = {};
- it('value should be transformed to "1024" from "1024m"', function () {
- config = {
- displayType: 'int',
- value: '1024m',
- defaultValue: '1024m'
- };
- App.config.handleSpecialProperties(config);
- expect(config.value).to.equal('1024');
- expect(config.defaultValue).to.equal('1024');
- });
- });
- describe('#capacitySchedulerFilter', function() {
- var testMessage = 'filter should {0} detect `{1}` property';
- describe('Stack version >= 2.0', function() {
- before(function() {
- setups.setupStackVersion(this, 'HDP-2.1');
- });
- var tests = [
- {
- config: {
- name: 'yarn.scheduler.capacity.maximum-am-resource-percent'
- },
- e: false
- },
- {
- config: {
- name: 'yarn.scheduler.capacity.root.capacity'
- },
- e: false
- },
- {
- config: {
- name: 'yarn.scheduler.capacity.root.default.capacity'
- },
- e: true
- }
- ];
- tests.forEach(function(test){
- it(testMessage.format( !!test.e ? '' : 'not', test.config.name), function() {
- expect(App.config.get('capacitySchedulerFilter')(test.config)).to.eql(test.e);
- });
- });
- after(function() {
- setups.restoreStackVersion(this);
- })
- });
- });
- describe('#fileConfigsIntoTextarea', function () {
- var filename = 'capacity-scheduler.xml';
- var configs = [
- {
- name: 'config1',
- value: 'value1',
- defaultValue: 'value1',
- filename: 'capacity-scheduler.xml'
- },
- {
- name: 'config2',
- value: 'value2',
- defaultValue: 'value2',
- filename: 'capacity-scheduler.xml'
- }
- ];
- it('two configs into textarea', function () {
- var result = App.config.fileConfigsIntoTextarea.call(App.config, configs, filename);
- expect(result.length).to.equal(1);
- expect(result[0].value).to.equal('config1=value1\nconfig2=value2\n');
- expect(result[0].defaultValue).to.equal('config1=value1\nconfig2=value2\n');
- });
- it('three config into textarea', function () {
- configs.push({
- name: 'config3',
- value: 'value3',
- defaultValue: 'value3',
- filename: 'capacity-scheduler.xml'
- });
- var result = App.config.fileConfigsIntoTextarea.call(App.config, configs, filename);
- expect(result.length).to.equal(1);
- expect(result[0].value).to.equal('config1=value1\nconfig2=value2\nconfig3=value3\n');
- expect(result[0].defaultValue).to.equal('config1=value1\nconfig2=value2\nconfig3=value3\n');
- });
- it('one of three configs has different filename', function () {
- configs[1].filename = 'another filename';
- var result = App.config.fileConfigsIntoTextarea.call(App.config, configs, filename);
- //result contains two configs: one with different filename and one textarea config
- expect(result.length).to.equal(2);
- expect(result[1].value).to.equal('config1=value1\nconfig3=value3\n');
- expect(result[1].defaultValue).to.equal('config1=value1\nconfig3=value3\n');
- });
- it('none configs into empty textarea', function () {
- filename = 'capacity-scheduler.xml';
- configs.clear();
- var result = App.config.fileConfigsIntoTextarea.call(App.config, configs, filename);
- expect(result.length).to.equal(1);
- expect(result[0].value).to.equal('');
- expect(result[0].defaultValue).to.equal('');
- });
- });
- describe('#textareaIntoFileConfigs', function () {
- var filename = 'capacity-scheduler.xml';
- var testData = [
- {
- configs: [Em.Object.create({
- "name": "capacity-scheduler",
- "value": "config1=value1",
- "filename": "capacity-scheduler.xml"
- })]
- },
- {
- configs: [Em.Object.create({
- "name": "capacity-scheduler",
- "value": "config1=value1\nconfig2=value2\n",
- "filename": "capacity-scheduler.xml"
- })]
- },
- {
- configs: [Em.Object.create({
- "name": "capacity-scheduler",
- "value": "config1=value1,value2\n",
- "filename": "capacity-scheduler.xml"
- })]
- },
- {
- configs: [Em.Object.create({
- "name": "capacity-scheduler",
- "value": "config1=value1 config2=value2\n",
- "filename": "capacity-scheduler.xml"
- })]
- }
- ];
- it('config1=value1 to one config', function () {
- var result = App.config.textareaIntoFileConfigs.call(App.config, testData[0].configs, filename);
- expect(result.length).to.equal(1);
- expect(result[0].value).to.equal('value1');
- expect(result[0].name).to.equal('config1');
- });
- it('config1=value1\\nconfig2=value2\\n to two configs', function () {
- var result = App.config.textareaIntoFileConfigs.call(App.config, testData[1].configs, filename);
- expect(result.length).to.equal(2);
- expect(result[0].value).to.equal('value1');
- expect(result[0].name).to.equal('config1');
- expect(result[1].value).to.equal('value2');
- expect(result[1].name).to.equal('config2');
- });
- it('config1=value1,value2\n to one config', function () {
- var result = App.config.textareaIntoFileConfigs.call(App.config, testData[2].configs, filename);
- expect(result.length).to.equal(1);
- expect(result[0].value).to.equal('value1,value2');
- expect(result[0].name).to.equal('config1');
- });
- it('config1=value1 config2=value2 to two configs', function () {
- var result = App.config.textareaIntoFileConfigs.call(App.config, testData[3].configs, filename);
- expect(result.length).to.equal(1);
- });
- });
- describe('#addAvancedConfigs()', function() {
- beforeEach(function() {
- this.storedConfigs = modelSetup.setupStoredConfigsObject();
- });
- it('`custom.zoo.cfg` absent in stored configs', function() {
- expect(this.storedConfigs.findProperty('name', 'custom.zoo.cfg')).to.be.undefined;
- });
- it('`custom.zoo.cfg.` from advanced configs should be added to stored configs', function() {
- App.config.addAdvancedConfigs(this.storedConfigs, modelSetup.setupAdvancedConfigsObject(), 'ZOOKEEPER');
- var property = this.storedConfigs.findProperty('name', 'custom.zoo.cfg');
- expect(property).to.be.ok;
- expect(property.category).to.eql('Advanced zoo.cfg');
- });
- it('`capacity-scheduler.xml` property with name `content` should have `displayType` `multiLine`', function() {
- App.config.addAdvancedConfigs(this.storedConfigs, modelSetup.setupAdvancedConfigsObject(), 'YARN');
- expect(this.storedConfigs.filterProperty('filename', 'capacity-scheduler.xml').findProperty('name','content').displayType).to.eql('multiLine');
- });
- it('storing different configs with the same name', function () {
- App.config.addAdvancedConfigs(this.storedConfigs, modelSetup.setupAdvancedConfigsObject(), 'HBASE');
- var properties = this.storedConfigs.filterProperty('name', 'hbase_log_dir');
- var hbaseProperty = properties.findProperty('filename', 'hbase-env.xml');
- var amsProperty = properties.findProperty('filename', 'ams-hbase-env.xml');
- expect(properties).to.have.length(2);
- expect(hbaseProperty.serviceName).to.equal('HBASE');
- expect(hbaseProperty.value).to.equal('/hadoop/hbase');
- expect(amsProperty.serviceName).to.equal('AMBARI_METRICS');
- expect(amsProperty.value).to.equal('/hadoop/ams-hbase');
- });
- });
- describe('#trimProperty',function() {
- var testMessage = 'displayType `{0}`, value `{1}`{3} should return `{2}`';
- var tests = [
- {
- config: {
- displayType: 'directory',
- value: ' /a /b /c'
- },
- e: '/a,/b,/c'
- },
- {
- config: {
- displayType: 'directories',
- value: ' /a /b '
- },
- e: '/a,/b'
- },
- {
- config: {
- displayType: 'datanodedirs',
- value: ' [DISK]/a [SSD]/b '
- },
- e: '[DISK]/a,[SSD]/b'
- },
- {
- config: {
- displayType: 'datanodedirs',
- value: '/a,/b, /c\n/d,\n/e /f'
- },
- e: '/a,/b,/c,/d,/e,/f'
- },
- {
- config: {
- displayType: 'host',
- value: ' localhost '
- },
- e: 'localhost'
- },
- {
- config: {
- displayType: 'password',
- value: ' passw ord '
- },
- e: ' passw ord '
- },
- {
- config: {
- displayType: 'advanced',
- value: ' value'
- },
- e: ' value'
- },
- {
- config: {
- displayType: 'advanced',
- value: ' value'
- },
- e: ' value'
- },
- {
- config: {
- displayType: 'advanced',
- value: 'http://localhost ',
- name: 'javax.jdo.option.ConnectionURL'
- },
- e: 'http://localhost'
- },
- {
- config: {
- displayType: 'advanced',
- value: 'http://localhost ',
- name: 'oozie.service.JPAService.jdbc.url'
- },
- e: 'http://localhost'
- },
- {
- config: {
- displayType: 'custom',
- value: ' custom value '
- },
- e: ' custom value'
- },
- {
- config: {
- displayType: 'masterHosts',
- value: ['host1.com', 'host2.com']
- },
- e: ['host1.com', 'host2.com']
- }
- ];
- tests.forEach(function(test) {
- it(testMessage.format(test.config.displayType, test.config.value, test.e, !!test.config.name ? ', name `' + test.config.name + '`' : ''), function() {
- expect(App.config.trimProperty(test.config)).to.eql(test.e);
- expect(App.config.trimProperty(Em.Object.create(test.config), true)).to.eql(test.e);
- });
- });
- });
- describe('#OnNnHAHideSnn()', function() {
- it('`SNameNode` category present in `ServiceConfig`. It should be removed.', function() {
- App.store.load(App.HDFSService, {
- 'id': 'HDFS'
- });
- var ServiceConfig = Em.Object.create({
- configCategories: [ { name: 'SNameNode' } ]
- });
- expect(ServiceConfig.get('configCategories').findProperty('name','SNameNode')).to.ok;
- App.config.OnNnHAHideSnn(ServiceConfig);
- expect(ServiceConfig.get('configCategories').findProperty('name','SNameNode')).to.undefined;
- var record = App.HDFSService.find('HDFS');
- record.deleteRecord();
- record.get('stateManager').transitionTo('loading');
- });
- it('`SNameNode` category absent in `ServiceConfig`. Nothing to do.', function() {
- App.store.load(App.HDFSService, {
- 'id': 'HDFS'
- });
- var ServiceConfig = Em.Object.create({
- configCategories: [ { name: 'DataNode' } ]
- });
- App.config.OnNnHAHideSnn(ServiceConfig);
- expect(ServiceConfig.get('configCategories').findProperty('name','DataNode')).to.ok;
- 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);
- });
- });
- describe('#generateConfigPropertiesByName', function() {
- var tests = [
- {
- names: ['property_1', 'property_2'],
- properties: undefined,
- e: {
- keys: ['name', 'displayName', 'isVisible', 'isReconfigurable']
- },
- m: 'Should generate base property object without additional fields'
- },
- {
- names: ['property_1', 'property_2'],
- properties: { category: 'SomeCat', serviceName: 'SERVICE_NAME' },
- e: {
- keys: ['name', 'displayName', 'isVisible', 'isReconfigurable', 'category', 'serviceName']
- },
- m: 'Should generate base property object without additional fields'
- }
- ];
- tests.forEach(function(test) {
- it(test.m, function() {
- expect(App.config.generateConfigPropertiesByName(test.names, test.properties).length).to.eql(test.names.length);
- expect(App.config.generateConfigPropertiesByName(test.names, test.properties).map(function(property) {
- return Em.keys(property);
- }).reduce(function(p, c) {
- return p.concat(c);
- }).uniq()).to.eql(test.e.keys);
- });
- });
- });
- describe('#setPreDefinedServiceConfigs', function() {
- beforeEach(function() {
- sinon.stub(App.StackService, 'find', function() {
- return [
- Em.Object.create({
- id: 'HDFS',
- serviceName: 'HDFS',
- configTypes: {
- 'hadoop-env': {},
- 'hdfs-site': {}
- }
- }),
- Em.Object.create({
- id: 'OOZIE',
- serviceName: 'OOZIE',
- configTypes: {
- 'oozie-env': {},
- 'oozie-site': {}
- }
- })
- ];
- });
- App.config.setPreDefinedServiceConfigs(true);
- });
- afterEach(function() {
- App.StackService.find.restore();
- });
- it('should include service MISC', function() {
- expect(App.config.get('preDefinedServiceConfigs').findProperty('serviceName', 'MISC')).to.be.ok;
- });
- it('should include -env config types according to stack services', function() {
- var miscCategory = App.config.get('preDefinedServiceConfigs').findProperty('serviceName', 'MISC');
- expect(Em.keys(miscCategory.get('configTypes'))).to.eql(['cluster-env', 'hadoop-env', 'oozie-env']);
- });
- });
-
- describe('#isManagedMySQLForHiveAllowed', function () {
- var cases = [
- {
- osFamily: 'redhat5',
- expected: false
- },
- {
- osFamily: 'redhat6',
- expected: true
- },
- {
- osFamily: 'suse11',
- expected: false
- }
- ],
- title = 'should be {0} for {1}';
- cases.forEach(function (item) {
- it(title.format(item.expected, item.osFamily), function () {
- expect(App.config.isManagedMySQLForHiveAllowed(item.osFamily)).to.equal(item.expected);
- });
- });
- });
- describe('#createAdvancedPropertyObject', function() {
- var tests = [
- {
- name: 'proxyuser_group',
- cases: [
- {
- key: 'displayType',
- e: 'user'
- },
- {
- key: 'serviceName',
- e: 'MISC'
- },
- {
- key: 'belongsToService',
- e: ['HIVE', 'OOZIE', 'FALCON']
- }
- ]
- },
- {
- name: 'oozie.service.JPAService.jdbc.password',
- cases: [
- {
- key: 'displayType',
- e: 'password'
- },
- {
- key: 'isVisible',
- e: true
- }
- ]
- },
- {
- name: 'ignore_groupsusers_create',
- cases: [
- {
- key: 'isVisible',
- e: false
- }
- ]
- },
- {
- name: 'user_group',
- cases: [
- {
- key: 'isVisible',
- e: true
- },
- {
- key: 'index',
- e: 30
- },
- {
- key: 'displayName',
- e: 'Hadoop Group'
- }
- ]
- },
- {
- name: 'zk_user',
- cases: [
- {
- key: 'displayName',
- e: 'ZooKeeper User'
- }
- ]
- },
- {
- name: 'mapred_user',
- cases: [
- {
- key: 'displayName',
- e: 'MapReduce User'
- }
- ]
- },
- {
- name: 'smokeuser',
- cases: [
- {
- key: 'displayName',
- e: 'Smoke Test User'
- }
- ]
- }
- ];
- var properties = [];
- modelSetup.advancedConfigs.items.forEach(function(item) {
- properties.push(App.config.createAdvancedPropertyObject(item.StackConfigurations));
- });
- App.config.loadClusterConfigSuccess(modelSetup.advancedClusterConfigs, {url: '/cluster/configurations'}, {callback: function (items) {properties = properties.concat(items)}});
- beforeEach(function () {
- sinon.stub(App, 'get').withArgs('isHadoopWindowsStack').returns(false);
- });
- afterEach(function () {
- App.get.restore();
- });
- tests.forEach(function(test) {
- test.cases.forEach(function(testCase) {
- it('config property `{0}` `{1}` key should be`{2}`'.format(test.name, testCase.key, testCase.e), function() {
- var property = properties.findProperty('name', test.name);
- expect(Em.get(property, testCase.key)).to.eql(testCase.e);
- });
- });
- });
- });
- describe('#mergePreDefinedWithLoaded', function() {
- var result;
- before(function() {
- setups.setupStackVersion(this, 'HDP-2.2');
- loadServiceModelsData(['HDFS', 'STORM']);
- App.config.loadAdvancedConfigSuccess(modelSetup.advancedConfigs, { url: '/serviceName/configurations'}, {
- callback: function(advancedConfigs) {
- App.config.loadClusterConfigSuccess(modelSetup.advancedClusterConfigs, { url: '/cluster/configurations'}, {
- callback: function(clusterConfigs) {
- var configCategories = modelSetup.setupConfigGroupsObject();
- var tags = [
- {newTagName: null, tagName: 'version1', siteName: 'hadoop-env'},
- {newTagName: null, tagName: 'version1', siteName: 'hdfs-site'},
- {newTagName: null, tagName: 'version1', siteName: 'cluster-env'},
- {newTagName: null, tagName: 'version1', siteName: 'storm-env'}
- ];
- var serviceName = 'STORM';
- result = App.config.mergePreDefinedWithLoaded(configCategories, advancedConfigs.concat(clusterConfigs), tags, serviceName);
- }
- });
- }
- });
- });
- after(function() {
- setups.restoreStackVersion(this);
- removeServiceModelData(['HDFS', 'STORM']);
- });
-
- var propertyTests = [
- {
- name: 'hdfs_user',
- cases: [
- {
- key: 'displayType',
- e: 'user'
- },
- {
- key: 'isVisible',
- e: true
- },
- {
- key: 'serviceName',
- e: 'MISC'
- },
- {
- key: 'category',
- e: 'Users and Groups'
- }
- ]
- }
- ];
- propertyTests.forEach(function(test) {
- test.cases.forEach(function(testCase) {
- it('config property `{0}` `{1}` key should be`{2}`'.format(test.name, testCase.key, testCase.e), function() {
- var property = result.configs.findProperty('name', test.name);
- expect(Em.get(property, testCase.key)).to.equal(testCase.e);
- });
- });
- });
- });
- describe('#replaceConfigValues', function () {
- var cases = [
- {
- name: 'name',
- express: '<templateName[0]>',
- value: '<templateName[0]>',
- globValue: 'v',
- expected: 'v',
- title: 'default case'
- },
- {
- name: 'templeton.hive.properties',
- express: '<templateName[0]>',
- value: 'hive.matestore.uris=<templateName[0]>',
- globValue: 'thrift://h0:9933,thrift://h1:9933,thrift://h2:9933',
- expected: 'hive.matestore.uris=thrift://h0:9933\\,thrift://h1:9933\\,thrift://h2:9933',
- title: 'should escape commas for templeton.hive.properties'
- }
- ];
- cases.forEach(function (item) {
- it(item.title, function () {
- expect(App.config.replaceConfigValues(item.name, item.express, item.value, item.globValue)).to.equal(item.expected);
- });
- });
- });
- describe('#advancedConfigIdentityData', function () {
- var configs = [
- {
- input: {
- property_type: ['USER'],
- property_name: 'hdfs_user'
- },
- output: {
- id: 'puppet var',
- category: 'Users and Groups',
- isVisible: true,
- serviceName: 'MISC',
- isOverridable: false,
- isReconfigurable: false,
- displayName: 'HDFS User',
- displayType: 'user',
- index: 30
- },
- title: 'user, no service name specified, default display name behaviour'
- },
- {
- input: {
- property_type: ['GROUP'],
- property_name: 'knox_group',
- service_name: 'KNOX'
- },
- output: {
- id: 'puppet var',
- category: 'Users and Groups',
- isVisible: true,
- serviceName: 'MISC',
- isOverridable: false,
- isReconfigurable: false,
- displayName: 'Knox Group',
- displayType: 'user',
- index: 0
- },
- title: 'group, service_name = KNOX, default display name behaviour'
- },
- {
- input: {
- property_type: ['USER']
- },
- output: {
- isVisible: false
- },
- isHDPWIN: true,
- title: 'HDPWIN stack'
- },
- {
- input: {
- property_type: ['USER'],
- property_name: 'smokeuser',
- service_name: 'MISC'
- },
- output: {
- displayName: 'Smoke Test User',
- serviceName: 'MISC',
- belongsToService: ['MISC'],
- index: 30
- },
- title: 'smokeuser, service_name = MISC'
- },
- {
- input: {
- property_type: ['GROUP'],
- property_name: 'user_group'
- },
- output: {
- displayName: 'Hadoop Group'
- },
- title: 'user_group'
- },
- {
- input: {
- property_type: ['USER'],
- property_name: 'mapred_user'
- },
- output: {
- displayName: 'MapReduce User'
- },
- title: 'mapred_user'
- },
- {
- input: {
- property_type: ['USER'],
- property_name: 'zk_user'
- },
- output: {
- displayName: 'ZooKeeper User'
- },
- title: 'zk_user'
- },
- {
- input: {
- property_type: ['USER'],
- property_name: 'ignore_groupsusers_create'
- },
- output: {
- displayName: 'Skip group modifications during install',
- displayType: 'checkbox'
- },
- title: 'ignore_groupsusers_create'
- },
- {
- input: {
- property_type: ['GROUP'],
- property_name: 'proxyuser_group'
- },
- output: {
- belongsToService: ['HIVE', 'OOZIE', 'FALCON']
- },
- title: 'proxyuser_group'
- },
- {
- input: {
- property_type: ['PASSWORD'],
- property_name: 'javax.jdo.option.ConnectionPassword'
- },
- output: {
- displayType: 'password'
- },
- title: 'password'
- }
- ];
- before(function () {
- sinon.stub(App.StackService, 'find').returns([
- {
- serviceName: 'KNOX'
- }
- ]);
- });
- afterEach(function () {
- App.get.restore();
- });
- after(function () {
- App.StackService.find.restore();
- });
- configs.forEach(function (item) {
- it(item.title, function () {
- sinon.stub(App, 'get').withArgs('isHadoopWindowsStack').returns(Boolean(item.isHDPWIN));
- var propertyData = App.config.advancedConfigIdentityData(item.input);
- Em.keys(item.output).forEach(function (key) {
- expect(propertyData[key]).to.eql(item.output[key]);
- });
- });
- });
- });
- describe('#addUserProperty', function () {
- var cases = [
- {
- stored: {
- id: 0,
- name: 'prop_name0',
- serviceName: 's0',
- value: 'v0',
- defaultValue: 'dv0',
- filename: 'fn0.xml',
- overrides: null,
- isVisible: false,
- isFinal: true,
- defaultIsFinal: false,
- supportsFinal: true,
- category: 'c0'
- },
- expected: {
- id: 0,
- name: 'prop_name0',
- displayName: 'Prop Name0',
- serviceName: 's0',
- value: 'v0',
- defaultValue: 'dv0',
- displayType: 'advanced',
- filename: 'fn0.xml',
- isUserProperty: false,
- hasInitialValue: false,
- isOverridable: true,
- overrides: null,
- isRequired: false,
- isVisible: false,
- isFinal: true,
- defaultIsFinal: false,
- supportsFinal: true,
- showLabel: true,
- category: 'c0'
- },
- title: 'default case'
- },
- {
- stored: {
- name: 'n1',
- value: 'multi\nline',
- filename: 'fn1.xml',
- isUserProperty: true,
- hasInitialValue: true,
- showLabel: false
- },
- expected: {
- displayType: 'multiLine',
- isUserProperty: true,
- hasInitialValue: true,
- showLabel: false
- },
- title: 'multiline user property with initial value, label not to be shown'
- },
- {
- stored: {
- name: 'n2',
- filename: 'fn2.xml'
- },
- expected: {
- isUserProperty: false,
- showLabel: true
- },
- title: 'isUserProperty and showLabel not set'
- },
- {
- stored: {
- name: 'ignore_groupsusers_create',
- category: 'Users and Groups',
- filename: 'fn3.xml'
- },
- expected: {
- displayName: 'dn0',
- displayType: 'checkbox',
- index: 0
- }
- },
- {
- stored: {
- name: 'smokeuser',
- category: 'Users and Groups',
- filename: 'fn4.xml'
- },
- expected: {
- displayName: 'dn1',
- index: 1
- }
- },
- {
- stored: {
- name: 'user_group',
- category: 'Users and Groups',
- filename: 'fn5.xml'
- },
- expected: {
- displayName: 'dn1',
- index: 2
- }
- },
- {
- stored: {
- name: 'mapred_user',
- category: 'Users and Groups',
- filename: 'fn6.xml'
- },
- expected: {
- displayName: 'dn1',
- index: 3
- }
- },
- {
- stored: {
- name: 'zk_user',
- category: 'Users and Groups',
- filename: 'fn7.xml'
- },
- expected: {
- displayName: 'dn1',
- index: 4
- }
- }
- ],
- advancedConfigs = [
- {
- name: 'ignore_groupsusers_create',
- displayName: 'dn0',
- displayType: 'checkbox',
- index: 0
- },
- {
- name: 'smokeuser',
- displayName: 'dn1',
- index: 1
- },
- {
- name: 'user_group',
- displayName: 'dn1',
- index: 2
- },
- {
- name: 'mapred_user',
- displayName: 'dn1',
- index: 3
- },
- {
- name: 'zk_user',
- displayName: 'dn1',
- index: 4
- }
- ];
- cases.forEach(function (item) {
- it(item.title || item.stored.name, function () {
- var configData = App.config.addUserProperty(item.stored, true, advancedConfigs);
- Em.keys(item.expected).forEach(function (key) {
- expect(configData[key]).to.equal(item.expected[key]);
- });
- });
- });
- });
- describe('#getOriginalConfigAttribute', function () {
- var stored = {
- name: 'p',
- displayName: 'dn'
- },
- cases = [
- {
- advancedConfigs: [
- {
- name: 'p',
- displayName: 'dn0'
- }
- ],
- expected: 'dn0',
- title: 'should take attribute from advancedConfigs'
- },
- {
- advancedConfigs: [],
- expected: 'dn',
- title: 'property is absent in advancedConfigs'
- }
- ];
- cases.forEach(function (item) {
- it(item.title, function () {
- expect(App.config.getOriginalConfigAttribute(stored, 'displayName', item.advancedConfigs)).to.equal(item.expected);
- });
- });
- });
- describe('#setConfigValue', function () {
- Em.A([
- {
- mappedConfigs: [
- {
- name: 'falcon_user',
- value: 'fu'
- }
- ],
- allConfigs: [],
- m: 'in mapped, value used',
- e: {
- _name: 'hadoop.proxyuser.fu.groups',
- value: 'fu',
- noMatchSoSkipThisConfig: false
- }
- },
- {
- mappedConfigs: [],
- allConfigs: [
- {
- name: 'falcon_user',
- value: 'fu'
- }
- ],
- m: 'in all, value used',
- e: {
- _name: 'hadoop.proxyuser.fu.groups',
- value: 'fu',
- noMatchSoSkipThisConfig: false
- }
- },
- {
- mappedConfigs: [],
- allConfigs: [
- {
- name: 'falcon_user',
- value: '',
- defaultValue: 'fu'
- }
- ],
- m: 'in all, default value used',
- e: {
- _name: 'hadoop.proxyuser.fu.groups',
- value: 'fu',
- noMatchSoSkipThisConfig: false
- }
- },
- {
- mappedConfigs: [],
- allConfigs: [],
- m: 'not found',
- e: {
- _name: 'hadoop.proxyuser.<foreignKey[0]>.groups',
- value: '<foreignKey[0]>',
- noMatchSoSkipThisConfig: true
- }
- }
- ]).forEach(function (test) {
- it(test.m, function () {
- var config = {
- name: "hadoop.proxyuser.<foreignKey[0]>.groups",
- templateName: ["proxyuser_group"],
- foreignKey: ["falcon_user"],
- noMatchSoSkipThisConfig: false,
- value: "<foreignKey[0]>"
- };
- App.config.setConfigValue(test.mappedConfigs, test.allConfigs, config);
- expect(config.value).to.equal(test.e.value);
- if(test.e.noMatchSoSkipThisConfig) {
- expect(Em.isNone(config._name)).to.be.true;
- }
- else {
- expect(config._name).to.equal(test.e._name);
- }
- expect(config.noMatchSoSkipThisConfig).to.equal(test.e.noMatchSoSkipThisConfig);
- });
- Em.A([
- {
- mappedConfigs: [],
- allConfigs: [
- {
- name: 'falcon_user',
- value: 'fu'
- },
- {
- name: 'proxyuser_group',
- value: 'pg'
- }
- ],
- m: 'in all, template in all',
- e: {
- _name: 'hadoop.proxyuser.fu.groups',
- value: 'fupg'
- }
- },
- {
- mappedConfigs: [
- {
- name: 'falcon_user',
- value: 'fu'
- },
- {
- name: 'proxyuser_group',
- value: 'pg'
- }
- ],
- allConfigs: [],
- m: 'in mapped, template in mapped',
- e: {
- _name: 'hadoop.proxyuser.fu.groups',
- value: 'fupg'
- }
- },
- {
- mappedConfigs: [],
- allConfigs: [],
- m: 'not found (template not found too)',
- e: {
- _name: 'hadoop.proxyuser.<foreignKey[0]>.groups',
- value: null
- }
- }
- ]).forEach(function (test) {
- it(test.m, function () {
- var config = {
- name: "hadoop.proxyuser.<foreignKey[0]>.groups",
- templateName: ["proxyuser_group"],
- foreignKey: ["falcon_user"],
- noMatchSoSkipThisConfig: false,
- value: "<foreignKey[0]><templateName[0]>"
- };
- App.config.setConfigValue(test.mappedConfigs, test.allConfigs, config);
- });
- });
- });
- });
- });
|