123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290 |
- /**
- * 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('#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('');
- });
- it("filename has configs that shouldn't be included in textarea", function () {
- var configs = [
- {
- name: 'config1',
- value: 'value1',
- defaultValue: 'value1',
- filename: filename
- },
- {
- name: 'config2',
- value: 'value2',
- defaultValue: 'value2',
- filename: filename
- }
- ];
- var cfg = {
- name: 'config3',
- value: 'value3',
- defaultValue: 'value3',
- filename: filename
- };
- configs.push(cfg);
- var result = App.config.fileConfigsIntoTextarea.call(App.config, configs, filename, [cfg]);
- expect(result.length).to.equal(2);
- expect(result[1].value).to.equal('config1=value1\nconfig2=value2\n');
- expect(result[1].defaultValue).to.equal('config1=value1\nconfig2=value2\n');
- expect(configs.findProperty('name', 'config3')).to.eql(cfg);
- });
- });
- describe('#textareaIntoFileConfigs', function () {
- var filename = 'capacity-scheduler.xml';
- var testData = [
- {
- configs: [Em.Object.create({
- "name": "capacity-scheduler",
- "value": "config1=value1",
- "filename": "capacity-scheduler.xml",
- "isRequiredByAgent": true
- })]
- },
- {
- configs: [Em.Object.create({
- "name": "capacity-scheduler",
- "value": "config1=value1\nconfig2=value2\n",
- "filename": "capacity-scheduler.xml",
- "isRequiredByAgent": false
- })]
- },
- {
- configs: [Em.Object.create({
- "name": "capacity-scheduler",
- "value": "config1=value1,value2\n",
- "filename": "capacity-scheduler.xml",
- "isRequiredByAgent": true
- })]
- },
- {
- configs: [Em.Object.create({
- "name": "capacity-scheduler",
- "value": "config1=value1 config2=value2\n",
- "filename": "capacity-scheduler.xml",
- "isRequiredByAgent": false
- })]
- }
- ];
- 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');
- expect(result[0].isRequiredByAgent).to.be.true;
- });
- 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');
- expect(result[0].isRequiredByAgent).to.be.false;
- expect(result[1].isRequiredByAgent).to.be.false;
- });
- 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');
- expect(result[0].isRequiredByAgent).to.be.true;
- });
- 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);
- expect(result[0].isRequiredByAgent).to.be.false;
- });
- });
- 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() {
- sinon.stub(App.config, 'parseValue', function(value) {return value});
- sinon.stub(App.config, 'getConfigTypesInfoFromService').returns({
- supportsFinal: ['hdfs-site']
- });
- 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() {
- App.config.parseValue.restore();
- App.config.getConfigTypesInfoFromService.restore();
- 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);
- });
- });
- });
- });
- describe('#shouldSupportFinal', function () {
- var cases = [
- {
- shouldSupportFinal: false,
- title: 'no service name specified'
- },
- {
- serviceName: 's0',
- shouldSupportFinal: false,
- title: 'no filename specified'
- },
- {
- serviceName: 'MISC',
- shouldSupportFinal: false,
- title: 'MISC'
- },
- {
- serviceName: 's0',
- filename: 's0-site',
- shouldSupportFinal: true,
- title: 'final attribute supported'
- },
- {
- serviceName: 's0',
- filename: 's0-env',
- shouldSupportFinal: false,
- title: 'final attribute not supported'
- }
- ];
- beforeEach(function () {
- sinon.stub(App.StackService, 'find').returns([
- {
- serviceName: 's0'
- }
- ]);
- sinon.stub(App.config, 'getConfigTypesInfoFromService').returns({
- supportsFinal: ['s0-site']
- });
- });
- afterEach(function () {
- App.StackService.find.restore();
- App.config.getConfigTypesInfoFromService.restore();
- });
- cases.forEach(function (item) {
- it(item.title, function () {
- expect(App.config.shouldSupportFinal(item.serviceName, item.filename)).to.equal(item.shouldSupportFinal);
- });
- });
- });
- });
|