12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401 |
- /**
- * 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('controllers/main/host/details');
- require('models/service');
- require('models/host_component');
- require('models/host_stack_version');
- var batchUtils = require('utils/batch_scheduled_requests');
- var hostsManagement = require('utils/hosts');
- var controller;
- describe('App.MainHostDetailsController', function () {
- beforeEach(function () {
- sinon.stub(App.ajax, 'send').returns({
- then: Em.K,
- complete: Em.K
- });
- controller = App.MainHostDetailsController.create(App.InstallComponent, {
- content: Em.Object.create({
- hostComponents: []
- })
- });
- });
- afterEach(function () {
- App.ajax.send.restore();
- });
- describe('#routeHome()', function () {
- it('transiotion to dashboard', function () {
- sinon.stub(App.router, 'transitionTo', Em.K);
- controller.routeHome();
- expect(App.router.transitionTo.calledWith('main.dashboard.index')).to.be.true;
- App.router.transitionTo.restore();
- });
- });
- describe('#startComponent()', function () {
- it('call sendComponentCommand', function () {
- var event = {
- context: Em.Object.create({
- displayName: 'comp'
- })
- };
- sinon.stub(App, 'showConfirmationPopup', function (callback) {
- callback();
- });
- sinon.stub(controller, 'sendComponentCommand');
- controller.startComponent(event);
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- expect(controller.sendComponentCommand.calledWith(Em.Object.create({
- displayName: 'comp'
- })), Em.I18n.t('requestInfo.startHostComponent') + " comp", App.HostComponentStatus.started).to.be.true;
- App.showConfirmationPopup.restore();
- controller.sendComponentCommand.restore();
- });
- });
- describe('#stopComponent()', function () {
- beforeEach(function () {
- sinon.stub(App, 'showConfirmationPopup', function (callback) {
- callback();
- });
- sinon.stub(controller, 'checkNnLastCheckpointTime', function (callback) {
- callback();
- });
- sinon.stub(controller, 'sendComponentCommand');
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- controller.sendComponentCommand.restore();
- controller.checkNnLastCheckpointTime.restore();
- });
- it('call sendComponentCommand', function () {
- var event = {
- context: Em.Object.create({
- displayName: 'comp'
- })
- };
- controller.stopComponent(event);
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- expect(controller.sendComponentCommand.calledWith(Em.Object.create({
- displayName: 'comp'
- })), Em.I18n.t('requestInfo.stopHostComponent') + " comp", App.HostComponentStatus.stopped).to.be.true;
- });
- it('stop NN, should check last NN checkpoint before stop', function () {
- var event = {
- context: Em.Object.create({
- displayName: 'NameNode',
- componentName: 'NAMENODE'
- })
- };
- controller.stopComponent(event);
- expect(controller.checkNnLastCheckpointTime.calledOnce).to.be.true;
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- expect(controller.sendComponentCommand.calledWith(event.context, Em.I18n.t('requestInfo.stopHostComponent') + " NameNode", App.HostComponentStatus.stopped)).to.be.true;
- });
- });
- describe("#pullNnCheckPointTime()", function() {
- it("", function() {
- controller.pullNnCheckPointTime('host1');
- expect(App.ajax.send.calledWith({
- name: 'common.host_component.getNnCheckPointTime',
- sender: controller,
- data: {
- host: 'host1'
- },
- success: 'parseNnCheckPointTime'
- })).to.be.true;
- });
- });
- describe('#sendComponentCommand()', function () {
- it('single component', function () {
- controller.set('content.hostName', 'host1');
- var component = Em.Object.create({
- service: {serviceName: 'S1'},
- componentName: 'COMP1'
- });
- controller.sendComponentCommand(component, {}, 'state');
- expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.host.host_component.update');
- expect(App.ajax.send.getCall(0).args[0].data).to.be.eql({
- "hostName": "host1",
- "context": {},
- "component": Em.Object.create({
- service: {serviceName: 'S1'},
- componentName: 'COMP1'
- }),
- "HostRoles": {
- "state": "state"
- },
- "componentName": "COMP1",
- "serviceName": "S1"
- });
- });
- it('multiple component', function () {
- controller.set('content.hostName', 'host1');
- var component = [
- Em.Object.create({
- service: {serviceName: 'S1'},
- componentName: 'COMP1'
- }),
- Em.Object.create({
- service: {serviceName: 'S1'},
- componentName: 'COMP2'
- })
- ];
- controller.sendComponentCommand(component, {}, 'state');
- expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.host.host_components.update');
- expect(App.ajax.send.getCall(0).args[0].data).to.be.eql({
- "hostName": "host1",
- "context": {},
- "component": [
- Em.Object.create({
- service: {serviceName: 'S1'},
- componentName: 'COMP1'
- }),
- Em.Object.create({
- service: {serviceName: 'S1'},
- componentName: 'COMP2'
- })
- ],
- "HostRoles": {
- "state": "state"
- },
- "query": "HostRoles/component_name.in(COMP1,COMP2)"
- });
- });
- });
- describe('#sendComponentCommandSuccessCallback()', function () {
- beforeEach(function () {
- sinon.stub(controller, 'mimicWorkStatusChange', Em.K);
- sinon.stub(controller, 'showBackgroundOperationsPopup', Em.K);
- });
- afterEach(function () {
- controller.showBackgroundOperationsPopup.restore();
- controller.mimicWorkStatusChange.restore();
- });
- it('testMode, starting component', function () {
- var params = {
- component: Em.Object.create({}),
- HostRoles: {
- state: App.HostComponentStatus.started
- }
- };
- App.set('testMode', true);
- controller.sendComponentCommandSuccessCallback({}, {}, params);
- expect(controller.mimicWorkStatusChange.calledWith(Em.Object.create({
- workStatus: App.HostComponentStatus.starting
- }), App.HostComponentStatus.starting, App.HostComponentStatus.started)).to.be.true;
- expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
- });
- it('testMode, stopping component', function () {
- var params = {
- component: Em.Object.create({}),
- HostRoles: {
- state: App.HostComponentStatus.stopped
- }
- };
- App.set('testMode', true);
- controller.sendComponentCommandSuccessCallback({}, {}, params);
- expect(controller.mimicWorkStatusChange.calledWith(Em.Object.create({
- workStatus: App.HostComponentStatus.stopping
- }), App.HostComponentStatus.stopping, App.HostComponentStatus.stopped)).to.be.true;
- expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
- });
- it('testMode, stopping component', function () {
- var params = {
- component: Em.Object.create({}),
- HostRoles: {
- state: App.HostComponentStatus.stopped
- }
- };
- App.set('testMode', false);
- controller.sendComponentCommandSuccessCallback({}, {}, params);
- expect(controller.mimicWorkStatusChange.called).to.be.false;
- expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
- });
- });
- describe('#ajaxErrorCallback()', function () {
- it('call mainServiceItemController.ajaxErrorCallback', function () {
- sinon.stub(controller, 'ajaxErrorCallback', Em.K);
- controller.ajaxErrorCallback('request', 'ajaxOptions', 'error', 'opt', 'params');
- expect(controller.ajaxErrorCallback.calledWith('request', 'ajaxOptions', 'error', 'opt', 'params')).to.be.true;
- controller.ajaxErrorCallback.restore();
- });
- });
- describe('#showBackgroundOperationsPopup()', function () {
- var mock = {
- done: function (callback) {
- callback(this.initValue);
- }
- };
- var bgController = {
- showPopup: Em.K
- };
- beforeEach(function () {
- var stub = sinon.stub(App.router, 'get');
- stub.withArgs('userSettingsController').returns({
- dataLoading: function () {
- return mock;
- }
- });
- stub.withArgs('backgroundOperationsController').returns(bgController);
- sinon.spy(bgController, 'showPopup');
- sinon.spy(mock, 'done');
- });
- afterEach(function () {
- bgController.showPopup.restore();
- mock.done.restore();
- App.router.get.restore();
- });
- it('initValue is true, callback is undefined', function () {
- mock.initValue = true;
- controller.showBackgroundOperationsPopup();
- expect(mock.done.calledOnce).to.be.true;
- expect(bgController.showPopup.calledOnce).to.be.true;
- });
- it('initValue is false, callback is defined', function () {
- mock.initValue = false;
- var callback = sinon.stub();
- controller.showBackgroundOperationsPopup(callback);
- expect(mock.done.calledOnce).to.be.true;
- expect(bgController.showPopup.calledOnce).to.be.false;
- expect(callback.calledOnce).to.be.true;
- });
- });
- describe('#serviceActiveComponents', function () {
- it('No host-components', function () {
- controller.set('content', {hostComponents: []});
- expect(controller.get('serviceActiveComponents')).to.be.empty;
- });
- it('No host-components in active state', function () {
- controller.set('content', {
- hostComponents: [Em.Object.create({
- service: {
- isInPassive: true
- }
- })]
- });
- expect(controller.get('serviceActiveComponents')).to.be.empty;
- });
- it('Host-components in active state', function () {
- controller.set('content', {
- hostComponents: [Em.Object.create({
- service: {
- isInPassive: false
- }
- })]
- });
- expect(controller.get('serviceActiveComponents')).to.eql([Em.Object.create({
- service: {
- isInPassive: false
- }
- })]);
- });
- });
- describe('#serviceNonClientActiveComponents', function () {
- it('No active host-components', function () {
- controller.reopen({
- serviceActiveComponents: []
- });
- controller.set('serviceActiveComponents', []);
- expect(controller.get('serviceNonClientActiveComponents')).to.be.empty;
- });
- it('Active host-component is client', function () {
- controller.reopen({
- serviceActiveComponents: [Em.Object.create({
- isClient: true
- })]
- });
- expect(controller.get('serviceNonClientActiveComponents')).to.be.empty;
- });
- it('Active host-component is not client', function () {
- controller.reopen({
- serviceActiveComponents: [Em.Object.create({
- isClient: false
- })]
- });
- expect(controller.get('serviceNonClientActiveComponents')).to.eql([Em.Object.create({
- isClient: false
- })]);
- });
- });
- describe.skip('#deleteComponent()', function () {
- var jQueryMock,
- cases = [
- {
- isDisabled: false,
- showCallCount: 1,
- title: 'confirm popup should be displayed'
- },
- {
- isDisabled: true,
- showCallCount: 0,
- title: 'confirm popup shouldn\'t be displayed'
- }
- ];
- beforeEach(function () {
- jQueryMock = sinon.stub(window, '$');
- sinon.spy(App.ModalPopup, 'show');
- sinon.stub(controller, '_doDeleteHostComponent', Em.K);
- });
- afterEach(function () {
- jQueryMock.restore();
- App.ModalPopup.show.restore();
- controller._doDeleteHostComponent.restore();
- });
- cases.forEach(function (item) {
- it(item.title, function () {
- jQueryMock.returns({
- closest: function () {
- return {
- hasClass: function () {
- return item.isDisabled;
- }
- }
- }
- });
- var event = {
- context: Em.Object.create({})
- },
- popup = controller.deleteComponent(event);
- expect(App.ModalPopup.show.callCount).to.equal(item.showCallCount);
- if (item.showCallCount) {
- popup.onPrimary();
- expect(controller._doDeleteHostComponent.calledWith(Em.Object.create({}))).to.be.true;
- }
- });
- });
- });
- describe('#mimicWorkStatusChange()', function () {
- var clock;
- beforeEach(function () {
- clock = sinon.useFakeTimers();
- });
- afterEach(function () {
- clock.restore();
- });
- it('change status of object', function () {
- var entity = Em.Object.create({
- workStatus: ''
- });
- controller.mimicWorkStatusChange(entity, 'STATE1', 'STATE2');
- expect(entity.get('workStatus')).to.equal('STATE1');
- clock.tick(App.testModeDelayForActions);
- expect(entity.get('workStatus')).to.equal('STATE2');
- });
- it('change status of objects in array', function () {
- var entity = [Em.Object.create({
- workStatus: ''
- })];
- controller.mimicWorkStatusChange(entity, 'STATE1', 'STATE2');
- expect(entity[0].get('workStatus')).to.equal('STATE1');
- clock.tick(App.testModeDelayForActions);
- expect(entity[0].get('workStatus')).to.equal('STATE2');
- });
- });
- describe('#upgradeComponent()', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- });
- it('confirm popup should be displayed', function () {
- var popup = controller.upgradeComponent({context: Em.Object.create()});
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(App.ajax.send.calledOnce).to.be.true;
- });
- });
- describe('#restartComponent()', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- sinon.stub(batchUtils, "restartHostComponents", Em.K);
- sinon.stub(controller, 'checkNnLastCheckpointTime', function(callback) {
- callback();
- });
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- batchUtils.restartHostComponents.restore();
- controller.checkNnLastCheckpointTime.restore();
- });
- it('popup should be displayed', function () {
- var popup = controller.restartComponent({context: Em.Object.create({'displayName': 'Comp1'})});
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(batchUtils.restartHostComponents.calledOnce).to.be.true;
- });
- it('restart NN, should check last NN checkpoint before restart', function () {
- var event = {
- context: Em.Object.create({
- displayName: 'NameNode',
- componentName: 'NAMENODE'
- })
- };
- controller.restartComponent(event);
- expect(controller.checkNnLastCheckpointTime.calledOnce).to.equal(true);
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- });
- });
- describe('#addComponent()', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- sinon.stub(controller, "addClientComponent", Em.K);
- sinon.stub(controller, "installHostComponentCall", Em.K);
- sinon.stub(controller, "checkComponentDependencies", Em.K);
- controller.set('content', {
- hostComponents: [Em.Object.create({
- componentName: "HDFS_CLIENT"
- })]
- });
- controller.reopen({
- securityEnabled: false
- });
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- controller.addClientComponent.restore();
- controller.installHostComponentCall.restore();
- controller.checkComponentDependencies.restore();
- });
- it('add ZOOKEEPER_SERVER', function () {
- var event = {
- context: Em.Object.create({
- componentName: 'ZOOKEEPER_SERVER'
- })
- };
- controller.addComponent(event);
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- });
- it('add WEBHCAT_SERVER', function () {
- var event = {
- context: Em.Object.create({
- componentName: 'WEBHCAT_SERVER'
- })
- };
- controller.addComponent(event);
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- });
- it('add slave component', function () {
- var event = {
- context: Em.Object.create({
- componentName: 'HIVE_CLIENT'
- })
- };
- controller.set('securityEnabled', false);
- controller.addComponent(event);
- expect(controller.addClientComponent.calledWith(Em.Object.create({
- componentName: 'HIVE_CLIENT'
- }))).to.be.true;
- });
- });
- describe('#formatClientsMessage()', function () {
- var testCases = [
- {
- title: 'subComponentNames is null',
- client: Em.Object.create({
- subComponentNames: null,
- displayName: 'CLIENTS'
- }),
- result: 'CLIENTS'
- },
- {
- title: 'subComponentNames is empty',
- client: Em.Object.create({
- subComponentNames: [],
- displayName: 'CLIENTS'
- }),
- result: 'CLIENTS'
- },
- {
- title: 'displayName is null',
- client: Em.Object.create({
- subComponentNames: ['DATANODE'],
- displayName: null
- }),
- result: ' (DataNode)'
- },
- {
- title: 'displayName is CLIENTS',
- client: Em.Object.create({
- subComponentNames: ['DATANODE'],
- displayName: 'CLIENTS'
- }),
- result: 'CLIENTS (DataNode)'
- }
- ];
- testCases.forEach(function (test) {
- it(test.title, function () {
- expect(controller.formatClientsMessage(test.client)).to.equal(test.result);
- });
- });
- });
- describe('#addClientComponent()', function () {
- var component = Em.Object.create({
- componentName: ' Comp1'
- });
- beforeEach(function () {
- sinon.spy(controller, 'showAddComponentPopup');
- sinon.stub(controller, 'installHostComponentCall', Em.K);
- });
- afterEach(function () {
- controller.showAddComponentPopup.restore();
- controller.installHostComponentCall.restore();
- });
- it('any CLIENT component', function () {
- controller.set('content.hostName', 'host1');
- var popup = controller.addClientComponent(component);
- expect(controller.showAddComponentPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(controller.installHostComponentCall.calledWith('host1', component)).to.be.true;
- });
- });
- describe("#loadOozieConfigs()", function() {
- it("", function() {
- controller.loadOozieConfigs({Clusters: {
- desired_configs: {
- 'oozie-env': {
- tag: 'tag'
- }
- }
- }});
- expect(App.ajax.send.calledWith({
- name: 'admin.get.all_configurations',
- sender: controller,
- data: {
- urlParams: '(type=oozie-env&tag=tag)'
- },
- success: 'onLoadOozieConfigs',
- error: 'onLoadConfigsErrorCallback'
- })).to.be.true;
- });
- });
- describe("#loadStormConfigs()", function() {
- it("", function() {
- controller.loadStormConfigs({Clusters: {
- desired_configs: {
- 'storm-site': {
- tag: 'tag'
- }
- }
- }});
- expect(App.ajax.send.calledWith({
- name: 'admin.get.all_configurations',
- sender: controller,
- data: {
- urlParams: '(type=storm-site&tag=tag)'
- },
- success: 'onLoadStormConfigs'
- })).to.be.true;
- });
- });
- describe("#onLoadStormConfigs()", function() {
- beforeEach(function () {
- sinon.stub(controller, 'getStormNimbusHosts').returns("host1");
- sinon.stub(controller, 'updateZkConfigs', Em.K);
- sinon.stub(controller, 'saveConfigsBatch', Em.K);
- });
- afterEach(function () {
- controller.getStormNimbusHosts.restore();
- controller.updateZkConfigs.restore();
- controller.saveConfigsBatch.restore();
- });
- it("", function() {
- var data = {items: [
- {
- type: 'storm-site',
- properties: {
- 'nimbus.seeds': ''
- }
- }
- ]};
- controller.set('nimbusHost', 'host2');
- controller.onLoadStormConfigs(data);
- expect(controller.updateZkConfigs.calledWith({'storm-site': {
- 'nimbus.seeds': "'host1'"
- }})).to.be.true;
- expect(controller.saveConfigsBatch.calledWith([
- {
- properties: {
- 'storm-site': {
- 'nimbus.seeds': "'host1'"
- }
- },
- properties_attributes: {
- 'storm-site': {}
- }
- }
- ], 'NIMBUS', 'host2')).to.be.true;
- });
- });
- describe("#loadHiveConfigs()", function() {
- it("", function() {
- controller.loadHiveConfigs({Clusters: {
- desired_configs: {
- 'hive-site': {
- tag: 'tag'
- },
- 'webhcat-site': {
- tag: 'tag'
- },
- 'hive-env': {
- tag: 'tag'
- },
- 'core-site': {
- tag: 'tag'
- }
- }
- }});
- expect(App.ajax.send.calledWith({
- name: 'admin.get.all_configurations',
- sender: controller,
- data: {
- urlParams: '(type=hive-site&tag=tag)|(type=webhcat-site&tag=tag)|(type=hive-env&tag=tag)|(type=core-site&tag=tag)'
- },
- success: 'onLoadHiveConfigs'
- })).to.be.true;
- });
- });
- describe("#loadRangerConfigs()", function() {
- it("", function() {
- controller.loadRangerConfigs({Clusters: {
- desired_configs: {
- 'hdfs-site': {
- tag: 'tag'
- },
- 'kms-env': {
- tag: 'tag'
- },
- 'core-site': {
- tag: 'tag'
- }
- }
- }});
- expect(App.ajax.send.calledWith({
- name: 'admin.get.all_configurations',
- sender: controller,
- data: {
- urlParams: '(type=core-site&tag=tag)|(type=hdfs-site&tag=tag)|(type=kms-env&tag=tag)'
- },
- success: 'onLoadRangerConfigs'
- })).to.be.true;
- });
- });
- describe("#getRangerKMSServerHosts()", function() {
- beforeEach(function(){
- sinon.stub(App.HostComponent, 'find').returns([{
- componentName: 'RANGER_KMS_SERVER',
- hostName: 'host1'
- }]);
- });
- afterEach(function(){
- App.HostComponent.find.restore();
- });
- it("", function() {
- controller.set('rangerKMSServerHost', 'host2');
- controller.set('content.hostName', 'host1');
- controller.set('deleteRangerKMSServer', true);
- controller.set('fromDeleteHost', true);
- expect(controller.getRangerKMSServerHosts()).to.eql(['host2']);
- expect(controller.get('rangerKMSServerHost')).to.be.empty;
- expect(controller.get('deleteRangerKMSServer')).to.be.false;
- expect(controller.get('fromDeleteHost')).to.be.false;
- });
- });
- describe("#getStormNimbusHosts()", function() {
- beforeEach(function(){
- sinon.stub(App.HostComponent, 'find').returns([{
- componentName: 'NIMBUS',
- hostName: 'host1'
- }]);
- });
- afterEach(function(){
- App.HostComponent.find.restore();
- });
- it("", function() {
- controller.set('nimbusHost', 'host2');
- controller.set('content.hostName', 'host1');
- controller.set('deleteNimbusHost', true);
- controller.set('fromDeleteHost', true);
- expect(controller.getStormNimbusHosts()).to.eql(['host2']);
- expect(controller.get('nimbusHost')).to.be.empty;
- expect(controller.get('deleteNimbusHost')).to.be.false;
- expect(controller.get('fromDeleteHost')).to.be.false;
- });
- });
- describe('#showAddComponentPopup()', function () {
- var message = 'Comp1',
- component = Em.Object.create({
- componentName: ' Comp1'
- });
- beforeEach(function () {
- sinon.spy(App.ModalPopup, 'show');
- });
- afterEach(function () {
- App.ModalPopup.show.restore();
- });
- it('should display add component confirmation', function () {
- var popup = controller.showAddComponentPopup(message, false, Em.K);
- expect(App.ModalPopup.show.calledOnce).to.be.true;
- expect(popup.get('addComponentMsg')).to.eql(Em.I18n.t('hosts.host.addComponent.msg').format(message));
- });
- });
- describe('#installNewComponentSuccessCallback()', function () {
- beforeEach(function () {
- sinon.stub(controller, "showBackgroundOperationsPopup", Em.K);
- });
- afterEach(function () {
- controller.showBackgroundOperationsPopup.restore();
- });
- it('data is null', function () {
- var data = {Requests: null};
- expect(controller.installNewComponentSuccessCallback(null, {}, {})).to.be.false;
- expect(controller.showBackgroundOperationsPopup.called).to.be.false;
- });
- it('data.Requests is null', function () {
- var data = {Requests: null};
- expect(controller.installNewComponentSuccessCallback(data, {}, {})).to.be.false;
- expect(controller.showBackgroundOperationsPopup.called).to.be.false;
- });
- it('data.Requests.id is null', function () {
- var data = {Requests: {id: null}};
- expect(controller.installNewComponentSuccessCallback(data, {}, {})).to.be.false;
- expect(controller.showBackgroundOperationsPopup.called).to.be.false;
- });
- it('data.Requests.id is correct', function () {
- var data = {Requests: {id: 1}};
- expect(controller.installNewComponentSuccessCallback(data, {}, {component: []})).to.be.true;
- expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
- });
- });
- describe('#refreshComponentConfigs()', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- sinon.stub(controller, "sendRefreshComponentConfigsCommand", Em.K);
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- controller.sendRefreshComponentConfigsCommand.restore();
- });
- it('popup should be displayed', function () {
- var popup = controller.refreshComponentConfigs({context: Em.Object.create({'displayName': 'Comp1'})});
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(controller.sendRefreshComponentConfigsCommand.calledOnce).to.be.true;
- });
- });
- describe('#sendRefreshComponentConfigsCommand()', function () {
- it('Query should be sent', function () {
- var component = Em.Object.create({
- service: {},
- componentName: 'COMP1',
- host: {}
- });
- controller.sendRefreshComponentConfigsCommand(component, {});
- expect(App.ajax.send.calledOnce).to.be.true;
- });
- });
- describe('#loadConfigs()', function () {
- it('Query should be sent', function () {
- controller.loadConfigs();
- expect(App.ajax.send.calledOnce).to.be.true;
- });
- });
- describe('#constructConfigUrlParams()', function () {
- it('URL params should be empty', function () {
- var data = {};
- App.Service.find().clear();
- expect(controller.constructConfigUrlParams(data)).to.eql([]);
- });
- it('isHaEnabled = true', function () {
- App.store.load(App.Service, {
- id: 'HDFS',
- service_name: 'HDFS'
- });
- var data = {Clusters: {desired_configs: {'core-site': {tag: 1}}}};
- App.HostComponent.find().clear();
- App.propertyDidChange('isHaEnabled');
- expect(controller.constructConfigUrlParams(data)).to.eql(['(type=core-site&tag=1)']);
- App.store.load(App.HostComponent, {
- id: 'SECONDARY_NAMENODE_host1',
- component_name: 'SECONDARY_NAMENODE'
- });
- App.set('currentStackVersion', 'HDP-2.0.1');
- });
- it('HBASE is installed', function () {
- App.store.load(App.Service, {
- id: 'HBASE',
- service_name: 'HBASE'
- });
- App.propertyDidChange('isHaEnabled');
- var data = {Clusters: {desired_configs: {'hbase-site': {tag: 1}}}};
- expect(controller.constructConfigUrlParams(data)).to.eql(['(type=hbase-site&tag=1)']);
- App.Service.find().clear();
- });
- it('HIVE is installed', function () {
- App.store.load(App.Service, {
- id: 'HIVE',
- service_name: 'HIVE'
- });
- var data = {Clusters: {desired_configs: {'webhcat-site': {tag: 1}, 'hive-site': {tag: 1}}}};
- expect(controller.constructConfigUrlParams(data)).to.eql(['(type=webhcat-site&tag=1)', '(type=hive-site&tag=1)']);
- App.Service.find().clear();
- });
- it('STORM is installed', function () {
- App.store.load(App.Service, {
- id: 'STORM',
- service_name: 'STORM'
- });
- var data = {Clusters: {desired_configs: {'storm-site': {tag: 1}}}};
- expect(controller.constructConfigUrlParams(data)).to.eql(['(type=storm-site&tag=1)']);
- App.Service.find().clear();
- });
- it('YARN for 2.2 stack is installed', function () {
- App.set('currentStackVersion', 'HDP-2.2.0');
- App.store.load(App.Service, {
- id: 'YARN',
- service_name: 'YARN'
- });
- var data = {Clusters: {desired_configs: {'yarn-site': {tag: 1}, 'zoo.cfg': {tag: 1}}}};
- expect(controller.constructConfigUrlParams(data)).to.eql(['(type=yarn-site&tag=1)', '(type=zoo.cfg&tag=1)']);
- App.set('currentStackVersion', 'HDP-2.0.1');
- App.Service.find().clear();
- });
- it('isRMHaEnabled true', function () {
- sinon.stub(App, 'get').withArgs('isRMHaEnabled').returns(true);
- var data = {Clusters: {desired_configs: {'yarn-site': {tag: 1}, 'zoo.cfg': {tag: 1}}}};
- expect(controller.constructConfigUrlParams(data)).to.eql(['(type=yarn-site&tag=1)', '(type=zoo.cfg&tag=1)']);
- App.get.restore();
- });
- });
- describe('#loadConfigsSuccessCallback()', function () {
- var mockUrlParams = [];
- beforeEach(function () {
- sinon.stub(controller, "constructConfigUrlParams", function () {
- return mockUrlParams;
- });
- });
- afterEach(function () {
- controller.constructConfigUrlParams.restore();
- });
- it('url params is empty', function () {
- expect(controller.loadConfigsSuccessCallback()).to.be.false;
- expect(App.ajax.send.called).to.be.false;
- });
- it('url params are correct', function () {
- mockUrlParams = ['param1'];
- expect(controller.loadConfigsSuccessCallback()).to.be.true;
- expect(App.ajax.send.calledOnce).to.be.true;
- });
- });
- describe('#saveZkConfigs()', function () {
- var yarnCases = [
- {
- isYARNInstalled: true,
- isHadoop22Stack: true,
- isRMHaEnabled: true,
- shouldYarnSiteBeModified: true,
- title: 'HDP 2.2, YARN installed, RM HA enabled'
- },
- {
- isYARNInstalled: true,
- isHadoop22Stack: false,
- isRMHaEnabled: true,
- shouldYarnSiteBeModified: true,
- title: 'HDP < 2.2, YARN installed, RM HA enabled'
- },
- {
- isYARNInstalled: true,
- isHadoop22Stack: true,
- isRMHaEnabled: false,
- shouldYarnSiteBeModified: true,
- title: 'HDP 2.2, YARN installed, RM HA disabled'
- },
- {
- isYARNInstalled: false,
- isHadoop22Stack: true,
- isRMHaEnabled: false,
- shouldYarnSiteBeModified: false,
- title: 'HDP 2.2, YARN not installed'
- },
- {
- isYARNInstalled: true,
- isHadoop22Stack: false,
- isRMHaEnabled: false,
- shouldYarnSiteBeModified: false,
- title: 'HDP < 2.2, YARN installed, RM HA disabled'
- },
- {
- isYARNInstalled: false,
- isHadoop22Stack: false,
- isRMHaEnabled: false,
- shouldYarnSiteBeModified: false,
- title: 'HDP < 2.2, YARN not installed'
- }
- ],
- yarnData = {
- items: [
- {
- type: 'yarn-site',
- properties: {
- p: 'v'
- }
- }
- ]
- };
- beforeEach(function () {
- sinon.stub(controller, "getZkServerHosts", Em.K);
- sinon.stub(controller, "concatZkNames", Em.K);
- sinon.stub(controller, "setZKConfigs", Em.K);
- sinon.stub(controller, 'saveConfigsBatch', Em.K);
- });
- afterEach(function () {
- controller.getZkServerHosts.restore();
- controller.concatZkNames.restore();
- controller.setZKConfigs.restore();
- controller.saveConfigsBatch.restore();
- });
- it('call saveConfigsBatch()', function () {
- var data = {items: []};
- controller.saveZkConfigs(data);
- expect(controller.saveConfigsBatch.calledOnce).to.be.true;
- });
- yarnCases.forEach(function (item) {
- it(item.title, function () {
- var servicesMock = item.isYARNInstalled ? [
- {
- serviceName: 'YARN'
- }
- ] : [];
- sinon.stub(App, 'get').withArgs('isHadoop22Stack').returns(item.isHadoop22Stack).
- withArgs('isRMHaEnabled').returns(item.isRMHaEnabled);
- sinon.stub(App.Service, 'find').returns(servicesMock);
- controller.saveZkConfigs(yarnData);
- expect(controller.saveConfigsBatch.firstCall.args[0].someProperty('properties.yarn-site')).to.equal(item.shouldYarnSiteBeModified);
- expect(controller.saveConfigsBatch.firstCall.args[0].someProperty('properties_attributes.yarn-site')).to.equal(item.shouldYarnSiteBeModified);
- App.get.restore();
- App.Service.find.restore();
- });
- });
- });
- describe("#saveConfigsBatch()", function () {
- it("no groups", function () {
- controller.saveConfigsBatch([]);
- expect(App.ajax.send.called).to.be.false;
- });
- it("configs is empty", function () {
- controller.saveConfigsBatch([{}]);
- expect(App.ajax.send.called).to.be.false;
- });
- it("configs is correct", function () {
- controller.saveConfigsBatch([{'properties': {'site': {}}, 'properties_attributes': {'site': {}}}]);
- expect(App.ajax.send.calledOnce).to.be.true;
- });
- });
- describe('#setZKConfigs()', function () {
- it('configs is null', function () {
- expect(controller.setZKConfigs(null)).to.be.false;
- });
- it('zks is null', function () {
- expect(controller.setZKConfigs({}, '', null)).to.be.false;
- });
- it('isHaEnabled = true', function () {
- var configs = {'core-site': {}};
- App.HostComponent.find().clear();
- App.store.load(App.Service, {
- id: 'HDFS',
- service_name: 'HDFS'
- });
- App.propertyDidChange('isHaEnabled');
- expect(controller.setZKConfigs(configs, 'host1:2181', [])).to.be.true;
- expect(configs).to.eql({
- "core-site": {
- "ha.zookeeper.quorum": "host1:2181"
- }
- });
- App.store.load(App.HostComponent, {
- id: 'SECONDARY_NAMENODE_host1',
- component_name: 'SECONDARY_NAMENODE'
- });
- App.propertyDidChange('isHaEnabled');
- });
- it('hbase-site is present', function () {
- var configs = {'hbase-site': {}};
- expect(controller.setZKConfigs(configs, '', ['host1', 'host2'])).to.be.true;
- expect(configs).to.eql({
- "hbase-site": {
- "hbase.zookeeper.quorum": "host1,host2"
- }
- });
- });
- it('accumulo-site is present', function () {
- var configs = {'accumulo-site': {}};
- expect(controller.setZKConfigs(configs, 'host1:2181', [])).to.be.true;
- expect(configs).to.eql({
- "accumulo-site": {
- "instance.zookeeper.host": 'host1:2181'
- }
- });
- });
- it('webhcat-site is present', function () {
- var configs = {'webhcat-site': {}};
- expect(controller.setZKConfigs(configs, 'host1:2181', [])).to.be.true;
- expect(configs).to.eql({
- "webhcat-site": {
- "templeton.zookeeper.hosts": "host1:2181"
- }
- });
- });
- it('hive-site is present and stack < 2.2', function () {
- var version = App.get('currentStackVersion');
- var configs = {'hive-site': {}};
- App.set('currentStackVersion', 'HDP-2.1.0');
- expect(controller.setZKConfigs(configs, 'host1:2181', [])).to.be.true;
- expect(configs).to.eql({
- "hive-site": {
- 'hive.cluster.delegation.token.store.zookeeper.connectString': "host1:2181"
- }
- });
- App.set('currentStackVersion', version);
- });
- it('hive-site is present and stack > 2.2', function () {
- var version = App.get('currentStackVersion');
- var configs = {'hive-site': {}};
- App.set('currentStackVersion', 'HDP-2.2.0');
- expect(controller.setZKConfigs(configs, 'host1:2181', [])).to.be.true;
- expect(configs).to.eql({
- "hive-site": {
- 'hive.cluster.delegation.token.store.zookeeper.connectString': "host1:2181",
- 'hive.zookeeper.quorum': "host1:2181"
- }
- });
- App.set('currentStackVersion', version);
- });
- it('yarn-site is present and stack > 2.2', function () {
- var version = App.get('currentStackVersion');
- var configs = {'yarn-site': {}};
- App.set('currentStackVersion', 'HDP-2.2.0');
- expect(controller.setZKConfigs(configs, 'host1:2181', [])).to.be.true;
- expect(configs).to.eql({
- "yarn-site": {
- 'hadoop.registry.zk.quorum': "host1:2181",
- 'yarn.resourcemanager.zk-address': "host1:2181"
- }
- });
- App.set('currentStackVersion', version);
- });
- it('storm-site is present', function () {
- var configs = {'storm-site': {}};
- expect(controller.setZKConfigs(configs, '', ["host1", 'host2'])).to.be.true;
- expect(configs).to.eql({
- "storm-site": {
- "storm.zookeeper.servers": "['host1','host2']"
- }
- });
- });
- it('isRMHaEnabled true', function () {
- var configs = {'yarn-site': {}};
- sinon.stub(App, 'get').withArgs('isRMHaEnabled').returns(true);
- expect(controller.setZKConfigs(configs, 'host1:2181', ['host1', 'host2'])).to.be.true;
- expect(configs).to.eql({
- "yarn-site": {
- "yarn.resourcemanager.zk-address": "host1:2181"
- }
- });
- App.get.restore();
- });
- });
- describe('#concatZkNames()', function () {
- it('No ZooKeeper hosts', function () {
- expect(controller.concatZkNames([])).to.equal('');
- });
- it('One ZooKeeper host', function () {
- expect(controller.concatZkNames(['host1'], '2181')).to.equal('host1:2181');
- });
- it('Two ZooKeeper hosts', function () {
- expect(controller.concatZkNames(['host1', 'host2'], '2181')).to.equal('host1:2181,host2:2181');
- });
- });
- describe('#getZkServerHosts()', function () {
- beforeEach(function () {
- controller.set('content', {});
- });
- afterEach(function () {
- App.HostComponent.find.restore();
- });
- it('No ZooKeeper hosts, fromDeleteHost = false', function () {
- sinon.stub(App.HostComponent, 'find', function () {
- return []
- });
- controller.set('fromDeleteHost', false);
- expect(controller.getZkServerHosts()).to.be.empty;
- });
- it('No ZooKeeper hosts, fromDeleteHost = true', function () {
- sinon.stub(App.HostComponent, 'find', function () {
- return []
- });
- controller.set('fromDeleteHost', true);
- expect(controller.getZkServerHosts()).to.be.empty;
- expect(controller.get('fromDeleteHost')).to.be.false;
- });
- it('One ZooKeeper host, fromDeleteHost = false', function () {
- controller.set('fromDeleteHost', false);
- sinon.stub(App.HostComponent, 'find', function () {
- return [
- {
- id: 'ZOOKEEPER_SERVER_host1',
- componentName: 'ZOOKEEPER_SERVER',
- hostName: 'host1'
- }
- ]
- });
- expect(controller.getZkServerHosts()).to.eql(['host1']);
- });
- it('One ZooKeeper host match current host name, fromDeleteHost = true', function () {
- sinon.stub(App.HostComponent, 'find', function () {
- return [
- {
- id: 'ZOOKEEPER_SERVER_host1',
- componentName: 'ZOOKEEPER_SERVER',
- hostName: 'host1'
- }
- ]
- });
- controller.set('fromDeleteHost', true);
- controller.set('content.hostName', 'host1');
- expect(controller.getZkServerHosts()).to.be.empty;
- expect(controller.get('fromDeleteHost')).to.be.false;
- });
- it('One ZooKeeper host does not match current host name, fromDeleteHost = true', function () {
- sinon.stub(App.HostComponent, 'find', function () {
- return [
- {
- id: 'ZOOKEEPER_SERVER_host1',
- componentName: 'ZOOKEEPER_SERVER',
- hostName: 'host1'
- }
- ]
- });
- controller.set('fromDeleteHost', true);
- controller.set('content.hostName', 'host2');
- expect(controller.getZkServerHosts()[0]).to.equal("host1");
- expect(controller.get('fromDeleteHost')).to.be.false;
- });
- });
- describe('#installComponent()', function () {
- beforeEach(function () {
- sinon.spy(App.ModalPopup, "show");
- });
- afterEach(function () {
- App.ModalPopup.show.restore();
- });
- it('popup should be displayed', function () {
- var event = {context: Em.Object.create()};
- var popup = controller.installComponent(event);
- expect(App.ModalPopup.show.calledOnce).to.be.true;
- popup.onPrimary();
- expect(App.ajax.send.called).to.be.true;
- });
- });
- describe('#decommission()', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- sinon.stub(controller, "runDecommission", Em.K);
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- controller.runDecommission.restore();
- });
- it('popup should be displayed', function () {
- var popup = controller.decommission(Em.Object.create({service: {}}));
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(controller.runDecommission.calledOnce).to.be.true;
- });
- });
- describe('#recommission()', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- sinon.stub(controller, "runRecommission", Em.K);
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- controller.runRecommission.restore();
- });
- it('popup should be displayed', function () {
- var popup = controller.recommission(Em.Object.create({service: {}}));
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(controller.runRecommission.calledOnce).to.be.true;
- });
- });
- describe('#runDecommission()', function () {
- beforeEach(function () {
- sinon.stub(controller, "doDecommission", Em.K);
- sinon.stub(controller, "showBackgroundOperationsPopup", Em.K);
- });
- afterEach(function () {
- controller.doDecommission.restore();
- controller.showBackgroundOperationsPopup.restore();
- });
- it('HDFS service', function () {
- controller.runDecommission('host1', 'HDFS');
- expect(controller.doDecommission.calledWith('host1', 'HDFS', "NAMENODE", "DATANODE")).to.be.true;
- });
- it('YARN service', function () {
- controller.runDecommission('host1', 'YARN');
- expect(controller.doDecommission.calledWith('host1', 'YARN', "RESOURCEMANAGER", "NODEMANAGER")).to.be.true;
- });
- it('HBASE service', function () {
- sinon.stub(controller, 'warnBeforeDecommission', Em.K);
- controller.runDecommission('host1', 'HBASE');
- expect(controller.warnBeforeDecommission.calledWith('host1')).to.be.true;
- controller.warnBeforeDecommission.restore();
- });
- });
- describe('#runRecommission()', function () {
- beforeEach(function () {
- sinon.stub(controller, "doRecommissionAndStart", Em.K);
- sinon.stub(controller, "showBackgroundOperationsPopup", Em.K);
- });
- afterEach(function () {
- controller.doRecommissionAndStart.restore();
- controller.showBackgroundOperationsPopup.restore();
- });
- it('HDFS service', function () {
- controller.runRecommission('host1', 'HDFS');
- expect(controller.doRecommissionAndStart.calledWith('host1', 'HDFS', "NAMENODE", "DATANODE")).to.be.true;
- expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
- });
- it('YARN service', function () {
- controller.runRecommission('host1', 'YARN');
- expect(controller.doRecommissionAndStart.calledWith('host1', 'YARN', "RESOURCEMANAGER", "NODEMANAGER")).to.be.true;
- expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
- });
- it('HBASE service', function () {
- controller.runRecommission('host1', 'HBASE');
- expect(controller.doRecommissionAndStart.calledWith('host1', 'HBASE', "HBASE_MASTER", "HBASE_REGIONSERVER")).to.be.true;
- expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
- });
- });
- describe('#doDecommission()', function () {
- it('Query should be sent', function () {
- controller.doDecommission('', '', '', '');
- expect(App.ajax.send.calledOnce).to.be.true;
- });
- });
- describe('#doDecommissionRegionServer()', function () {
- it('Query should be sent', function () {
- controller.doDecommissionRegionServer('', '', '', '');
- expect(App.ajax.send.calledOnce).to.be.true;
- });
- });
- describe('#warnBeforeDecommission()', function () {
- beforeEach(function () {
- sinon.stub(controller, "showHbaseActiveWarning", Em.K);
- sinon.stub(controller, "checkRegionServerState", Em.K);
- });
- afterEach(function () {
- controller.checkRegionServerState.restore();
- controller.showHbaseActiveWarning.restore();
- });
- it('Component in passive state', function () {
- controller.set('content.hostComponents', [Em.Object.create({
- componentName: 'HBASE_REGIONSERVER',
- passiveState: 'ON'
- })]);
- controller.warnBeforeDecommission('host1');
- expect(controller.checkRegionServerState.calledOnce).to.be.true;
- });
- it('Component is not in passive state', function () {
- controller.set('content.hostComponents', [Em.Object.create({
- componentName: 'HBASE_REGIONSERVER',
- passiveState: 'OFF'
- })]);
- controller.warnBeforeDecommission('host1');
- expect(controller.showHbaseActiveWarning.calledOnce).to.be.true;
- });
- });
- describe('#checkRegionServerState()', function () {
- it('', function () {
- expect(controller.checkRegionServerState('host1')).to.be.an('object');
- expect(App.ajax.send.getCall(0).args[0].data.hostNames).to.equal('host1');
- });
- });
- describe('#checkRegionServerStateSuccessCallback()', function () {
- beforeEach(function () {
- sinon.stub(controller, "doDecommissionRegionServer", Em.K);
- sinon.stub(controller, "showRegionServerWarning", Em.K);
- });
- afterEach(function () {
- controller.doDecommissionRegionServer.restore();
- controller.showRegionServerWarning.restore();
- });
- it('Decommission all regionservers', function () {
- var data = {
- items: [
- {
- HostRoles: {
- host_name: 'host1'
- }
- },
- {
- HostRoles: {
- host_name: 'host2'
- }
- }
- ]
- };
- controller.checkRegionServerStateSuccessCallback(data, {}, {hostNames: 'host1,host2'});
- expect(controller.showRegionServerWarning.calledOnce).to.be.true;
- });
- it('Decommission one of two regionservers', function () {
- var data = {
- items: [
- {
- HostRoles: {
- host_name: 'host1'
- }
- },
- {
- HostRoles: {
- host_name: 'host2'
- }
- }
- ]
- };
- controller.checkRegionServerStateSuccessCallback(data, {}, {hostNames: 'host1'});
- expect(controller.doDecommissionRegionServer.calledWith('host1', "HBASE", "HBASE_MASTER", "HBASE_REGIONSERVER")).to.be.true;
- });
- it('Decommission one of three regionservers', function () {
- var data = {
- items: [
- {
- HostRoles: {
- host_name: 'host1'
- }
- },
- {
- HostRoles: {
- host_name: 'host2'
- }
- },
- {
- HostRoles: {
- host_name: 'host3'
- }
- }
- ]
- };
- controller.checkRegionServerStateSuccessCallback(data, {}, {hostNames: 'host1'});
- expect(controller.doDecommissionRegionServer.calledWith('host1', "HBASE", "HBASE_MASTER", "HBASE_REGIONSERVER")).to.be.true;
- });
- });
- describe('#showRegionServerWarning()', function () {
- beforeEach(function () {
- sinon.stub(App.ModalPopup, 'show', Em.K);
- });
- afterEach(function () {
- App.ModalPopup.show.restore();
- });
- it('', function () {
- controller.showRegionServerWarning();
- expect(App.ModalPopup.show.calledOnce).to.be.true;
- });
- });
- describe('#doRecommissionAndStart()', function () {
- it('Query should be sent', function () {
- controller.doRecommissionAndStart('', '', '', '');
- expect(App.ajax.send.calledOnce).to.be.true;
- });
- });
- describe('#decommissionSuccessCallback()', function () {
- beforeEach(function () {
- sinon.stub(controller, "showBackgroundOperationsPopup", Em.K);
- });
- afterEach(function () {
- controller.showBackgroundOperationsPopup.restore();
- });
- it('data is null', function () {
- expect(controller.decommissionSuccessCallback(null)).to.be.false;
- expect(controller.showBackgroundOperationsPopup.called).to.be.false;
- });
- it('data has Requests', function () {
- var data = {Requests: []};
- expect(controller.decommissionSuccessCallback(data)).to.be.true;
- expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
- });
- it('data has resources', function () {
- var data = {
- resources: [
- {RequestSchedule: {}}
- ]
- };
- expect(controller.decommissionSuccessCallback(data)).to.be.true;
- expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
- });
- });
- describe('#doAction()', function () {
- beforeEach(function () {
- sinon.stub(controller, "validateAndDeleteHost", Em.K);
- sinon.stub(controller, "doStartAllComponents", Em.K);
- sinon.stub(controller, "doStopAllComponents", Em.K);
- sinon.stub(controller, "doRestartAllComponents", Em.K);
- sinon.stub(controller, "onOffPassiveModeForHost", Em.K);
- sinon.stub(controller, "setRackIdForHost", Em.K);
- });
- afterEach(function () {
- controller.validateAndDeleteHost.restore();
- controller.doStartAllComponents.restore();
- controller.doStopAllComponents.restore();
- controller.doRestartAllComponents.restore();
- controller.onOffPassiveModeForHost.restore();
- controller.setRackIdForHost.restore();
- });
- it('"deleteHost" action', function () {
- var option = {context: {action: "deleteHost"}};
- controller.doAction(option);
- expect(controller.validateAndDeleteHost.calledOnce).to.be.true;
- });
- it('"startAllComponents" action, isNotHeartBeating = false', function () {
- var option = {context: {action: "startAllComponents"}};
- controller.set('content', {isNotHeartBeating: false});
- controller.doAction(option);
- expect(controller.doStartAllComponents.calledOnce).to.be.true;
- });
- it('"startAllComponents" action, isNotHeartBeating = true', function () {
- var option = {context: {action: "startAllComponents"}};
- controller.set('content', {isNotHeartBeating: true});
- controller.doAction(option);
- expect(controller.doStartAllComponents.called).to.be.false;
- });
- it('"stopAllComponents" action, isNotHeartBeating = false', function () {
- var option = {context: {action: "stopAllComponents"}};
- controller.set('content', {isNotHeartBeating: false});
- controller.doAction(option);
- expect(controller.doStopAllComponents.calledOnce).to.be.true;
- });
- it('"stopAllComponents" action, isNotHeartBeating = true', function () {
- var option = {context: {action: "stopAllComponents"}};
- controller.set('content', {isNotHeartBeating: true});
- controller.doAction(option);
- expect(controller.doStopAllComponents.called).to.be.false;
- });
- it('"restartAllComponents" action, isNotHeartBeating = false', function () {
- var option = {context: {action: "restartAllComponents"}};
- controller.set('content', {isNotHeartBeating: false});
- controller.doAction(option);
- expect(controller.doRestartAllComponents.calledOnce).to.be.true;
- });
- it('"restartAllComponents" action, isNotHeartBeating = true', function () {
- var option = {context: {action: "restartAllComponents"}};
- controller.set('content', {isNotHeartBeating: true});
- controller.doAction(option);
- expect(controller.doRestartAllComponents.called).to.be.false;
- });
- it('"onOffPassiveModeForHost" action', function () {
- var option = {context: {action: "onOffPassiveModeForHost"}};
- controller.doAction(option);
- expect(controller.onOffPassiveModeForHost.calledWith({action: "onOffPassiveModeForHost"})).to.be.true;
- });
- it('"setRackId" action', function () {
- var option = {context: {action: "setRackId"}};
- controller.doAction(option);
- expect(controller.setRackIdForHost.calledOnce).to.be.true;
- });
- });
- describe("#setRackIdForHost()", function() {
- beforeEach(function(){
- sinon.stub(hostsManagement, 'setRackInfo', Em.K);
- });
- afterEach(function() {
- hostsManagement.setRackInfo.restore();
- });
- it("", function() {
- controller.set('content.rack', 'rack');
- controller.set('content.hostName', 'host1');
- controller.setRackIdForHost();
- expect(hostsManagement.setRackInfo.calledWith({message: Em.I18n.t('hosts.host.details.setRackId')}, [{hostName: 'host1'}], 'rack')).to.be.true;
- });
- });
- describe('#onOffPassiveModeForHost()', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- sinon.stub(controller, "hostPassiveModeRequest", Em.K);
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- controller.hostPassiveModeRequest.restore();
- });
- it('popup should be displayed, active = true', function () {
- var popup = controller.onOffPassiveModeForHost({active: true});
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(controller.hostPassiveModeRequest.calledWith('ON')).to.be.true;
- });
- it('popup should be displayed, active = false', function () {
- var popup = controller.onOffPassiveModeForHost({active: false});
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(controller.hostPassiveModeRequest.calledWith('OFF')).to.be.true;
- });
- });
- describe('#hostPassiveModeRequest()', function () {
- it('Query should be sent', function () {
- controller.hostPassiveModeRequest('', '');
- expect(App.ajax.send.calledOnce).to.be.true;
- });
- });
- describe('#doStartAllComponents()', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- sinon.stub(controller, 'sendComponentCommand', Em.K);
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- controller.sendComponentCommand.restore();
- });
- it('serviceNonClientActiveComponents is empty', function () {
- controller.reopen({
- serviceNonClientActiveComponents: Em.A([])
- });
- controller.doStartAllComponents();
- expect(App.showConfirmationPopup.called).to.be.false;
- });
- it('serviceNonClientActiveComponents is correct', function () {
- controller.reopen({
- serviceNonClientActiveComponents: Em.A([{}])
- });
- var popup = controller.doStartAllComponents();
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(controller.sendComponentCommand.calledWith(
- controller.get('serviceNonClientActiveComponents'),
- Em.I18n.t('hosts.host.maintainance.startAllComponents.context'),
- App.HostComponentStatus.started)
- ).to.be.true;
- });
- });
- describe('#doStopAllComponents()', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- sinon.stub(controller, 'sendComponentCommand', Em.K);
- sinon.stub(controller, 'checkNnLastCheckpointTime', function(callback){
- callback();
- });
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- controller.sendComponentCommand.restore();
- controller.checkNnLastCheckpointTime.restore();
- });
- it('serviceNonClientActiveComponents is empty', function () {
- controller.reopen({
- serviceNonClientActiveComponents: []
- });
- controller.doStopAllComponents();
- expect(App.showConfirmationPopup.called).to.be.false;
- });
- it('serviceNonClientActiveComponents is correct', function () {
- controller.reopen({
- serviceNonClientActiveComponents: Em.A([{}])
- });
- var popup = controller.doStopAllComponents();
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(controller.sendComponentCommand.calledWith(
- controller.get('serviceNonClientActiveComponents'),
- Em.I18n.t('hosts.host.maintainance.stopAllComponents.context'),
- App.HostComponentStatus.stopped)
- ).to.be.true;
- });
- it('serviceNonClientActiveComponents is correct, NAMENODE started', function () {
- controller.reopen({
- serviceNonClientActiveComponents: Em.A([Em.Object.create({
- componentName: 'NAMENODE',
- workStatus: 'STARTED'
- })])
- });
- controller.set('content.hostComponents', [Em.Object.create({
- componentName: 'NAMENODE',
- workStatus: 'STARTED'
- })]);
- controller.doStopAllComponents();
- expect(controller.checkNnLastCheckpointTime.calledOnce).to.be.true;
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- });
- });
- describe('#doRestartAllComponents()', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- sinon.stub(batchUtils, 'restartHostComponents', Em.K);
- sinon.stub(controller, 'checkNnLastCheckpointTime', function(callback){
- callback();
- });
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- batchUtils.restartHostComponents.restore();
- controller.checkNnLastCheckpointTime.restore();
- });
- it('serviceActiveComponents is empty', function () {
- controller.reopen({
- serviceActiveComponents: []
- });
- controller.doRestartAllComponents();
- expect(App.showConfirmationPopup.called).to.be.false;
- });
- it('serviceActiveComponents is correct', function () {
- controller.reopen({
- serviceActiveComponents: [
- {}
- ]
- });
- var popup = controller.doRestartAllComponents();
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(batchUtils.restartHostComponents.calledWith(
- [
- {}
- ])
- ).to.be.true;
- });
- it('serviceActiveComponents is correct, NAMENODE started', function () {
- controller.reopen({
- serviceActiveComponents: Em.A([Em.Object.create({
- componentName: 'NAMENODE',
- workStatus: 'STARTED'
- })])
- });
- controller.set('content.hostComponents', [Em.Object.create({
- componentName: 'NAMENODE',
- workStatus: 'STARTED'
- })]);
- controller.doRestartAllComponents();
- expect(controller.checkNnLastCheckpointTime.calledOnce).to.be.true;
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- });
- });
- describe('#getHostComponentsInfo()', function () {
- var result = {
- zkServerInstalled: false,
- lastComponents: [],
- masterComponents: [],
- runningComponents: [],
- nonDeletableComponents: [],
- unknownComponents: [],
- toDecommissionComponents: []
- };
- it('content.hostComponents is null', function () {
- controller.set('content', {hostComponents: null});
- expect(controller.getHostComponentsInfo()).to.eql(result);
- });
- it('content.hostComponents is empty', function () {
- controller.set('content', {hostComponents: []});
- expect(controller.getHostComponentsInfo()).to.eql(result);
- });
- it('content.hostComponents has ZOOKEEPER_SERVER', function () {
- App.HostComponent.find().clear();
- controller.set('content', {
- hostComponents: [Em.Object.create({
- componentName: 'ZOOKEEPER_SERVER',
- workStatus: 'INIT',
- isDeletable: true
- })]
- });
- expect(controller.getHostComponentsInfo().zkServerInstalled).to.be.true;
- });
- it('content.hostComponents has last component', function () {
- sinon.stub(App.HostComponent, 'find', function () {
- return [
- {
- id: 'TASKTRACKER_host1',
- componentName: 'TASKTRACKER'
- }
- ];
- });
- controller.set('content', {
- hostComponents: [Em.Object.create({
- componentName: 'TASKTRACKER',
- displayName: 'TaskTracker',
- workStatus: 'INIT',
- isDeletable: true
- })]
- });
- expect(controller.getHostComponentsInfo().lastComponents).to.eql(['TaskTracker']);
- App.HostComponent.find.restore();
- });
- it('content.hostComponents has master non-deletable component', function () {
- sinon.stub(App.HostComponent, 'find', function () {
- return [
- {
- id: 'TASKTRACKER_host1',
- componentName: 'TASKTRACKER'
- }
- ];
- });
- controller.set('content', {
- hostComponents: [Em.Object.create({
- componentName: 'TASKTRACKER',
- workStatus: 'INIT',
- isDeletable: false,
- isMaster: true,
- displayName: 'ZK1'
- })]
- });
- expect(controller.getHostComponentsInfo().masterComponents).to.eql(['ZK1']);
- expect(controller.getHostComponentsInfo().nonDeletableComponents).to.eql(['ZK1']);
- App.HostComponent.find.restore();
- });
- it('content.hostComponents has running component', function () {
- sinon.stub(App.HostComponent, 'find', function () {
- return [
- {
- id: 'TASKTRACKER_host1',
- componentName: 'TASKTRACKER'
- }
- ];
- });
- controller.set('content', {
- hostComponents: [Em.Object.create({
- componentName: 'TASKTRACKER',
- workStatus: 'STARTED',
- isDeletable: true,
- displayName: 'ZK1'
- })]
- });
- expect(controller.getHostComponentsInfo().runningComponents).to.eql(['ZK1']);
- App.HostComponent.find.restore();
- });
- it('content.hostComponents has non-deletable component', function () {
- sinon.stub(App.HostComponent, 'find', function () {
- return [
- {
- id: 'TASKTRACKER_host1',
- componentName: 'TASKTRACKER'
- }
- ];
- });
- controller.set('content', {
- hostComponents: [Em.Object.create({
- componentName: 'TASKTRACKER',
- workStatus: 'INIT',
- isDeletable: false,
- displayName: 'ZK1'
- })]
- });
- expect(controller.getHostComponentsInfo().nonDeletableComponents).to.eql(['ZK1']);
- App.HostComponent.find.restore();
- });
- it('content.hostComponents has component with UNKNOWN state', function () {
- sinon.stub(App.HostComponent, 'find', function () {
- return [
- {
- id: 'TASKTRACKER_host1',
- componentName: 'TASKTRACKER'
- }
- ];
- });
- controller.set('content', {
- hostComponents: [Em.Object.create({
- componentName: 'TASKTRACKER',
- workStatus: 'UNKNOWN',
- isDeletable: false,
- displayName: 'ZK1'
- })]
- });
- expect(controller.getHostComponentsInfo().unknownComponents).to.eql(['ZK1']);
- App.HostComponent.find.restore();
- });
- });
- describe('#validateAndDeleteHost()', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- sinon.stub(controller, "getHostComponentsInfo", function () {
- return this.get('mockHostComponentsInfo');
- });
- sinon.stub(controller, "raiseDeleteComponentsError", Em.K);
- sinon.stub(controller, "confirmDeleteHost", Em.K);
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- controller.getHostComponentsInfo.restore();
- controller.raiseDeleteComponentsError.restore();
- controller.confirmDeleteHost.restore();
- });
- it('masterComponents exist', function () {
- controller.set('mockHostComponentsInfo', {
- masterComponents: [
- {}
- ]
- });
- controller.validateAndDeleteHost();
- expect(controller.raiseDeleteComponentsError.calledWith({masterComponents: [
- {}
- ]}, 'masterList')).to.be.true;
- });
- it('nonDeletableComponents exist', function () {
- controller.set('mockHostComponentsInfo', {
- masterComponents: [],
- nonDeletableComponents: [
- {}
- ]
- });
- controller.validateAndDeleteHost();
- expect(controller.raiseDeleteComponentsError.calledWith({
- masterComponents: [],
- nonDeletableComponents: [
- {}
- ]
- }, 'nonDeletableList')).to.be.true;
- });
- it('runningComponents exist', function () {
- controller.set('mockHostComponentsInfo', {
- masterComponents: [],
- nonDeletableComponents: [],
- runningComponents: [{}]
- });
- controller.validateAndDeleteHost();
- expect(controller.raiseDeleteComponentsError.calledWith({
- masterComponents: [],
- nonDeletableComponents: [],
- runningComponents: [{}]
- }, 'runningList')).to.be.true;
- });
- it('zkServerInstalled = true', function () {
- controller.set('mockHostComponentsInfo', {
- masterComponents: [],
- nonDeletableComponents: [],
- runningComponents: [],
- unknownComponents: [],
- lastComponents: [],
- zkServerInstalled: true
- });
- var popup = controller.validateAndDeleteHost();
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(controller.confirmDeleteHost.calledWith({
- masterComponents: [],
- nonDeletableComponents: [],
- runningComponents: [],
- unknownComponents: [],
- lastComponents: [],
- zkServerInstalled: true
- })).to.be.true;
- });
- it('zkServerInstalled = false', function () {
- controller.set('mockHostComponentsInfo', {
- masterComponents: [],
- nonDeletableComponents: [],
- runningComponents: [],
- unknownComponents: [],
- lastComponents: [],
- zkServerInstalled: false
- });
- controller.validateAndDeleteHost();
- expect(controller.confirmDeleteHost.calledWith({
- masterComponents: [],
- nonDeletableComponents: [],
- runningComponents: [],
- unknownComponents: [],
- lastComponents: [],
- zkServerInstalled: false
- })).to.be.true;
- });
- });
- describe('#raiseDeleteComponentsError()', function () {
- beforeEach(function () {
- sinon.stub(App.ModalPopup, "show", Em.K);
- });
- afterEach(function () {
- App.ModalPopup.show.restore();
- });
- it('Popup should be displayed', function () {
- controller.raiseDeleteComponentsError([], '');
- expect(App.ModalPopup.show.calledOnce).to.be.true;
- });
- });
- describe('#confirmDeleteHost()', function () {
- it('Popup should be displayed', function () {
- sinon.spy(App.ModalPopup, "show");
- sinon.stub(controller, 'doDeleteHost');
- var popup = controller.confirmDeleteHost({toDecommissionComponents:[]});
- expect(App.ModalPopup.show.calledOnce).to.be.true;
- popup.onPrimary();
- expect(controller.doDeleteHost.calledOnce).to.be.true;
- App.ModalPopup.show.restore();
- controller.doDeleteHost.restore();
- });
- });
- describe('#setRackId', function () {
- beforeEach(function () {
- sinon.stub(hostsManagement, 'setRackInfo', Em.K);
- });
- afterEach(function () {
- hostsManagement.setRackInfo.restore();
- });
- it('should call setRackInfo with appropriate arguments', function () {
- var mockedHost = Em.Object.create({
- rack: 'rackId'
- });
- controller.setRackId({
- context: mockedHost
- });
- expect(hostsManagement.setRackInfo.calledWith({message: Em.I18n.t('hosts.host.details.setRackId')}, [mockedHost], 'rackId')).to.be.true;
- });
- });
- describe('#restartAllStaleConfigComponents()', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- sinon.stub(batchUtils, "restartHostComponents", Em.K);
- sinon.stub(controller, 'checkNnLastCheckpointTime', function(callback){
- callback();
- });
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- batchUtils.restartHostComponents.restore();
- controller.checkNnLastCheckpointTime.restore();
- });
- it('popup should be displayed', function () {
- controller.set('content', {
- componentsWithStaleConfigs: [
- {}
- ]
- });
- var popup = controller.restartAllStaleConfigComponents();
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(batchUtils.restartHostComponents.calledWith([
- {}
- ])).to.be.true;
- });
- it('popup ro check NameNode checkpoint should be displayed first', function () {
- controller.set('content.componentsWithStaleConfigs', [Em.Object.create({
- componentName: 'NAMENODE',
- workStatus: 'STARTED'
- })]);
- controller.set('content.hostComponents', [Em.Object.create({
- componentName: 'NAMENODE',
- workStatus: 'STARTED'
- })]);
- controller.restartAllStaleConfigComponents();
- expect(controller.checkNnLastCheckpointTime.calledOnce).to.be.true;
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- });
- });
- describe.skip('#moveComponent()', function () {
- var jQueryMock,
- mock = {
- saveComponentToReassign: Em.K,
- getSecurityStatus: Em.K,
- setCurrentStep: Em.K
- },
- cases = [
- {
- isDisabled: false,
- showConfirmationPopupCallCount: 1,
- title: 'popup should be displayed'
- },
- {
- isDisabled: true,
- showConfirmationPopupCallCount: 0,
- title: 'popup shouldn\'t be displayed'
- }
- ];
- beforeEach(function () {
- jQueryMock = sinon.stub(window, '$');
- sinon.spy(App, "showConfirmationPopup");
- sinon.stub(App.router, 'get').withArgs('reassignMasterController').returns(mock);
- sinon.stub(App.router, 'transitionTo', Em.K);
- sinon.spy(mock, "saveComponentToReassign");
- sinon.spy(mock, "getSecurityStatus");
- sinon.spy(mock, "setCurrentStep");
- });
- afterEach(function () {
- window.$.restore();
- App.showConfirmationPopup.restore();
- App.router.get.restore();
- App.router.transitionTo.restore();
- mock.saveComponentToReassign.restore();
- mock.getSecurityStatus.restore();
- mock.setCurrentStep.restore();
- });
- cases.forEach(function (item) {
- it(item.title, function () {
- jQueryMock.returns({
- closest: function () {
- return {
- hasClass: function () {
- return item.isDisabled;
- }
- }
- }
- });
- var popup = controller.moveComponent({context: {}});
- expect(App.showConfirmationPopup.callCount).to.equal(item.showConfirmationPopupCallCount);
- if (item.showConfirmationPopupCallCount) {
- popup.onPrimary();
- expect(App.router.get.calledWith('reassignMasterController')).to.be.true;
- expect(mock.saveComponentToReassign.calledWith({})).to.be.true;
- expect(mock.getSecurityStatus.calledOnce).to.be.true;
- expect(mock.setCurrentStep.calledWith('1')).to.be.true;
- expect(App.router.transitionTo.calledWith('reassign')).to.be.true;
- }
- });
- });
- });
- describe('#refreshConfigs()', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- sinon.stub(batchUtils, "restartHostComponents", Em.K);
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- batchUtils.restartHostComponents.restore();
- });
- it('No components', function () {
- var event = {context: Em.A([])};
- controller.refreshConfigs(event);
- expect(App.showConfirmationPopup.called).to.be.false;
- });
- it('Some components present', function () {
- var event = {context: Em.A([Em.Object.create()])};
- var popup = controller.refreshConfigs(event);
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(batchUtils.restartHostComponents.calledWith(event.context)).to.be.true;
- });
- });
- describe('#getTotalComponent()', function () {
- beforeEach(function () {
- sinon.stub(App.SlaveComponent, 'find', function () {
- return Em.Object.create({
- componentName: "SLAVE",
- totalCount: 1
- });
- });
- sinon.stub(App.ClientComponent, 'find', function () {
- return Em.Object.create({
- componentName: "CLIENT",
- totalCount: 1
- });
- });
- sinon.stub(App.HostComponent, 'find', function () {
- return [Em.Object.create({
- componentName: "MASTER",
- totalCount: 1
- })]
- });
- });
- afterEach(function () {
- App.SlaveComponent.find.restore();
- App.ClientComponent.find.restore();
- App.HostComponent.find.restore();
- });
- it('component is slave', function () {
- expect(controller.getTotalComponent(Em.Object.create({
- componentName: "SLAVE",
- isSlave: true
- }))).to.equal(1);
- });
- it('component is client', function () {
- expect(controller.getTotalComponent(Em.Object.create({
- componentName: "CLIENT",
- isClient: true
- }))).to.equal(1);
- });
- it('component is master', function () {
- expect(controller.getTotalComponent(Em.Object.create({
- componentName: "MASTER"
- }))).to.equal(1);
- });
- it('unknown component', function () {
- expect(controller.getTotalComponent(Em.Object.create({
- componentName: "UNKNOWN"
- }))).to.equal(0);
- });
- });
- describe('#downloadClientConfigsCall', function () {
- beforeEach(function () {
- sinon.stub(controller, 'downloadClientConfigsCall', Em.K);
- });
- afterEach(function () {
- controller.downloadClientConfigsCall.restore();
- });
- it('should launch controller.downloadClientConfigsCall method', function () {
- controller.downloadClientConfigs({
- context: Em.Object.create({
- componentName: 'name',
- hostName: 'host1',
- displayName: 'dName'
- })
- });
- expect(controller.downloadClientConfigsCall.calledWith({
- componentName: 'name',
- hostName: 'host1',
- displayName: 'dName'
- })).to.be.true;
- });
- });
- describe('#executeCustomCommands', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- });
- it('confirm popup should be displayed', function () {
- var popup = controller.executeCustomCommand({context: Em.Object.create()});
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(App.ajax.send.calledOnce).to.be.true;
- });
- });
- describe('#_doDeleteHostComponent()', function () {
- it('single component', function () {
- controller.set('content.hostName', 'host1');
- var component = Em.Object.create({componentName: 'COMP'});
- controller._doDeleteHostComponent(component);
- expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.delete.host_component');
- expect(App.ajax.send.getCall(0).args[0].data).to.be.eql({
- componentName: 'COMP',
- hostName: 'host1'
- });
- });
- it('all components', function () {
- controller.set('content.hostName', 'host1');
- controller._doDeleteHostComponent(null);
- expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.delete.host');
- expect(App.ajax.send.getCall(0).args[0].data).to.be.eql({
- componentName: '',
- hostName: 'host1'
- });
- });
- });
- describe('#_doDeleteHostComponentSuccessCallback()', function () {
- beforeEach(function () {
- sinon.stub(controller, 'removeHostComponentModel', Em.K);
- sinon.stub(controller, 'isServiceMetricsLoaded', function (callback) {
- callback();
- });
- sinon.stub(controller, 'loadConfigs', Em.K);
- });
- afterEach(function () {
- controller.removeHostComponentModel.restore();
- controller.isServiceMetricsLoaded.restore();
- controller.loadConfigs.restore();
- });
- it('ZOOKEEPER_SERVER component', function () {
- var data = {
- componentName: 'ZOOKEEPER_SERVER'
- };
- controller._doDeleteHostComponentSuccessCallback({}, {}, data);
- expect(controller.get('_deletedHostComponentResult')).to.be.null;
- expect(controller.get('fromDeleteZkServer')).to.be.true;
- expect(controller.loadConfigs.calledOnce).to.be.true;
- });
- it('Not ZOOKEEPER_SERVER component', function () {
- var data = {
- componentName: 'COMP'
- };
- controller.set('fromDeleteZkServer', false);
- controller._doDeleteHostComponentSuccessCallback({}, {}, data);
- expect(controller.get('_deletedHostComponentResult')).to.be.null;
- expect(controller.get('fromDeleteZkServer')).to.be.false;
- });
- it('should call `removeHostComponentModel` with correct params', function () {
- var data = {
- componentName: 'COMPONENT',
- hostName: 'h1'
- };
- controller._doDeleteHostComponentSuccessCallback({}, {}, data);
- expect(controller.removeHostComponentModel.calledWith('COMPONENT', 'h1')).to.be.true;
- });
- it('HIVE_METASTORE component', function () {
- var data = {
- componentName: 'HIVE_METASTORE'
- };
- controller._doDeleteHostComponentSuccessCallback({}, {}, data);
- expect(controller.get('_deletedHostComponentResult')).to.be.null;
- expect(controller.get('deleteHiveMetaStore')).to.be.true;
- expect(controller.loadConfigs.calledWith('loadHiveConfigs')).to.be.true;
- });
- it('NIMBUS component', function () {
- var data = {
- componentName: 'NIMBUS'
- };
- controller._doDeleteHostComponentSuccessCallback({}, {}, data);
- expect(controller.get('_deletedHostComponentResult')).to.be.null;
- expect(controller.get('deleteNimbusHost')).to.be.true;
- expect(controller.loadConfigs.calledWith('loadStormConfigs')).to.be.true;
- });
- it('RANGER_KMS_SERVER component', function () {
- var data = {
- componentName: 'RANGER_KMS_SERVER'
- };
- controller._doDeleteHostComponentSuccessCallback({}, {}, data);
- expect(controller.get('_deletedHostComponentResult')).to.be.null;
- expect(controller.get('deleteRangerKMSServer')).to.be.true;
- expect(controller.loadConfigs.calledWith('loadRangerConfigs')).to.be.true;
- });
- });
- describe('#upgradeComponentSuccessCallback()', function () {
- beforeEach(function () {
- sinon.stub(controller, 'showBackgroundOperationsPopup', Em.K);
- sinon.stub(controller, 'mimicWorkStatusChange', Em.K);
- });
- afterEach(function () {
- controller.mimicWorkStatusChange.restore();
- controller.showBackgroundOperationsPopup.restore();
- });
- it('testMode is true', function () {
- App.set('testMode', true);
- controller.upgradeComponentSuccessCallback({}, {}, {component: "COMP"});
- expect(controller.mimicWorkStatusChange.calledWith("COMP", App.HostComponentStatus.starting, App.HostComponentStatus.started)).to.be.true;
- expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
- });
- it('testMode is false', function () {
- App.set('testMode', false);
- controller.upgradeComponentSuccessCallback({}, {}, {component: "COMP"});
- expect(controller.mimicWorkStatusChange.called).to.be.false;
- expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
- });
- });
- describe('#refreshComponentConfigsSuccessCallback()', function () {
- it('call showBackgroundOperationsPopup', function () {
- sinon.stub(controller, 'showBackgroundOperationsPopup', Em.K);
- controller.refreshComponentConfigsSuccessCallback();
- expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
- controller.showBackgroundOperationsPopup.restore();
- });
- });
- describe('#checkZkConfigs()', function () {
- beforeEach(function () {
- sinon.stub(controller, 'removeObserver');
- sinon.stub(controller, 'loadConfigs');
- sinon.stub(controller, 'isServiceMetricsLoaded', function (callback) {
- callback();
- });
- });
- afterEach(function () {
- controller.loadConfigs.restore();
- controller.removeObserver.restore();
- controller.isServiceMetricsLoaded.restore();
- App.router.get.restore();
- });
- it('No operations of ZOOKEEPER_SERVER', function () {
- sinon.stub(App.router, 'get').withArgs('backgroundOperationsController.services').returns([]);
- controller.checkZkConfigs();
- expect(controller.removeObserver.called).to.be.false;
- expect(controller.loadConfigs.called).to.be.false;
- });
- it('Operation of ZOOKEEPER_SERVER running', function () {
- sinon.stub(App.router, 'get').withArgs('backgroundOperationsController.services').returns([Em.Object.create({
- id: 1,
- isRunning: true
- })]);
- controller.set('zkRequestId', 1);
- controller.checkZkConfigs();
- expect(controller.removeObserver.called).to.be.false;
- expect(controller.loadConfigs.called).to.be.false;
- });
- it('Operation of ZOOKEEPER_SERVER finished', function () {
- sinon.stub(App.router, 'get').withArgs('backgroundOperationsController.services').returns([Em.Object.create({
- id: 1
- })]);
- var clock = sinon.useFakeTimers();
- controller.set('zkRequestId', 1);
- controller.checkZkConfigs();
- expect(controller.removeObserver.calledWith('App.router.backgroundOperationsController.serviceTimestamp', controller, controller.checkZkConfigs)).to.be.true;
- clock.tick(App.get('componentsUpdateInterval'));
- expect(controller.loadConfigs.calledOnce).to.be.true;
- clock.restore();
- });
- });
- describe('#_doDeleteHostComponentErrorCallback()', function () {
- it('call showBackgroundOperationsPopup', function () {
- controller._doDeleteHostComponentErrorCallback({}, 'textStatus', {}, {url: 'url'});
- expect(controller.get('_deletedHostComponentResult')).to.be.eql({xhr: {}, url: 'url', method: 'DELETE'});
- });
- });
- describe('#installComponentSuccessCallback()', function () {
- beforeEach(function () {
- sinon.stub(controller, 'showBackgroundOperationsPopup', Em.K);
- sinon.stub(controller, 'mimicWorkStatusChange', Em.K);
- });
- afterEach(function () {
- controller.mimicWorkStatusChange.restore();
- controller.showBackgroundOperationsPopup.restore();
- });
- it('testMode is true', function () {
- App.set('testMode', true);
- controller.installComponentSuccessCallback({}, {}, {component: "COMP"});
- expect(controller.mimicWorkStatusChange.calledWith("COMP", App.HostComponentStatus.installing, App.HostComponentStatus.stopped)).to.be.true;
- expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
- });
- it('testMode is false', function () {
- App.set('testMode', false);
- controller.installComponentSuccessCallback({}, {}, {component: "COMP"});
- expect(controller.mimicWorkStatusChange.called).to.be.false;
- expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true;
- });
- });
- describe('#showHbaseActiveWarning()', function () {
- it('popup should be displayed', function () {
- sinon.spy(App.ModalPopup, "show");
- var popup = controller.showHbaseActiveWarning(Em.Object.create({service: {}}));
- expect(App.ModalPopup.show.calledOnce).to.be.true;
- App.ModalPopup.show.restore();
- });
- });
- describe('#updateHost()', function () {
- it('popup should be displayed', function () {
- sinon.stub(batchUtils, "infoPassiveState", Em.K);
- controller.updateHost({}, {}, {passive_state: 'state'});
- expect(controller.get('content.passiveState')).to.equal('state');
- expect(batchUtils.infoPassiveState.calledWith('state')).to.be.true;
- batchUtils.infoPassiveState.restore();
- });
- });
- describe('#updateComponentPassiveState()', function () {
- it('popup should be displayed', function () {
- controller.set('content.hostName', 'host1');
- var component = Em.Object.create({
- componentName: 'COMP1'
- });
- controller.updateComponentPassiveState(component, 'state', 'message');
- expect(App.ajax.send.getCall(0).args[0].data).to.be.eql({
- "hostName": "host1",
- "componentName": "COMP1",
- "component": component,
- "passive_state": "state",
- "context": "message"
- });
- });
- });
- describe('#updateHostComponent()', function () {
- it('popup should be displayed', function () {
- sinon.stub(batchUtils, "infoPassiveState", Em.K);
- var params = {
- component: Em.Object.create(),
- passive_state: 'state'
- };
- controller.updateHostComponent({}, {}, params);
- expect(params.component.get('passiveState')).to.equal('state');
- expect(batchUtils.infoPassiveState.calledWith('state')).to.be.true;
- batchUtils.infoPassiveState.restore();
- });
- });
- describe('#toggleMaintenanceMode()', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- sinon.stub(controller, 'updateComponentPassiveState');
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- controller.updateComponentPassiveState.restore();
- });
- it('passive state is ON', function () {
- var event = {
- context: Em.Object.create({
- passiveState: 'ON'
- })
- };
- var popup = controller.toggleMaintenanceMode(event);
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(controller.updateComponentPassiveState.calledWith(Em.Object.create({
- passiveState: 'ON'
- }), 'OFF')).to.be.true;
- });
- it('passive state is OFF', function () {
- var event = {
- context: Em.Object.create({
- passiveState: 'OFF'
- })
- };
- var popup = controller.toggleMaintenanceMode(event);
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(controller.updateComponentPassiveState.calledWith(Em.Object.create({
- passiveState: 'OFF'
- }), 'ON')).to.be.true;
- });
- });
- describe('#installClients()', function () {
- var cases = [
- {
- context: [
- Em.Object.create({
- componentName: 'c0',
- workStatus: 'INSTALLED'
- }),
- Em.Object.create({
- componentName: 'c1',
- workStatus: 'INIT'
- }),
- Em.Object.create({
- componentName: 'c2',
- workStatus: 'INSTALL_FAILED'
- })
- ],
- dependencies: {
- c0: [],
- c1: [],
- c2: []
- },
- getSecurityTypeCalled: null, //should have same value as getKDCSessionStateCalled, always
- getKDCSessionStateCalled: true,
- sendComponentCommandCalled: true,
- showAlertPopupCalled: false,
- title: 'No clients to add, some clients to install'
- },
- {
- context: [
- Em.Object.create({
- componentName: 'c3',
- displayName: 'c3'
- })
- ],
- dependencies: {
- c3: []
- },
- getSecurityTypeCalled: null, //should have same value as getKDCSessionStateCalled, always
- getKDCSessionStateCalled: true,
- sendComponentCommandCalled: false,
- showAlertPopupCalled: false,
- title: 'No clients to install, some clients to add'
- },
- {
- context: [
- Em.Object.create({
- componentName: 'c4',
- displayName: 'c4'
- })
- ],
- dependencies: {
- c4: ['c5']
- },
- getSecurityTypeCalled: null, //should have same value as getKDCSessionStateCalled, always
- getKDCSessionStateCalled: false,
- sendComponentCommandCalled: false,
- showAlertPopupCalled: true,
- title: 'Clients to add have unresolved dependencies'
- },
- {
- context: [
- Em.Object.create({
- componentName: 'c5',
- displayName: 'c5'
- }),
- Em.Object.create({
- componentName: 'c6',
- displayName: 'c6'
- })
- ],
- dependencies: {
- c5: ['c6'],
- c6: ['c5']
- },
- getSecurityTypeCalled: null, //should have same value as getKDCSessionStateCalled, always
- getKDCSessionStateCalled: true,
- sendComponentCommandCalled: false,
- showAlertPopupCalled: false,
- title: 'Clients to add have mutual dependencies'
- }
- ];
- beforeEach(function () {
- sinon.stub(controller, 'sendComponentCommand', Em.K);
- sinon.stub(controller, 'showAddComponentPopup', Em.K);
- sinon.stub(App.get('router.mainAdminKerberosController'), 'getKDCSessionState', function (arg) {
- return arg();
- });
- sinon.stub(App.get('router.mainAdminKerberosController'), 'getSecurityType', function (arg) {
- return arg();
- });
- sinon.stub(App, 'showAlertPopup', Em.K);
- sinon.stub(App.StackServiceComponent, 'find', function (componentName) {
- return Em.Object.create({
- displayName: componentName
- });
- });
- controller.set('content.hostComponents', []);
- });
- afterEach(function () {
- controller.sendComponentCommand.restore();
- controller.showAddComponentPopup.restore();
- App.get('router.mainAdminKerberosController').getKDCSessionState.restore();
- App.get('router.mainAdminKerberosController').getSecurityType.restore();
- App.showAlertPopup.restore();
- App.StackServiceComponent.find.restore();
- controller.checkComponentDependencies.restore();
- });
- cases.forEach(function (item) {
- it(item.title, function () {
- sinon.stub(controller, 'checkComponentDependencies', function (componentName, params) {
- return item.dependencies[componentName];
- });
- controller.installClients({
- context: item.context
- });
- expect(App.get('router.mainAdminKerberosController').getSecurityType.calledOnce).to.equal(item.getKDCSessionStateCalled);
- expect(App.get('router.mainAdminKerberosController').getKDCSessionState.calledOnce).to.equal(item.getKDCSessionStateCalled);
- expect(controller.sendComponentCommand.calledOnce).to.equal(item.sendComponentCommandCalled);
- expect(App.showAlertPopup.calledOnce).to.equal(item.showAlertPopupCalled);
- });
- });
- });
- describe("#executeCustomCommandSuccessCallback()", function () {
- it("BO popup should be shown", function () {
- var mock = {
- showPopup: Em.K
- };
- sinon.stub(App.router, 'get').returns(mock);
- sinon.spy(mock, 'showPopup');
- var data = {
- Requests: {
- id: 1
- }
- };
- controller.executeCustomCommandSuccessCallback(data, {}, {});
- expect(App.router.get.calledWith('backgroundOperationsController')).to.be.true;
- expect(mock.showPopup.calledOnce).to.be.true;
- App.router.get.restore();
- mock.showPopup.restore();
- });
- });
- describe("#executeCustomCommandErrorCallback()", function () {
- beforeEach(function () {
- sinon.stub($, 'parseJSON');
- sinon.spy(App, 'showAlertPopup');
- });
- afterEach(function () {
- App.showAlertPopup.restore();
- $.parseJSON.restore();
- });
- it("data empty", function () {
- controller.executeCustomCommandErrorCallback(null);
- expect(App.showAlertPopup.calledWith(Em.I18n.t('services.service.actions.run.executeCustomCommand.error'), Em.I18n.t('services.service.actions.run.executeCustomCommand.error'))).to.be.true;
- expect($.parseJSON.called).to.be.false;
- });
- it("responseText empty", function () {
- var data = {
- responseText: null
- };
- controller.executeCustomCommandErrorCallback(data);
- expect(App.showAlertPopup.calledWith(Em.I18n.t('services.service.actions.run.executeCustomCommand.error'), Em.I18n.t('services.service.actions.run.executeCustomCommand.error'))).to.be.true;
- expect($.parseJSON.called).to.be.false;
- });
- it("data empty", function () {
- var data = {
- responseText: "test"
- };
- controller.executeCustomCommandErrorCallback(data);
- expect(App.showAlertPopup.calledWith(Em.I18n.t('services.service.actions.run.executeCustomCommand.error'), Em.I18n.t('services.service.actions.run.executeCustomCommand.error'))).to.be.true;
- expect($.parseJSON.calledWith('test')).to.be.true;
- });
- });
- describe("#doDeleteHost()", function () {
- beforeEach(function () {
- controller.set('fromDeleteHost', false);
- controller.set('content.hostName', 'host1');
- sinon.stub(controller, '_doDeleteHostComponent', function (comp, callback) {
- callback();
- });
- });
- afterEach(function () {
- controller._doDeleteHostComponent.restore();
- });
- it("Host has no components", function () {
- controller.set('content.hostComponents', Em.A([]));
- controller.doDeleteHost(Em.K);
- expect(controller.get('fromDeleteHost')).to.be.true;
- expect(App.ajax.send.getCall(0).args[0].data.hostName).to.be.equal('host1');
- expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.delete.host');
- });
- it("Host has components", function () {
- controller.set('content.hostComponents', Em.A([Em.Object.create({
- componentName: 'COMP1'
- })]));
- controller.doDeleteHost(Em.K);
- expect(controller._doDeleteHostComponent.calledWith(Em.Object.create({
- componentName: 'COMP1'
- }))).to.be.true;
- expect(controller.get('fromDeleteHost')).to.be.true;
- expect(App.ajax.send.getCall(0).args[0].data.hostName).to.be.equal('host1');
- expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.delete.host');
- });
- });
- describe("#deleteHostSuccessCallback", function () {
- it("call updateHost", function () {
- var mock = {
- updateHost: function (callback) {
- callback();
- },
- getAllHostNames: Em.K
- };
- sinon.stub(App.router, 'get').withArgs('updateController').returns(mock).withArgs('clusterController').returns(mock);
- sinon.spy(mock, 'updateHost');
- sinon.spy(mock, 'getAllHostNames');
- sinon.stub(controller, 'loadConfigs', Em.K);
- sinon.stub(App.router, 'transitionTo', Em.K);
- sinon.stub(controller, 'isServiceMetricsLoaded', function (callback) {
- callback();
- });
- controller.deleteHostSuccessCallback();
- expect(App.router.get.calledWith('updateController')).to.be.true;
- expect(mock.updateHost.calledOnce).to.be.true;
- expect(controller.loadConfigs.called).to.be.false;
- expect(App.router.transitionTo.calledWith('hosts.index')).to.be.true;
- expect(App.router.get.calledWith('clusterController')).to.be.true;
- expect(mock.getAllHostNames.calledOnce).to.be.true;
- App.router.get.restore();
- mock.updateHost.restore();
- mock.getAllHostNames.restore();
- controller.loadConfigs.restore();
- controller.isServiceMetricsLoaded.restore();
- App.router.transitionTo.restore();
- });
- });
- describe("#deleteHostErrorCallback", function () {
- it("call defaultErrorHandler", function () {
- sinon.stub(controller, 'loadConfigs', Em.K);
- sinon.stub(App.ajax, 'defaultErrorHandler', Em.K);
- sinon.stub(controller, 'isServiceMetricsLoaded', function (callback) {
- callback();
- });
- controller.deleteHostErrorCallback({
- status: 'status',
- statusText: "statusText"
- }, 'textStatus', 'errorThrown', {url: 'url'});
- expect(controller.loadConfigs.calledOnce).to.be.true;
- expect(App.ajax.defaultErrorHandler.calledOnce).to.be.true;
- App.ajax.defaultErrorHandler.restore();
- controller.loadConfigs.restore();
- controller.isServiceMetricsLoaded.restore();
- });
- });
- describe('#installVersionConfirmation()', function () {
- beforeEach(function () {
- sinon.spy(App, "showConfirmationPopup");
- sinon.stub(controller, 'installVersion', Em.K);
- });
- afterEach(function () {
- App.showConfirmationPopup.restore();
- controller.installVersion.restore();
- });
- it('confirm popup should be displayed', function () {
- var event = {context: Em.Object.create({displayName: 'displayName'})};
- var popup = controller.installVersionConfirmation(event);
- expect(App.showConfirmationPopup.calledOnce).to.be.true;
- popup.onPrimary();
- expect(controller.installVersion.calledWith(event)).to.be.true;
- });
- });
- describe("#installVersion()", function () {
- it("call App.ajax.send", function () {
- controller.set('content.hostName', 'host1');
- controller.installVersion({context: {}});
- expect(App.ajax.send.getCall(0).args[0]).to.eql({
- name: 'host.stack_versions.install',
- sender: controller,
- data: {
- hostName: 'host1',
- version: {}
- },
- success: 'installVersionSuccessCallback'
- });
- });
- });
- describe("#installVersionSuccessCallback()", function () {
- before(function () {
- this.mock = sinon.stub(App.HostStackVersion, 'find');
- sinon.stub(App.db, 'set', Em.K);
- sinon.stub(App.clusterStatus, 'setClusterStatus', Em.K);
- });
- after(function () {
- this.mock.restore();
- App.db.set.restore();
- App.clusterStatus.setClusterStatus.restore();
- });
- it("", function () {
- var version = Em.Object.create({
- id: 1,
- status: 'INIT'
- });
- this.mock.returns(version);
- controller.installVersionSuccessCallback({Requests: {id: 1}}, {}, {version: version});
- expect(version.get('status')).to.equal('INSTALLING');
- expect(App.db.set.calledWith('repoVersionInstall', 'id', [1])).to.be.true;
- expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
- });
- });
- describe('#getHiveHosts()', function () {
- var cases = [
- {
- 'input': {
- 'hiveMetastoreHost': '',
- 'fromDeleteHost': false,
- 'deleteHiveMetaStore': false,
- 'deleteWebHCatServer': false
- },
- 'hiveHosts': ['h1', 'h2', 'h4'],
- 'title': 'adding HiveServer2'
- },
- {
- 'input': {
- 'hiveMetastoreHost': 'h0',
- 'fromDeleteHost': false,
- 'deleteHiveMetaStore': false,
- 'deleteWebHCatServer': false
- },
- 'hiveHosts': ['h0', 'h1', 'h2', 'h4'],
- 'title': 'adding Hive Metastore'
- },
- {
- 'input': {
- 'webhcatServerHost': 'h0',
- 'fromDeleteHost': false,
- 'deleteHiveMetaStore': false,
- 'deleteWebHCatServer': false
- },
- 'hiveHosts': ['h0', 'h1', 'h2', 'h4'],
- 'title': 'adding WebHCat Server'
- },
- {
- 'input': {
- 'hiveMetastoreHost': '',
- 'content.hostName': 'h1',
- 'fromDeleteHost': false,
- 'deleteHiveMetaStore': true,
- 'deleteWebHCatServer': false
- },
- 'hiveHosts': ['h2', 'h4'],
- 'title': 'deleting Hive component'
- },
- {
- 'input': {
- 'hiveMetastoreHost': '',
- 'content.hostName': 'h4',
- 'fromDeleteHost': false,
- 'deleteHiveMetaStore': false,
- 'deleteWebHCatServer': true
- },
- 'hiveHosts': ['h1', 'h2'],
- 'title': 'deleting WebHCat Server'
- },
- {
- 'input': {
- 'hiveMetastoreHost': '',
- 'content.hostName': 'h2',
- 'fromDeleteHost': true,
- 'deleteHiveMetaStore': false,
- 'deleteWebHCatServer': false
- },
- 'hiveHosts': ['h1', 'h4'],
- 'title': 'deleting host with Hive component'
- },
- {
- 'input': {
- 'webhcatServerHost': '',
- 'content.hostName': 'h2',
- 'fromDeleteHost': true,
- 'deleteHiveMetaStore': false,
- 'deleteWebHCatServer': false
- },
- 'hiveHosts': ['h1', 'h4'],
- 'title': 'deleting host with WebHCat Server'
- }
- ];
- before(function () {
- sinon.stub(App.HostComponent, 'find').returns([
- {
- componentName: 'HIVE_METASTORE',
- hostName: 'h2'
- },
- {
- componentName: 'HIVE_METASTORE',
- hostName: 'h1'
- },
- {
- componentName: 'HIVE_SERVER',
- hostName: 'h3'
- },
- {
- componentName: 'WEBHCAT_SERVER',
- hostName: 'h4'
- }
- ]);
- });
- after(function () {
- App.HostComponent.find.restore();
- });
- cases.forEach(function (item) {
- it(item.title, function () {
- Em.keys(item.input).forEach(function (key) {
- controller.set(key, item.input[key]);
- });
- expect(controller.getHiveHosts().toArray()).to.eql(item.hiveHosts);
- expect(controller.get('hiveMetastoreHost')).to.be.empty;
- expect(controller.get('webhcatServerHost')).to.be.empty;
- expect(controller.get('fromDeleteHost')).to.be.false;
- expect(controller.get('deleteHiveMetaStore')).to.be.false;
- });
- });
- });
- describe('#onLoadRangerConfigs()', function () {
- var cases = [
- {
- 'kmsHosts': ['host1'],
- 'kmsPort': 'port',
- 'title': 'single host',
- 'hostToInstall': undefined,
- 'result': [
- {
- properties: {
- 'core-site': {'hadoop.security.key.provider.path': 'kms://http@host1:port/kms'},
- 'hdfs-site': {'dfs.encryption.key.provider.uri': 'kms://http@host1:port/kms'}
- },
- properties_attributes: {
- 'core-site': undefined,
- 'hdfs-site': undefined
- }
- }
- ]
- },
- {
- 'kmsHosts': ['host1', 'host2'],
- 'kmsPort': 'port',
- 'title': 'two hosts',
- 'hostToInstall': 'host2',
- 'result': [
- {
- properties: {
- 'core-site': {'hadoop.security.key.provider.path': 'kms://http@host1;host2:port/kms'},
- 'hdfs-site': {'dfs.encryption.key.provider.uri': 'kms://http@host1;host2:port/kms'}
- },
- properties_attributes: {
- 'core-site': undefined,
- 'hdfs-site': undefined
- }
- }
- ]
- }
- ];
- beforeEach(function () {
- sinon.spy(controller, 'saveConfigsBatch')
- });
- afterEach(function () {
- controller.saveConfigsBatch.restore();
- });
- cases.forEach(function (item) {
- it(item.title, function () {
- controller.set('rangerKMSServerHost', item.hostToInstall);
- sinon.stub(controller, 'getRangerKMSServerHosts').returns(item.kmsHosts);
- var data = {
- items: [
- {
- type: 'kms-env',
- properties: {'kms_port': item.kmsPort}
- },
- {
- type: 'core-site',
- properties: {}
- },
- {
- type: 'hdfs-site',
- properties: {}
- }
- ]
- };
- controller.onLoadRangerConfigs(data);
- expect(controller.saveConfigsBatch.calledWith(item.result, 'RANGER_KMS_SERVER', item.hostToInstall)).to.be.true;
- });
- });
- });
- describe("#removeHostComponentModel()", function () {
- beforeEach(function () {
- sinon.stub(App.HostComponent, 'find').returns([
- Em.Object.create({
- id: 'C1_host1',
- componentName: 'C1',
- hostName: 'host1',
- service: Em.Object.create({
- serviceName: 'S1'
- })
- })
- ]);
- sinon.stub(App.serviceMapper, 'deleteRecord', Em.K);
- });
- afterEach(function () {
- App.HostComponent.find.restore();
- App.serviceMapper.deleteRecord.restore();
- });
- it("", function () {
- App.cache['services'] = [
- {
- ServiceInfo: {
- service_name: 'S1'
- },
- host_components: ['C1_host1']
- }
- ];
- controller.removeHostComponentModel('C1', 'host1');
- expect(App.cache['services'][0].host_components).to.be.empty;
- expect(App.HostComponent.find.calledOnce).to.be.true;
- expect(App.serviceMapper.deleteRecord.calledOnce).to.be.true;
- });
- });
- describe("#updateStormConfigs()", function () {
- beforeEach(function () {
- this.serviceMock = sinon.stub(App.Service, 'find');
- sinon.stub(controller, 'loadConfigs');
- this.mock = sinon.stub(App, 'get')
- });
- afterEach(function () {
- this.serviceMock.restore();
- this.mock.restore();
- controller.loadConfigs.restore();
- });
- it("storm not installed, hadoop stack is 2.2", function () {
- this.serviceMock.returns(Em.Object.create({
- isLoaded: false
- }));
- this.mock.returns(false);
- controller.updateStormConfigs();
- expect(controller.loadConfigs.called).to.be.false;
- });
- it("storm installed, hadoop stack is 2.2", function () {
- this.serviceMock.returns(Em.Object.create({
- isLoaded: true
- }));
- this.mock.returns(false);
- controller.updateStormConfigs();
- expect(controller.loadConfigs.called).to.be.false;
- });
- it("storm installed, hadoop stack is 2.3", function () {
- this.serviceMock.returns(Em.Object.create({
- isLoaded: true
- }));
- this.mock.returns(true);
- controller.updateStormConfigs();
- expect(controller.loadConfigs.calledWith('loadStormConfigs')).to.be.true;
- });
- });
- describe("#parseNnCheckPointTime", function () {
- var tests = [
- {
- m: "NameNode on this host has JMX data, the last checkpoint time is less than 12 hours ago",
- data:
- {
- "href" : "",
- "HostRoles" : {
- "cluster_name" : "c123",
- "component_name" : "NAMENODE",
- "host_name" : "c6401.ambari.apache.org"
- },
- "metrics" : {
- "dfs" : {
- "FSNamesystem" : {
- "HAState" : "active",
- "LastCheckpointTime" : 1435775648000
- }
- }
- }
- },
- result: false
- },
- {
- m: "NameNode on this host has JMX data, the last checkpoint time is > 12 hours ago",
- data:
- {
- "href" : "",
- "HostRoles" : {
- "cluster_name" : "c123",
- "component_name" : "NAMENODE",
- "host_name" : "c6401.ambari.apache.org"
- },
- "metrics" : {
- "dfs" : {
- "FSNamesystem" : {
- "HAState" : "active",
- "LastCheckpointTime" : 1435617248000
- }
- }
- }
- },
- result: "c6401.ambari.apache.org"
- },
- {
- m: "NameNode(standby) on this host has JMX data",
- data:
- {
- "href" : "",
- "HostRoles" : {
- "cluster_name" : "c123",
- "component_name" : "NAMENODE",
- "host_name" : "c6401.ambari.apache.org"
- },
- "metrics" : {
- "dfs" : {
- "FSNamesystem" : {
- "HAState" : "standby",
- "LastCheckpointTime" : 1435617248000
- }
- }
- }
- },
- result: false
- },
- {
- m: "NameNode on this host has no JMX data",
- data:
- {
- "href" : "",
- "HostRoles" : {
- "cluster_name" : "c123",
- "component_name" : "NAMENODE",
- "host_name" : "c6401.ambari.apache.org"
- },
- "metrics" : {
- "dfs" : {
- "FSNamesystem" : {
- "HAState" : "active"
- }
- }
- }
- },
- result: null
- },
- {
- m: "NameNode on this host has no JMX data",
- data:
- {
- "href" : "",
- "HostRoles" : {
- "cluster_name" : "c123",
- "component_name" : "NAMENODE",
- "host_name" : "c6401.ambari.apache.org"
- },
- "metrics" : {
- }
- },
- result: null
- }
- ];
- beforeEach(function () {
- sinon.stub(App, 'dateTime').returns(1435790048000);
- });
- afterEach(function () {
- App.dateTime.restore();
- });
- tests.forEach(function (test) {
- it(test.m, function () {
- var mainHostDetailsController = App.MainHostDetailsController.create({isNNCheckpointTooOld: null});
- mainHostDetailsController.parseNnCheckPointTime(test.data);
- expect(mainHostDetailsController.get('isNNCheckpointTooOld')).to.equal(test.result);
- });
- });
- });
- describe("#checkComponentDependencies()", function() {
- beforeEach(function () {
- this.mock = sinon.stub(App.StackServiceComponent, 'find');
- sinon.stub(App.HostComponent, 'find').returns([{
- hostName: 'host1',
- componentName: 'C1'
- }]);
- });
- afterEach(function () {
- this.mock.restore();
- App.HostComponent.find.restore();
- });
- it("no dependencies", function () {
- var opt = {scope: '*'};
- this.mock.returns(Em.Object.create({
- dependencies: []
- }));
- expect(controller.checkComponentDependencies('C1', opt)).to.be.empty;
- });
- it("dependecies already installed", function () {
- var opt = {scope: '*', installedComponents: ['C2']};
- this.mock.returns(Em.Object.create({
- dependencies: [{componentName: 'C2'}]
- }));
- expect(controller.checkComponentDependencies('C1', opt)).to.be.empty;
- });
- it("dependecies should be added", function () {
- var opt = {scope: '*', installedComponents: ['C2']};
- this.mock.returns(Em.Object.create({
- dependencies: [{componentName: 'C3'}]
- }));
- expect(controller.checkComponentDependencies('C1', opt)).to.eql(['C3']);
- });
- it("scope is host", function () {
- var opt = {scope: 'host', hostName: 'host1'};
- this.mock.returns(Em.Object.create({
- dependencies: [{componentName: 'C3', scope: 'host'}]
- }));
- expect(controller.checkComponentDependencies('C1', opt)).to.eql(['C3']);
- });
- });
- });
|