1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110 |
- /**
- * 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');
- var numberUtils = require('utils/number_utils');
- require('mixins/common/localStorage');
- require('models/config_group');
- require('controllers/wizard/step7_controller');
- var installerStep7Controller,
- issuesFilterCases = [
- {
- isSubmitDisabled: true,
- submitButtonClicked: true,
- isIssuesFilterActive: true,
- issuesFilterText: '',
- issuesFilterLinkText: Em.I18n.t('installer.step7.showAllProperties'),
- title: 'issues filter on, submit button clicked'
- },
- {
- isSubmitDisabled: true,
- submitButtonClicked: false,
- isIssuesFilterActive: true,
- issuesFilterText: Em.I18n.t('installer.step7.showingPropertiesWithIssues'),
- issuesFilterLinkText: Em.I18n.t('installer.step7.showAllProperties'),
- title: 'issues filter on, submit button disabled'
- },
- {
- isSubmitDisabled: true,
- submitButtonClicked: true,
- isIssuesFilterActive: false,
- issuesFilterText: '',
- issuesFilterLinkText: '',
- title: 'issues filter off, submit button clicked'
- },
- {
- isSubmitDisabled: true,
- submitButtonClicked: false,
- isIssuesFilterActive: false,
- issuesFilterText: '',
- issuesFilterLinkText: Em.I18n.t('installer.step7.showPropertiesWithIssues'),
- title: 'issues filter off, submit button disabled'
- },
- {
- isSubmitDisabled: false,
- submitButtonClicked: false,
- isIssuesFilterActive: true,
- issuesFilterText: '',
- issuesFilterLinkText: Em.I18n.t('installer.step7.showAllProperties'),
- title: 'issues filter on, submit button enabled'
- },
- {
- isSubmitDisabled: false,
- submitButtonClicked: false,
- isIssuesFilterActive: false,
- issuesFilterText: '',
- issuesFilterLinkText: '',
- title: 'issues filter off, submit button enabled'
- },
- {
- isSubmitDisabled: false,
- submitButtonClicked: false,
- isIssuesFilterActive: true,
- issuesFilterText: '',
- issuesFilterLinkText: Em.I18n.t('installer.step7.showAllProperties'),
- title: 'issues filter on, submit button not clicked but active'
- },
- {
- isSubmitDisabled: false,
- submitButtonClicked: true,
- isIssuesFilterActive: true,
- issuesFilterText: '',
- issuesFilterLinkText: Em.I18n.t('installer.step7.showAllProperties'),
- title: 'issues filter on, submit button clicked and active'
- }
- ],
- issuesFilterTestSetup = function (controller, testCase) {
- controller.set('submitButtonClicked', testCase.submitButtonClicked);
- controller.reopen({
- isSubmitDisabled: testCase.isSubmitDisabled
- });
- controller.get('filterColumns').findProperty('attributeName', 'hasIssues').set('selected', testCase.isIssuesFilterActive);
- };
- describe('App.InstallerStep7Controller', function () {
- beforeEach(function () {
- sinon.stub(App.config, 'setPreDefinedServiceConfigs', Em.K);
- installerStep7Controller = App.WizardStep7Controller.create({
- content: {
- advancedServiceConfig: [],
- serviceConfigProperties: []
- }
- });
- });
- afterEach(function() {
- App.config.setPreDefinedServiceConfigs.restore();
- });
- describe('#installedServiceNames', function () {
- var tests = Em.A([
- {
- content: Em.Object.create({
- controllerName: 'installerController',
- services: Em.A([
- Em.Object.create({
- isInstalled: true,
- serviceName: 'SQOOP'
- }),
- Em.Object.create({
- isInstalled: true,
- serviceName: 'HDFS'
- })
- ])
- }),
- e: ['SQOOP', 'HDFS'],
- m: 'installerController with SQOOP'
- },
- {
- content: Em.Object.create({
- controllerName: 'installerController',
- services: Em.A([
- Em.Object.create({
- isInstalled: true,
- serviceName: 'HIVE'
- }),
- Em.Object.create({
- isInstalled: true,
- serviceName: 'HDFS'
- })
- ])
- }),
- e: ['HIVE', 'HDFS'],
- m: 'installerController without SQOOP'
- },
- {
- content: Em.Object.create({
- controllerName: 'addServiceController',
- services: Em.A([
- Em.Object.create({
- isInstalled: true,
- serviceName: 'HIVE'
- }),
- Em.Object.create({
- isInstalled: true,
- serviceName: 'HDFS'
- })
- ])
- }),
- e: ['HIVE', 'HDFS'],
- m: 'addServiceController without SQOOP'
- }
- ]);
- tests.forEach(function (test) {
- it(test.m, function () {
- installerStep7Controller.set('content', test.content);
- expect(installerStep7Controller.get('installedServiceNames')).to.include.members(test.e);
- expect(test.e).to.include.members(installerStep7Controller.get('installedServiceNames'));
- });
- });
- });
- describe('#isSubmitDisabled', function () {
- it('should be true if miscModalVisible', function () {
- installerStep7Controller.reopen({miscModalVisible: true});
- expect(installerStep7Controller.get('isSubmitDisabled')).to.equal(true);
- });
- it('should be true if some of stepConfigs has errors', function () {
- installerStep7Controller.reopen({
- miscModalVisible: false,
- stepConfigs: [
- {
- showConfig: true,
- errorCount: 1
- }
- ]
- });
- expect(installerStep7Controller.get('isSubmitDisabled')).to.equal(true);
- });
- it('should be false if all of stepConfigs don\'t have errors and miscModalVisible is false', function () {
- installerStep7Controller.reopen({
- miscModalVisible: false,
- stepConfigs: [
- {
- showConfig: true,
- errorCount: 0
- }
- ]
- });
- expect(installerStep7Controller.get('isSubmitDisabled')).to.equal(false);
- });
- });
- describe('#selectedServiceNames', function () {
- it('should use content.services as source of data', function () {
- installerStep7Controller.set('content', {
- services: [
- {isSelected: true, isInstalled: false, serviceName: 's1'},
- {isSelected: false, isInstalled: false, serviceName: 's2'},
- {isSelected: true, isInstalled: true, serviceName: 's3'},
- {isSelected: false, isInstalled: false, serviceName: 's4'},
- {isSelected: true, isInstalled: false, serviceName: 's5'},
- {isSelected: false, isInstalled: false, serviceName: 's6'},
- {isSelected: true, isInstalled: true, serviceName: 's7'},
- {isSelected: false, isInstalled: false, serviceName: 's8'}
- ]
- });
- var expected = ['s1', 's5'];
- expect(installerStep7Controller.get('selectedServiceNames')).to.eql(expected);
- });
- });
- describe('#allSelectedServiceNames', function () {
- it('should use content.services as source of data', function () {
- installerStep7Controller.set('content', {
- services: [
- Em.Object.create({isSelected: true, isInstalled: false, serviceName: 's1'}),
- Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's2'}),
- Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's3'}),
- Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's4'}),
- Em.Object.create({isSelected: true, isInstalled: false, serviceName: 's5'}),
- Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's6'}),
- Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's7'}),
- Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's8'})
- ]
- });
- var expected = ['s1', 's3', 's5', 's7'];
- expect(installerStep7Controller.get('allSelectedServiceNames')).to.eql(expected);
- });
- });
- describe('#masterComponentHosts', function () {
- it('should be equal to content.masterComponentHosts', function () {
- var masterComponentHosts = [
- {},
- {},
- {}
- ];
- installerStep7Controller.reopen({content: {masterComponentHosts: masterComponentHosts}});
- expect(installerStep7Controller.get('masterComponentHosts')).to.eql(masterComponentHosts);
- });
- });
- describe('#slaveComponentHosts', function () {
- it('should be equal to content.slaveGroupProperties', function () {
- var slaveGroupProperties = [
- {},
- {},
- {}
- ];
- installerStep7Controller.reopen({content: {slaveGroupProperties: slaveGroupProperties}});
- expect(installerStep7Controller.get('slaveComponentHosts')).to.eql(slaveGroupProperties);
- });
- });
- describe('#_createSiteToTagMap', function () {
- it('should return filtered map', function () {
- var desired_configs = {
- site1: {
- tag: "tag1"
- },
- site2: {
- tag: "tag2"
- },
- site3: {
- tag: "tag3"
- }
- };
- var sites = {
- site1: true,
- site3: true
- };
- var siteToTagMap = installerStep7Controller._createSiteToTagMap(desired_configs,sites)
- expect(siteToTagMap).to.eql({
- site1: "tag1",
- site3: "tag3"
- });
- });
- });
- describe('#checkDatabaseConnectionTest', function () {
- it('should return promise in process', function () {
- installerStep7Controller.set('content', {
- services: Em.A([
- Em.Object.create({isSelected: true, isInstalled: false, serviceName: 'OOZIE', ignored: []}),
- Em.Object.create({isSelected: false, isInstalled: false, serviceName: 'HIVE', ignored: []}),
- Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's3', ignored: []}),
- Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's4', ignored: []}),
- Em.Object.create({isSelected: true, isInstalled: false, serviceName: 's5', ignored: []}),
- Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's6', ignored: []}),
- Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's7', ignored: []}),
- Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's8', ignored: []})
- ])
- });
- var obj = Em.Object.create({name:'oozie_database',value:"aa"});
- installerStep7Controller.set('stepConfigs',Em.A([Em.Object.create({serviceName: 'OOZIE', configs: Em.A([obj]) })]));
- var deffer = installerStep7Controller.checkDatabaseConnectionTest();
- expect(deffer.isResolved()).to.equal(false);
- deffer.resolve(true);
- deffer.done(function(data) {
- expect(data).to.equal(true);
- });
- });
- });
- describe('#submit', function () {
- it('should return undefined if submit disabled', function () {
- installerStep7Controller.set('isSubmitDisabled',true);
- expect(installerStep7Controller.submit()).to.be.undefined;
- });
- it('sumbit button should be unclicked if no configs', function () {
- installerStep7Controller.set('isSubmitDisabled',false);
- installerStep7Controller.submit();
- expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
- });
- });
- describe('#activateSpecialConfigs', function () {
- var expected = [{
- "smokeuser": {
- "isEditable": true
- },
- "group": {
- "isEditable": true
- },
- "services": [
- {
- "serviceName": "s1",
- "isSelected": true,
- "isInstalled": false
- },
- {
- "serviceName": "s2",
- "isSelected": false,
- "isInstalled": false
- },
- {
- "serviceName": "s3",
- "isSelected": true,
- "isInstalled": true
- },
- {
- "serviceName": "s4",
- "isSelected": false,
- "isInstalled": false
- },
- {
- "serviceName": "s5",
- "isSelected": true,
- "isInstalled": false
- },
- {
- "serviceName": "s6",
- "isSelected": false,
- "isInstalled": false
- },
- {
- "serviceName": "s7",
- "isSelected": true,
- "isInstalled": true
- },
- {
- "serviceName": "s8",
- "isSelected": false,
- "isInstalled": false
- }
- ]
- },[
- {
- "serviceName": "MISC",
- "configs": [
- {
- "name": "smokeuser",
- "value": {
- "isEditable": true
- },
- "isEditable": false
- },
- {
- "name": "user_group",
- "value": {
- "isEditable": true
- },
- "isEditable": false
- },
- {
- "name": "kdc_type"
- }
- ]
- },
- {
- "serviceName": "KERBEROS",
- "configs": [
- {
- "name": "smokeuser",
- "value": {
- "isEditable": true
- },
- "isEditable": false
- },
- {
- "name": "user_group",
- "value": {
- "isEditable": true
- },
- "isEditable": false
- },
- {
- "name": "kdc_type"
- }
- ]
- }
- ]];
- var allSelectedServiceNames = ['SLIDER', 'YARN'];
- var configs = Em.A([Em.Object.create({
- name: 'smokeuser',
- value: ''
- }),Em.Object.create({
- name: 'user_group',
- value: ''
- }),Em.Object.create({
- name: 'kdc_type',
- value: ''
- })]);
- var stepConfigs = Em.A([Em.Object.create({serviceName: 'MISC', configs: configs}),
- Em.Object.create({serviceName: 'KERBEROS', configs: configs})]);
- var content = Em.Object.create({
- smokeuser: Em.Object.create({isEditable: true}),
- group: Em.Object.create({isEditable: true}),
- services: Em.A([
- Em.Object.create({isSelected: true, isInstalled: false, serviceName: 's1'}),
- Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's2'}),
- Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's3'}),
- Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's4'}),
- Em.Object.create({isSelected: true, isInstalled: false, serviceName: 's5'}),
- Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's6'}),
- Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's7'}),
- Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's8'})
- ])
- });
- it('should return configs with true value', function () {
- installerStep7Controller.set('wizardController', Em.Object.create(App.LocalStorage, {name: 'addServiceController'}));
- installerStep7Controller.set('addMiscTabToPage',true);
- installerStep7Controller.reopen({allSelectedServiceNames: allSelectedServiceNames});
- installerStep7Controller.set('stepConfigs', stepConfigs);
- installerStep7Controller.set('content', content);
- installerStep7Controller.activateSpecialConfigs();
- expect(JSON.parse(JSON.stringify(installerStep7Controller.get('content')))).to.be.eql(expected[0]);
- });
- it('should return stepsConfigs with true value', function () {
- installerStep7Controller.set('wizardController', Em.Object.create(App.LocalStorage, {name: 'kerberosWizardController'}));
- installerStep7Controller.set('addMiscTabToPage',true);
- installerStep7Controller.reopen({allSelectedServiceNames: allSelectedServiceNames});
- installerStep7Controller.set('stepConfigs', stepConfigs);
- installerStep7Controller.set('content', content);
- installerStep7Controller.activateSpecialConfigs();
- expect(JSON.parse(JSON.stringify(installerStep7Controller.get('stepConfigs')))).to.be.eql(expected[1]);
- });
- });
- describe('#getConfigTagsSuccess', function () {
- beforeEach(function(){
- sinon.stub(App.StackService, 'find', function () {
- return [
- Em.Object.create({
- serviceName: 's0',
- isInstalled: true,
- configTypes: {
- site3: true,
- site1: true
- }
- }),
- Em.Object.create({
- serviceName: 's1',
- isInstalled: true,
- configTypes: {
- site1: true,
- site2: true
- }
- })
- ];
- });
- });
- afterEach(function(){
- App.StackService.find.restore();
- });
- it('should return serviceConfigTags', function () {
- var desired_configs = {
- site1: {
- tag: "tag1"
- },
- site2: {
- tag: "tag2"
- },
- site3: {
- tag: "tag3"
- }
- };
- var data = {
- Clusters: {
- desired_configs: desired_configs
- }
- };
- var siteToTagMap = installerStep7Controller.getConfigTagsSuccess(data)
- expect(installerStep7Controller.get('serviceConfigTags')).to.eql([
- {
- "siteName": "site1",
- "tagName": "tag1",
- "newTagName": null
- },
- {
- "siteName": "site2",
- "tagName": "tag2",
- "newTagName": null
- },
- {
- "siteName": "site3",
- "tagName": "tag3",
- "newTagName": null
- }
- ]);
- expect(installerStep7Controller.get('isAppliedConfigLoaded')).to.equal(true);
- });
- });
- describe('#clearStep', function () {
- it('should clear stepConfigs', function () {
- installerStep7Controller.set('stepConfigs', [
- {},
- {}
- ]);
- installerStep7Controller.clearStep();
- expect(installerStep7Controller.get('stepConfigs.length')).to.equal(0);
- });
- it('should clear filter', function () {
- installerStep7Controller.set('filter', 'filter');
- installerStep7Controller.clearStep();
- expect(installerStep7Controller.get('filter')).to.equal('');
- });
- it('should set for each filterColumns "selected" false', function () {
- installerStep7Controller.set('filterColumns', [
- {selected: true},
- {selected: false},
- {selected: true}
- ]);
- installerStep7Controller.clearStep();
- expect(installerStep7Controller.get('filterColumns').everyProperty('selected', false)).to.equal(true);
- });
- });
- describe('#loadInstalledServicesConfigGroups', function () {
- before(function () {
- sinon.stub(App.ajax, 'send', Em.K);
- });
- after(function () {
- App.ajax.send.restore();
- });
- it('should do ajax request for each received service name', function () {
- var serviceNames = ['s1', 's2', 's3'];
- installerStep7Controller.loadInstalledServicesConfigGroups(serviceNames);
- expect(App.ajax.send.callCount).to.equal(serviceNames.length);
- });
- });
- describe('#getConfigTags', function () {
- before(function () {
- sinon.stub(App.ajax, 'send', Em.K);
- });
- after(function () {
- App.ajax.send.restore();
- });
- it('should do ajax-request', function () {
- installerStep7Controller.getConfigTags();
- expect(App.ajax.send.calledOnce).to.equal(true);
- });
- });
- describe('#setGroupsToDelete', function () {
- beforeEach(function () {
- installerStep7Controller.set('wizardController', Em.Object.create(App.LocalStorage, {name: 'tdk'}));
- });
- it('should add new groups to groupsToDelete', function () {
- var groupsToDelete = [
- {id: '1'},
- {id: '2'}
- ],
- groups = [
- Em.Object.create({id: '3'}),
- Em.Object.create(),
- Em.Object.create({id: '5'})
- ],
- expected = [
- {id: "1"},
- {id: "2"},
- {id: "3"},
- {id: "5"}
- ];
- installerStep7Controller.set('groupsToDelete', groupsToDelete);
- installerStep7Controller.setGroupsToDelete(groups);
- expect(installerStep7Controller.get('groupsToDelete')).to.eql(expected);
- expect(installerStep7Controller.get('wizardController').getDBProperty('groupsToDelete')).to.eql(expected);
- });
- });
- describe('#checkMySQLHost', function () {
- it('should send query', function () {
- expect(installerStep7Controller.checkMySQLHost().readyState).to.equal(1);
- });
- });
- describe('#selectConfigGroup', function () {
- beforeEach(function () {
- installerStep7Controller.reopen({content: {services: []}});
- sinon.stub(installerStep7Controller, 'switchConfigGroupConfigs', Em.K);
- });
- afterEach(function () {
- installerStep7Controller.switchConfigGroupConfigs.restore();
- });
- it('should set selectedConfigGroup', function () {
- var group = {':': []};
- installerStep7Controller.selectConfigGroup({context: group});
- expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(group);
- });
- });
- describe('#addOverrideProperty', function () {
- it('should add override property', function () {
- var groupName = 'groupName',
- selectedService = {configGroups: [Em.Object.create({name: groupName, properties: []})]},
- selectedConfigGroup = {name: groupName},
- serviceConfigProperty = Em.Object.create({overrides: []}),
- expected = Em.Object.create({
- value: '',
- isOriginalSCP: false,
- isEditable: true
- });
- installerStep7Controller.reopen({selectedService: selectedService, selectedConfigGroup: selectedConfigGroup});
- var newSCP = installerStep7Controller.addOverrideProperty(serviceConfigProperty);
- Em.keys(expected).forEach(function (k) {
- expect(newSCP.get(k)).to.equal(expected.get(k));
- });
- var group = installerStep7Controller.get('selectedService.configGroups').findProperty('name', groupName);
- expect(newSCP.get('group')).to.eql(group);
- expect(newSCP.get('parentSCP')).to.eql(serviceConfigProperty);
- expect(group.get('properties.length')).to.equal(1);
- });
- });
- describe('#resolveYarnConfigs', function () {
- it('should set property to true', function () {
- var allSelectedServiceNames = ['SLIDER', 'YARN'],
- configs = [
- {name: 'hadoop.registry.rm.enabled', value: false, recommendedValue: false}
- ],
- expected = [
- {name: 'hadoop.registry.rm.enabled', value: true, recommendedValue: true}
- ];
- installerStep7Controller.reopen({allSelectedServiceNames: allSelectedServiceNames});
- installerStep7Controller.resolveYarnConfigs(configs);
- expect(configs[0]).to.eql(expected[0]);
- });
- it('should set property to false', function () {
- var allSelectedServiceNames = ['YARN'],
- configs = [
- {name: 'hadoop.registry.rm.enabled', value: true, recommendedValue: true}
- ],
- expected = [
- {name: 'hadoop.registry.rm.enabled', value: false, recommendedValue: false}
- ];
- installerStep7Controller.reopen({allSelectedServiceNames: allSelectedServiceNames});
- installerStep7Controller.resolveYarnConfigs(configs);
- expect(configs[0]).to.eql(expected[0]);
- });
- it('should skip setting property', function () {
- var allSelectedServiceNames = ['YARN', 'SLIDER'],
- configs = [
- {name: 'hadoop.registry.rm.enabled', value: true, recommendedValue: true}
- ],
- expected = [
- {name: 'hadoop.registry.rm.enabled', value: true, recommendedValue: true}
- ];
- installerStep7Controller.reopen({allSelectedServiceNames: allSelectedServiceNames});
- installerStep7Controller.resolveYarnConfigs(configs);
- expect(configs[0]).to.eql(expected[0]);
- });
- });
- describe('#resolveStormConfigs', function () {
- beforeEach(function () {
- installerStep7Controller.reopen({
- content: {services: []},
- wizardController: Em.Object.create({
- hosts: {'h1': {name: 'host1', id: 'h1'}},
- masterComponentHosts: [{component: 'GANGLIA_SERVER', host_id: 'h1'}],
- getDBProperty: function (k) {
- return this.get(k);
- }
- })
- });
- });
- it('shouldn\'t do nothing if Ganglia and Storm are installed', function () {
- var installedServiceNames = ['GANGLIA', 'STORM'],
- configs = [
- {name: 'nimbus.childopts', value: '.jar=host=host2', recommendedValue: ''},
- {name: 'supervisor.childopts', value: '.jar=host=host2', recommendedValue: ''},
- {name: 'worker.childopts', value: '.jar=host=host2', recommendedValue: ''}
- ],
- expected = [
- {name: 'nimbus.childopts', value: '.jar=host=host2', recommendedValue: ''},
- {name: 'supervisor.childopts', value: '.jar=host=host2', recommendedValue: ''},
- {name: 'worker.childopts', value: '.jar=host=host2', recommendedValue: ''}
- ];
- installerStep7Controller.reopen({installedServiceNames: installedServiceNames});
- installerStep7Controller.resolveStormConfigs(configs);
- expect(configs).to.eql(expected);
- });
- it('shouldn\'t do nothing if Ganglia is in allSelectedServiceNames', function () {
- var allSelectedServiceNames = ['GANGLIA'],
- configs = [
- {name: 'nimbus.childopts', value: '.jar=host=host2', recommendedValue: ''},
- {name: 'supervisor.childopts', value: '.jar=host=host2', recommendedValue: ''},
- {name: 'worker.childopts', value: '.jar=host=host2', recommendedValue: ''}
- ],
- expected = [
- {name: 'nimbus.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'},
- {name: 'supervisor.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'},
- {name: 'worker.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'}
- ];
- installerStep7Controller.reopen({allSelectedServiceNames: allSelectedServiceNames});
- installerStep7Controller.resolveStormConfigs(configs);
- Em.keys(expected[0]).forEach(function (k) {
- expect(configs.mapProperty(k)).to.eql(expected.mapProperty(k));
- });
- });
- it('shouldn\'t do nothing if Ganglia is in installedServiceNames (2)', function () {
- var installedServiceNames = ['GANGLIA'],
- configs = [
- {name: 'nimbus.childopts', value: '.jar=host=host2', recommendedValue: ''},
- {name: 'supervisor.childopts', value: '.jar=host=host2', recommendedValue: ''},
- {name: 'worker.childopts', value: '.jar=host=host2', recommendedValue: ''}
- ],
- expected = [
- {name: 'nimbus.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'},
- {name: 'supervisor.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'},
- {name: 'worker.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'}
- ];
- installerStep7Controller.reopen({installedServiceNames: installedServiceNames});
- installerStep7Controller.resolveStormConfigs(configs);
- Em.keys(expected[0]).forEach(function (k) {
- expect(configs.mapProperty(k)).to.eql(expected.mapProperty(k));
- });
- });
- it('should replace host name for *.childopts properties if Ganglia is in installedServiceNames for Add Service Wizard', function () {
- var installedServiceNames = ['GANGLIA'],
- configs = [
- {name: 'nimbus.childopts', value: '.jar=host=host2', recommendedValue: ''},
- {name: 'supervisor.childopts', value: '.jar=host=host2', recommendedValue: ''},
- {name: 'worker.childopts', value: '.jar=host=host2', recommendedValue: ''}
- ],
- expected = [
- {name: 'nimbus.childopts', value: '.jar=host=realhost1', recommendedValue: '.jar=host=realhost1'},
- {name: 'supervisor.childopts', value: '.jar=host=realhost1', recommendedValue: '.jar=host=realhost1'},
- {name: 'worker.childopts', value: '.jar=host=realhost1', recommendedValue: '.jar=host=realhost1'}
- ];
- installerStep7Controller.reopen({
- installedServiceNames: installedServiceNames,
- wizardController: Em.Object.create({
- name: 'addServiceController',
- masterComponentHosts: [{component: 'GANGLIA_SERVER', hostName: 'realhost1'}],
- getDBProperty: function (k) {
- return this.get(k);
- }
- })
- });
- installerStep7Controller.resolveStormConfigs(configs);
- Em.keys(expected[0]).forEach(function (k) {
- expect(configs.mapProperty(k)).to.eql(expected.mapProperty(k));
- });
- });
- });
- describe('#resolveServiceDependencyConfigs', function () {
- beforeEach(function () {
- sinon.stub(installerStep7Controller, 'resolveStormConfigs', Em.K);
- sinon.stub(installerStep7Controller, 'resolveYarnConfigs', Em.K);
- });
- afterEach(function () {
- installerStep7Controller.resolveStormConfigs.restore();
- installerStep7Controller.resolveYarnConfigs.restore();
- });
- [
- {serviceName: 'STORM', method: "resolveStormConfigs"},
- {serviceName: 'YARN', method: "resolveYarnConfigs"}
- ].forEach(function(t) {
- it("should call " + t.method + " if serviceName is " + t.serviceName, function () {
- var configs = [
- {},
- {}
- ];
- installerStep7Controller.resolveServiceDependencyConfigs(t.serviceName, configs);
- expect(installerStep7Controller[t.method].calledWith(configs)).to.equal(true);
- });
- });
- });
- describe('#selectedServiceObserver', function () {
- beforeEach(function () {
- installerStep7Controller.reopen({content: {services: []}});
- sinon.stub(installerStep7Controller, 'switchConfigGroupConfigs', Em.K);
- });
- afterEach(function () {
- installerStep7Controller.switchConfigGroupConfigs.restore();
- });
- it('shouldn\'t do nothing if App.supports.hostOverridesInstaller is false', function () {
- App.set('supports.hostOverridesInstaller', false);
- var configGroups = [
- {},
- {}
- ],
- selectedConfigGroup = {};
- installerStep7Controller.reopen({configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
- installerStep7Controller.selectedServiceObserver();
- expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
- expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
- });
- it('shouldn\'t do nothing if selectedService is null', function () {
- App.set('supports.hostOverridesInstaller', true);
- var configGroups = [
- {},
- {}
- ],
- selectedConfigGroup = {};
- installerStep7Controller.reopen({selectedService: null, configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
- installerStep7Controller.selectedServiceObserver();
- expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
- expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
- });
- it('shouldn\'t do nothing if selectedService.serviceName is MISC', function () {
- App.set('supports.hostOverridesInstaller', true);
- var configGroups = [
- {},
- {}
- ],
- selectedConfigGroup = {};
- installerStep7Controller.reopen({selectedService: {serviceName: 'MISC'}, configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
- installerStep7Controller.selectedServiceObserver();
- expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
- expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
- });
- it('should update configGroups and selectedConfigGroup', function () {
- App.set('supports.hostOverridesInstaller', true);
- var defaultGroup = {isDefault: true, n: 'n2'},
- configGroups = [
- {isDefault: false, n: 'n1'},
- defaultGroup,
- {n: 'n3'}
- ],
- selectedConfigGroup = {};
- installerStep7Controller.reopen({selectedService: {serviceName: 's1', configGroups: configGroups}});
- installerStep7Controller.selectedServiceObserver();
- expect(installerStep7Controller.get('configGroups').mapProperty('n')).to.eql(['n2', 'n1', 'n3']);
- expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(defaultGroup);
- });
- });
- describe('#loadConfigGroups', function () {
- beforeEach(function () {
- installerStep7Controller.reopen({
- wizardController: Em.Object.create({
- allHosts: [
- {hostName: 'h1'},
- {hostName: 'h2'},
- {hostName: 'h3'}
- ]
- })
- });
- });
- it('shouldn\'t do nothing if only MISC available', function () {
- var configGroups = [
- {}
- ];
- installerStep7Controller.reopen({
- stepConfigs: [Em.Object.create({serviceName: 'MISC', configGroups: configGroups})]
- });
- installerStep7Controller.loadConfigGroups([]);
- expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups')).to.eql(configGroups);
- });
- it('should set configGroups for service if they don\'t exist', function () {
- var configGroups = [],
- serviceName = 'HDFS',
- serviceConfigGroups = [
- {service: {id: 's1'}}
- ];
- installerStep7Controller.reopen({
- stepConfigs: [Em.Object.create({serviceName: serviceName, displayName: serviceName, configGroups: configGroups})]
- });
- installerStep7Controller.loadConfigGroups(serviceConfigGroups);
- expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups.length')).to.equal(1);
- var group = installerStep7Controller.get('stepConfigs.firstObject.configGroups.firstObject');
- expect(group.get('name')).to.equal(serviceName + ' Default');
- expect(group.get('description').contains(serviceName)).to.equal(true);
- expect(group.get('isDefault')).to.equal(true);
- expect(group.get('hosts')).to.eql(['h1', 'h2', 'h3']);
- expect(group.get('service.id')).to.equal(serviceName);
- expect(group.get('serviceName')).to.equal(serviceName);
- });
- it('should update configGroups for service (only default group)', function () {
- var configGroups = [],
- serviceName = 'HDFS',
- serviceConfigGroups = [
- {service: {id: 'HDFS'}, isDefault: true, n: 'n1'}
- ];
- installerStep7Controller.reopen({
- stepConfigs: [Em.Object.create({serviceName: serviceName, displayName: serviceName, configGroups: configGroups})]
- });
- installerStep7Controller.loadConfigGroups(serviceConfigGroups);
- expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault').get('n')).to.equal('n1');
- });
- it('should update configGroups for service', function () {
- var configGroups = [],
- serviceName = 'HDFS',
- properties = [
- { name: "p1", filename: "file.xml" },
- { name: "p2", filename: "file.xml" }
- ],
- serviceConfigGroups = [
- {service: {id: 'HDFS'}, properties: properties.slice(), isDefault: true, n: 'n1'},
- {service: {id: 'HDFS'}, properties: properties.slice(), isDefault: false, n: 'n2'}
- ];
- installerStep7Controller.reopen({
- stepConfigs: [Em.Object.create({serviceName: serviceName, configGroups: configGroups, configs: properties})]
- });
- installerStep7Controller.loadConfigGroups(serviceConfigGroups);
- expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups.length')).to.equal(2);
- expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault').get('n')).to.equal('n1');
- expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault', false).get('properties').everyProperty('group.n', 'n2')).to.equal(true);
- expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault', false).get('parentConfigGroup.n')).to.equal('n1');
- });
- });
- describe('#_getDisplayedConfigGroups', function () {
- it('should return [] if no selected group', function () {
- installerStep7Controller.reopen({
- content: {services: []},
- selectedConfigGroup: null
- });
- expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([]);
- });
- it('should return default config group if another selected', function () {
- var defaultGroup = Em.Object.create({isDefault: false});
- installerStep7Controller.reopen({
- content: {services: []},
- selectedConfigGroup: defaultGroup
- });
- expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([defaultGroup]);
- });
- it('should return other groups if default selected', function () {
- var defaultGroup = Em.Object.create({isDefault: true}),
- cfgG = Em.Object.create({isDefault: true}),
- configGroups = Em.A([
- Em.Object.create({isDefault: false}),
- Em.Object.create({isDefault: false}),
- cfgG,
- Em.Object.create({isDefault: false})
- ]);
- installerStep7Controller.reopen({
- content: {services: []},
- selectedConfigGroup: defaultGroup,
- selectedService: {configGroups: configGroups}
- });
- expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql(configGroups.without(cfgG));
- });
- });
- describe('#_setEditableValue', function () {
- it('shouldn\'t update config if no selectedConfigGroup', function () {
- installerStep7Controller.reopen({
- selectedConfigGroup: null
- });
- var config = Em.Object.create({isEditable: null});
- var updatedConfig = installerStep7Controller._setEditableValue(config);
- expect(updatedConfig.get('isEditable')).to.be.null;
- });
- it('should set isEditable equal to selectedGroup.isDefault if service not installed', function () {
- var isDefault = true;
- installerStep7Controller.reopen({
- installedServiceNames: [],
- selectedService: {serviceName: 'abc'},
- selectedConfigGroup: Em.Object.create({isDefault: isDefault})
- });
- var config = Em.Object.create({isEditable: null});
- var updatedConfig = installerStep7Controller._setEditableValue(config);
- expect(updatedConfig.get('isEditable')).to.equal(isDefault);
- installerStep7Controller.toggleProperty('selectedConfigGroup.isDefault');
- updatedConfig = installerStep7Controller._setEditableValue(config);
- expect(updatedConfig.get('isEditable')).to.equal(!isDefault);
- });
- Em.A([
- {
- isEditable: false,
- isReconfigurable: false,
- isDefault: true,
- e: false
- },
- {
- isEditable: true,
- isReconfigurable: true,
- isDefault: true,
- e: true
- },
- {
- isEditable: false,
- isReconfigurable: true,
- isDefault: false,
- e: false
- },
- {
- isEditable: true,
- isReconfigurable: false,
- isDefault: false,
- e: false
- }
- ]).forEach(function (test) {
- it('service installed, isEditable = ' + test.isEditable.toString() + ', isReconfigurable = ' + test.isReconfigurable.toString(), function () {
- var config = Em.Object.create({
- isReconfigurable: test.isReconfigurable,
- isEditable: test.isEditable
- });
- installerStep7Controller.reopen({
- installedServiceNames: Em.A(['a']),
- selectedService: Em.Object.create({serviceName: 'a'}),
- selectedConfigGroup: Em.Object.create({isDefault: test.isDefault})
- });
- var updateConfig = installerStep7Controller._setEditableValue(config);
- expect(updateConfig.get('isEditable')).to.equal(test.e);
- });
- });
- });
- describe('#_setOverrides', function () {
- it('shouldn\'t update config if no selectedConfigGroup', function () {
- installerStep7Controller.reopen({
- selectedConfigGroup: null
- });
- var config = Em.Object.create({overrides: null});
- var updatedConfig = installerStep7Controller._setOverrides(config, []);
- expect(updatedConfig.get('overrides')).to.be.null;
- });
- it('no overrideToAdd', function () {
- var isDefault = true,
- name = 'n1',
- config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
- overrides = Em.A([
- Em.Object.create({name: name, value: 'v1'}),
- Em.Object.create({name: name, value: 'v2'}),
- Em.Object.create({name: 'n2', value: 'v3'})
- ]);
- installerStep7Controller.reopen({
- overrideToAdd: null,
- selectedConfigGroup: Em.Object.create({
- isDefault: isDefault
- })
- });
- var updatedConfig = installerStep7Controller._setOverrides(config, overrides);
- expect(updatedConfig.get('overrides.length')).to.equal(2);
- expect(updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
- expect(updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
- });
- it('overrideToAdd exists', function () {
- var isDefault = true,
- name = 'n1',
- config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
- overrides = Em.A([
- Em.Object.create({name: name, value: 'v1'}),
- Em.Object.create({name: name, value: 'v2'}),
- Em.Object.create({name: 'n2', value: 'v3'})
- ]);
- installerStep7Controller.reopen({
- overrideToAdd: Em.Object.create({name: name}),
- selectedService: {configGroups: [Em.Object.create({name: 'n', properties: []})]},
- selectedConfigGroup: Em.Object.create({
- isDefault: isDefault,
- name: 'n'
- })
- });
- var updatedConfig = installerStep7Controller._setOverrides(config, overrides);
- expect(updatedConfig.get('overrides.length')).to.equal(3);
- expect(updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
- expect(updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
- });
- });
- describe('#switchConfigGroupConfigs', function () {
- it('if selectedConfigGroup is null, serviceConfigs shouldn\'t be changed', function () {
- installerStep7Controller.reopen({
- selectedConfigGroup: null,
- content: {services: []},
- serviceConfigs: {configs: [
- {overrides: []},
- {overrides: []}
- ]}
- });
- installerStep7Controller.switchConfigGroupConfigs();
- expect(installerStep7Controller.get('serviceConfigs.configs').everyProperty('overrides.length', 0)).to.equal(true);
- });
- it('should set configs for serviceConfigs', function () {
- var configGroups = [
- Em.Object.create({
- properties: [
- {name: 'g1', value: 'v1'},
- {name: 'g2', value: 'v2'}
- ]
- })
- ];
- sinon.stub(installerStep7Controller, '_getDisplayedConfigGroups', function () {
- return configGroups;
- });
- sinon.stub(installerStep7Controller, '_setEditableValue', function (config) {
- config.set('isEditable', true);
- return config;
- });
- installerStep7Controller.reopen({
- selectedConfigGroup: Em.Object.create({isDefault: true, name: 'g1'}),
- content: {services: []},
- selectedService: {configs: Em.A([Em.Object.create({name: 'g1', overrides: [], properties: []}), Em.Object.create({name: 'g2', overrides: []})])},
- serviceConfigs: {configs: [Em.Object.create({name: 'g1'})]}
- });
- installerStep7Controller.switchConfigGroupConfigs();
- var configs = installerStep7Controller.get('selectedService.configs');
- expect(configs.findProperty('name', 'g1').get('overrides').length).to.equal(1);
- expect(configs.findProperty('name', 'g2').get('overrides').length).to.equal(1);
- expect(configs.everyProperty('isEditable', true)).to.equal(true);
- installerStep7Controller._getDisplayedConfigGroups.restore();
- installerStep7Controller._setEditableValue.restore();
- });
- });
- describe('#selectProperService', function () {
- Em.A([
- {
- name: 'addServiceController',
- stepConfigs: [
- {selected: false, name: 'n1'},
- {selected: true, name: 'n2'},
- {selected: true, name: 'n3'}
- ],
- e: 'n2'
- },
- {
- name: 'installerController',
- stepConfigs: [
- {showConfig: false, name: 'n1'},
- {showConfig: false, name: 'n2'},
- {showConfig: true, name: 'n3'}
- ],
- e: 'n3'
- }
- ]).forEach(function (test) {
- it(test.name, function () {
- sinon.stub(installerStep7Controller, 'selectedServiceObserver', Em.K);
- installerStep7Controller.reopen({
- wizardController: Em.Object.create({
- name: test.name
- }),
- stepConfigs: test.stepConfigs
- });
- installerStep7Controller.selectProperService();
- expect(installerStep7Controller.get('selectedService.name')).to.equal(test.e);
- installerStep7Controller.selectedServiceObserver.restore();
- });
- });
- });
- describe('#setStepConfigs', function () {
- beforeEach(function () {
- installerStep7Controller.reopen({
- content: {services: []},
- wizardController: Em.Object.create({
- getDBProperty: function (key) {
- return this.get(key);
- }
- })
- });
- });
- afterEach(function () {
- App.config.renderConfigs.restore();
- });
- it('if wizard isn\'t addService, should set output of App.config.renderConfigs', function () {
- var serviceConfigs = Em.A([
- {serviceName:'HDFS', configs: []},
- {}
- ]);
- sinon.stub(App.config, 'renderConfigs', function () {
- return serviceConfigs;
- });
- installerStep7Controller.set('wizardController.name', 'installerController');
- installerStep7Controller.setStepConfigs([], []);
- expect(installerStep7Controller.get('stepConfigs')).to.eql(serviceConfigs);
- });
- it('addServiceWizard used', function () {
- var serviceConfigs = Em.A([Em.Object.create({serviceName: 'HDFS', configs: []}), Em.Object.create({serviceName: 's2'})]);
- installerStep7Controller.set('wizardController.name', 'addServiceController');
- installerStep7Controller.reopen({selectedServiceNames: ['s2']});
- sinon.stub(App.config, 'renderConfigs', function () {
- return serviceConfigs;
- });
- installerStep7Controller.setStepConfigs([], []);
- expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
- expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 's2').get('selected')).to.equal(true);
- });
- it('addServiceWizard used, HA enabled', function () {
- sinon.stub(App, 'get', function (k) {
- if (k === 'isHaEnabled') {
- return true;
- }
- return Em.get(App, k);
- });
- var serviceConfigs = Em.A([
- Em.Object.create({
- serviceName: 'HDFS',
- configs: [
- Em.Object.create({category: 'SECONDARY_NAMENODE'}),
- Em.Object.create({category: 'SECONDARY_NAMENODE'}),
- Em.Object.create({category: 'NameNode'}),
- Em.Object.create({category: 'NameNode'}),
- Em.Object.create({category: 'SECONDARY_NAMENODE'})
- ]
- }),
- Em.Object.create({serviceName: 's2'})]
- );
- installerStep7Controller.set('wizardController.name', 'addServiceController');
- installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
- sinon.stub(App.config, 'renderConfigs', function () {
- return serviceConfigs;
- });
- installerStep7Controller.setStepConfigs([], []);
- expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
- expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('selected')).to.equal(true);
- expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(5);
- App.get.restore();
- });
- it('not windows stack', function () {
- var s = sinon.stub(App, 'get');
- s.withArgs('isHadoopWindowsStack').returns(false);
- s.withArgs('isHaEnabled').returns(false);
- var serviceConfigs = Em.A([
- Em.Object.create({
- serviceName: 'HDFS',
- configs: [
- {category: 'NameNode'},
- {category: 'NameNode'}
- ]
- }),
- Em.Object.create({serviceName: 's2'})]
- );
- installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
- sinon.stub(App.config, 'renderConfigs', function () {
- return serviceConfigs;
- });
- installerStep7Controller.setStepConfigs([], []);
- expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
- s.restore();
- });
- it('windows stack', function () {
- var s = sinon.stub(App, 'get');
- s.withArgs('isHadoopWindowsStack').returns(true);
- s.withArgs('isHaEnabled').returns(false);
- var serviceConfigs = Em.A([
- Em.Object.create({
- serviceName: 'HDFS',
- configs: [
- {category: 'NameNode'},
- {category: 'NameNode'}
- ]
- }),
- Em.Object.create({serviceName: 's2'})]
- );
- installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
- installerStep7Controller.set('installedServiceNames',['HDFS', 's2', 's3']);
- sinon.stub(App.config, 'renderConfigs', function () {
- return serviceConfigs;
- });
- installerStep7Controller.setStepConfigs([], []);
- expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
- s.restore();
- });
- });
- describe('#checkHostOverrideInstaller', function () {
- beforeEach(function () {
- sinon.stub(installerStep7Controller, 'loadConfigGroups', Em.K);
- sinon.stub(installerStep7Controller, 'loadInstalledServicesConfigGroups', Em.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'],
- m: 'installedServiceNames isn\'t empty',
- e: {
- loadConfigGroups: true,
- loadInstalledServicesConfigGroups: true
- }
- }
- ]).forEach(function (test) {
- it(test.m, function () {
- sinon.stub(App, 'get', function (k) {
- if (k === 'supports.hostOverridesInstaller') return test.hostOverridesInstaller;
- return Em.get(App, k);
- });
- installerStep7Controller.reopen({installedServiceNames: test.installedServiceNames});
- installerStep7Controller.checkHostOverrideInstaller();
- if (test.e.loadConfigGroups) {
- expect(installerStep7Controller.loadConfigGroups.calledOnce).to.equal(true);
- }
- else {
- expect(installerStep7Controller.loadConfigGroups.called).to.equal(false);
- }
- if (test.e.loadInstalledServicesConfigGroups) {
- expect(installerStep7Controller.loadInstalledServicesConfigGroups.calledOnce).to.equal(true);
- }
- else {
- expect(installerStep7Controller.loadInstalledServicesConfigGroups.called).to.equal(false);
- }
- });
- });
- });
- describe('#loadStep', function () {
- beforeEach(function () {
- installerStep7Controller.reopen({
- content: {services: []},
- wizardController: Em.Object.create({
- getDBProperty: function (k) {
- return this.get(k);
- }
- })
- });
- sinon.stub(App.config, 'mergePreDefinedWithStored', Em.K);
- sinon.stub(App.config, 'addAdvancedConfigs', Em.K);
- sinon.stub(App.config, 'fileConfigsIntoTextarea', Em.K);
- sinon.stub(installerStep7Controller, 'clearStep', Em.K);
- sinon.stub(installerStep7Controller, 'getConfigTags', Em.K);
- sinon.stub(installerStep7Controller, 'setInstalledServiceConfigs', Em.K);
- sinon.stub(installerStep7Controller, 'resolveServiceDependencyConfigs', Em.K);
- sinon.stub(installerStep7Controller, 'setStepConfigs', Em.K);
- sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
- sinon.stub(installerStep7Controller, 'activateSpecialConfigs', Em.K);
- sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
- sinon.stub(installerStep7Controller, 'applyServicesConfigs', Em.K);
- sinon.stub(App.router, 'send', Em.K);
- });
- afterEach(function () {
- App.config.mergePreDefinedWithStored.restore();
- App.config.addAdvancedConfigs.restore();
- App.config.fileConfigsIntoTextarea.restore();
- installerStep7Controller.clearStep.restore();
- installerStep7Controller.getConfigTags.restore();
- installerStep7Controller.setInstalledServiceConfigs.restore();
- installerStep7Controller.resolveServiceDependencyConfigs.restore();
- installerStep7Controller.setStepConfigs.restore();
- installerStep7Controller.checkHostOverrideInstaller.restore();
- installerStep7Controller.activateSpecialConfigs.restore();
- installerStep7Controller.selectProperService.restore();
- installerStep7Controller.applyServicesConfigs.restore();
- App.router.send.restore();
- });
- it('should call clearStep', function () {
- installerStep7Controller.loadStep();
- expect(installerStep7Controller.clearStep.calledOnce).to.equal(true);
- });
- it('shouldn\'t do nothing if isAdvancedConfigLoaded is false', function () {
- installerStep7Controller.set('isAdvancedConfigLoaded', false);
- installerStep7Controller.loadStep();
- expect(installerStep7Controller.clearStep.called).to.equal(false);
- });
- it('should use App.config to map configs', function () {
- installerStep7Controller.loadStep();
- expect(App.config.mergePreDefinedWithStored.calledOnce).to.equal(true);
- expect(App.config.addAdvancedConfigs.calledOnce).to.equal(true);
- });
- it('should call setInstalledServiceConfigs for addServiceController', function () {
- installerStep7Controller.set('wizardController.name', 'addServiceController');
- installerStep7Controller.loadStep();
- expect(installerStep7Controller.setInstalledServiceConfigs.calledOnce).to.equal(true);
- });
- });
- describe('#applyServicesConfigs', function() {
- beforeEach(function() {
- installerStep7Controller.reopen({
- allSelectedServiceNames: []
- });
- sinon.stub(App.config, 'fileConfigsIntoTextarea', function(configs) {
- return configs;
- });
- sinon.stub(installerStep7Controller, 'resolveServiceDependencyConfigs', Em.K);
- sinon.stub(installerStep7Controller, 'loadServerSideConfigsRecommendations', function() {
- return $.Deferred().resolve();
- });
- sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
- sinon.stub(installerStep7Controller, 'activateSpecialConfigs', Em.K);
- sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
- sinon.stub(installerStep7Controller, 'setStepConfigs', Em.K);
- sinon.stub(App.router, 'send', Em.K);
- sinon.stub(App.StackService, 'find', function () {
- return {
- findProperty: function () {
- return Em.Object.create({
- isInstalled: true,
- isSelected: false
- });
- },
- filterProperty: function () {
- return [];
- }
- }
- });
- });
- afterEach(function () {
- App.config.fileConfigsIntoTextarea.restore();
- installerStep7Controller.resolveServiceDependencyConfigs.restore();
- installerStep7Controller.loadServerSideConfigsRecommendations.restore();
- installerStep7Controller.checkHostOverrideInstaller.restore();
- installerStep7Controller.activateSpecialConfigs.restore();
- installerStep7Controller.selectProperService.restore();
- installerStep7Controller.setStepConfigs.restore();
- App.router.send.restore();
- App.StackService.find.restore();
- });
- it('should run some methods' , function () {
- installerStep7Controller.applyServicesConfigs({name: 'configs'}, {name: 'storedConfigs'});
- expect(installerStep7Controller.loadServerSideConfigsRecommendations.calledOnce).to.equal(true);
- expect(installerStep7Controller.get('isRecommendedLoaded')).to.equal(true);
- expect(installerStep7Controller.setStepConfigs.calledWith({name: 'configs'}, {name: 'storedConfigs'})).to.equal(true);
- expect(installerStep7Controller.checkHostOverrideInstaller.calledOnce).to.equal(true);
- expect(installerStep7Controller.activateSpecialConfigs.calledOnce).to.equal(true);
- expect(installerStep7Controller.selectProperService.calledOnce).to.equal(true);
- });
- Em.A([
- {
- allSelectedServiceNames: ['YARN'],
- fileConfigsIntoTextarea: true,
- m: 'should run fileConfigsIntoTextarea and resolveServiceDependencyConfigs',
- resolveServiceDependencyConfigs: true
- },
- {
- allSelectedServiceNames: ['STORM'],
- resolveServiceDependencyConfigs: true,
- m: 'should run resolveServiceDependencyConfigs'
- }
- ]).forEach(function(t) {
- it(t.m, function () {
- installerStep7Controller.reopen({
- allSelectedServiceNames: t.allSelectedServiceNames
- });
- installerStep7Controller.applyServicesConfigs({name: 'configs'}, {name: 'storedConfigs'});
- if (t.fileConfigsIntoTextarea) {
- expect(App.config.fileConfigsIntoTextarea.calledWith({name: 'configs'}, 'capacity-scheduler.xml')).to.equal(true);
- } else {
- expect(App.config.fileConfigsIntoTextarea.calledOnce).to.equal(false);
- }
- if (t.resolveServiceDependencyConfigs) {
- expect(installerStep7Controller.resolveServiceDependencyConfigs.calledWith(t.allSelectedServiceNames[0], {name: 'configs'})).to.equal(true);
- } else {
- expect(installerStep7Controller.resolveServiceDependencyConfigs.calledOnce).to.equal(false);
- }
- });
- });
- });
- describe('#_updateIsEditableFlagForConfig', function () {
- beforeEach(function(){
- this.mock = sinon.stub(App, 'isAccessible');
- });
- afterEach(function () {
- this.mock.restore();
- });
- Em.A([
- {
- isAdmin: false,
- isReconfigurable: false,
- isHostsConfigsPage: true,
- defaultGroupSelected: false,
- m: 'false for non-admin users',
- e: false
- },
- {
- isAdmin: true,
- isReconfigurable: false,
- isHostsConfigsPage: true,
- defaultGroupSelected: false,
- m: 'false if defaultGroupSelected is false and isHostsConfigsPage is true',
- e: false
- },
- {
- isAdmin: true,
- isReconfigurable: false,
- isHostsConfigsPage: true,
- defaultGroupSelected: true,
- m: 'false if defaultGroupSelected is true and isHostsConfigsPage is true',
- e: false
- },
- {
- isAdmin: true,
- isReconfigurable: false,
- isHostsConfigsPage: false,
- defaultGroupSelected: false,
- m: 'false if defaultGroupSelected is false and isHostsConfigsPage is false',
- e: false
- },
- {
- isAdmin: true,
- isReconfigurable: true,
- isHostsConfigsPage: false,
- defaultGroupSelected: true,
- m: 'equal to isReconfigurable if defaultGroupSelected is true and isHostsConfigsPage is false',
- e: true
- }
- ]).forEach(function (test) {
- it(test.m, function () {
- this.mock.returns(test.isAdmin);
- installerStep7Controller.reopen({isHostsConfigsPage: test.isHostsConfigsPage});
- var serviceConfigProperty = Em.Object.create({
- isReconfigurable: test.isReconfigurable
- });
- installerStep7Controller._updateIsEditableFlagForConfig(serviceConfigProperty, test.defaultGroupSelected);
- expect(serviceConfigProperty.get('isEditable')).to.equal(test.e);
- });
- });
- });
- describe('#_updateOverridesForConfig', function () {
- it('should set empty array', function () {
- var serviceConfigProperty = Em.Object.create({
- overrides: null
- }), component = Em.Object.create();
- installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
- expect(serviceConfigProperty.get('overrides')).to.eql(Em.A([]));
- });
- it('host overrides not supported', function () {
- var serviceConfigProperty = Em.Object.create({
- overrides: [
- {value: 'new value'}
- ]
- }), component = Em.Object.create({selectedConfigGroup: {isDefault: false}});
- installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
- expect(serviceConfigProperty.get('overrides').length).to.equal(1);
- expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
- expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
- expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
- });
- it('host overrides supported', function () {
- sinon.stub(App, 'get', function (k) {
- if (k === 'supports.hostOverrides') return true;
- return Em.get(App, k);
- });
- var serviceConfigProperty = Em.Object.create({
- overrides: [
- {value: 'new value', group: Em.Object.create({name: 'n1'})}
- ]
- }),
- component = Em.Object.create({
- selectedConfigGroup: {isDefault: true},
- configGroups: Em.A([
- Em.Object.create({name: 'n1', properties: []})
- ])
- });
- installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
- App.get.restore();
- expect(serviceConfigProperty.get('overrides').length).to.equal(1);
- expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
- expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
- expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
- expect(component.get('configGroups.firstObject.properties').length).to.equal(1);
- expect(component.get('configGroups.firstObject.properties.firstObject.isEditable')).to.equal(false);
- expect(component.get('configGroups.firstObject.properties.firstObject.group')).to.be.object;
- });
- });
- describe('#setInstalledServiceConfigs', function () {
- var controller = App.WizardStep7Controller.create({
- installedServiceNames: ['HBASE', 'AMBARI_METRICS']
- }),
- serviceConfigTags = [
- {
- siteName: 'hbase-site',
- tagName: 'version1'
- },
- {
- siteName: 'ams-hbase-site',
- tagName: 'version1'
- },
- {
- siteName: 'site-without-properties',
- tagName: 'version1'
- }
- ],
- configs = [
- {
- name: 'hbase.client.scanner.caching',
- value: '1000',
- serviceName: 'HBASE',
- filename: 'hbase-site.xml'
- },
- {
- name: 'hbase.client.scanner.caching',
- value: '2000',
- serviceName: 'AMBARI_METRICS',
- filename: 'ams-hbase-site.xml'
- }
- ],
- configsByTags = [
- {
- type: 'hbase-site',
- tag: 'version2',
- properties: {
- 'hbase.client.scanner.caching': '1500'
- }
- },
- {
- type: 'ams-hbase-site',
- tag: 'version2',
- properties: {
- 'hbase.client.scanner.caching': '2500'
- }
- },
- {
- type: 'site-without-properties',
- tag: 'version1'
- }
- ],
- installedServiceNames = ['HBASE', 'AMBARI_METRICS'];
- it('should handle properties with the same name', function () {
- controller.setInstalledServiceConfigs(serviceConfigTags, configs, configsByTags, installedServiceNames);
- var properties = configs.filterProperty('name', 'hbase.client.scanner.caching');
- expect(properties).to.have.length(2);
- expect(properties.findProperty('filename', 'hbase-site.xml').value).to.equal('1500');
- expect(properties.findProperty('filename', 'hbase-site.xml').savedValue).to.equal('1500');
- expect(properties.findProperty('filename', 'ams-hbase-site.xml').value).to.equal('2500');
- expect(properties.findProperty('filename', 'ams-hbase-site.xml').savedValue).to.equal('2500');
- });
- });
- describe('#setServiceDatabaseConfigs', function () {
- var controller = App.WizardStep7Controller.create({
- installedServiceNames: ['OOZIE', 'HIVE']
- });
- var configs = [
- {
- name: 'hive_database',
- value: 'MySQL',
- serviceName: 'HIVE',
- filename: 'hbase-site.xml'
- },
- {
- name: 'oozie_database',
- value: 'MySQL',
- serviceName: 'OOZIE',
- filename: 'ams-hbase-site.xml'
- }
- ];
- it('should handle properties with the same name', function () {
- var services = Em.A([
- Em.Object.create({
- isInstalled: true,
- serviceName: 'SQOOP'
- }),
- Em.Object.create({
- isInstalled: true,
- serviceName: 'HDFS'
- })
- ]);
- controller.setServiceDatabaseConfigs(configs);
- var properties = configs.filterProperty('name', 'hive_database');
- expect(properties).to.have.length(1);
- });
- });
- describe('#getAmbariDatabaseSuccess', function () {
- var controller = App.WizardStep7Controller.create({
- stepConfigs: [
- {
- serviceName: 'HIVE',
- configs: [
- {
- name: 'hive_ambari_host',
- value: 'h0'
- }
- ]
- }
- ]
- }),
- cases = [
- {
- data: {
- hostComponents: []
- },
- mySQLServerConflict: false,
- title: 'no Ambari Server host components'
- },
- {
- data: {
- hostComponents: [
- {
- RootServiceHostComponents: {
- properties: {
- 'server.jdbc.url': 'jdbc:mysql://h0/db0?createDatabaseIfNotExist=true'
- }
- }
- }
- ]
- },
- mySQLServerConflict: true,
- title: 'Ambari MySQL Server and Hive Server are on the same host'
- },
- {
- data: {
- hostComponents: [
- {
- RootServiceHostComponents: {
- properties: {
- 'server.jdbc.url': 'jdbc:mysql://h1/db1?createDatabaseIfNotExist=true'
- }
- }
- }
- ]
- },
- mySQLServerConflict: false,
- title: 'Ambari MySQL Server and Hive Server are on different hosts'
- }
- ];
- cases.forEach(function (item) {
- it(item.title, function () {
- controller.getAmbariDatabaseSuccess(item.data);
- expect(controller.get('mySQLServerConflict')).to.equal(item.mySQLServerConflict);
- });
- });
- });
- describe('#showDatabaseConnectionWarningPopup', function () {
- var cases = [
- {
- method: 'onSecondary',
- submitButtonClicked: false,
- isRejected: true,
- title: 'Cancel button clicked'
- },
- {
- method: 'onPrimary',
- submitButtonClicked: true,
- isResolved: true,
- title: 'Proceed Anyway button clicked'
- }
- ],
- dfd,
- testObject,
- serviceNames = ['HIVE', 'OOZIE'],
- bodyMessage = 'HIVE, OOZIE';
- beforeEach(function () {
- installerStep7Controller.set('submitButtonClicked', true);
- dfd = $.Deferred(function (d) {
- d.done(function () {
- testObject.isResolved = true;
- });
- d.fail(function () {
- testObject.isRejected = true;
- })
- });
- testObject = {};
- });
- cases.forEach(function (item) {
- it(item.title, function () {
- var popup = installerStep7Controller.showDatabaseConnectionWarningPopup(serviceNames, dfd);
- expect(popup.get('body')).to.equal(Em.I18n.t('installer.step7.popup.database.connection.body').format(bodyMessage));
- popup[item.method]();
- expect(testObject.isResolved).to.equal(item.isResolved);
- expect(testObject.isRejected).to.equal(item.isRejected);
- expect(installerStep7Controller.get('submitButtonClicked')).to.equal(item.submitButtonClicked);
- });
- });
- });
- describe('#issuesFilterText', function () {
- issuesFilterCases.forEach(function (item) {
- it(item.title, function () {
- issuesFilterTestSetup(installerStep7Controller, item);
- expect(installerStep7Controller.get('issuesFilterText')).to.equal(item.issuesFilterText);
- })
- });
- });
- describe('#loadServiceTagsSuccess', function () {
- it('should create ClusterSiteToTagMap', function () {
- var params = Em.Object.create({
- serviceName: "OOZIE",
- serviceConfigsDef: Em.Object.create({
- configTypes: Em.Object.create({
- site3: true,
- site2: true,
- site1: true
- })
- })
- });
- var wizardController = Em.Object.create({
- allHosts: [
- {hostName: 'h1'},
- {hostName: 'h2'},
- {hostName: 'h3'}
- ]
- });
- installerStep7Controller.set('wizardController', wizardController);
- installerStep7Controller.set('stepConfigs', Em.A([Em.Object.create({serviceName: 'OOZIE', configs: Em.A([]) })]));
- var desired_configs = {
- site1: {
- tag: "tag1"
- },
- site2: {
- tag: "tag2"
- },
- site3: {
- tag: "tag3"
- }
- };
- var data = {
- config_groups: Em.A([Em.Object.create({
- ConfigGroup: Em.Object.create({
- tag: 'OOZIE',
- hosts: Em.A([Em.Object.create({host_name: 'h1'})]),
- id: 1,
- group_name: "",
- description: "",
- desired_configs: Em.A([Em.Object.create({
- type: '1',
- tag: 'h1'
- })])
- })
- })]),
- Clusters: {
- desired_configs: desired_configs
- }
- };
- installerStep7Controller.loadServiceTagsSuccess(data, {}, params);
- var result = installerStep7Controller.get("loadedClusterSiteToTagMap");
- expect(JSON.parse(JSON.stringify(result))).to.eql(JSON.parse(JSON.stringify({"site1":"tag1","site2":"tag2","site3":"tag3"})));
- })
- });
- describe('#issuesFilterLinkText', function () {
- issuesFilterCases.forEach(function (item) {
- it(item.title, function () {
- issuesFilterTestSetup(installerStep7Controller, item);
- expect(installerStep7Controller.get('issuesFilterLinkText')).to.equal(item.issuesFilterLinkText);
- })
- });
- });
- describe('#toggleIssuesFilter', function () {
- it('should toggle issues filter', function () {
- var issuesFilter = installerStep7Controller.get('filterColumns').findProperty('attributeName', 'hasIssues');
- issuesFilter.set('selected', false);
- installerStep7Controller.toggleIssuesFilter();
- expect(issuesFilter.get('selected')).to.be.true;
- installerStep7Controller.toggleIssuesFilter();
- expect(issuesFilter.get('selected')).to.be.false;
- });
- });
- describe('#addKerberosDescriptorConfigs', function() {
- var configs = [
- { name: 'prop1', displayName: 'Prop1' },
- { name: 'prop2', displayName: 'Prop2' },
- { name: 'prop3', displayName: 'Prop3' }
- ];
- var descriptor = [
- Em.Object.create({ name: 'prop4', filename: 'file-1'}),
- Em.Object.create({ name: 'prop1', filename: 'file-1'})
- ];
- var propertiesAttrTests = [
- {
- attr: 'isUserProperty', val: false,
- m: 'descriptor properties should not be marked as custom'
- },
- {
- attr: 'category', val: 'Advanced file-1',
- m: 'descriptor properties should be added to Advanced category'
- },
- {
- attr: 'isOverridable', val: false,
- m: 'descriptor properties should not be overriden'
- }
- ];
- propertiesAttrTests.forEach(function(test) {
- it(test.m, function() {
- installerStep7Controller.addKerberosDescriptorConfigs(configs, descriptor);
- expect(configs.findProperty('name', 'prop1')[test.attr]).to.be.eql(test.val);
- });
- });
- });
- describe('#errorsCount', function () {
- it('should ignore configs with widgets (enhanced configs)', function () {
- installerStep7Controller.reopen({selectedService: {
- configs: [
- Em.Object.create({isVisible: true, widget: Em.View, isValid: false}),
- Em.Object.create({isVisible: true, widget: Em.View, isValid: true}),
- Em.Object.create({isVisible: true, isValid: true}),
- Em.Object.create({isVisible: true, isValid: false})
- ]
- }});
- expect(installerStep7Controller.get('errorsCount')).to.equal(1);
- });
- it('should ignore configs with widgets (enhanced configs) and hidden configs', function () {
- installerStep7Controller.reopen({selectedService: {
- configs: [
- Em.Object.create({isVisible: true, widget: Em.View, isValid: false}),
- Em.Object.create({isVisible: true, widget: Em.View, isValid: true}),
- Em.Object.create({isVisible: false, isValid: false}),
- Em.Object.create({isVisible: true, isValid: true}),
- Em.Object.create({isVisible: true, isValid: false})
- ]
- }});
- expect(installerStep7Controller.get('errorsCount')).to.equal(1);
- });
- });
- describe('#restoreRecommendedConfigs', function () {
- var recommendationsConfigs = {
- site: {
- properties: {
- a: 'recommendedA',
- b: 'recommendedB'
- }
- }
- };
- var stepConfigs = [
- Em.Object.create({
- serviceName: 'srv',
- configs: [
- {name: 'a', value: '--', filename: 'site'},
- {name: 'b', value: '--', filename: 'Custom site'}
- ]
- })
- ];
- var serviceConfigProperties = [
- {name: 'a', value: 'valueA', filename: 'site'},
- {name: 'b', value: 'valueB', filename: 'Custom site'}
- ];
- beforeEach(function() {
- installerStep7Controller.reopen({
- content: {
- serviceConfigProperties: serviceConfigProperties
- },
- recommendationsConfigs: recommendationsConfigs,
- stepConfigs: stepConfigs
- });
- });
- it('should restore provided by user values', function () {
- installerStep7Controller.restoreRecommendedConfigs();
- var configs = installerStep7Controller.get('stepConfigs')[0].configs;
- expect(Em.get(configs.findProperty('name', 'a'), 'value')).to.equal('valueA');
- expect(Em.get(configs.findProperty('name', 'b'), 'value')).to.equal('valueB');
- });
- });
- describe('#_reconfigureServicesOnNnHa', function () {
- var dfsNameservices = 'some_cluster';
- Em.A([
- {
- serviceName: 'HBASE',
- configToUpdate: 'hbase.rootdir',
- oldValue: 'hdfs://nameserv:8020/apps/hbase/data',
- expectedNewValue: 'hdfs://' + dfsNameservices + '/apps/hbase/data'
- },
- {
- serviceName: 'ACCUMULO',
- configToUpdate: 'instance.volumes',
- oldValue: 'hdfs://localhost:8020/apps/accumulo/data',
- expectedNewValue: 'hdfs://' + dfsNameservices + '/apps/accumulo/data'
- }
- ]).forEach(function (test) {
- it(test.serviceName + ' ' + test.configToUpdate, function () {
- var serviceConfigs = [App.ServiceConfig.create({
- serviceName: test.serviceName,
- configs: [
- Em.Object.create({
- name: test.configToUpdate,
- value: test.oldValue
- })
- ]
- }),
- App.ServiceConfig.create({
- serviceName: 'HDFS',
- configs: [
- Em.Object.create({
- name: 'dfs.nameservices',
- value: dfsNameservices
- })
- ]
- })];
- installerStep7Controller.reopen({
- selectedServiceNames: [test.serviceName, 'HDFS']
- });
- serviceConfigs = installerStep7Controller._reconfigureServicesOnNnHa(serviceConfigs);
- expect(serviceConfigs.findProperty('serviceName', test.serviceName).configs.findProperty('name', test.configToUpdate).get('value')).to.equal(test.expectedNewValue);
- });
- });
- });
- });
|