step9_test.js 42 KB

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