1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585 |
- /**
- * 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 Ember = require('ember');
- var App = require('app');
- require('models/stack_service_component');
- require('models/hosts');
- require('controllers/wizard');
- require('controllers/installer');
- require('controllers/wizard/step9_controller');
- require('utils/helper');
- require('utils/ajax/ajax');
- var modelSetup = require('test/init_model_test');
- var c, obj;
- describe('App.InstallerStep9Controller', function () {
- beforeEach(function () {
- modelSetup.setupStackServiceComponent();
- c = App.WizardStep9Controller.create({
- content: {controllerName: ''},
- saveClusterStatus: Em.K,
- saveInstalledHosts: Em.K,
- togglePreviousSteps: Em.K,
- setFinishState: Em.K,
- changeParseHostInfo: Em.K,
- parseHostInfoPolling: Em.K,
- wizardController: Em.Object.create({
- requestsId: [],
- cluster: {oldRequestsId: []},
- getDBProperty: function(name) {
- return this.get(name);
- }
- })
- });
- obj = App.InstallerController.create();
- sinon.stub(App.ajax, 'send', function() {
- return {
- then: function() {
- return true;
- },
- retry: function() {
- return {
- then: Em.K,
- complete: Em.K
- };
- },
- complete: Em.K
- };
- });
- });
- afterEach(function () {
- modelSetup.cleanStackServiceComponent();
- App.ajax.send.restore();
- });
- describe('#isSubmitDisabled', function () {
- var tests = Em.A([
- {controllerName: 'addHostController', state: 'STARTED', e: false},
- {controllerName: 'addHostController', state: 'START FAILED', e: false},
- {controllerName: 'addHostController', state: 'INSTALL FAILED', e: false},
- {controllerName: 'addHostController', state: 'PENDING', e: true},
- {controllerName: 'addHostController', state: 'INSTALLED', e: true},
- {controllerName: 'addServiceController', state: 'STARTED', e: false},
- {controllerName: 'addServiceController', state: 'START FAILED', e: false},
- {controllerName: 'addServiceController', state: 'INSTALL FAILED', e: false},
- {controllerName: 'addServiceController', state: 'PENDING', e: true},
- {controllerName: 'addServiceController', state: 'INSTALLED', e: true},
- {controllerName: 'installerController', state: 'STARTED', e: false},
- {controllerName: 'installerController', state: 'START FAILED', e: false},
- {controllerName: 'installerController', state: 'INSTALL FAILED', e: true},
- {controllerName: 'installerController', state: 'INSTALLED', e: true},
- {controllerName: 'installerController', state: 'PENDING', e: true}
- ]);
- tests.forEach(function (test) {
- var controller = App.WizardStep9Controller.create({
- saveClusterStatus: Em.K,
- saveInstalledHosts: Em.K,
- content: {
- controllerName: test.controllerName,
- cluster: {
- status: test.state
- }
- }
- });
- it('controllerName is ' + test.controllerName + '; cluster status is ' + test.state + '; isSubmitDisabled should be ' + test.e, function () {
- expect(controller.get('isSubmitDisabled')).to.equal(test.e);
- });
- });
- });
- describe('#status', function () {
- var tests = Em.A([
- {
- hosts: [
- {status: 'failed'},
- {status: 'success'}
- ],
- isStepFailed: false,
- progress: '100',
- m: 'One host is failed',
- e: 'failed'
- },
- {
- hosts: [
- {status: 'warning'},
- {status: 'success'}
- ],
- m: 'One host is failed and step is not failed',
- isStepFailed: false,
- progress: '100',
- e: 'warning'
- },
- {
- hosts: [
- {status: 'warning'},
- {status: 'success'}
- ],
- m: 'One host is failed and step is failed',
- isStepFailed: true,
- progress: '100',
- e: 'failed'
- },
- {
- hosts: [
- {status: 'success'},
- {status: 'success'}
- ],
- m: 'All hosts are success and progress is 100',
- isStepFailed: false,
- progress: '100',
- e: 'success'
- },
- {
- hosts: [
- {status: 'success'},
- {status: 'success'}
- ],
- m: 'All hosts are success and progress is 50',
- isStepFailed: false,
- progress: '50',
- e: 'info'
- }
- ]);
- tests.forEach(function (test) {
- var controller = App.WizardStep9Controller.create({
- saveClusterStatus: Em.K,
- saveInstalledHosts: Em.K,
- hosts: test.hosts,
- isStepFailed: function () {
- return test.isStepFailed
- },
- progress: test.progress
- });
- controller.updateStatus();
- it(test.m, function () {
- expect(controller.get('status')).to.equal(test.e);
- });
- });
- });
- describe('#showRetry', function () {
- it('cluster status is not INSTALL FAILED', function () {
- c.reopen({content: {cluster: {status: 'INSTALLED'}}});
- expect(c.get('showRetry')).to.equal(false);
- });
- it('cluster status is INSTALL FAILED', function () {
- c.reopen({content: {cluster: {status: 'INSTALL FAILED'}}});
- expect(c.get('showRetry')).to.equal(true);
- });
- });
- describe('#resetHostsForRetry', function () {
- it('All should have status "pending" and message "Waiting"', function () {
- var hosts = {'host1': Em.Object.create({status: 'failed', message: 'Failed'}), 'host2': Em.Object.create({status: 'success', message: 'Success'})};
- c.reopen({content: {hosts: hosts}});
- c.resetHostsForRetry();
- for (var name in hosts) {
- if (hosts.hasOwnProperty(name)) {
- expect(c.get('content.hosts')[name].get('status', 'pending')).to.equal('pending');
- expect(c.get('content.hosts')[name].get('message', 'Waiting')).to.equal('Waiting');
- }
- }
- });
- });
- describe('#setParseHostInfo', function () {
- var tasks = Em.A([
- Em.Object.create({
- Tasks: Em.Object.create({
- host_name: 'host1',
- status: 'PENDING'
- })
- }),
- Em.Object.create({
- Tasks: Em.Object.create({
- host_name: 'host1',
- status: 'PENDING'
- })
- })
- ]);
- var content = Em.Object.create({
- cluster: Em.Object.create({
- requestId: '11',
- status: 'PENDING'
- })
- });
- beforeEach(function(){
- c.set('content', content)
- });
- it('Should make parseHostInfo false"', function () {
- var polledData = Em.Object.create({
- tasks: tasks,
- Requests: Em.Object.create({
- id: '222'
- })
- });
- c.setParseHostInfo(polledData);
- expect(c.get('parseHostInfo')).to.be.false;
- });
- it('Should set polledData"', function () {
- var polledData = Em.Object.create({
- tasks: tasks,
- Requests: Em.Object.create({
- id: '11'
- })
- });
- c.setParseHostInfo(polledData);
- var expected = [
- {
- "Tasks": {
- "status": "PENDING",
- "host_name": "host1",
- "request_id": "11"
- }
- },
- {
- "Tasks": {
- "status": "PENDING",
- "host_name": "host1",
- "request_id": "11"
- }
- }
- ];
- var result = JSON.parse(JSON.stringify(c.get('polledData')));
- expect(result).to.eql(expected);
- });
- it('Should set progress for hosts"', function () {
- var polledData = Em.Object.create({
- tasks: tasks,
- Requests: Em.Object.create({
- id: '11'
- })
- });
- var hosts = Em.A([
- Em.Object.create({
- name: 'host1',
- logTasks: [
- {Tasks: {role: 'HDFS_CLIENT'}},
- {Tasks: {role: 'DATANODE'}}
- ],
- status: 'old_status',
- progress: '10',
- isNoTasksForInstall: true,
- e: {status: 'old_status', progress: '10'}
- }),
- Em.Object.create({
- name: 'host2',
- logTasks: [
- {Tasks: {role: 'HDFS_CLIENT'}}
- ],
- status: 'old_status',
- progress: '10',
- e: {status: 'success', progress: '100'}
- })
- ]);
- c.set('hosts', hosts);
- c.setParseHostInfo(polledData);
- var expected = [
- {
- "name": "host1",
- "logTasks": [
- {
- "Tasks": {
- "role": "HDFS_CLIENT",
- "status": "PENDING"
- }
- },
- {
- "Tasks": {
- "role": "DATANODE"
- }
- }
- ],
- "progress": "0",
- "isNoTasksForInstall": false,
- "e": {
- "status": "old_status",
- "progress": "10"
- },
- "status": "in_progress",
- "message": ""
- },
- {
- "name": "host2",
- "logTasks": [
- {
- "Tasks": {
- "role": "HDFS_CLIENT"
- }
- }
- ],
- "progress": "33",
- "e": {
- "status": "success",
- "progress": "100"
- },
- "status": "pending",
- "isNoTasksForInstall": true,
- "message": "Install complete (Waiting to start)"
- }
- ];
- var result = JSON.parse(JSON.stringify(c.get('hosts')));
- expect(result).to.eql(expected);
- });
- });
- var hosts_for_load_and_render = {
- 'host1': {
- message: 'message1',
- status: 'unknown',
- progress: '1',
- logTasks: [
- {},
- {}
- ],
- bootStatus: 'REGISTERED'
- },
- 'host2': {
- message: '',
- status: 'failed',
- progress: '1',
- logTasks: [
- {},
- {}
- ],
- bootStatus: ''
- },
- 'host3': {
- message: '',
- status: 'waiting',
- progress: null,
- logTasks: [
- {},
- {}
- ],
- bootStatus: ''
- },
- 'host4': {
- message: 'message4',
- status: null,
- progress: '10',
- logTasks: [
- {}
- ],
- bootStatus: 'REGISTERED'
- }
- };
- describe('#loadHosts', function () {
- beforeEach(function() {
- c.reopen({content: {hosts: hosts_for_load_and_render}});
- c.loadHosts();
- });
- it('Only REGISTERED hosts', function () {
- var loaded_hosts = c.get('hosts');
- expect(loaded_hosts.length).to.equal(2);
- });
- it('All hosts have progress 0', function () {
- var loaded_hosts = c.get('hosts');
- expect(loaded_hosts.everyProperty('progress', 0)).to.equal(true);
- });
- it('All hosts have progress 0', function () {
- var loaded_hosts = c.get('hosts');
- expect(loaded_hosts.everyProperty('progress', 0)).to.equal(true);
- });
- it('All host don\'t have logTasks', function () {
- var loaded_hosts = c.get('hosts');
- expect(loaded_hosts.everyProperty('logTasks.length', 0)).to.equal(true);
- });
- });
- describe('#isServicesStarted', function () {
- it('Should return false when server not started', function () {
- var polledData = Em.A([
- Em.Object.create({
- Tasks: Em.Object.create({
- status: 'PENDING'
- })
- }),
- Em.Object.create({
- Tasks: Em.Object.create({
- status: 'PENDING'
- })
- })
- ]);
- expect(c.isServicesStarted(polledData)).to.be.false;
- });
- it('Should return true when server started', function () {
- var polledData = Em.A([
- Em.Object.create({
- Tasks: Em.Object.create({
- status: 'NONE'
- })
- }),
- Em.Object.create({
- Tasks: Em.Object.create({
- status: 'NONE'
- })
- })
- ]);
- expect(c.isServicesStarted(polledData)).to.be.true;
- });
- it('Should return true when tasks completed', function () {
- var polledData = Em.A([
- Em.Object.create({
- Tasks: Em.Object.create({
- status: 'COMPLETED'
- })
- }),
- Em.Object.create({
- Tasks: Em.Object.create({
- status: 'COMPLETED'
- })
- })
- ]);
- expect(c.isServicesStarted(polledData)).to.be.true;
- });
- });
- describe('#setIsServicesInstalled', function () {
- it('Should return 100% completed', function () {
- var polledData = Em.A([
- Em.Object.create({
- Tasks: Em.Object.create({
- status: 'NONE'
- })
- }),
- Em.Object.create({
- Tasks: Em.Object.create({
- status: 'NONE'
- })
- })
- ]);
- c.setProperties({
- status: 'failed',
- isPolling: true,
- hosts: Em.A([
- Em.Object.create({
- progress: 0
- })
- ])
- });
- c.setIsServicesInstalled(polledData);
- expect(c.get('progress')).to.equal('100');
- expect(c.get('isPolling')).to.be.false;
- });
- it('Should return 34% completed', function () {
- var polledData = Em.A([
- Em.Object.create({
- Tasks: Em.Object.create({
- status: 'NONE'
- })
- }),
- Em.Object.create({
- Tasks: Em.Object.create({
- status: 'NONE'
- })
- })
- ]);
- c.setProperties({
- status: '',
- isPolling: true,
- hosts: Em.A([
- Em.Object.create({
- progress: 0
- })
- ]),
- content: Em.Object.create({
- controllerName: 'installerController'
- })
- });
- c.setIsServicesInstalled(polledData);
- expect(c.get('progress')).to.equal('34');
- expect(c.get('isPolling')).to.be.true;
- });
- });
- describe('#launchStartServices', function () {
- beforeEach(function() {
- sinon.stub(App, 'get', function(k) {
- if (k === 'components.slaves')
- return ["TASKTRACKER", "DATANODE",
- "JOURNALNODE", "ZKFC",
- "APP_TIMELINE_SERVER",
- "NODEMANAGER",
- "GANGLIA_MONITOR",
- "HBASE_REGIONSERVER",
- "SUPERVISOR",
- "FLUME_HANDLER"];
- return true;
- });
- });
- afterEach(function() {
- App.get.restore();
- });
- var tests = [
- {
- expected: [],
- message: 'should return query',
- controllerName: 'addHostController',
- hosts: Em.A([
- Em.Object.create({
- name: 'h1'
- }),
- Em.Object.create({
- name: 'h2'
- })
- ])
- },
- {
- expected: [],
- text: 'should return server info',
- controllerName: 'addServiceController',
- services: Em.A([
- Em.Object.create({
- serviceName: 'OOZIE',
- isSelected: true,
- isInstalled: false
- }),
- Em.Object.create({
- serviceName: 'h2',
- isSelected: false,
- isInstalled: true
- })
- ])
- },
- {
- expected: [],
- text: 'should return default data',
- controllerName: 'addHostContro',
- hosts: Em.A([
- Em.Object.create({
- name: 'h1'
- }),
- Em.Object.create({
- name: 'h2'
- })
- ])
- }
- ];
- tests.forEach(function(test) {
- it(test.message, function () {
- var content = Em.Object.create({
- controllerName: test.controllerName,
- services: test.services
- });
- var wizardController = Em.Object.create({
- getDBProperty: function() {
- return test.hosts
- }
- });
- c.set('content', content);
- c.set('wizardController', wizardController);
- expect(c.launchStartServices(function(){})).to.be.true;
- });
- })
- });
- describe('#hostHasClientsOnly', function () {
- var tests = Em.A([
- {
- hosts: [
- Em.Object.create({
- hostName: 'host1',
- logTasks: [
- {Tasks: {role: 'HDFS_CLIENT'}},
- {Tasks: {role: 'DATANODE'}}
- ],
- status: 'old_status',
- progress: '10',
- e: {status: 'old_status', progress: '10'}
- }),
- Em.Object.create({
- hostName: 'host2',
- logTasks: [
- {Tasks: {role: 'HDFS_CLIENT'}}
- ],
- status: 'old_status',
- progress: '10',
- e: {status: 'success', progress: '100'}
- })
- ],
- jsonError: false
- },
- {
- hosts: [
- Em.Object.create({
- hostName: 'host1',
- logTasks: [
- {Tasks: {role: 'HDFS_CLIENT'}},
- {Tasks: {role: 'DATANODE'}}
- ],
- status: 'old_status',
- progress: '10',
- e: {status: 'success', progress: '100'}
- }),
- Em.Object.create({
- hostName: 'host2',
- logTasks: [
- {Tasks: {role: 'HDFS_CLIENT'}}
- ],
- status: 'old_status',
- progress: '10',
- e: {status: 'success', progress: '100'}
- })
- ],
- jsonError: true
- }
- ]);
- tests.forEach(function (test) {
- it('', function () {
- c.reopen({hosts: test.hosts});
- c.hostHasClientsOnly(test.jsonError);
- test.hosts.forEach(function (host) {
- expect(c.get('hosts').findProperty('hostName', host.hostName).get('status')).to.equal(host.e.status);
- expect(c.get('hosts').findProperty('hostName', host.hostName).get('progress')).to.equal(host.e.progress);
- });
- });
- });
- });
- describe('#onSuccessPerHost', function () {
- var tests = Em.A([
- {
- cluster: {status: 'INSTALLED'},
- host: Em.Object.create({status: 'pending'}),
- actions: [],
- e: {status: 'success'},
- m: 'No tasks for host'
- },
- {
- cluster: {status: 'INSTALLED'},
- host: Em.Object.create({status: 'info'}),
- actions: [
- {Tasks: {status: 'COMPLETED'}},
- {Tasks: {status: 'COMPLETED'}}
- ],
- e: {status: 'success'},
- m: 'All Tasks COMPLETED and cluster status INSTALLED'
- },
- {
- cluster: {status: 'FAILED'},
- host: Em.Object.create({status: 'info'}),
- actions: [
- {Tasks: {status: 'COMPLETED'}},
- {Tasks: {status: 'COMPLETED'}}
- ],
- e: {status: 'info'},
- m: 'All Tasks COMPLETED and cluster status FAILED'
- },
- {
- cluster: {status: 'INSTALLED'},
- host: Em.Object.create({status: 'info'}),
- actions: [
- {Tasks: {status: 'FAILED'}},
- {Tasks: {status: 'COMPLETED'}}
- ],
- e: {status: 'info'},
- m: 'Not all Tasks COMPLETED and cluster status INSTALLED'
- },
- {
- cluster: {status: 'FAILED'},
- host: Em.Object.create({status: 'info'}),
- actions: [
- {Tasks: {status: 'FAILED'}},
- {Tasks: {status: 'COMPLETED'}}
- ],
- e: {status: 'info'},
- m: 'Not all Tasks COMPLETED and cluster status FAILED'
- }
- ]);
- tests.forEach(function (test) {
- it(test.m, function () {
- c.reopen({content: {cluster: {status: test.cluster.status}}});
- c.onSuccessPerHost(test.actions, test.host);
- expect(test.host.status).to.equal(test.e.status);
- });
- });
- });
- describe('#onErrorPerHost', function () {
- var tests = Em.A([
- {
- cluster: {status: 'INSTALLED'},
- host: Em.Object.create({status: 'pending'}),
- actions: [],
- e: {status: 'pending'},
- isMasterFailed: false,
- m: 'No tasks for host'
- },
- {
- cluster: {status: 'INSTALLED'},
- host: Em.Object.create({status: 'info'}),
- actions: [
- {Tasks: {status: 'FAILED'}},
- {Tasks: {status: 'COMPLETED'}}
- ],
- e: {status: 'warning'},
- isMasterFailed: false,
- m: 'One Task FAILED and cluster status INSTALLED'
- },
- {
- cluster: {status: 'INSTALLED'},
- host: Em.Object.create({status: 'info'}),
- actions: [
- {Tasks: {status: 'ABORTED'}},
- {Tasks: {status: 'COMPLETED'}}
- ],
- e: {status: 'warning'},
- isMasterFailed: false,
- m: 'One Task ABORTED and cluster status INSTALLED'
- },
- {
- cluster: {status: 'INSTALLED'},
- host: Em.Object.create({status: 'info'}),
- actions: [
- {Tasks: {status: 'TIMEDOUT'}},
- {Tasks: {status: 'COMPLETED'}}
- ],
- e: {status: 'warning'},
- isMasterFailed: false,
- m: 'One Task TIMEDOUT and cluster status INSTALLED'
- },
- {
- cluster: {status: 'PENDING'},
- host: Em.Object.create({status: 'info'}),
- actions: [
- {Tasks: {status: 'FAILED'}},
- {Tasks: {status: 'COMPLETED'}}
- ],
- e: {status: 'failed'},
- isMasterFailed: true,
- m: 'One Task FAILED and cluster status PENDING isMasterFailed true'
- },
- {
- cluster: {status: 'PENDING'},
- host: Em.Object.create({status: 'info'}),
- actions: [
- {Tasks: {status: 'COMPLETED'}},
- {Tasks: {status: 'COMPLETED'}}
- ],
- e: {status: 'info'},
- isMasterFailed: false,
- m: 'One Task FAILED and cluster status PENDING isMasterFailed false'
- }
- ]);
- tests.forEach(function (test) {
- it(test.m, function () {
- c.reopen({content: {cluster: {status: test.cluster.status}}, isMasterFailed: function () {
- return test.isMasterFailed;
- }});
- c.onErrorPerHost(test.actions, test.host);
- expect(test.host.status).to.equal(test.e.status);
- });
- });
- });
- describe('#isMasterFailed', function () {
- beforeEach(function() {
- sinon.stub(App, 'get', function(k) {
- if (k === 'components.slaves')
- return ["TASKTRACKER", "DATANODE", "JOURNALNODE", "ZKFC", "APP_TIMELINE_SERVER", "NODEMANAGER", "GANGLIA_MONITOR", "HBASE_REGIONSERVER", "SUPERVISOR", "FLUME_HANDLER"];
- return Em.get(App, k);
- });
- });
- afterEach(function() {
- App.get.restore();
- });
- var tests = Em.A([
- {
- actions: [
- {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'DATANODE'}},
- {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'TASKTRACKER'}},
- {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'HBASE_REGIONSERVER'}},
- {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'GANGLIA_MONITOR'}},
- {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'SUPERVISOR'}}
- ],
- e: false,
- m: 'No one Master is failed'
- },
- {
- actions: [
- {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'NAMENODE'}},
- {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'TASKTRACKER'}},
- {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'HBASE_REGIONSERVER'}},
- {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'GANGLIA_MONITOR'}},
- {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'SUPERVISOR'}}
- ],
- e: true,
- m: 'One Master is failed'
- },
- {
- actions: [
- {Tasks: {command: 'PENDING', status: 'FAILED', role: 'NAMENODE'}},
- {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'TASKTRACKER'}},
- {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'HBASE_REGIONSERVER'}},
- {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'GANGLIA_MONITOR'}},
- {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'SUPERVISOR'}}
- ],
- e: false,
- m: 'one Master is failed but command is not install'
- }
- ]);
- tests.forEach(function (test) {
- it(test.m, function () {
- expect(c.isMasterFailed(test.actions)).to.equal(test.e);
- });
- });
- });
- describe('#onInProgressPerHost', function () {
- var tests = Em.A([
- {
- host: Em.Object.create({message: 'default_message'}),
- actions: [
- {Tasks: {status: 'COMPLETED'}},
- {Tasks: {status: 'COMPLETED'}}
- ],
- e: {message: 'default_message', b: true},
- m: 'All Tasks COMPLETED'
- },
- {
- host: Em.Object.create({message: 'default_message'}),
- actions: [
- {Tasks: {status: 'IN_PROGRESS'}},
- {Tasks: {status: 'COMPLETED'}}
- ],
- e: {message: 'default_message', b: false},
- m: 'One Task IN_PROGRESS'
- },
- {
- host: Em.Object.create({message: 'default_message'}),
- actions: [
- {Tasks: {status: 'QUEUED'}},
- {Tasks: {status: 'COMPLETED'}}
- ],
- e: {message: 'default_message', b: false},
- m: 'One Task QUEUED'
- },
- {
- host: Em.Object.create({message: 'default_message'}),
- actions: [
- {Tasks: {status: 'PENDING'}},
- {Tasks: {status: 'COMPLETED'}}
- ],
- e: {message: 'default_message', b: false},
- m: 'One Task PENDING'
- }
- ]);
- tests.forEach(function (test) {
- it(test.m, function () {
- c.onInProgressPerHost(test.actions, test.host);
- expect(test.host.message == test.e.message).to.equal(test.e.b);
- });
- });
- });
- describe('#progressPerHost', function () {
- var tests = Em.A([
- {
- cluster: {status: 'PENDING'},
- host: Em.Object.create({progress: 0}),
- actions: [
- {Tasks: {status: 'COMPLETED'}},
- {Tasks: {status: 'COMPLETED'}},
- {Tasks: {status: 'QUEUED'}},
- {Tasks: {status: 'QUEUED'}},
- {Tasks: {status: 'IN_PROGRESS'}}
- ],
- e: {ret: 17, host: '17'},
- m: 'All types of status available. cluster status PENDING'
- },
- {
- cluster: {status: 'PENDING'},
- host: Em.Object.create({progress: 0}),
- actions: [],
- e: {ret: 33, host: '33'},
- m: 'No tasks available. cluster status PENDING'
- },
- {
- cluster: {status: 'INSTALLED'},
- host: Em.Object.create({progress: 0}),
- actions: [],
- e: {ret: 100, host: '100'},
- m: 'No tasks available. cluster status INSTALLED'
- },
- {
- cluster: {status: 'INSTALLED'},
- host: Em.Object.create({progress: 0}),
- actions: [
- {Tasks: {status: 'COMPLETED'}},
- {Tasks: {status: 'COMPLETED'}},
- {Tasks: {status: 'QUEUED'}},
- {Tasks: {status: 'QUEUED'}},
- {Tasks: {status: 'IN_PROGRESS'}}
- ],
- e: {ret: 68, host: '68'},
- m: 'All types of status available. cluster status INSTALLED'
- },
- {
- cluster: {status: 'FAILED'},
- host: Em.Object.create({progress: 0}),
- actions: [],
- e: {ret: 100, host: '100'},
- m: 'Cluster status is not PENDING or INSTALLED'
- }
- ]);
- tests.forEach(function (test) {
- it(test.m, function () {
- c.reopen({content: {cluster: {status: test.cluster.status}}});
- var progress = c.progressPerHost(test.actions, test.host);
- expect(progress).to.equal(test.e.ret);
- expect(test.host.progress).to.equal(test.e.host);
- });
- });
- });
- describe('#clearStep', function () {
- it('All to default values', function () {
- c.reopen({hosts: [{},{},{}]});
- c.clearStep();
- expect(c.get('hosts.length')).to.equal(0);
- expect(c.get('status')).to.equal('info');
- expect(c.get('progress')).to.equal('0');
- expect(c.get('numPolls')).to.equal(1);
- });
- });
- describe('#replacePolledData', function () {
- it('replacing polled data', function () {
- c.reopen({polledData: [{},{},{}]});
- var newPolledData = [{}];
- c.replacePolledData(newPolledData);
- expect(c.get('polledData.length')).to.equal(newPolledData.length);
- });
- });
- describe('#isSuccess', function () {
- var tests = Em.A([
- {
- polledData: [
- {Tasks: {status: 'COMPLETED'}},
- {Tasks: {status: 'COMPLETED'}}
- ],
- e: true,
- m: 'All tasks are COMPLETED'
- },
- {
- polledData: [
- {Tasks: {status: 'COMPLETED'}},
- {Tasks: {status: 'FAILED'}}
- ],
- e: false,
- m: 'Not all tasks are COMPLETED'
- }
- ]);
- tests.forEach(function (test) {
- it(test.m, function () {
- expect(c.isSuccess(test.polledData)).to.equal(test.e);
- });
- });
- });
- describe('#isStepFailed', function () {
- beforeEach(function() {
- sinon.stub(App, 'get', function(k) {
- if (k === 'components.slaves')
- return ["TASKTRACKER", "DATANODE", "JOURNALNODE", "ZKFC", "APP_TIMELINE_SERVER", "NODEMANAGER", "GANGLIA_MONITOR", "HBASE_REGIONSERVER", "SUPERVISOR", "FLUME_HANDLER"];
- return Em.get(App, k);
- });
- });
- afterEach(function() {
- App.get.restore();
- });
- var tests = Em.A([
- {
- polledData: [
- {Tasks: {command: 'INSTALL', role: 'GANGLIA_MONITOR', status: 'TIMEDOUT'}},
- {Tasks: {command: 'INSTALL', role: 'GANGLIA_MONITOR', status: 'FAILED'}},
- {Tasks: {command: 'INSTALL', role: 'GANGLIA_MONITOR', status: 'PENDING'}}
- ],
- e: true,
- m: 'GANGLIA_MONITOR 2/3 failed'
- },
- {
- polledData: [
- {Tasks: {command: 'INSTALL', role: 'GANGLIA_MONITOR', status: 'TIMEDOUT'}},
- {Tasks: {command: 'INSTALL', role: 'GANGLIA_MONITOR', status: 'PENDING'}},
- {Tasks: {command: 'INSTALL', role: 'GANGLIA_MONITOR', status: 'PENDING'}}
- ],
- e: false,
- m: 'GANGLIA_MONITOR 1/3 failed'
- },
- {
- polledData: [
- {Tasks: {command: 'INSTALL', role: 'HBASE_REGIONSERVER', status: 'TIMEDOUT'}},
- {Tasks: {command: 'INSTALL', role: 'HBASE_REGIONSERVER', status: 'FAILED'}},
- {Tasks: {command: 'INSTALL', role: 'HBASE_REGIONSERVER', status: 'PENDING'}}
- ],
- e: true,
- m: 'HBASE_REGIONSERVER 2/3 failed'
- },
- {
- polledData: [
- {Tasks: {command: 'INSTALL', role: 'HBASE_REGIONSERVER', status: 'TIMEDOUT'}},
- {Tasks: {command: 'INSTALL', role: 'HBASE_REGIONSERVER', status: 'PENDING'}},
- {Tasks: {command: 'INSTALL', role: 'HBASE_REGIONSERVER', status: 'PENDING'}}
- ],
- e: false,
- m: 'HBASE_REGIONSERVER 1/3 failed'
- },
- {
- polledData: [
- {Tasks: {command: 'INSTALL', role: 'TASKTRACKER', status: 'TIMEDOUT'}},
- {Tasks: {command: 'INSTALL', role: 'TASKTRACKER', status: 'FAILED'}},
- {Tasks: {command: 'INSTALL', role: 'TASKTRACKER', status: 'PENDING'}}
- ],
- e: true,
- m: 'TASKTRACKER 2/3 failed'
- },
- {
- polledData: [
- {Tasks: {command: 'INSTALL', role: 'TASKTRACKER', status: 'TIMEDOUT'}},
- {Tasks: {command: 'INSTALL', role: 'TASKTRACKER', status: 'PENDING'}},
- {Tasks: {command: 'INSTALL', role: 'TASKTRACKER', status: 'PENDING'}}
- ],
- e: false,
- m: 'TASKTRACKER 1/3 failed'
- },
- {
- polledData: [
- {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'TIMEDOUT'}},
- {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'FAILED'}},
- {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'PENDING'}}
- ],
- e: true,
- m: 'DATANODE 2/3 failed'
- },
- {
- polledData: [
- {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'TIMEDOUT'}},
- {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'PENDING'}},
- {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'PENDING'}}
- ],
- e: false,
- m: 'DATANODE 1/3 failed'
- },
- {
- polledData: [
- {Tasks: {command: 'INSTALL', role: 'NAMENODE', status: 'TIMEDOUT'}},
- {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'PENDING'}},
- {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'PENDING'}}
- ],
- e: true,
- m: 'NAMENODE failed'
- },
- {
- polledData: [
- {Tasks: {command: 'INSTALL', role: 'NAMENODE', status: 'PENDING'}},
- {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'PENDING'}},
- {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'PENDING'}}
- ],
- e: false,
- m: 'Nothing failed failed'
- }
- ]);
- tests.forEach(function (test) {
- it(test.m, function () {
- c.reopen({polledData: test.polledData});
- expect(c.isStepFailed()).to.equal(test.e);
- });
- });
- });
- describe('#setLogTasksStatePerHost', function () {
- var tests = Em.A([
- {
- tasksPerHost: [
- {Tasks: {id: 1, status: 'COMPLETED'}},
- {Tasks: {id: 2, status: 'COMPLETED'}}
- ],
- tasks: [],
- e: {m: 'COMPLETED', l: 2},
- m: 'host didn\'t have tasks and got 2 new'
- },
- {
- tasksPerHost: [
- {Tasks: {id: 1, status: 'COMPLETED'}},
- {Tasks: {id: 2, status: 'COMPLETED'}}
- ],
- tasks: [
- {Tasks: {id: 1, status: 'IN_PROGRESS'}},
- {Tasks: {id: 2, status: 'IN_PROGRESS'}}
- ],
- e: {m: 'COMPLETED', l: 2},
- m: 'host had 2 tasks and got both updated'
- },
- {
- tasksPerHost: [],
- tasks: [
- {Tasks: {id: 1, status: 'IN_PROGRESS'}},
- {Tasks: {id: 2, status: 'IN_PROGRESS'}}
- ],
- e: {m: 'IN_PROGRESS', l: 2},
- m: 'host had 2 tasks and didn\'t get updates'
- },
- {
- tasksPerHost: [
- {Tasks: {id: 1, status: 'COMPLETED'}},
- {Tasks: {id: 2, status: 'COMPLETED'}},
- {Tasks: {id: 3, status: 'COMPLETED'}}
- ],
- tasks: [
- {Tasks: {id: 1, status: 'IN_PROGRESS'}},
- {Tasks: {id: 2, status: 'IN_PROGRESS'}}
- ],
- e: {m: 'COMPLETED', l: 3},
- m: 'host had 2 tasks and got both updated and 1 new'
- }
- ]);
- tests.forEach(function (test) {
- it(test.m, function () {
- c.reopen({hosts: [Em.Object.create({logTasks: test.tasks})]});
- c.setLogTasksStatePerHost(test.tasksPerHost, c.get('hosts')[0]);
- expect(c.get('hosts')[0].get('logTasks').everyProperty('Tasks.status', test.e.m)).to.equal(true);
- expect(c.get('hosts')[0].get('logTasks.length')).to.equal(test.e.l);
- });
- });
- });
- // On completion of Start all services error callback function,
- // Cluster Status should be INSTALL FAILED
- // All progress bar on the screen should be finished (100%) with blue color.
- // Retry button should be enabled, next button should be disabled
- describe('#launchStartServicesErrorCallback', function () {
- beforeEach(function() {
- sinon.stub(App, 'get', function(k) {
- if ('testMode' === k) return true;
- return Em.get(App, k);
- });
- });
- afterEach(function() {
- App.get.restore();
- });
- it('Main progress bar on the screen should be finished (100%) with red color', function () {
- var hosts = Em.A([Em.Object.create({name: 'host1', progress: '33', status: 'info'}), Em.Object.create({name: 'host2', progress: '33', status: 'info'})]);
- c.reopen({hosts: hosts, content: {controllerName: 'installerController', cluster: {status: 'PENDING', name: 'c1'}}});
- c.launchStartServicesErrorCallback({status: 500, statusTesxt: 'Server Error'}, {}, '', {});
- expect(c.get('progress')).to.equal('100');
- expect(c.get('status')).to.equal('failed');
- });
- it('All Host progress bars on the screen should be finished (100%) with blue color', function () {
- var hosts = Em.A([Em.Object.create({name: 'host1', progress: '33', status: 'info'}), Em.Object.create({name: 'host2', progress: '33', status: 'info'})]);
- c.reopen({hosts: hosts, content: {controllerName: 'installerController', cluster: {status: 'PENDING', name: 'c1'}}});
- c.launchStartServicesErrorCallback({status: 500, statusTesxt: 'Server Error'}, {}, '', {});
- c.get('hosts').forEach(function (host) {
- expect(host.get('progress')).to.equal('100');
- expect(host.get('status')).to.equal('info');
- });
- });
- it('Next button should be disabled', function () {
- var hosts = Em.A([Em.Object.create({name: 'host1', progress: '33', status: 'info'}), Em.Object.create({name: 'host2', progress: '33', status: 'info'})]);
- c.reopen({hosts: hosts, content: {controllerName: 'installerController', cluster: {status: 'PENDING', name: 'c1'}}});
- c.launchStartServicesErrorCallback({status: 500, statusTesxt: 'Server Error'}, {}, '', {});
- expect(c.get('isSubmitDisabled')).to.equal(true);
- });
- });
- describe('#submit', function () {
- it('should call App.router.send', function () {
- sinon.stub(App.router, 'send', Em.K);
- c.submit();
- expect(App.router.send.calledWith('next')).to.equal(true);
- App.router.send.restore();
- });
- });
- describe('#back', function () {
- beforeEach(function () {
- sinon.stub(App.router, 'send', Em.K);
- });
- afterEach(function () {
- App.router.send.restore();
- });
- it('should call App.router.send', function () {
- c.reopen({isSubmitDisabled: false});
- c.back();
- expect(App.router.send.calledWith('back')).to.equal(true);
- });
- it('shouldn\'t call App.router.send', function () {
- c.reopen({isSubmitDisabled: true});
- c.back();
- expect(App.router.send.called).to.equal(false);
- });
- });
- describe('#loadStep', function () {
- beforeEach(function () {
- sinon.stub(c, 'clearStep', Em.K);
- sinon.stub(c, 'loadHosts', Em.K);
- });
- afterEach(function () {
- c.clearStep.restore();
- c.loadHosts.restore();
- });
- it('should call clearStep', function () {
- c.loadStep();
- expect(c.clearStep.calledOnce).to.equal(true);
- });
- it('should call loadHosts', function () {
- c.loadStep();
- expect(c.loadHosts.calledOnce).to.equal(true);
- });
- });
- describe('#startPolling', function () {
- beforeEach(function () {
- sinon.stub(c, 'getLogsByRequestErrorCallback', Em.K);
- });
- afterEach(function () {
- c.getLogsByRequestErrorCallback.restore();
- });
- it('should set isSubmitDisabled to true', function () {
- c.set('isSubmitDisabled', false);
- c.startPolling();
- expect(c.get('isSubmitDisabled')).to.equal(true);
- });
- it('should call doPolling', function () {
- sinon.stub(c, 'doPolling', Em.K);
- c.startPolling();
- expect(c.doPolling.calledOnce).to.equal(true);
- c.doPolling.restore();
- });
- });
- describe('#loadLogData', function () {
- beforeEach(function () {
- obj.reopen({
- cluster: {oldRequestsId: [1,2,3]},
- getDBProperty: function (name) {
- return this.get(name);
- }
- });
- c.reopen({wizardController: obj});
- sinon.stub(c, 'getLogsByRequest', Em.K);
- });
- afterEach(function () {
- c.getLogsByRequest.restore();
- });
- it('should call getLogsByRequest 1 time with 3', function () {
- c.loadLogData(true);
- expect(c.getLogsByRequest.calledWith(true, 3)).to.equal(true);
- });
- it('should set POLL_INTERVAL to 1 if testMode enabled', function () {
- sinon.stub(App, 'get', function(k) { if ('testMode' === k) return true; return Em.get(App, k);});
- c.loadLogData();
- expect(c.get('POLL_INTERVAL')).to.equal(1);
- App.get.restore();
- });
- });
- describe('#loadCurrentTaskLog', function () {
- beforeEach(function () {
- sinon.stub(c, 'loadLogData', Em.K);
- c.set('wizardController', Em.Object.create({
- getDBProperty: Em.K
- }));
- });
- afterEach(function () {
- c.loadLogData.restore();
- });
- it('shouldn\'t call App.ajax.send if no currentOpenTaskId', function () {
- c.set('currentOpenTaskId', null);
- c.loadCurrentTaskLog();
- expect(App.ajax.send.called).to.equal(false);
- });
- it('should call App.ajax.send with provided data', function () {
- sinon.stub(c, 'togglePreviousSteps', Em.K);
- c.set('currentOpenTaskId', 1);
- c.set('currentOpenTaskRequestId', 2);
- c.set('content', {cluster: {name: 3}});
- c.loadCurrentTaskLog();
- expect(App.ajax.send.args[0][0].data).to.eql({taskId: 1, requestId: 2, clusterName: 3});
- c.togglePreviousSteps.restore();
- });
- });
- describe('#loadCurrentTaskLogSuccessCallback', function () {
- beforeEach(function() {
- sinon.stub(c, 'getLogsByRequest', Em.K);
- sinon.stub(c, 'loadLogData', Em.K);
- });
- afterEach(function() {
- c.getLogsByRequest.restore();
- c.loadLogData.restore();
- });
- it('should increment logTasksChangesCounter', function () {
- c.set('logTasksChangesCounter', 0);
- c.loadCurrentTaskLogSuccessCallback();
- expect(c.get('logTasksChangesCounter')).to.equal(1);
- });
- it('should update stdout, stderr', function () {
- c.set('currentOpenTaskId', 1);
- c.reopen({
- hosts: [
- Em.Object.create({
- name: 'h1',
- logTasks: [
- {Tasks: {id: 1, stdout: '', stderr: ''}}
- ]
- })
- ]
- });
- var data = {Tasks: {host_name: 'h1', id: 1, stderr: 'stderr', stdout: 'stdout'}};
- c.loadCurrentTaskLogSuccessCallback(data);
- var t = c.get('hosts')[0].logTasks[0].Tasks;
- expect(t.stdout).to.equal('stdout');
- expect(t.stderr).to.equal('stderr');
- });
- it('shouldn\'t update stdout, stderr', function () {
- c.set('currentOpenTaskId', 1);
- c.reopen({
- hosts: [
- Em.Object.create({
- name: 'h1',
- logTasks: [
- {Tasks: {id: 2, stdout: '', stderr: ''}}
- ]
- })
- ]
- });
- var data = {Tasks: {host_name: 'h1', id: 1, stderr: 'stderr', stdout: 'stdout'}};
- c.loadCurrentTaskLogSuccessCallback(data);
- var t = c.get('hosts')[0].logTasks[0].Tasks;
- expect(t.stdout).to.equal('');
- expect(t.stderr).to.equal('');
- });
- it('shouldn\'t update stdout, stderr (2)', function () {
- c.set('currentOpenTaskId', 1);
- c.reopen({
- hosts: [
- Em.Object.create({
- name: 'h2',
- logTasks: [
- {Tasks: {id: 1, stdout: '', stderr: ''}}
- ]
- })
- ]
- });
- var data = {Tasks: {host_name: 'h1', id: 1, stderr: 'stderr', stdout: 'stdout'}};
- c.loadCurrentTaskLogSuccessCallback(data);
- var t = c.get('hosts')[0].logTasks[0].Tasks;
- expect(t.stdout).to.equal('');
- expect(t.stderr).to.equal('');
- });
- });
- describe('#loadCurrentTaskLogErrorCallback', function () {
- it('should set currentOpenTaskId to 0', function () {
- c.set('currentOpenTaskId', 123);
- c.loadCurrentTaskLogErrorCallback();
- expect(c.get('currentOpenTaskId')).to.equal(0);
- });
- });
- describe('#doPolling', function () {
- beforeEach(function () {
- sinon.stub(c, 'getLogsByRequest', Em.K);
- sinon.stub(c, 'togglePreviousSteps', Em.K);
- });
- afterEach(function () {
- c.getLogsByRequest.restore();
- c.togglePreviousSteps.restore();
- });
- it('should increment numPolls if testMode', function () {
- App.set('testMode', true);
- c.set('numPolls', 0);
- c.doPolling();
- expect(c.get('numPolls')).to.equal(1);
- App.set('testMode', false);
- });
- it('should call getLogsByRequest', function () {
- c.set('content', {cluster: {requestId: 1}});
- c.doPolling();
- expect(c.getLogsByRequest.calledWith(true, 1)).to.equal(true);
- });
- });
- describe('#isAllComponentsInstalledErrorCallback', function () {
- beforeEach(function () {
- sinon.stub(c, 'saveClusterStatus', Em.K);
- sinon.stub(c, 'togglePreviousSteps', Em.K);
- });
- afterEach(function () {
- c.saveClusterStatus.restore();
- c.togglePreviousSteps.restore();
- });
- it('should call saveClusterStatus', function () {
- c.isAllComponentsInstalledErrorCallback({});
- expect(c.saveClusterStatus.calledOnce).to.equal(true);
- });
- });
- describe('#navigateStep', function () {
- beforeEach(function () {
- sinon.stub(c, 'togglePreviousSteps', Em.K);
- sinon.stub(c, 'loadStep', Em.K);
- sinon.stub(c, 'loadLogData', Em.K);
- sinon.stub(c, 'startPolling', Em.K);
- });
- afterEach(function () {
- c.togglePreviousSteps.restore();
- c.loadStep.restore();
- c.loadLogData.restore();
- c.startPolling.restore();
- App.get.restore();
- });
- it('should set custom data in testMode', function () {
- sinon.stub(App, 'get', function(k) {if('testMode' === k) return true; return Em.get(App, k);});
- c.reopen({content: {cluster: {status: 'st', isCompleted: true, requestId: 0}}});
- c.navigateStep();
- expect(c.get('content.cluster.status')).to.equal('PENDING');
- expect(c.get('content.cluster.isCompleted')).to.equal(false);
- expect(c.get('content.cluster.requestId')).to.equal(1);
- });
- it('isCompleted = true, requestId = 1', function () {
- sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);});
- c.reopen({content: {cluster: {isCompleted: true, requestId: 1}}});
- c.navigateStep();
- expect(c.loadStep.calledOnce).to.equal(true);
- expect(c.loadLogData.calledWith(false)).to.equal(true);
- expect(c.get('progress')).to.equal('100');
- });
- it('isCompleted = false, requestId = 1, status = INSTALL FAILED', function () {
- sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);});
- c.reopen({content: {cluster: {status: 'INSTALL FAILED', isCompleted: false, requestId: 1}}});
- c.navigateStep();
- expect(c.loadStep.calledOnce).to.equal(true);
- expect(c.loadLogData.calledWith(false)).to.equal(true);
- });
- it('isCompleted = false, requestId = 1, status = START FAILED', function () {
- sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);});
- c.reopen({content: {cluster: {status: 'START FAILED', isCompleted: false, requestId: 1}}});
- c.navigateStep();
- expect(c.loadStep.calledOnce).to.equal(true);
- expect(c.loadLogData.calledWith(false)).to.equal(true);
- });
- it('isCompleted = false, requestId = 1, status = OTHER', function () {
- sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);});
- c.reopen({content: {cluster: {status: 'STARTED', isCompleted: false, requestId: 1}}});
- c.navigateStep();
- expect(c.loadStep.calledOnce).to.equal(true);
- expect(c.loadLogData.calledWith(true)).to.equal(true);
- });
- });
- describe('#launchStartServicesSuccessCallback', function () {
- beforeEach(function () {
- sinon.stub(App.clusterStatus, 'setClusterStatus', function() {
- return $.ajax();
- });
- sinon.stub(c, 'saveClusterStatus', Em.K);
- sinon.stub(c, 'doPolling', Em.K);
- sinon.stub(c, 'hostHasClientsOnly', Em.K);
- });
- afterEach(function () {
- c.saveClusterStatus.restore();
- c.doPolling.restore();
- c.hostHasClientsOnly.restore();
- App.clusterStatus.setClusterStatus.restore();
- });
- it('should call doPolling if some data were received', function () {
- c.launchStartServicesSuccessCallback({Requests: {id: 2}});
- expect(c.doPolling.calledOnce).to.equal(true);
- });
- Em.A([
- {
- jsonData: {Requests: {id: 2}},
- e: {
- hostHasClientsOnly: false,
- clusterStatus: {
- status: 'INSTALLED',
- requestId: 2,
- isStartError: false,
- isCompleted: false
- }
- }
- },
- {
- jsonData: null,
- e: {
- hostHasClientsOnly: true,
- clusterStatus: {
- status: 'STARTED',
- isStartError: false,
- isCompleted: true
- },
- status: 'success',
- progress: '100'
- }
- }
- ]).forEach(function (test) {
- it(test.m, function () {
- c.launchStartServicesSuccessCallback(test.jsonData);
- expect(c.hostHasClientsOnly.calledWith(test.e.hostHasClientsOnly)).to.equal(true);
- expect(c.saveClusterStatus.calledWith(test.e.clusterStatus)).to.equal(true);
- if (test.e.status) {
- expect(c.get('status')).to.equal(test.e.status);
- }
- if (test.e.progress) {
- expect(c.get('progress')).to.equal(test.e.progress);
- }
- });
- });
- });
- });
|