123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481 |
- /**
- * 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('mixins/common/localStorage');
- require('controllers/wizard/step7_controller');
- var testHelpers = require('test/helpers');
- 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);
- };
- function getController() {
- return App.WizardStep7Controller.create({
- content: Em.Object.create({
- services: [],
- advancedServiceConfig: [],
- serviceConfigProperties: []
- })
- });
- }
- describe('App.InstallerStep7Controller', function () {
- beforeEach(function () {
- sinon.stub(App.config, 'setPreDefinedServiceConfigs', Em.K);
- installerStep7Controller = getController();
- App.router.nextBtnClickInProgress = false;
- });
- afterEach(function() {
- App.router.nextBtnClickInProgress = false;
- App.config.setPreDefinedServiceConfigs.restore();
- installerStep7Controller.destroy();
- });
- App.TestAliases.testAsComputedAlias(getController(), 'masterComponentHosts', 'content.masterComponentHosts', 'array');
- App.TestAliases.testAsComputedAlias(getController(), 'slaveComponentHosts', 'content.slaveGroupProperties', 'array');
- App.TestAliases.testAsComputedAnd(getController(), 'isConfigsLoaded', ['wizardController.stackConfigsLoaded', 'isAppliedConfigLoaded']);
- 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('#_createSiteToTagMap', function () {
- it('should return filtered map', function () {
- var desiredConfigs = {
- site1: {
- tag: "tag1"
- },
- site2: {
- tag: "tag2"
- },
- site3: {
- tag: "tag3"
- }
- };
- var sites = {
- site1: true,
- site3: true
- };
- var siteToTagMap = installerStep7Controller._createSiteToTagMap(desiredConfigs,sites);
- expect(siteToTagMap).to.eql({
- site1: "tag1",
- site3: "tag3"
- });
- });
- });
- describe('#checkDatabaseConnectionTest', function () {
- beforeEach(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]) })]));
- this.deffer = installerStep7Controller.checkDatabaseConnectionTest();
- });
- it('should return promise in process', function () {
- expect(this.deffer.isResolved()).to.equal(false);
- this.deffer.resolve(true);
- this.deffer.done(function(data) {
- expect(data).to.equal(true);
- });
- });
- });
- describe.skip('#submit', function () {
- beforeEach(function () {
- sinon.stub(App, 'get').withArgs('supports.preInstallChecks').returns(false);
- });
- afterEach(function () {
- App.get.restore();
- });
- it('should return false if submit disabled', function () {
- installerStep7Controller.set('isSubmitDisabled',true);
- expect(installerStep7Controller.submit()).to.be.false;
- });
- it('sumbit button should be unclicked if no configs', function () {
- installerStep7Controller.set('isSubmitDisabled',false);
- installerStep7Controller.submit();
- expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
- });
- it('if Next button is clicked multiple times before the next step renders, it must not be processed',function(){
- installerStep7Controller.submit();
- expect(App.router.send.calledWith('next')).to.equal(true);
- App.router.send.reset();
- installerStep7Controller.submit();
- expect(App.router.send.calledWith('next')).to.equal(false);
- });
- });
- 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 desiredConfigs = {
- site1: {
- tag: "tag1"
- },
- site2: {
- tag: "tag2"
- },
- site3: {
- tag: "tag3"
- }
- };
- var data = {
- Clusters: {
- desired_configs: desiredConfigs
- }
- };
- 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 () {
- it('should do ajax request for each received service name', function () {
- var serviceNames = ['s1', 's2', 's3'];
- installerStep7Controller.loadInstalledServicesConfigGroups(serviceNames);
- var args = testHelpers.filterAjaxRequests('name', 'config.tags_and_groups');
- expect(args).to.have.property('length').equal(serviceNames.length);
- });
- });
- describe('#getConfigTags', function () {
- it('should do ajax-request', function () {
- installerStep7Controller.getConfigTags();
- var args = testHelpers.findAjaxRequest('name', 'config.tags');
- expect(args).exists;
- });
- });
- 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 () {
- installerStep7Controller.checkMySQLHost();
- var args = testHelpers.findAjaxRequest('name', 'ambari.service');
- expect(args).exists;
- });
- });
- 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('#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'}
- ];
- 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'}
- ]
- })
- });
- });
- afterEach(function () {
- App.ServiceConfigGroup.find().clear();
- });
- 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);
- });
- });
- 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;
- });
- describe('no overrideToAdd', function () {
- var isDefault;
- beforeEach(function () {
- isDefault = true;
- var 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
- })
- });
- this.updatedConfig = installerStep7Controller._setOverrides(config, overrides);
- });
- it('2 overrides', function () {
- expect(this.updatedConfig.get('overrides.length')).to.equal(2);
- });
- it('each isEditable is ' + !isDefault, function () {
- expect(this.updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
- });
- it('each parentSCP.flag is `flag`', function () {
- expect(this.updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
- });
- });
- describe('overrideToAdd exists', function () {
- var isDefault = true;
- beforeEach(function () {
- var 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'
- })
- });
- this.updatedConfig = installerStep7Controller._setOverrides(config, overrides);
- });
- it('3 overrides', function () {
- expect(this.updatedConfig.get('overrides.length')).to.equal(3);
- });
- it('each isEditable is ' + !isDefault, function () {
- expect(this.updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
- });
- it('each parentSCP.flag is `flag`', function () {
- expect(this.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);
- });
- describe('should set configs for serviceConfigs', function () {
- var configGroups = [
- Em.Object.create({
- properties: [
- {name: 'g1', value: 'v1'},
- {name: 'g2', value: 'v2'}
- ]
- })
- ];
- beforeEach(function () {
- 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();
- this.configs = installerStep7Controller.get('selectedService.configs');
- });
- afterEach(function () {
- installerStep7Controller._getDisplayedConfigGroups.restore();
- installerStep7Controller._setEditableValue.restore();
- });
- it('g1 has 1 override', function () {
- expect(this.configs.findProperty('name', 'g1').get('overrides').length).to.equal(1);
- });
- it('g2 has 1 override', function () {
- expect(this.configs.findProperty('name', 'g2').get('overrides').length).to.equal(1);
- });
- it('all configs are editable', function () {
- expect(this.configs.everyProperty('isEditable', true)).to.equal(true);
- });
- });
- });
- 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) {
- describe(test.name, function () {
- beforeEach(function () {
- sinon.stub(installerStep7Controller, 'selectedServiceObserver', Em.K);
- installerStep7Controller.reopen({
- wizardController: Em.Object.create({
- name: test.name
- }),
- stepConfigs: test.stepConfigs
- });
- installerStep7Controller.selectProperService();
- });
- afterEach(function () {
- installerStep7Controller.selectedServiceObserver.restore();
- });
- it('selected service name is valid', function () {
- expect(installerStep7Controller.get('selectedService.name')).to.equal(test.e);
- });
- });
- });
- });
- describe.skip('#setStepConfigs', function () {
- var serviceConfigs;
- beforeEach(function () {
- installerStep7Controller.reopen({
- content: {services: []},
- wizardController: Em.Object.create({
- getDBProperty: function (key) {
- return this.get(key);
- }
- })
- });
- sinon.stub(installerStep7Controller, 'renderConfigs', function () {
- return serviceConfigs;
- });
- this.stub = sinon.stub(App, 'get');
- });
- afterEach(function () {
- installerStep7Controller.renderConfigs.restore();
- App.get.restore();
- });
- it('if wizard isn\'t addService, should set output of installerStep7Controller.renderConfigs', function () {
- serviceConfigs = Em.A([
- {serviceName:'HDFS', configs: []},
- {}
- ]);
- installerStep7Controller.set('wizardController.name', 'installerController');
- installerStep7Controller.setStepConfigs([], []);
- expect(installerStep7Controller.get('stepConfigs')).to.eql(serviceConfigs);
- });
- it('addServiceWizard used', function () {
- serviceConfigs = Em.A([Em.Object.create({serviceName: 'HDFS', configs: []}), Em.Object.create({serviceName: 's2'})]);
- installerStep7Controller.set('wizardController.name', 'addServiceController');
- installerStep7Controller.reopen({selectedServiceNames: ['s2']});
- 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 () {
- this.stub.withArgs('isHaEnabled').returns(true);
- 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']});
- 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);
- });
- it('not windows stack', function () {
- this.stub.withArgs('isHadoopWindowsStack').returns(false);
- this.stub.withArgs('isHaEnabled').returns(false);
- serviceConfigs = Em.A([
- Em.Object.create({
- serviceName: 'HDFS',
- configs: [
- {category: 'NameNode'},
- {category: 'NameNode'}
- ]
- }),
- Em.Object.create({serviceName: 's2'})]
- );
- installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
- installerStep7Controller.setStepConfigs([], []);
- expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
- });
- it('windows stack', function () {
- this.stub.withArgs('isHadoopWindowsStack').returns(true);
- this.stub.withArgs('isHaEnabled').returns(false);
- 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']);
- installerStep7Controller.setStepConfigs([], []);
- expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
- });
- });
- describe('#checkHostOverrideInstaller', function () {
- beforeEach(function () {
- sinon.stub(installerStep7Controller, 'loadConfigGroups', Em.K);
- sinon.stub(installerStep7Controller, 'loadInstalledServicesConfigGroups', Em.K);
- sinon.stub(App, 'get', function (k) {
- if (k === 'supports.hostOverridesInstaller') return false;
- return Em.get(App, 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'],
- areInstalledConfigGroupsLoaded: false,
- m: 'installedServiceNames isn\'t empty, config groups not yet loaded',
- e: {
- loadConfigGroups: true,
- loadInstalledServicesConfigGroups: true
- }
- },
- {
- installedServiceNames: ['s1', 's2', 's3'],
- areInstalledConfigGroupsLoaded: true,
- m: 'installedServiceNames isn\'t empty, config groups already loaded',
- e: {
- loadConfigGroups: true,
- loadInstalledServicesConfigGroups: false
- }
- }
- ]).forEach(function (test) {
- describe(test.m, function () {
- beforeEach(function () {
- installerStep7Controller.reopen({
- installedServiceNames: test.installedServiceNames,
- wizardController: {
- areInstalledConfigGroupsLoaded: test.areInstalledConfigGroupsLoaded
- }
- });
- installerStep7Controller.checkHostOverrideInstaller();
- });
- if (test.e.loadConfigGroups) {
- it('loadConfigGroups is called once', function () {
- expect(installerStep7Controller.loadConfigGroups.calledOnce).to.equal(true);
- });
- }
- else {
- it('loadConfigGroups is not called', function () {
- expect(installerStep7Controller.loadConfigGroups.called).to.equal(false);
- });
- }
- if (test.e.loadInstalledServicesConfigGroups) {
- it('loadInstalledServicesConfigGroups is called once', function () {
- expect(installerStep7Controller.loadInstalledServicesConfigGroups.calledOnce).to.equal(true);
- });
- }
- else {
- it('loadInstalledServicesConfigGroups is not called', function () {
- 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);
- },
- stackConfigsLoaded: true
- })
- });
- sinon.stub(installerStep7Controller, 'clearStep', Em.K);
- sinon.stub(installerStep7Controller, 'getConfigTags', Em.K);
- sinon.stub(installerStep7Controller, 'setInstalledServiceConfigs', Em.K);
- sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
- sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
- sinon.stub(installerStep7Controller, 'applyServicesConfigs', Em.K);
- sinon.stub(App.router, 'send', Em.K);
- });
- afterEach(function () {
- installerStep7Controller.clearStep.restore();
- installerStep7Controller.getConfigTags.restore();
- installerStep7Controller.setInstalledServiceConfigs.restore();
- installerStep7Controller.checkHostOverrideInstaller.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('wizardController.stackConfigsLoaded', false);
- installerStep7Controller.loadStep();
- expect(installerStep7Controller.clearStep.called).to.equal(false);
- });
- 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(installerStep7Controller, 'loadConfigRecommendations', function(c, callback) {
- return callback();
- });
- sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
- sinon.stub(installerStep7Controller, 'selectProperService', 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 [];
- }
- }
- });
- installerStep7Controller.applyServicesConfigs([{name: 'configs'}]);
- });
- afterEach(function () {
- installerStep7Controller.loadConfigRecommendations.restore();
- installerStep7Controller.checkHostOverrideInstaller.restore();
- installerStep7Controller.selectProperService.restore();
- App.router.send.restore();
- App.StackService.find.restore();
- });
- it('loadConfigRecommendations is called once' , function () {
- expect(installerStep7Controller.loadConfigRecommendations.calledOnce).to.equal(true);
- });
- it('isRecommendedLoaded is true' , function () {
- expect(installerStep7Controller.get('isRecommendedLoaded')).to.equal(true);
- });
- it('checkHostOverrideInstalleris called once' , function () {
- expect(installerStep7Controller.checkHostOverrideInstaller.calledOnce).to.equal(true);
- });
- it('selectProperServiceis called once' , function () {
- expect(installerStep7Controller.selectProperService.calledOnce).to.equal(true);
- });
- });
- describe('#removeHawqStandbyHostAddressConfig', function() {
- installerStep7Controller = App.WizardStep7Controller.create({
- content: Em.Object.create({}),
- });
- var testHawqSiteConfigs = [
- {
- name: 'hawq_standby_address_host',
- value: 'h2'
- },
- {
- name: 'hawq_master_address_host',
- value: 'h1'
- }
- ];
- var oldHawqSiteLength = testHawqSiteConfigs.length;
- it('hawq_standby_address_host should be removed on single node cluster', function() {
- var hawqSiteConfigs = testHawqSiteConfigs.slice();
- installerStep7Controller.set('content.hosts', {'hostname': 'h1'});
- var updatedHawqSiteConfigs = installerStep7Controller.updateHawqConfigs(hawqSiteConfigs);
- expect(updatedHawqSiteConfigs.length).to.be.equal(oldHawqSiteLength-1);
- expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_standby_address_host')).to.not.exist;
- expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_master_address_host').value).to.be.equal('h1');
- });
- it('hawq_standby_address_host should not be removed on multi node clusters', function() {
- var hawqSiteConfigs = testHawqSiteConfigs.slice();
- installerStep7Controller.set('content.hosts', Em.A([{'hostname': 'h1'}, {'hostname': 'h2'}]));
- var updatedHawqSiteConfigs = installerStep7Controller.updateHawqConfigs(hawqSiteConfigs);
- expect(updatedHawqSiteConfigs.length).to.be.equal(oldHawqSiteLength);
- expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_standby_address_host').value).to.be.equal('h2');
- expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_master_address_host').value).to.be.equal('h1');
- });
- });
- describe('#_updateIsEditableFlagForConfig', function () {
- 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
- }
- ]).forEach(function (test) {
- it(test.m, function () {
- 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([]));
- });
- describe('host overrides not supported', function () {
- var serviceConfigProperty = Em.Object.create({
- overrides: [
- {value: 'new value'}
- ]
- });
- var component = Em.Object.create({selectedConfigGroup: {isDefault: false}});
- beforeEach(function () {
- installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
- });
- it('there is 1 override', function () {
- expect(serviceConfigProperty.get('overrides').length).to.equal(1);
- });
- it('override value is valid', function () {
- expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
- });
- it('override is not original SCP', function () {
- expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
- });
- it('override is linked to parent', function () {
- expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
- });
- });
- describe('host overrides supported', function () {
- var serviceConfigProperty;
- var component;
- beforeEach(function () {
- sinon.stub(App, 'get', function (k) {
- if (k === 'supports.hostOverrides') return true;
- return Em.get(App, k);
- });
- 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);
- });
- afterEach(function () {
- App.get.restore();
- });
- it('there is 1 override', function () {
- expect(serviceConfigProperty.get('overrides').length).to.equal(1);
- });
- it('override.value is valid', function () {
- expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
- });
- it('override is not original SCP', function () {
- expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
- });
- it('override.parentSCP is valid', function () {
- expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
- });
- it('there is 1 property in the config group', function () {
- expect(component.get('configGroups.firstObject.properties').length).to.equal(1);
- });
- it('property in the config group is not editable', function () {
- expect(component.get('configGroups.firstObject.properties.firstObject.isEditable')).to.equal(false);
- });
- it('property in the config group is linked to it', function () {
- expect(component.get('configGroups.firstObject.properties.firstObject.group')).to.be.object;
- });
- });
- });
- describe('#setInstalledServiceConfigs', function () {
- var controller = App.WizardStep7Controller.create({
- installedServiceNames: ['HBASE', 'AMBARI_METRICS']
- }),
- 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'];
- describe('should handle properties with the same name', function () {
- var properties;
- beforeEach(function () {
- controller.setInstalledServiceConfigs(configs, configsByTags, installedServiceNames);
- properties = configs.filterProperty('name', 'hbase.client.scanner.caching');
- });
- it('there are 2 properties', function () {
- expect(properties).to.have.length(2);
- });
- it('hbase-site/ value is valid', function () {
- expect(properties.findProperty('filename', 'hbase-site.xml').value).to.equal('1500');
- });
- it('hbase-site/ savedValue is valid', function () {
- expect(properties.findProperty('filename', 'hbase-site.xml').savedValue).to.equal('1500');
- });
- it('ams-hbase-site/ value is valid', function () {
- expect(properties.findProperty('filename', 'ams-hbase-site.xml').value).to.equal('2500');
- });
- it('ams-hbase-site/ savedValue is valid', function () {
- expect(properties.findProperty('filename', 'ams-hbase-site.xml').savedValue).to.equal('2500');
- });
- });
- });
- describe('#getAmbariDatabaseSuccess', function () {
- var controller = App.WizardStep7Controller.create({
- stepConfigs: [
- {
- serviceName: 'HIVE',
- configs: [
- {
- name: 'javax.jdo.option.ConnectionURL',
- value: 'jdbc:mysql://h0/db_name?createDatabaseIfNotExist=true',
- filename: 'hive-site.xml'
- }
- ]
- }
- ]
- }),
- cases = [
- {
- data: {
- hostComponents: []
- },
- mySQLServerConflict: false,
- title: 'no Ambari Server host components'
- },
- {
- data: {
- hostComponents: [
- {
- RootServiceHostComponents: {
- host_name: 'h0',
- properties: {
- 'server.jdbc.database': 'postgres'
- }
- }
- }
- ]
- },
- mySQLServerConflict: false,
- title: 'Ambari MySQL Server and Hive Server are on the same host but different database types'
- },
- {
- data: {
- hostComponents: [
- {
- RootServiceHostComponents: {
- host_name: 'h0',
- properties: {
- 'server.jdbc.database': 'mysql'
- }
- }
- }
- ]
- },
- mySQLServerConflict: true,
- title: 'Ambari MySQL Server and Hive Server are on the same host'
- },
- {
- data: {
- hostComponents: [
- {
- RootServiceHostComponents: {
- host_name: 'h1',
- properties: {
- 'server.jdbc.database': 'mysql'
- }
- }
- }
- ]
- },
- 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) {
- describe(item.title, function () {
- var popup;
- beforeEach(function () {
- popup = installerStep7Controller.showDatabaseConnectionWarningPopup(serviceNames, dfd);
- });
- it('popup body is valid', function () {
- expect(popup.get('body')).to.equal(Em.I18n.t('installer.step7.popup.database.connection.body').format(bodyMessage));
- });
- it('after ' + item.method + ' execution', function () {
- 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.skip('#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 desiredConfigs = {
- 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: desiredConfigs
- }
- };
- 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;
- });
- it('selected service should be changed', function () {
- installerStep7Controller.setProperties({
- selectedService: {
- errorCount: 0,
- configGroups: []
- },
- stepConfigs: [
- {
- errorCount: 1,
- configGroups: []
- },
- {
- errorCount: 2,
- configGroups: []
- }
- ]
- });
- installerStep7Controller.toggleIssuesFilter();
- expect(installerStep7Controller.get('selectedService')).to.eql({
- errorCount: 1,
- configGroups: []
- });
- });
- });
- 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('#addHawqConfigsOnNnHa', function () {
- var configs = [
- {
- id: 'dfs.nameservices__hdfs-site',
- description: 'dfs.nameservices__hdfs-site',
- displayName: 'dfs.nameservices',
- displayType: 'string',
- name: 'dfs.nameservices',
- value: 'haservice',
- recommendedValue: 'haservice'
- },
- {
- id: 'dfs.ha.namenodes.haservice__hdfs-site',
- description: 'dfs.ha.namenodes.haservice__hdfs-site',
- displayName: 'dfs.ha.namenodes.haservice',
- displayType: 'string',
- name: 'dfs.ha.namenodes.haservice',
- value: 'nn1,nn2',
- recommendedValue: 'nn1,nn2'
- },
- {
- id: 'dfs.namenode.rpc-address.haservice.nn1__hdfs-site',
- description: 'dfs.namenode.rpc-address.haservice.nn1__hdfs-site',
- displayName: 'dfs.namenode.rpc-address.haservice.nn1',
- displayType: 'string',
- name: 'dfs.namenode.rpc-address.haservice.nn1',
- value: 'c6401.ambari.apache.org:8020',
- recommendedValue: 'c6401.ambari.apache.org:8020'
- },
- {
- id: 'dfs.namenode.rpc-address.haservice.nn2__hdfs-site',
- description: 'dfs.namenode.rpc-address.haservice.nn2__hdfs-site',
- displayName: 'dfs.namenode.rpc-address.haservice.nn2',
- displayType: 'string',
- name: 'dfs.namenode.rpc-address.haservice.nn2',
- value: 'c6402.ambari.apache.org:8020',
- recommendedValue: 'c6402.ambari.apache.org:8020'
- },
- {
- id: 'dfs.namenode.http-address.haservice.nn1__hdfs-site',
- description: 'dfs.namenode.http-address.haservice.nn1__hdfs-site',
- displayName: 'dfs.namenode.http-address.haservice.nn1',
- displayType: 'string',
- name: 'dfs.namenode.http-address.haservice.nn1',
- value: 'c6401.ambari.apache.org:50070',
- recommendedValue: 'c6401.ambari.apache.org:50070'
- },
- {
- id: 'dfs.namenode.http-address.haservice.nn2__hdfs-site',
- description: 'dfs.namenode.http-address.haservice.nn2__hdfs-site',
- displayName: 'dfs.namenode.http-address.haservice.nn2',
- displayType: 'string',
- name: 'dfs.namenode.http-address.haservice.nn2',
- value: 'c6402.ambari.apache.org:50070',
- recommendedValue: 'c6402.ambari.apache.org:50070'
- }
- ];
- var oldConfigs = configs.slice();
- it('should copy properties from hdfs-site to hdfs-client for HAWQ', function() {
- installerStep7Controller.addHawqConfigsOnNnHa(configs);
- // ensure 6 new configs were added
- expect(configs.length).to.be.equal(oldConfigs.length + 6);
- });
- describe('find the same property in hdfs-client for HAWQ and see if attribute value matches with the corresponding property\'s attribute value in hdfs-site', function () {
- oldConfigs.forEach(function(property) {
- var id = property.name + '__hdfs-client';
- it(id, function () {
- expect(configs.findProperty('id', id).description).to.be.equal(property.description);
- expect(configs.findProperty('id', id).displayName).to.be.equal(property.displayName);
- expect(configs.findProperty('id', id).value).to.be.equal(property.value);
- expect(configs.findProperty('id', id).recommendedValue).to.be.equal(property.recommendedValue);
- });
- });
- });
- });
- describe('#addHawqConfigsOnRMHa', function () {
- var configs = [
- {
- id: 'yarn.resourcemanager.hostname.rm1__yarn-site',
- name: 'yarn.resourcemanager.hostname.rm1',
- value: 'c6401.ambari.apache.org',
- recommendedValue: 'c6401.ambari.apache.org'
- },
- {
- id: 'yarn.resourcemanager.hostname.rm2__yarn-site',
- name: 'yarn.resourcemanager.hostname.rm2',
- value: 'c6402.ambari.apache.org',
- recommendedValue: 'c6402.ambari.apache.org'
- }
- ];
- beforeEach(function () {
- this.inputConfigsCount = configs.length;
- installerStep7Controller.addHawqConfigsOnRMHa(configs);
- this.yarnRmDetails = configs.findProperty('id', 'yarn.resourcemanager.ha__yarn-client');
- this.yarnRmSchedulerDetails = configs.findProperty('id', 'yarn.resourcemanager.scheduler.ha__yarn-client');
- });
- it('should update properties in yarn-client for HAWQ if yarn ha is enabled', function() {
- var noOfConfigsAdded = 2;
- expect(configs.length).to.be.equal(this.inputConfigsCount + noOfConfigsAdded);
- });
- it('yarn.resourcemanager.ha__yarn-client', function() {
- var expectedYarnRmHaValue = 'c6401.ambari.apache.org:8032,c6402.ambari.apache.org:8032';
- expect(this.yarnRmDetails.value).to.be.equal(expectedYarnRmHaValue);
- expect(this.yarnRmDetails.recommendedValue).to.be.equal(expectedYarnRmHaValue);
- expect(this.yarnRmDetails.displayName).to.be.equal('yarn.resourcemanager.ha');
- expect(this.yarnRmDetails.description).to.be.equal('Comma separated yarn resourcemanager host addresses with port');
- });
- it('yarn.resourcemanager.scheduler.ha__yarn-client', function() {
- var expectedYarnRmSchedulerValue = 'c6401.ambari.apache.org:8030,c6402.ambari.apache.org:8030';
- expect(this.yarnRmSchedulerDetails.value).to.be.equal(expectedYarnRmSchedulerValue);
- expect(this.yarnRmSchedulerDetails.recommendedValue).to.be.equal(expectedYarnRmSchedulerValue);
- expect(this.yarnRmSchedulerDetails.displayName).to.be.equal('yarn.resourcemanager.scheduler.ha');
- expect(this.yarnRmSchedulerDetails.description).to.be.equal('Comma separated yarn resourcemanager scheduler addresses with port');
- });
- });
- describe('#errorsCount', function () {
- it('should ignore configs with widgets (enhanced configs)', function () {
- installerStep7Controller.reopen({selectedService: Em.Object.create({
- configsWithErrors: Em.A([
- Em.Object.create({widget: {}}),
- Em.Object.create({widget: null})
- ])
- })
- });
- expect(installerStep7Controller.get('errorsCount')).to.equal(1);
- });
- });
- 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'
- },
- {
- serviceName: 'HAWQ',
- configToUpdate: 'hawq_dfs_url',
- oldValue: 'localhost:8020/hawq_data',
- expectedNewValue: dfsNameservices + '/hawq_data'
- }
- ]).forEach(function (test) {
- 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
- })
- ]
- })];
- it(test.serviceName + ' ' + test.configToUpdate, function () {
- 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);
- });
- });
- });
- describe('#showOozieDerbyWarning', function() {
- var controller;
- beforeEach(function() {
- controller = App.WizardStep7Controller.create({});
- sinon.stub(App.ModalPopup, 'show', Em.K);
- });
- afterEach(function() {
- App.ModalPopup.show.restore();
- });
- Em.A([
- {
- selectedServiceNames: ['HDFS', 'OOZIE'],
- databaseType: Em.I18n.t('installer.step7.oozie.database.new'),
- e: true,
- m: 'Oozie selected with derby database, warning popup should be shown'
- },
- {
- selectedServiceNames: ['HDFS'],
- databaseType: Em.I18n.t('installer.step7.oozie.database.new'),
- e: false,
- m: 'Oozie not selected warning popup should be skipped'
- },
- {
- selectedServiceNames: ['HDFS', 'OOZIE'],
- databaseType: 'New Mysql Database',
- e: false,
- m: 'Oozie selected, mysql database used, warning popup should be sk'
- }
- ]).forEach(function(test) {
- describe(test.m, function() {
- beforeEach(function () {
- sinon.stub(App.config, 'findConfigProperty').returns(Em.Object.create({ value: test.databaseType}));
- controller.reopen({
- selectedServiceNames: test.selectedServiceNames
- });
- controller.showOozieDerbyWarningPopup(Em.K);
- });
- afterEach(function () {
- App.config.findConfigProperty.restore();
- });
- it('modal popup is shown needed number of times', function () {
- expect(App.ModalPopup.show.calledOnce).to.equal(test.e);
- });
- });
- });
- });
- describe('#addHostNamesToConfigs', function() {
- beforeEach(function () {
- sinon.stub(App.StackServiceComponent, 'find', function () {
- return Em.Object.create({
- id: 'NAMENODE',
- displayName: 'NameNode'
- });
- });
- });
- afterEach(function () {
- App.StackServiceComponent.find.restore();
- });
- it('should not create duplicate configs', function () {
- var serviceConfig = Em.Object.create({
- configs: [],
- serviceName: 'HDFS',
- configCategories: [
- {
- showHost: true,
- name: 'NAMENODE'
- }
- ]
- });
- var masterComponents = [
- {component: 'NAMENODE', hostName: 'h1'}
- ];
- var slaveComponents = [];
- installerStep7Controller.addHostNamesToConfigs(serviceConfig, masterComponents, slaveComponents);
- expect(serviceConfig.get('configs').filterProperty('name', 'namenode_host').length).to.equal(1);
- installerStep7Controller.addHostNamesToConfigs(serviceConfig, masterComponents, slaveComponents);
- expect(serviceConfig.get('configs').filterProperty('name', 'namenode_host').length).to.equal(1);
- });
- });
- describe('#resolveHiveMysqlDatabase', function () {
- beforeEach(function () {
- installerStep7Controller.get('content').setProperties({
- services: Em.A([
- Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false})
- ])
- });
- installerStep7Controller.setProperties({
- stepConfigs: Em.A([
- Em.Object.create({serviceName: 'HIVE', configs: [{name: 'hive_database', value: 'New MySQL Database'}]})
- ]),
- mySQLServerConflict: true
- });
- sinon.stub(installerStep7Controller, 'moveNext', Em.K);
- sinon.stub(installerStep7Controller, 'checkMySQLHost', function () {
- return $.Deferred().resolve();
- });
- sinon.spy(App.ModalPopup, 'show');
- });
- afterEach(function () {
- installerStep7Controller.moveNext.restore();
- installerStep7Controller.checkMySQLHost.restore();
- App.ModalPopup.show.restore();
- });
- it('no HIVE service', function () {
- installerStep7Controller.set('content.services', Em.A([]));
- installerStep7Controller.resolveHiveMysqlDatabase();
- expect(installerStep7Controller.moveNext.calledOnce).to.be.true;
- expect(App.ModalPopup.show.called).to.be.false;
- });
- it('if mySQLServerConflict, popup is shown', function () {
- installerStep7Controller.resolveHiveMysqlDatabase();
- expect(installerStep7Controller.moveNext.called).to.be.false;
- expect(App.ModalPopup.show.calledOnce).to.be.true;
- });
- });
- describe('#mySQLWarningHandler', function () {
- beforeEach(function () {
- installerStep7Controller.set('mySQLServerConflict', true);
- sinon.spy(App.ModalPopup, 'show');
- sinon.stub(App.router, 'get').returns({gotoStep: Em.K});
- sinon.stub(App.router.get(), 'gotoStep', Em.K);
- });
- afterEach(function () {
- App.ModalPopup.show.restore();
- App.router.get().gotoStep.restore();
- App.router.get.restore();
- });
- it('warning popup is shown', function () {
- installerStep7Controller.mySQLWarningHandler();
- expect(App.ModalPopup.show.calledOnce).to.be.true;
- });
- it('submitButtonClicked is set to false on primary click', function () {
- installerStep7Controller.mySQLWarningHandler().onPrimary();
- expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
- });
- it('second popup is shown on secondary click', function () {
- installerStep7Controller.mySQLWarningHandler().onSecondary();
- expect(App.ModalPopup.show.calledTwice).to.be.true;
- });
- it('submitButtonClicked is set to false on secondary click on the second popup', function () {
- installerStep7Controller.mySQLWarningHandler().onSecondary().onSecondary();
- expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
- });
- it('user is moved to step5 on primary click on the second popup (installerController)', function () {
- installerStep7Controller.set('content.controllerName', 'installerController');
- installerStep7Controller.mySQLWarningHandler().onSecondary().onPrimary();
- expect(App.router.get('installerController').gotoStep.calledWith(5, true)).to.be.true;
- });
- it('user is moved to step2 on primary click on the second popup (addSeviceController)', function () {
- installerStep7Controller.set('content.controllerName', 'addServiceController');
- installerStep7Controller.mySQLWarningHandler().onSecondary().onPrimary();
- expect(App.router.get('addSeviceController').gotoStep.calledWith(2, true)).to.be.true;
- });
- });
- describe('#supportsPreInstallChecks', function () {
- beforeEach(function () {
- this.stub = sinon.stub(App, 'get');
- });
- afterEach(function () {
- this.stub.restore();
- });
- Em.A([
- {preInstallChecks: true, controllerName: 'installerController', e: true},
- {preInstallChecks: true, controllerName: '', e: false},
- {preInstallChecks: false, controllerName: 'installerController', e: false},
- {preInstallChecks: false, controllerName: '', e: false}
- ]).forEach(function (test) {
- it(JSON.stringify(test), function () {
- this.stub.withArgs('supports.preInstallChecks').returns(test.preInstallChecks);
- installerStep7Controller.set('content', {controllerName: test.controllerName});
- installerStep7Controller.propertyDidChange('supportsPreInstallChecks');
- expect(installerStep7Controller.get('supportsPreInstallChecks')).to.be.equal(test.e);
- });
- });
- });
- describe('#getHash', function () {
- var stepConfigs = [
- {
- configs: [
- Em.Object.create({name: 's1c1', isFinal: true, value: 'v11'}),
- Em.Object.create({name: 's1c2', isFinal: false, value: 'v12', overrides: []}),
- Em.Object.create({name: 's1c3', isFinal: true, value: 'v13', overrides: [
- Em.Object.create({value: 'v131'})
- ]})
- ]
- },
- {
- configs: [
- Em.Object.create({name: 's2c1', isFinal: true, value: 'v21'}),
- Em.Object.create({name: 's2c2', isFinal: false, value: 'v22', overrides: []}),
- Em.Object.create({name: 's2c3', isFinal: true, value: 'v23', overrides: [
- Em.Object.create({value: 'v231'})
- ]})
- ]
- }
- ];
- beforeEach(function () {
- installerStep7Controller.set('stepConfigs', stepConfigs);
- this.hash = installerStep7Controller.getHash();
- });
- it('should map value, isFinal and overrides values', function () {
- var expected = JSON.stringify({
- s1c1: {
- value: 'v11',
- overrides: [],
- isFinal: true
- },
- s1c2: {
- value: 'v12',
- overrides: [],
- isFinal: false
- },
- s1c3: {
- value: 'v13',
- overrides: ['v131'],
- isFinal: true
- },
- s2c1: {
- value: 'v21',
- overrides: [],
- isFinal: true
- },
- s2c2: {
- value: 'v22',
- overrides: [],
- isFinal: false
- },
- s2c3: {
- value: 'v23',
- overrides: ['v231'],
- isFinal: true
- }
- });
- expect(this.hash).to.be.equal(expected);
- });
- });
- describe('#loadServiceConfigGroupOverrides', function () {
- var serviceConfigs = [
- {filename: 'f1', name: 'n1'}
- ];
- var configGroups = [
- {
- "name": "Default",
- "description": "desc",
- "isDefault": true,
- "hosts": ['h1', 'h2', 'h3'],
- "parentConfigGroup": null,
- "service": {"id": "YARN"},
- "serviceName": "YARN",
- "configSiteTags": [],
- "clusterHosts": []
- }
- ];
- var loadedGroupToOverrideSiteToTagMap = {
- Default: {
- type1: 'tag1',
- type2: 'tag2',
- type3: 'tag3'
- }
- };
- beforeEach(function () {
- installerStep7Controller.loadServiceConfigGroupOverrides(serviceConfigs, loadedGroupToOverrideSiteToTagMap, configGroups);
- this.args = testHelpers.findAjaxRequest('name', 'config.host_overrides')[0].data;
- });
- it('url params are valid', function () {
- expect(this.args.params).to.be.equal('(type=type1&tag=tag1)|(type=type2&tag=tag2)|(type=type3&tag=tag3)');
- });
- it('configKeyToConfigMap is valid', function () {
- var expected = {
- "f1": {
- "n1": {
- "filename": "f1",
- "name": "n1"
- }
- }
- };
- expect(this.args.configKeyToConfigMap).to.be.eql(expected);
- });
- describe('typeTagToGroupMap is valid', function () {
- it('type1///tag1', function () {
- var expected = {
- "name": "Default",
- "description": "desc",
- "isDefault": true,
- "hosts": [
- "h1",
- "h2",
- "h3"
- ],
- "parentConfigGroup": null,
- "service": {
- "id": "YARN"
- },
- "serviceName": "YARN",
- "configSiteTags": [],
- "clusterHosts": []
- };
- expect(this.args.typeTagToGroupMap['type1///tag1']).to.be.eql(expected);
- });
- it('type2///tag2', function () {
- var expected = {
- "name": "Default",
- "description": "desc",
- "isDefault": true,
- "hosts": [
- "h1",
- "h2",
- "h3"
- ],
- "parentConfigGroup": null,
- "service": {
- "id": "YARN"
- },
- "serviceName": "YARN",
- "configSiteTags": [],
- "clusterHosts": []
- };
- expect(this.args.typeTagToGroupMap['type2///tag2']).to.be.eql(expected);
- });
- it('type3///tag3', function () {
- var expected = {
- "name": "Default",
- "description": "desc",
- "isDefault": true,
- "hosts": [
- "h1",
- "h2",
- "h3"
- ],
- "parentConfigGroup": null,
- "service": {
- "id": "YARN"
- },
- "serviceName": "YARN",
- "configSiteTags": [],
- "clusterHosts": []
- };
- expect(this.args.typeTagToGroupMap['type3///tag3']).to.be.eql(expected);
- });
- });
- it('serviceConfigs is valid', function () {
- var expected = [
- {
- "filename": "f1",
- "name": "n1"
- }
- ];
- expect(this.args.serviceConfigs).to.be.eql(expected);
- });
- });
- describe('#updateHostOverrides', function () {
- var configProperty;
- var storedConfigProperty;
- beforeEach(function () {
- configProperty = Em.Object.create({});
- storedConfigProperty = {
- overrides: [
- {value: 'v1'}
- ]
- };
- installerStep7Controller.updateHostOverrides(configProperty, storedConfigProperty);
- });
- it('override is valid', function () {
- var override = configProperty.get('overrides.0');
- expect(override.get('value')).to.be.equal('v1');
- expect(override.get('isOriginalSCP')).to.be.false;
- expect(override.get('parentSCP')).to.be.eql(configProperty);
- });
- });
- describe('#allowUpdateProperty', function () {
- it('true if it is installer', function () {
- installerStep7Controller.set('wizardController', {name: 'installerController'});
- expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.true;
- });
- it('true if it is parentProperties are not empty', function () {
- installerStep7Controller.set('wizardController', {name: 'some'});
- expect(installerStep7Controller.allowUpdateProperty([{}], '', '')).to.be.true;
- });
- describe('#addServiceController', function () {
- beforeEach(function () {
- installerStep7Controller.set('wizardController', {name: 'addServiceController'});
- this.stub = sinon.stub(App.configsCollection, 'getConfigByName');
- sinon.stub(App.config, 'getServiceByConfigType', function (type) {
- return Em.Object.create({serviceName: type === 't1' ? 's1' : 's2'});
- })
- });
- afterEach(function () {
- App.configsCollection.getConfigByName.restore();
- App.config.getServiceByConfigType.restore();
- });
- it('stackProperty does not exist', function () {
- this.stub.returns(null);
- expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.true;
- });
- it('installedServices does not contain stackProperty.serviceName', function () {
- this.stub.returns({serviceName: 's1'});
- installerStep7Controller.set('installedServices', {});
- expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.true;
- });
- it('stackProperty.propertyDependsOn is empty', function () {
- installerStep7Controller.reopen({installedServices: {s1: true}});
- this.stub.returns({serviceName: 's1', propertyDependsOn: []});
- expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.false;
- });
- it('stackProperty.propertyDependsOn is not empty', function () {
- installerStep7Controller.reopen({installedServices: {s1: true}});
- this.stub.returns({serviceName: 's1', propertyDependsOn: [
- {type: 't1'},
- {type: 't2'}
- ]});
- expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.true;
- });
- it('stackProperty.propertyDependsOn is not empty (2)', function () {
- installerStep7Controller.reopen({installedServices: {s1: true}});
- this.stub.returns({serviceName: 's1', propertyDependsOn: [
- {type: 't1'},
- {type: 't1'}
- ]});
- expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.false;
- });
- });
- it('true if it is not installer or addService', function () {
- installerStep7Controller.set('wizardController', {name: 'some'});
- expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.true;
- });
- });
- describe('#loadServiceConfigGroupOverridesSuccess', function () {
- var data = {
- items: [
- {
- type: 'type1',
- tag: 'tag1',
- properties: {
- p1: 'v1',
- p3: 'v3'
- },
- properties_attributes: {
- final: {
- p1: true,
- p3: true
- }
- }
- },
- {
- type: 'type2',
- tag: 'tag1',
- properties: {
- p2: 'v2',
- p4: 'v4'
- },
- properties_attributes: {}
- }
- ]
- };
- var params;
- beforeEach(function () {
- params = {
- serviceConfigs: [],
- typeTagToGroupMap: {
- 'type1///tag1': Em.Object.create({
- name: 't1t1'
- }),
- 'type2///tag1': Em.Object.create({
- name: 't2t1'
- })
- },
- configKeyToConfigMap: {
- type1: {},
- type2: {
- p4: {}
- }
- }
- };
- sinon.stub(installerStep7Controller, 'onLoadOverrides', Em.K);
- sinon.stub(App.config, 'getOriginalFileName', function (type) {return type;});
- sinon.stub(App.config, 'formatPropertyValue', function (serviceConfigProperty, originalValue) {
- return Em.isNone(originalValue) ? Em.get(serviceConfigProperty, 'value') : originalValue;
- });
- installerStep7Controller.loadServiceConfigGroupOverridesSuccess(data, {}, params);
- this.serviceConfigs = installerStep7Controller.onLoadOverrides.args[0][0];
- });
- afterEach(function () {
- installerStep7Controller.onLoadOverrides.restore();
- App.config.getOriginalFileName.restore();
- App.config.formatPropertyValue.restore();
- });
- it('type2/p4 is mapped to the params.configKeyToConfigMap', function () {
- expect(params).to.have.deep.property('configKeyToConfigMap.type2.p4').that.is.an('object').with.deep.property('overrides');
- });
- it('type2/p4 has 1 override', function () {
- expect(params.configKeyToConfigMap.type2.p4.overrides).to.have.property('length').equal(1);
- });
- it('type2/p4 override is valid', function () {
- var override = params.configKeyToConfigMap.type2.p4.overrides[0];
- expect(override.value).to.be.equal('v4');
- expect(override.group.name).to.be.equal('t2t1');
- expect(override.isFinal).to.be.false;
- });
- it('onLoadOverrides is called for 3 configs', function () {
- expect(this.serviceConfigs).to.have.property('length').equal(3);
- });
- it('serviceConfigs ids are valid', function () {
- expect(this.serviceConfigs.mapProperty('id')).to.be.eql(['p1__type1', 'p3__type1', 'p2__type2']);
- });
- it('serviceConfigs groups are valid', function () {
- expect(this.serviceConfigs.mapProperty('group.name')).to.be.eql(['t1t1', 't1t1', 't2t1']);
- });
- it('serviceConfigs filenames are valid', function () {
- expect(this.serviceConfigs.mapProperty('filename')).to.be.eql(['type1', 'type1', 'type2']);
- });
- });
- });
|