step9_test.js 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var Ember = require('ember');
  19. var App = require('app');
  20. require('models/stack_service_component');
  21. require('models/hosts');
  22. require('controllers/wizard');
  23. require('controllers/installer');
  24. require('controllers/wizard/step9_controller');
  25. require('utils/helper');
  26. require('utils/ajax/ajax');
  27. var modelSetup = require('test/init_model_test');
  28. var c, obj;
  29. describe('App.InstallerStep9Controller', function () {
  30. beforeEach(function () {
  31. modelSetup.setupStackServiceComponent();
  32. c = App.WizardStep9Controller.create({
  33. content: {controllerName: ''},
  34. saveClusterStatus: Em.K,
  35. saveInstalledHosts: Em.K,
  36. togglePreviousSteps: Em.K,
  37. setFinishState: Em.K,
  38. changeParseHostInfo: Em.K,
  39. parseHostInfoPolling: Em.K,
  40. wizardController: Em.Object.create({
  41. requestsId: [],
  42. cluster: {oldRequestsId: []},
  43. getDBProperty: function(name) {
  44. return this.get(name);
  45. }
  46. })
  47. });
  48. obj = App.InstallerController.create();
  49. sinon.stub(App.ajax, 'send', function() {
  50. return {
  51. retry: function() {
  52. return {
  53. then: Em.K,
  54. complete: Em.K
  55. };
  56. },
  57. complete: Em.K
  58. };
  59. });
  60. });
  61. afterEach(function () {
  62. modelSetup.cleanStackServiceComponent();
  63. App.ajax.send.restore();
  64. });
  65. describe('#isSubmitDisabled', function () {
  66. var tests = Em.A([
  67. {controllerName: 'addHostController', state: 'STARTED', e: false},
  68. {controllerName: 'addHostController', state: 'START FAILED', e: false},
  69. {controllerName: 'addHostController', state: 'INSTALL FAILED', e: false},
  70. {controllerName: 'addHostController', state: 'PENDING', e: true},
  71. {controllerName: 'addHostController', state: 'INSTALLED', e: true},
  72. {controllerName: 'addServiceController', state: 'STARTED', e: false},
  73. {controllerName: 'addServiceController', state: 'START FAILED', e: false},
  74. {controllerName: 'addServiceController', state: 'INSTALL FAILED', e: false},
  75. {controllerName: 'addServiceController', state: 'PENDING', e: true},
  76. {controllerName: 'addServiceController', state: 'INSTALLED', e: true},
  77. {controllerName: 'installerController', state: 'STARTED', e: false},
  78. {controllerName: 'installerController', state: 'START FAILED', e: false},
  79. {controllerName: 'installerController', state: 'INSTALL FAILED', e: true},
  80. {controllerName: 'installerController', state: 'INSTALLED', e: true},
  81. {controllerName: 'installerController', state: 'PENDING', e: true}
  82. ]);
  83. tests.forEach(function (test) {
  84. var controller = App.WizardStep9Controller.create({
  85. saveClusterStatus: Em.K,
  86. saveInstalledHosts: Em.K,
  87. content: {
  88. controllerName: test.controllerName,
  89. cluster: {
  90. status: test.state
  91. }
  92. }
  93. });
  94. it('controllerName is ' + test.controllerName + '; cluster status is ' + test.state + '; isSubmitDisabled should be ' + test.e, function () {
  95. expect(controller.get('isSubmitDisabled')).to.equal(test.e);
  96. });
  97. });
  98. });
  99. describe('#status', function () {
  100. var tests = Em.A([
  101. {
  102. hosts: [
  103. {status: 'failed'},
  104. {status: 'success'}
  105. ],
  106. isStepFailed: false,
  107. progress: '100',
  108. m: 'One host is failed',
  109. e: 'failed'
  110. },
  111. {
  112. hosts: [
  113. {status: 'warning'},
  114. {status: 'success'}
  115. ],
  116. m: 'One host is failed and step is not failed',
  117. isStepFailed: false,
  118. progress: '100',
  119. e: 'warning'
  120. },
  121. {
  122. hosts: [
  123. {status: 'warning'},
  124. {status: 'success'}
  125. ],
  126. m: 'One host is failed and step is failed',
  127. isStepFailed: true,
  128. progress: '100',
  129. e: 'failed'
  130. },
  131. {
  132. hosts: [
  133. {status: 'success'},
  134. {status: 'success'}
  135. ],
  136. m: 'All hosts are success and progress is 100',
  137. isStepFailed: false,
  138. progress: '100',
  139. e: 'success'
  140. },
  141. {
  142. hosts: [
  143. {status: 'success'},
  144. {status: 'success'}
  145. ],
  146. m: 'All hosts are success and progress is 50',
  147. isStepFailed: false,
  148. progress: '50',
  149. e: 'info'
  150. }
  151. ]);
  152. tests.forEach(function (test) {
  153. var controller = App.WizardStep9Controller.create({
  154. saveClusterStatus: Em.K,
  155. saveInstalledHosts: Em.K,
  156. hosts: test.hosts,
  157. isStepFailed: function () {
  158. return test.isStepFailed
  159. },
  160. progress: test.progress
  161. });
  162. controller.updateStatus();
  163. it(test.m, function () {
  164. expect(controller.get('status')).to.equal(test.e);
  165. });
  166. });
  167. });
  168. describe('#showRetry', function () {
  169. it('cluster status is not INSTALL FAILED', function () {
  170. c.reopen({content: {cluster: {status: 'INSTALLED'}}});
  171. expect(c.get('showRetry')).to.equal(false);
  172. });
  173. it('cluster status is INSTALL FAILED', function () {
  174. c.reopen({content: {cluster: {status: 'INSTALL FAILED'}}});
  175. expect(c.get('showRetry')).to.equal(true);
  176. });
  177. });
  178. describe('#resetHostsForRetry', function () {
  179. it('All should have status "pending" and message "Waiting"', function () {
  180. var hosts = {'host1': Em.Object.create({status: 'failed', message: 'Failed'}), 'host2': Em.Object.create({status: 'success', message: 'Success'})};
  181. c.reopen({content: {hosts: hosts}});
  182. c.resetHostsForRetry();
  183. for (var name in hosts) {
  184. if (hosts.hasOwnProperty(name)) {
  185. expect(c.get('content.hosts')[name].get('status', 'pending')).to.equal('pending');
  186. expect(c.get('content.hosts')[name].get('message', 'Waiting')).to.equal('Waiting');
  187. }
  188. }
  189. });
  190. });
  191. var hosts_for_load_and_render = {
  192. 'host1': {
  193. message: 'message1',
  194. status: 'unknown',
  195. progress: '1',
  196. logTasks: [
  197. {},
  198. {}
  199. ],
  200. bootStatus: 'REGISTERED'
  201. },
  202. 'host2': {
  203. message: '',
  204. status: 'failed',
  205. progress: '1',
  206. logTasks: [
  207. {},
  208. {}
  209. ],
  210. bootStatus: ''
  211. },
  212. 'host3': {
  213. message: '',
  214. status: 'waiting',
  215. progress: null,
  216. logTasks: [
  217. {},
  218. {}
  219. ],
  220. bootStatus: ''
  221. },
  222. 'host4': {
  223. message: 'message4',
  224. status: null,
  225. progress: '10',
  226. logTasks: [
  227. {}
  228. ],
  229. bootStatus: 'REGISTERED'
  230. }
  231. };
  232. describe('#loadHosts', function () {
  233. beforeEach(function() {
  234. c.reopen({content: {hosts: hosts_for_load_and_render}});
  235. c.loadHosts();
  236. });
  237. it('Only REGISTERED hosts', function () {
  238. var loaded_hosts = c.get('hosts');
  239. expect(loaded_hosts.length).to.equal(2);
  240. });
  241. it('All hosts have progress 0', function () {
  242. var loaded_hosts = c.get('hosts');
  243. expect(loaded_hosts.everyProperty('progress', 0)).to.equal(true);
  244. });
  245. it('All hosts have progress 0', function () {
  246. var loaded_hosts = c.get('hosts');
  247. expect(loaded_hosts.everyProperty('progress', 0)).to.equal(true);
  248. });
  249. it('All host don\'t have logTasks', function () {
  250. var loaded_hosts = c.get('hosts');
  251. expect(loaded_hosts.everyProperty('logTasks.length', 0)).to.equal(true);
  252. });
  253. });
  254. describe('#hostHasClientsOnly', function () {
  255. var tests = Em.A([
  256. {
  257. hosts: [
  258. Em.Object.create({
  259. hostName: 'host1',
  260. logTasks: [
  261. {Tasks: {role: 'HDFS_CLIENT'}},
  262. {Tasks: {role: 'DATANODE'}}
  263. ],
  264. status: 'old_status',
  265. progress: '10',
  266. e: {status: 'old_status', progress: '10'}
  267. }),
  268. Em.Object.create({
  269. hostName: 'host2',
  270. logTasks: [
  271. {Tasks: {role: 'HDFS_CLIENT'}}
  272. ],
  273. status: 'old_status',
  274. progress: '10',
  275. e: {status: 'success', progress: '100'}
  276. })
  277. ],
  278. jsonError: false
  279. },
  280. {
  281. hosts: [
  282. Em.Object.create({
  283. hostName: 'host1',
  284. logTasks: [
  285. {Tasks: {role: 'HDFS_CLIENT'}},
  286. {Tasks: {role: 'DATANODE'}}
  287. ],
  288. status: 'old_status',
  289. progress: '10',
  290. e: {status: 'success', progress: '100'}
  291. }),
  292. Em.Object.create({
  293. hostName: 'host2',
  294. logTasks: [
  295. {Tasks: {role: 'HDFS_CLIENT'}}
  296. ],
  297. status: 'old_status',
  298. progress: '10',
  299. e: {status: 'success', progress: '100'}
  300. })
  301. ],
  302. jsonError: true
  303. }
  304. ]);
  305. tests.forEach(function (test) {
  306. it('', function () {
  307. c.reopen({hosts: test.hosts});
  308. c.hostHasClientsOnly(test.jsonError);
  309. test.hosts.forEach(function (host) {
  310. expect(c.get('hosts').findProperty('hostName', host.hostName).get('status')).to.equal(host.e.status);
  311. expect(c.get('hosts').findProperty('hostName', host.hostName).get('progress')).to.equal(host.e.progress);
  312. });
  313. });
  314. });
  315. });
  316. describe('#onSuccessPerHost', function () {
  317. var tests = Em.A([
  318. {
  319. cluster: {status: 'INSTALLED'},
  320. host: Em.Object.create({status: 'pending'}),
  321. actions: [],
  322. e: {status: 'success'},
  323. m: 'No tasks for host'
  324. },
  325. {
  326. cluster: {status: 'INSTALLED'},
  327. host: Em.Object.create({status: 'info'}),
  328. actions: [
  329. {Tasks: {status: 'COMPLETED'}},
  330. {Tasks: {status: 'COMPLETED'}}
  331. ],
  332. e: {status: 'success'},
  333. m: 'All Tasks COMPLETED and cluster status INSTALLED'
  334. },
  335. {
  336. cluster: {status: 'FAILED'},
  337. host: Em.Object.create({status: 'info'}),
  338. actions: [
  339. {Tasks: {status: 'COMPLETED'}},
  340. {Tasks: {status: 'COMPLETED'}}
  341. ],
  342. e: {status: 'info'},
  343. m: 'All Tasks COMPLETED and cluster status FAILED'
  344. },
  345. {
  346. cluster: {status: 'INSTALLED'},
  347. host: Em.Object.create({status: 'info'}),
  348. actions: [
  349. {Tasks: {status: 'FAILED'}},
  350. {Tasks: {status: 'COMPLETED'}}
  351. ],
  352. e: {status: 'info'},
  353. m: 'Not all Tasks COMPLETED and cluster status INSTALLED'
  354. },
  355. {
  356. cluster: {status: 'FAILED'},
  357. host: Em.Object.create({status: 'info'}),
  358. actions: [
  359. {Tasks: {status: 'FAILED'}},
  360. {Tasks: {status: 'COMPLETED'}}
  361. ],
  362. e: {status: 'info'},
  363. m: 'Not all Tasks COMPLETED and cluster status FAILED'
  364. }
  365. ]);
  366. tests.forEach(function (test) {
  367. it(test.m, function () {
  368. c.reopen({content: {cluster: {status: test.cluster.status}}});
  369. c.onSuccessPerHost(test.actions, test.host);
  370. expect(test.host.status).to.equal(test.e.status);
  371. });
  372. });
  373. });
  374. describe('#onErrorPerHost', function () {
  375. var tests = Em.A([
  376. {
  377. cluster: {status: 'INSTALLED'},
  378. host: Em.Object.create({status: 'pending'}),
  379. actions: [],
  380. e: {status: 'pending'},
  381. isMasterFailed: false,
  382. m: 'No tasks for host'
  383. },
  384. {
  385. cluster: {status: 'INSTALLED'},
  386. host: Em.Object.create({status: 'info'}),
  387. actions: [
  388. {Tasks: {status: 'FAILED'}},
  389. {Tasks: {status: 'COMPLETED'}}
  390. ],
  391. e: {status: 'warning'},
  392. isMasterFailed: false,
  393. m: 'One Task FAILED and cluster status INSTALLED'
  394. },
  395. {
  396. cluster: {status: 'INSTALLED'},
  397. host: Em.Object.create({status: 'info'}),
  398. actions: [
  399. {Tasks: {status: 'ABORTED'}},
  400. {Tasks: {status: 'COMPLETED'}}
  401. ],
  402. e: {status: 'warning'},
  403. isMasterFailed: false,
  404. m: 'One Task ABORTED and cluster status INSTALLED'
  405. },
  406. {
  407. cluster: {status: 'INSTALLED'},
  408. host: Em.Object.create({status: 'info'}),
  409. actions: [
  410. {Tasks: {status: 'TIMEDOUT'}},
  411. {Tasks: {status: 'COMPLETED'}}
  412. ],
  413. e: {status: 'warning'},
  414. isMasterFailed: false,
  415. m: 'One Task TIMEDOUT and cluster status INSTALLED'
  416. },
  417. {
  418. cluster: {status: 'PENDING'},
  419. host: Em.Object.create({status: 'info'}),
  420. actions: [
  421. {Tasks: {status: 'FAILED'}},
  422. {Tasks: {status: 'COMPLETED'}}
  423. ],
  424. e: {status: 'failed'},
  425. isMasterFailed: true,
  426. m: 'One Task FAILED and cluster status PENDING isMasterFailed true'
  427. },
  428. {
  429. cluster: {status: 'PENDING'},
  430. host: Em.Object.create({status: 'info'}),
  431. actions: [
  432. {Tasks: {status: 'COMPLETED'}},
  433. {Tasks: {status: 'COMPLETED'}}
  434. ],
  435. e: {status: 'info'},
  436. isMasterFailed: false,
  437. m: 'One Task FAILED and cluster status PENDING isMasterFailed false'
  438. }
  439. ]);
  440. tests.forEach(function (test) {
  441. it(test.m, function () {
  442. c.reopen({content: {cluster: {status: test.cluster.status}}, isMasterFailed: function () {
  443. return test.isMasterFailed;
  444. }});
  445. c.onErrorPerHost(test.actions, test.host);
  446. expect(test.host.status).to.equal(test.e.status);
  447. });
  448. });
  449. });
  450. describe('#isMasterFailed', function () {
  451. beforeEach(function() {
  452. sinon.stub(App, 'get', function(k) {
  453. if (k === 'components.slaves')
  454. return ["TASKTRACKER", "DATANODE", "JOURNALNODE", "ZKFC", "APP_TIMELINE_SERVER", "NODEMANAGER", "GANGLIA_MONITOR", "HBASE_REGIONSERVER", "SUPERVISOR", "FLUME_HANDLER"];
  455. return Em.get(App, k);
  456. });
  457. });
  458. afterEach(function() {
  459. App.get.restore();
  460. });
  461. var tests = Em.A([
  462. {
  463. actions: [
  464. {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'DATANODE'}},
  465. {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'TASKTRACKER'}},
  466. {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'HBASE_REGIONSERVER'}},
  467. {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'GANGLIA_MONITOR'}},
  468. {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'SUPERVISOR'}}
  469. ],
  470. e: false,
  471. m: 'No one Master is failed'
  472. },
  473. {
  474. actions: [
  475. {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'NAMENODE'}},
  476. {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'TASKTRACKER'}},
  477. {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'HBASE_REGIONSERVER'}},
  478. {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'GANGLIA_MONITOR'}},
  479. {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'SUPERVISOR'}}
  480. ],
  481. e: true,
  482. m: 'One Master is failed'
  483. },
  484. {
  485. actions: [
  486. {Tasks: {command: 'PENDING', status: 'FAILED', role: 'NAMENODE'}},
  487. {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'TASKTRACKER'}},
  488. {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'HBASE_REGIONSERVER'}},
  489. {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'GANGLIA_MONITOR'}},
  490. {Tasks: {command: 'INSTALL', status: 'FAILED', role: 'SUPERVISOR'}}
  491. ],
  492. e: false,
  493. m: 'one Master is failed but command is not install'
  494. }
  495. ]);
  496. tests.forEach(function (test) {
  497. it(test.m, function () {
  498. expect(c.isMasterFailed(test.actions)).to.equal(test.e);
  499. });
  500. });
  501. });
  502. describe('#onInProgressPerHost', function () {
  503. var tests = Em.A([
  504. {
  505. host: Em.Object.create({message: 'default_message'}),
  506. actions: [
  507. {Tasks: {status: 'COMPLETED'}},
  508. {Tasks: {status: 'COMPLETED'}}
  509. ],
  510. e: {message: 'default_message', b: true},
  511. m: 'All Tasks COMPLETED'
  512. },
  513. {
  514. host: Em.Object.create({message: 'default_message'}),
  515. actions: [
  516. {Tasks: {status: 'IN_PROGRESS'}},
  517. {Tasks: {status: 'COMPLETED'}}
  518. ],
  519. e: {message: 'default_message', b: false},
  520. m: 'One Task IN_PROGRESS'
  521. },
  522. {
  523. host: Em.Object.create({message: 'default_message'}),
  524. actions: [
  525. {Tasks: {status: 'QUEUED'}},
  526. {Tasks: {status: 'COMPLETED'}}
  527. ],
  528. e: {message: 'default_message', b: false},
  529. m: 'One Task QUEUED'
  530. },
  531. {
  532. host: Em.Object.create({message: 'default_message'}),
  533. actions: [
  534. {Tasks: {status: 'PENDING'}},
  535. {Tasks: {status: 'COMPLETED'}}
  536. ],
  537. e: {message: 'default_message', b: false},
  538. m: 'One Task PENDING'
  539. }
  540. ]);
  541. tests.forEach(function (test) {
  542. it(test.m, function () {
  543. c.onInProgressPerHost(test.actions, test.host);
  544. expect(test.host.message == test.e.message).to.equal(test.e.b);
  545. });
  546. });
  547. });
  548. describe('#progressPerHost', function () {
  549. var tests = Em.A([
  550. {
  551. cluster: {status: 'PENDING'},
  552. host: Em.Object.create({progress: 0}),
  553. actions: [
  554. {Tasks: {status: 'COMPLETED'}},
  555. {Tasks: {status: 'COMPLETED'}},
  556. {Tasks: {status: 'QUEUED'}},
  557. {Tasks: {status: 'QUEUED'}},
  558. {Tasks: {status: 'IN_PROGRESS'}}
  559. ],
  560. e: {ret: 17, host: '17'},
  561. m: 'All types of status available. cluster status PENDING'
  562. },
  563. {
  564. cluster: {status: 'PENDING'},
  565. host: Em.Object.create({progress: 0}),
  566. actions: [],
  567. e: {ret: 33, host: '33'},
  568. m: 'No tasks available. cluster status PENDING'
  569. },
  570. {
  571. cluster: {status: 'INSTALLED'},
  572. host: Em.Object.create({progress: 0}),
  573. actions: [],
  574. e: {ret: 100, host: '100'},
  575. m: 'No tasks available. cluster status INSTALLED'
  576. },
  577. {
  578. cluster: {status: 'INSTALLED'},
  579. host: Em.Object.create({progress: 0}),
  580. actions: [
  581. {Tasks: {status: 'COMPLETED'}},
  582. {Tasks: {status: 'COMPLETED'}},
  583. {Tasks: {status: 'QUEUED'}},
  584. {Tasks: {status: 'QUEUED'}},
  585. {Tasks: {status: 'IN_PROGRESS'}}
  586. ],
  587. e: {ret: 68, host: '68'},
  588. m: 'All types of status available. cluster status INSTALLED'
  589. },
  590. {
  591. cluster: {status: 'FAILED'},
  592. host: Em.Object.create({progress: 0}),
  593. actions: [],
  594. e: {ret: 100, host: '100'},
  595. m: 'Cluster status is not PENDING or INSTALLED'
  596. }
  597. ]);
  598. tests.forEach(function (test) {
  599. it(test.m, function () {
  600. c.reopen({content: {cluster: {status: test.cluster.status}}});
  601. var progress = c.progressPerHost(test.actions, test.host);
  602. expect(progress).to.equal(test.e.ret);
  603. expect(test.host.progress).to.equal(test.e.host);
  604. });
  605. });
  606. });
  607. describe('#clearStep', function () {
  608. it('All to default values', function () {
  609. c.reopen({hosts: [{},{},{}]});
  610. c.clearStep();
  611. expect(c.get('hosts.length')).to.equal(0);
  612. expect(c.get('status')).to.equal('info');
  613. expect(c.get('progress')).to.equal('0');
  614. expect(c.get('numPolls')).to.equal(1);
  615. });
  616. });
  617. describe('#replacePolledData', function () {
  618. it('replacing polled data', function () {
  619. c.reopen({polledData: [{},{},{}]});
  620. var newPolledData = [{}];
  621. c.replacePolledData(newPolledData);
  622. expect(c.get('polledData.length')).to.equal(newPolledData.length);
  623. });
  624. });
  625. describe('#isSuccess', function () {
  626. var tests = Em.A([
  627. {
  628. polledData: [
  629. {Tasks: {status: 'COMPLETED'}},
  630. {Tasks: {status: 'COMPLETED'}}
  631. ],
  632. e: true,
  633. m: 'All tasks are COMPLETED'
  634. },
  635. {
  636. polledData: [
  637. {Tasks: {status: 'COMPLETED'}},
  638. {Tasks: {status: 'FAILED'}}
  639. ],
  640. e: false,
  641. m: 'Not all tasks are COMPLETED'
  642. }
  643. ]);
  644. tests.forEach(function (test) {
  645. it(test.m, function () {
  646. expect(c.isSuccess(test.polledData)).to.equal(test.e);
  647. });
  648. });
  649. });
  650. describe('#isStepFailed', function () {
  651. beforeEach(function() {
  652. sinon.stub(App, 'get', function(k) {
  653. if (k === 'components.slaves')
  654. return ["TASKTRACKER", "DATANODE", "JOURNALNODE", "ZKFC", "APP_TIMELINE_SERVER", "NODEMANAGER", "GANGLIA_MONITOR", "HBASE_REGIONSERVER", "SUPERVISOR", "FLUME_HANDLER"];
  655. return Em.get(App, k);
  656. });
  657. });
  658. afterEach(function() {
  659. App.get.restore();
  660. });
  661. var tests = Em.A([
  662. {
  663. polledData: [
  664. {Tasks: {command: 'INSTALL', role: 'GANGLIA_MONITOR', status: 'TIMEDOUT'}},
  665. {Tasks: {command: 'INSTALL', role: 'GANGLIA_MONITOR', status: 'FAILED'}},
  666. {Tasks: {command: 'INSTALL', role: 'GANGLIA_MONITOR', status: 'PENDING'}}
  667. ],
  668. e: true,
  669. m: 'GANGLIA_MONITOR 2/3 failed'
  670. },
  671. {
  672. polledData: [
  673. {Tasks: {command: 'INSTALL', role: 'GANGLIA_MONITOR', status: 'TIMEDOUT'}},
  674. {Tasks: {command: 'INSTALL', role: 'GANGLIA_MONITOR', status: 'PENDING'}},
  675. {Tasks: {command: 'INSTALL', role: 'GANGLIA_MONITOR', status: 'PENDING'}}
  676. ],
  677. e: false,
  678. m: 'GANGLIA_MONITOR 1/3 failed'
  679. },
  680. {
  681. polledData: [
  682. {Tasks: {command: 'INSTALL', role: 'HBASE_REGIONSERVER', status: 'TIMEDOUT'}},
  683. {Tasks: {command: 'INSTALL', role: 'HBASE_REGIONSERVER', status: 'FAILED'}},
  684. {Tasks: {command: 'INSTALL', role: 'HBASE_REGIONSERVER', status: 'PENDING'}}
  685. ],
  686. e: true,
  687. m: 'HBASE_REGIONSERVER 2/3 failed'
  688. },
  689. {
  690. polledData: [
  691. {Tasks: {command: 'INSTALL', role: 'HBASE_REGIONSERVER', status: 'TIMEDOUT'}},
  692. {Tasks: {command: 'INSTALL', role: 'HBASE_REGIONSERVER', status: 'PENDING'}},
  693. {Tasks: {command: 'INSTALL', role: 'HBASE_REGIONSERVER', status: 'PENDING'}}
  694. ],
  695. e: false,
  696. m: 'HBASE_REGIONSERVER 1/3 failed'
  697. },
  698. {
  699. polledData: [
  700. {Tasks: {command: 'INSTALL', role: 'TASKTRACKER', status: 'TIMEDOUT'}},
  701. {Tasks: {command: 'INSTALL', role: 'TASKTRACKER', status: 'FAILED'}},
  702. {Tasks: {command: 'INSTALL', role: 'TASKTRACKER', status: 'PENDING'}}
  703. ],
  704. e: true,
  705. m: 'TASKTRACKER 2/3 failed'
  706. },
  707. {
  708. polledData: [
  709. {Tasks: {command: 'INSTALL', role: 'TASKTRACKER', status: 'TIMEDOUT'}},
  710. {Tasks: {command: 'INSTALL', role: 'TASKTRACKER', status: 'PENDING'}},
  711. {Tasks: {command: 'INSTALL', role: 'TASKTRACKER', status: 'PENDING'}}
  712. ],
  713. e: false,
  714. m: 'TASKTRACKER 1/3 failed'
  715. },
  716. {
  717. polledData: [
  718. {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'TIMEDOUT'}},
  719. {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'FAILED'}},
  720. {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'PENDING'}}
  721. ],
  722. e: true,
  723. m: 'DATANODE 2/3 failed'
  724. },
  725. {
  726. polledData: [
  727. {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'TIMEDOUT'}},
  728. {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'PENDING'}},
  729. {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'PENDING'}}
  730. ],
  731. e: false,
  732. m: 'DATANODE 1/3 failed'
  733. },
  734. {
  735. polledData: [
  736. {Tasks: {command: 'INSTALL', role: 'NAMENODE', status: 'TIMEDOUT'}},
  737. {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'PENDING'}},
  738. {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'PENDING'}}
  739. ],
  740. e: true,
  741. m: 'NAMENODE failed'
  742. },
  743. {
  744. polledData: [
  745. {Tasks: {command: 'INSTALL', role: 'NAMENODE', status: 'PENDING'}},
  746. {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'PENDING'}},
  747. {Tasks: {command: 'INSTALL', role: 'DATANODE', status: 'PENDING'}}
  748. ],
  749. e: false,
  750. m: 'Nothing failed failed'
  751. }
  752. ]);
  753. tests.forEach(function (test) {
  754. it(test.m, function () {
  755. c.reopen({polledData: test.polledData});
  756. expect(c.isStepFailed()).to.equal(test.e);
  757. });
  758. });
  759. });
  760. describe('#setLogTasksStatePerHost', function () {
  761. var tests = Em.A([
  762. {
  763. tasksPerHost: [
  764. {Tasks: {id: 1, status: 'COMPLETED'}},
  765. {Tasks: {id: 2, status: 'COMPLETED'}}
  766. ],
  767. tasks: [],
  768. e: {m: 'COMPLETED', l: 2},
  769. m: 'host didn\'t have tasks and got 2 new'
  770. },
  771. {
  772. tasksPerHost: [
  773. {Tasks: {id: 1, status: 'COMPLETED'}},
  774. {Tasks: {id: 2, status: 'COMPLETED'}}
  775. ],
  776. tasks: [
  777. {Tasks: {id: 1, status: 'IN_PROGRESS'}},
  778. {Tasks: {id: 2, status: 'IN_PROGRESS'}}
  779. ],
  780. e: {m: 'COMPLETED', l: 2},
  781. m: 'host had 2 tasks and got both updated'
  782. },
  783. {
  784. tasksPerHost: [],
  785. tasks: [
  786. {Tasks: {id: 1, status: 'IN_PROGRESS'}},
  787. {Tasks: {id: 2, status: 'IN_PROGRESS'}}
  788. ],
  789. e: {m: 'IN_PROGRESS', l: 2},
  790. m: 'host had 2 tasks and didn\'t get updates'
  791. },
  792. {
  793. tasksPerHost: [
  794. {Tasks: {id: 1, status: 'COMPLETED'}},
  795. {Tasks: {id: 2, status: 'COMPLETED'}},
  796. {Tasks: {id: 3, status: 'COMPLETED'}}
  797. ],
  798. tasks: [
  799. {Tasks: {id: 1, status: 'IN_PROGRESS'}},
  800. {Tasks: {id: 2, status: 'IN_PROGRESS'}}
  801. ],
  802. e: {m: 'COMPLETED', l: 3},
  803. m: 'host had 2 tasks and got both updated and 1 new'
  804. }
  805. ]);
  806. tests.forEach(function (test) {
  807. it(test.m, function () {
  808. c.reopen({hosts: [Em.Object.create({logTasks: test.tasks})]});
  809. c.setLogTasksStatePerHost(test.tasksPerHost, c.get('hosts')[0]);
  810. expect(c.get('hosts')[0].get('logTasks').everyProperty('Tasks.status', test.e.m)).to.equal(true);
  811. expect(c.get('hosts')[0].get('logTasks.length')).to.equal(test.e.l);
  812. });
  813. });
  814. });
  815. // On completion of Start all services error callback function,
  816. // Cluster Status should be INSTALL FAILED
  817. // All progress bar on the screen should be finished (100%) with blue color.
  818. // Retry button should be enabled, next button should be disabled
  819. describe('#launchStartServicesErrorCallback', function () {
  820. beforeEach(function() {
  821. sinon.stub(App, 'get', function(k) {
  822. if ('testMode' === k) return true;
  823. return Em.get(App, k);
  824. });
  825. });
  826. afterEach(function() {
  827. App.get.restore();
  828. });
  829. it('Main progress bar on the screen should be finished (100%) with red color', function () {
  830. var hosts = Em.A([Em.Object.create({name: 'host1', progress: '33', status: 'info'}), Em.Object.create({name: 'host2', progress: '33', status: 'info'})]);
  831. c.reopen({hosts: hosts, content: {controllerName: 'installerController', cluster: {status: 'PENDING', name: 'c1'}}});
  832. c.launchStartServicesErrorCallback({status: 500, statusTesxt: 'Server Error'}, {}, '', {});
  833. expect(c.get('progress')).to.equal('100');
  834. expect(c.get('status')).to.equal('failed');
  835. });
  836. it('All Host progress bars on the screen should be finished (100%) with blue color', function () {
  837. var hosts = Em.A([Em.Object.create({name: 'host1', progress: '33', status: 'info'}), Em.Object.create({name: 'host2', progress: '33', status: 'info'})]);
  838. c.reopen({hosts: hosts, content: {controllerName: 'installerController', cluster: {status: 'PENDING', name: 'c1'}}});
  839. c.launchStartServicesErrorCallback({status: 500, statusTesxt: 'Server Error'}, {}, '', {});
  840. c.get('hosts').forEach(function (host) {
  841. expect(host.get('progress')).to.equal('100');
  842. expect(host.get('status')).to.equal('info');
  843. });
  844. });
  845. it('Next button should be disabled', function () {
  846. var hosts = Em.A([Em.Object.create({name: 'host1', progress: '33', status: 'info'}), Em.Object.create({name: 'host2', progress: '33', status: 'info'})]);
  847. c.reopen({hosts: hosts, content: {controllerName: 'installerController', cluster: {status: 'PENDING', name: 'c1'}}});
  848. c.launchStartServicesErrorCallback({status: 500, statusTesxt: 'Server Error'}, {}, '', {});
  849. expect(c.get('isSubmitDisabled')).to.equal(true);
  850. });
  851. });
  852. describe('#submit', function () {
  853. it('should call App.router.send', function () {
  854. sinon.stub(App.router, 'send', Em.K);
  855. c.submit();
  856. expect(App.router.send.calledWith('next')).to.equal(true);
  857. App.router.send.restore();
  858. });
  859. });
  860. describe('#back', function () {
  861. beforeEach(function () {
  862. sinon.stub(App.router, 'send', Em.K);
  863. });
  864. afterEach(function () {
  865. App.router.send.restore();
  866. });
  867. it('should call App.router.send', function () {
  868. c.reopen({isSubmitDisabled: false});
  869. c.back();
  870. expect(App.router.send.calledWith('back')).to.equal(true);
  871. });
  872. it('shouldn\'t call App.router.send', function () {
  873. c.reopen({isSubmitDisabled: true});
  874. c.back();
  875. expect(App.router.send.called).to.equal(false);
  876. });
  877. });
  878. describe('#loadStep', function () {
  879. beforeEach(function () {
  880. sinon.stub(c, 'clearStep', Em.K);
  881. sinon.stub(c, 'loadHosts', Em.K);
  882. });
  883. afterEach(function () {
  884. c.clearStep.restore();
  885. c.loadHosts.restore();
  886. });
  887. it('should call clearStep', function () {
  888. c.loadStep();
  889. expect(c.clearStep.calledOnce).to.equal(true);
  890. });
  891. it('should call loadHosts', function () {
  892. c.loadStep();
  893. expect(c.loadHosts.calledOnce).to.equal(true);
  894. });
  895. });
  896. describe('#startPolling', function () {
  897. beforeEach(function () {
  898. sinon.stub(c, 'getLogsByRequestErrorCallback', Em.K);
  899. });
  900. afterEach(function () {
  901. c.getLogsByRequestErrorCallback.restore();
  902. });
  903. it('should set isSubmitDisabled to true', function () {
  904. c.set('isSubmitDisabled', false);
  905. c.startPolling();
  906. expect(c.get('isSubmitDisabled')).to.equal(true);
  907. });
  908. it('should call doPolling', function () {
  909. sinon.stub(c, 'doPolling', Em.K);
  910. c.startPolling();
  911. expect(c.doPolling.calledOnce).to.equal(true);
  912. c.doPolling.restore();
  913. });
  914. });
  915. describe('#loadLogData', function () {
  916. beforeEach(function () {
  917. obj.reopen({
  918. cluster: {oldRequestsId: [1,2,3]},
  919. getDBProperty: function (name) {
  920. return this.get(name);
  921. }
  922. });
  923. c.reopen({wizardController: obj});
  924. sinon.stub(c, 'getLogsByRequest', Em.K);
  925. });
  926. afterEach(function () {
  927. c.getLogsByRequest.restore();
  928. });
  929. it('should call getLogsByRequest 1 time with 3', function () {
  930. c.loadLogData(true);
  931. expect(c.getLogsByRequest.calledWith(true, 3)).to.equal(true);
  932. });
  933. it('should set POLL_INTERVAL to 1 if testMode enabled', function () {
  934. sinon.stub(App, 'get', function(k) { if ('testMode' === k) return true; return Em.get(App, k);});
  935. c.loadLogData();
  936. expect(c.get('POLL_INTERVAL')).to.equal(1);
  937. App.get.restore();
  938. });
  939. });
  940. describe('#loadCurrentTaskLog', function () {
  941. beforeEach(function () {
  942. sinon.stub(c, 'loadLogData', Em.K);
  943. c.set('wizardController', Em.Object.create({
  944. getDBProperty: Em.K
  945. }));
  946. });
  947. afterEach(function () {
  948. c.loadLogData.restore();
  949. });
  950. it('shouldn\'t call App.ajax.send if no currentOpenTaskId', function () {
  951. c.set('currentOpenTaskId', null);
  952. c.loadCurrentTaskLog();
  953. expect(App.ajax.send.called).to.equal(false);
  954. });
  955. it('should call App.ajax.send with provided data', function () {
  956. sinon.stub(c, 'togglePreviousSteps', Em.K);
  957. c.set('currentOpenTaskId', 1);
  958. c.set('currentOpenTaskRequestId', 2);
  959. c.set('content', {cluster: {name: 3}});
  960. c.loadCurrentTaskLog();
  961. expect(App.ajax.send.args[0][0].data).to.eql({taskId: 1, requestId: 2, clusterName: 3});
  962. c.togglePreviousSteps.restore();
  963. });
  964. });
  965. describe('#loadCurrentTaskLogSuccessCallback', function () {
  966. beforeEach(function() {
  967. sinon.stub(c, 'getLogsByRequest', Em.K);
  968. sinon.stub(c, 'loadLogData', Em.K);
  969. });
  970. afterEach(function() {
  971. c.getLogsByRequest.restore();
  972. c.loadLogData.restore();
  973. });
  974. it('should increment logTasksChangesCounter', function () {
  975. c.set('logTasksChangesCounter', 0);
  976. c.loadCurrentTaskLogSuccessCallback();
  977. expect(c.get('logTasksChangesCounter')).to.equal(1);
  978. });
  979. it('should update stdout, stderr', function () {
  980. c.set('currentOpenTaskId', 1);
  981. c.reopen({
  982. hosts: [
  983. Em.Object.create({
  984. name: 'h1',
  985. logTasks: [
  986. {Tasks: {id: 1, stdout: '', stderr: ''}}
  987. ]
  988. })
  989. ]
  990. });
  991. var data = {Tasks: {host_name: 'h1', id: 1, stderr: 'stderr', stdout: 'stdout'}};
  992. c.loadCurrentTaskLogSuccessCallback(data);
  993. var t = c.get('hosts')[0].logTasks[0].Tasks;
  994. expect(t.stdout).to.equal('stdout');
  995. expect(t.stderr).to.equal('stderr');
  996. });
  997. it('shouldn\'t update stdout, stderr', function () {
  998. c.set('currentOpenTaskId', 1);
  999. c.reopen({
  1000. hosts: [
  1001. Em.Object.create({
  1002. name: 'h1',
  1003. logTasks: [
  1004. {Tasks: {id: 2, stdout: '', stderr: ''}}
  1005. ]
  1006. })
  1007. ]
  1008. });
  1009. var data = {Tasks: {host_name: 'h1', id: 1, stderr: 'stderr', stdout: 'stdout'}};
  1010. c.loadCurrentTaskLogSuccessCallback(data);
  1011. var t = c.get('hosts')[0].logTasks[0].Tasks;
  1012. expect(t.stdout).to.equal('');
  1013. expect(t.stderr).to.equal('');
  1014. });
  1015. it('shouldn\'t update stdout, stderr (2)', function () {
  1016. c.set('currentOpenTaskId', 1);
  1017. c.reopen({
  1018. hosts: [
  1019. Em.Object.create({
  1020. name: 'h2',
  1021. logTasks: [
  1022. {Tasks: {id: 1, stdout: '', stderr: ''}}
  1023. ]
  1024. })
  1025. ]
  1026. });
  1027. var data = {Tasks: {host_name: 'h1', id: 1, stderr: 'stderr', stdout: 'stdout'}};
  1028. c.loadCurrentTaskLogSuccessCallback(data);
  1029. var t = c.get('hosts')[0].logTasks[0].Tasks;
  1030. expect(t.stdout).to.equal('');
  1031. expect(t.stderr).to.equal('');
  1032. });
  1033. });
  1034. describe('#loadCurrentTaskLogErrorCallback', function () {
  1035. it('should set currentOpenTaskId to 0', function () {
  1036. c.set('currentOpenTaskId', 123);
  1037. c.loadCurrentTaskLogErrorCallback();
  1038. expect(c.get('currentOpenTaskId')).to.equal(0);
  1039. });
  1040. });
  1041. describe('#doPolling', function () {
  1042. beforeEach(function () {
  1043. sinon.stub(c, 'getLogsByRequest', Em.K);
  1044. sinon.stub(c, 'togglePreviousSteps', Em.K);
  1045. });
  1046. afterEach(function () {
  1047. c.getLogsByRequest.restore();
  1048. c.togglePreviousSteps.restore();
  1049. });
  1050. it('should increment numPolls if testMode', function () {
  1051. App.set('testMode', true);
  1052. c.set('numPolls', 0);
  1053. c.doPolling();
  1054. expect(c.get('numPolls')).to.equal(1);
  1055. App.set('testMode', false);
  1056. });
  1057. it('should call getLogsByRequest', function () {
  1058. c.set('content', {cluster: {requestId: 1}});
  1059. c.doPolling();
  1060. expect(c.getLogsByRequest.calledWith(true, 1)).to.equal(true);
  1061. });
  1062. });
  1063. describe('#isAllComponentsInstalledErrorCallback', function () {
  1064. beforeEach(function () {
  1065. sinon.stub(c, 'saveClusterStatus', Em.K);
  1066. sinon.stub(c, 'togglePreviousSteps', Em.K);
  1067. });
  1068. afterEach(function () {
  1069. c.saveClusterStatus.restore();
  1070. c.togglePreviousSteps.restore();
  1071. });
  1072. it('should call saveClusterStatus', function () {
  1073. c.isAllComponentsInstalledErrorCallback({});
  1074. expect(c.saveClusterStatus.calledOnce).to.equal(true);
  1075. });
  1076. });
  1077. describe('#navigateStep', function () {
  1078. beforeEach(function () {
  1079. sinon.stub(c, 'togglePreviousSteps', Em.K);
  1080. sinon.stub(c, 'loadStep', Em.K);
  1081. sinon.stub(c, 'loadLogData', Em.K);
  1082. sinon.stub(c, 'startPolling', Em.K);
  1083. });
  1084. afterEach(function () {
  1085. c.togglePreviousSteps.restore();
  1086. c.loadStep.restore();
  1087. c.loadLogData.restore();
  1088. c.startPolling.restore();
  1089. App.get.restore();
  1090. });
  1091. it('should set custom data in testMode', function () {
  1092. sinon.stub(App, 'get', function(k) {if('testMode' === k) return true; return Em.get(App, k);});
  1093. c.reopen({content: {cluster: {status: 'st', isCompleted: true, requestId: 0}}});
  1094. c.navigateStep();
  1095. expect(c.get('content.cluster.status')).to.equal('PENDING');
  1096. expect(c.get('content.cluster.isCompleted')).to.equal(false);
  1097. expect(c.get('content.cluster.requestId')).to.equal(1);
  1098. });
  1099. it('isCompleted = true, requestId = 1', function () {
  1100. sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);});
  1101. c.reopen({content: {cluster: {isCompleted: true, requestId: 1}}});
  1102. c.navigateStep();
  1103. expect(c.loadStep.calledOnce).to.equal(true);
  1104. expect(c.loadLogData.calledWith(false)).to.equal(true);
  1105. expect(c.get('progress')).to.equal('100');
  1106. });
  1107. it('isCompleted = false, requestId = 1, status = INSTALL FAILED', function () {
  1108. sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);});
  1109. c.reopen({content: {cluster: {status: 'INSTALL FAILED', isCompleted: false, requestId: 1}}});
  1110. c.navigateStep();
  1111. expect(c.loadStep.calledOnce).to.equal(true);
  1112. expect(c.loadLogData.calledWith(false)).to.equal(true);
  1113. });
  1114. it('isCompleted = false, requestId = 1, status = START FAILED', function () {
  1115. sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);});
  1116. c.reopen({content: {cluster: {status: 'START FAILED', isCompleted: false, requestId: 1}}});
  1117. c.navigateStep();
  1118. expect(c.loadStep.calledOnce).to.equal(true);
  1119. expect(c.loadLogData.calledWith(false)).to.equal(true);
  1120. });
  1121. it('isCompleted = false, requestId = 1, status = OTHER', function () {
  1122. sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);});
  1123. c.reopen({content: {cluster: {status: 'STARTED', isCompleted: false, requestId: 1}}});
  1124. c.navigateStep();
  1125. expect(c.loadStep.calledOnce).to.equal(true);
  1126. expect(c.loadLogData.calledWith(true)).to.equal(true);
  1127. });
  1128. });
  1129. describe('#launchStartServicesSuccessCallback', function () {
  1130. beforeEach(function () {
  1131. sinon.stub(App.clusterStatus, 'setClusterStatus', function() {
  1132. return $.ajax();
  1133. });
  1134. sinon.stub(c, 'saveClusterStatus', Em.K);
  1135. sinon.stub(c, 'doPolling', Em.K);
  1136. sinon.stub(c, 'hostHasClientsOnly', Em.K);
  1137. });
  1138. afterEach(function () {
  1139. c.saveClusterStatus.restore();
  1140. c.doPolling.restore();
  1141. c.hostHasClientsOnly.restore();
  1142. App.clusterStatus.setClusterStatus.restore();
  1143. });
  1144. it('should call doPolling if some data were received', function () {
  1145. c.launchStartServicesSuccessCallback({Requests: {id: 2}});
  1146. expect(c.doPolling.calledOnce).to.equal(true);
  1147. });
  1148. Em.A([
  1149. {
  1150. jsonData: {Requests: {id: 2}},
  1151. e: {
  1152. hostHasClientsOnly: false,
  1153. clusterStatus: {
  1154. status: 'INSTALLED',
  1155. requestId: 2,
  1156. isStartError: false,
  1157. isCompleted: false
  1158. }
  1159. }
  1160. },
  1161. {
  1162. jsonData: null,
  1163. e: {
  1164. hostHasClientsOnly: true,
  1165. clusterStatus: {
  1166. status: 'STARTED',
  1167. isStartError: false,
  1168. isCompleted: true
  1169. },
  1170. status: 'success',
  1171. progress: '100'
  1172. }
  1173. }
  1174. ]).forEach(function (test) {
  1175. it(test.m, function () {
  1176. c.launchStartServicesSuccessCallback(test.jsonData);
  1177. expect(c.hostHasClientsOnly.calledWith(test.e.hostHasClientsOnly)).to.equal(true);
  1178. expect(c.saveClusterStatus.calledWith(test.e.clusterStatus)).to.equal(true);
  1179. if (test.e.status) {
  1180. expect(c.get('status')).to.equal(test.e.status);
  1181. }
  1182. if (test.e.progress) {
  1183. expect(c.get('progress')).to.equal(test.e.progress);
  1184. }
  1185. });
  1186. });
  1187. });
  1188. });