step6_test.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  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('utils/helper');
  21. require('controllers/wizard/step6_controller');
  22. var controller,
  23. services = [
  24. Em.Object.create({
  25. serviceName: 'YARN',
  26. isSelected: true
  27. }),
  28. Em.Object.create({
  29. serviceName: 'HBASE',
  30. isSelected: true
  31. }),
  32. Em.Object.create({
  33. serviceName: 'HDFS',
  34. isSelected: true
  35. }),
  36. Em.Object.create({
  37. serviceName: 'STORM',
  38. isSelected: true
  39. }),
  40. Em.Object.create({
  41. serviceName: 'FLUME',
  42. isSelected: true
  43. })
  44. ];
  45. describe('App.WizardStep6Controller', function () {
  46. beforeEach(function () {
  47. controller = App.WizardStep6Controller.create();
  48. controller.set('content', Em.Object.create({
  49. hosts: {},
  50. masterComponentHosts: {},
  51. services: services
  52. }));
  53. var h = {}, m = [];
  54. Em.A(['host0', 'host1', 'host2', 'host3']).forEach(function (hostName) {
  55. var obj = Em.Object.create({
  56. name: hostName,
  57. hostName: hostName,
  58. bootStatus: 'REGISTERED'
  59. });
  60. h[hostName] = obj;
  61. m.push(obj);
  62. });
  63. controller.set('content.hosts', h);
  64. controller.set('content.masterComponentHosts', m);
  65. controller.set('isMasters', false);
  66. });
  67. describe('#isAddHostWizard', function () {
  68. it('true if content.controllerName is addHostController', function () {
  69. controller.set('content.controllerName', 'addHostController');
  70. expect(controller.get('isAddHostWizard')).to.equal(true);
  71. });
  72. it('false if content.controllerName is not addHostController', function () {
  73. controller.set('content.controllerName', 'mainController');
  74. expect(controller.get('isAddHostWizard')).to.equal(false);
  75. });
  76. });
  77. describe('#isInstallerWizard', function () {
  78. it('true if content.controllerName is addHostController', function () {
  79. controller.set('content.controllerName', 'installerController');
  80. expect(controller.get('isInstallerWizard')).to.equal(true);
  81. });
  82. it('false if content.controllerName is not addHostController', function () {
  83. controller.set('content.controllerName', 'mainController');
  84. expect(controller.get('isInstallerWizard')).to.equal(false);
  85. });
  86. });
  87. describe('#isAddServiceWizard', function () {
  88. it('true if content.controllerName is addServiceController', function () {
  89. controller.set('content.controllerName', 'addServiceController');
  90. expect(controller.get('isAddServiceWizard')).to.equal(true);
  91. });
  92. it('false if content.controllerName is not addServiceController', function () {
  93. controller.set('content.controllerName', 'mainController');
  94. expect(controller.get('isAddServiceWizard')).to.equal(false);
  95. });
  96. });
  97. describe('#clearStep', function () {
  98. beforeEach(function () {
  99. sinon.stub(controller, 'clearError', Em.K);
  100. });
  101. afterEach(function () {
  102. controller.clearError.restore();
  103. });
  104. it('should call clearError', function () {
  105. controller.clearStep();
  106. expect(controller.clearError.calledOnce).to.equal(true);
  107. });
  108. it('should clear hosts', function () {
  109. controller.set('hosts', [
  110. {},
  111. {}
  112. ]);
  113. controller.clearStep();
  114. expect(controller.get('hosts')).to.eql([]);
  115. });
  116. it('should clear headers', function () {
  117. controller.set('headers', [
  118. {},
  119. {}
  120. ]);
  121. controller.clearStep();
  122. expect(controller.get('headers')).to.eql([]);
  123. });
  124. it('should set isLoaded to false', function () {
  125. controller.set('isLoaded', true);
  126. controller.clearStep();
  127. expect(controller.get('isLoaded')).to.equal(false);
  128. });
  129. });
  130. describe('#checkCallback', function () {
  131. beforeEach(function () {
  132. sinon.stub(controller, 'clearError', Em.K);
  133. });
  134. afterEach(function () {
  135. controller.clearError.restore();
  136. });
  137. it('should call clearError', function () {
  138. controller.checkCallback('');
  139. expect(controller.clearError.calledOnce).to.equal(true);
  140. });
  141. Em.A([
  142. {
  143. m: 'all checked, isInstalled false',
  144. headers: Em.A([
  145. Em.Object.create({name: 'c1'})
  146. ]),
  147. hosts: Em.A([
  148. Em.Object.create({
  149. checkboxes: Em.A([
  150. Em.Object.create({
  151. component: 'c1',
  152. isInstalled: false,
  153. checked: true
  154. })
  155. ])
  156. })
  157. ]),
  158. component: 'c1',
  159. e: {
  160. allChecked: true,
  161. noChecked: false
  162. }
  163. },
  164. {
  165. m: 'all checked, isInstalled true',
  166. headers: Em.A([
  167. Em.Object.create({name: 'c1'})
  168. ]),
  169. hosts: Em.A([
  170. Em.Object.create({
  171. checkboxes: Em.A([
  172. Em.Object.create({
  173. component: 'c1',
  174. isInstalled: true,
  175. checked: true
  176. })
  177. ])
  178. })
  179. ]),
  180. component: 'c1',
  181. e: {
  182. allChecked: true,
  183. noChecked: true
  184. }
  185. },
  186. {
  187. m: 'no one checked',
  188. headers: Em.A([
  189. Em.Object.create({name: 'c1'})
  190. ]),
  191. hosts: Em.A([
  192. Em.Object.create({
  193. checkboxes: Em.A([
  194. Em.Object.create({
  195. component: 'c1',
  196. isInstalled: false,
  197. checked: false
  198. })
  199. ])
  200. })
  201. ]),
  202. component: 'c1',
  203. e: {
  204. allChecked: false,
  205. noChecked: true
  206. }
  207. },
  208. {
  209. m: 'some checked',
  210. headers: Em.A([
  211. Em.Object.create({name: 'c1'})
  212. ]),
  213. hosts: Em.A([
  214. Em.Object.create({
  215. checkboxes: Em.A([
  216. Em.Object.create({
  217. component: 'c1',
  218. isInstalled: false,
  219. checked: true
  220. }),
  221. Em.Object.create({
  222. component: 'c1',
  223. isInstalled: false,
  224. checked: false
  225. })
  226. ])
  227. })
  228. ]),
  229. component: 'c1',
  230. e: {
  231. allChecked: false,
  232. noChecked: false
  233. }
  234. },
  235. {
  236. m: 'some checked, some isInstalled true',
  237. headers: Em.A([
  238. Em.Object.create({name: 'c1'})
  239. ]),
  240. hosts: Em.A([
  241. Em.Object.create({
  242. checkboxes: Em.A([
  243. Em.Object.create({
  244. component: 'c1',
  245. isInstalled: true,
  246. checked: true
  247. }),
  248. Em.Object.create({
  249. component: 'c1',
  250. isInstalled: true,
  251. checked: true
  252. })
  253. ])
  254. })
  255. ]),
  256. component: 'c1',
  257. e: {
  258. allChecked: true,
  259. noChecked: true
  260. }
  261. },
  262. {
  263. m: 'some checked, some isInstalled true (2)',
  264. headers: Em.A([
  265. Em.Object.create({name: 'c1'})
  266. ]),
  267. hosts: Em.A([
  268. Em.Object.create({
  269. checkboxes: Em.A([
  270. Em.Object.create({
  271. component: 'c1',
  272. isInstalled: false,
  273. checked: false
  274. }),
  275. Em.Object.create({
  276. component: 'c1',
  277. isInstalled: true,
  278. checked: true
  279. })
  280. ])
  281. })
  282. ]),
  283. component: 'c1',
  284. e: {
  285. allChecked: false,
  286. noChecked: true
  287. }
  288. }
  289. ]).forEach(function (test) {
  290. it(test.m, function () {
  291. controller.clearStep();
  292. controller.set('headers', test.headers);
  293. controller.set('hosts', test.hosts);
  294. controller.checkCallback(test.component);
  295. var header = controller.get('headers').findProperty('name', test.component);
  296. expect(header.get('allChecked')).to.equal(test.e.allChecked);
  297. expect(header.get('noChecked')).to.equal(test.e.noChecked);
  298. });
  299. });
  300. });
  301. describe('#getHostNames', function () {
  302. var tests = Em.A([
  303. {
  304. hosts: {
  305. h1: {bootStatus: 'REGISTERED', name: 'h1'},
  306. h2: {bootStatus: 'REGISTERED', name: 'h2'},
  307. h3: {bootStatus: 'REGISTERED', name: 'h3'}
  308. },
  309. m: 'All REGISTERED',
  310. e: ['h1', 'h2', 'h3']
  311. },
  312. {
  313. hosts: {
  314. h1: {bootStatus: 'REGISTERED', name: 'h1'},
  315. h2: {bootStatus: 'FAILED', name: 'h2'},
  316. h3: {bootStatus: 'REGISTERED', name: 'h3'}
  317. },
  318. m: 'Some REGISTERED',
  319. e: ['h1', 'h3']
  320. },
  321. {
  322. hosts: {
  323. h1: {bootStatus: 'FAILED', name: 'h1'},
  324. h2: {bootStatus: 'FAILED', name: 'h2'},
  325. h3: {bootStatus: 'FAILED', name: 'h3'}
  326. },
  327. m: 'No one REGISTERED',
  328. e: []
  329. },
  330. {
  331. hosts: {},
  332. m: 'Empty hosts',
  333. e: []
  334. }
  335. ]);
  336. tests.forEach(function (test) {
  337. it(test.m, function () {
  338. controller.set('content.hosts', test.hosts);
  339. var r = controller.getHostNames();
  340. expect(r).to.eql(test.e);
  341. });
  342. });
  343. });
  344. describe('#getMasterComponentsForHost', function () {
  345. var tests = Em.A([
  346. {
  347. masterComponentHosts: Em.A([
  348. {hostName: 'h1', component: 'c1'}
  349. ]),
  350. hostName: 'h1',
  351. m: 'host exists',
  352. e: ['c1']
  353. },
  354. {
  355. masterComponentHosts: Em.A([
  356. {hostName: 'h1', component: 'c1'}
  357. ]),
  358. hostName: 'h2',
  359. m: 'host donesn\'t exists',
  360. e: []
  361. }
  362. ]);
  363. tests.forEach(function (test) {
  364. it(test.m, function () {
  365. controller.set('content.masterComponentHosts', test.masterComponentHosts);
  366. var r = controller.getMasterComponentsForHost(test.hostName);
  367. expect(r).to.eql(test.e);
  368. });
  369. });
  370. });
  371. describe('#selectMasterComponents', function () {
  372. var tests = Em.A([
  373. {
  374. masterComponentHosts: Em.A([
  375. {
  376. hostName: 'h1',
  377. component: 'c1'
  378. }
  379. ]),
  380. hostsObj: [
  381. Em.Object.create({
  382. hostName: 'h1',
  383. checkboxes: [
  384. Em.Object.create({
  385. component: 'c1',
  386. checked: false
  387. })
  388. ]
  389. })
  390. ],
  391. e: true,
  392. m: 'host and component exist'
  393. },
  394. {
  395. masterComponentHosts: Em.A([
  396. {
  397. hostName: 'h1',
  398. component: 'c2'
  399. }
  400. ]),
  401. hostsObj: [
  402. Em.Object.create({
  403. hostName: 'h1',
  404. checkboxes: [
  405. Em.Object.create({
  406. component: 'c1',
  407. checked: false
  408. })
  409. ]
  410. })
  411. ],
  412. e: false,
  413. m: 'host exists'
  414. },
  415. {
  416. masterComponentHosts: Em.A([
  417. {
  418. hostName: 'h2',
  419. component: 'c2'
  420. }
  421. ]),
  422. hostsObj: [
  423. Em.Object.create({
  424. hostName: 'h1',
  425. checkboxes: [
  426. Em.Object.create({
  427. component: 'c1',
  428. checked: false
  429. })
  430. ]
  431. })
  432. ],
  433. e: false,
  434. m: 'host and component don\'t exist'
  435. }
  436. ]);
  437. tests.forEach(function (test) {
  438. it(test.m, function () {
  439. controller.set('content.masterComponentHosts', test.masterComponentHosts);
  440. var r = controller.selectMasterComponents(test.hostsObj);
  441. expect(r.findProperty('hostName', 'h1').get('checkboxes').findProperty('component', 'c1').get('checked')).to.equal(test.e);
  442. });
  443. });
  444. });
  445. describe('#getCurrentMastersBlueprint', function () {
  446. var tests = Em.A([
  447. {
  448. masterComponentHosts: Em.A([
  449. {hostName: 'h1', component: 'c1'}
  450. ]),
  451. hosts: {'h1': {}},
  452. m: 'one host and one component',
  453. e:{
  454. blueprint: {
  455. host_groups: [
  456. {
  457. name: 'host-group-1',
  458. components: [
  459. { name: 'c1' }
  460. ]
  461. }
  462. ]
  463. },
  464. blueprint_cluster_binding: {
  465. host_groups: [
  466. {
  467. name: 'host-group-1',
  468. hosts: [
  469. { fqdn: 'h1' }
  470. ]
  471. }
  472. ]
  473. }
  474. }
  475. },
  476. {
  477. masterComponentHosts: Em.A([
  478. {hostName: 'h1', component: 'c1'},
  479. {hostName: 'h2', component: 'c2'},
  480. {hostName: 'h2', component: 'c3'}
  481. ]),
  482. hosts: {'h1': {}, 'h2': {}, 'h3': {}},
  483. m: 'multiple hosts and multiple components',
  484. e: {
  485. blueprint: {
  486. host_groups: [
  487. {
  488. name: 'host-group-1',
  489. components: [
  490. { name: 'c1' }
  491. ]
  492. },
  493. {
  494. name: 'host-group-2',
  495. components: [
  496. { name: 'c2' },
  497. { name: 'c3' }
  498. ]
  499. },
  500. {
  501. name: 'host-group-3',
  502. components: []
  503. }
  504. ]
  505. },
  506. blueprint_cluster_binding: {
  507. host_groups: [
  508. {
  509. name: 'host-group-1',
  510. hosts: [
  511. { fqdn: 'h1' }
  512. ]
  513. },
  514. {
  515. name: 'host-group-2',
  516. hosts: [
  517. { fqdn: 'h2' }
  518. ]
  519. },
  520. {
  521. name: 'host-group-3',
  522. hosts: [
  523. { fqdn: 'h3' }
  524. ]
  525. }
  526. ]
  527. }
  528. }
  529. }
  530. ]);
  531. tests.forEach(function (test) {
  532. it(test.m, function () {
  533. controller.set('content.masterComponentHosts', test.masterComponentHosts);
  534. controller.set('content.hosts', test.hosts);
  535. var r = controller.getCurrentMastersBlueprint();
  536. expect(r).to.eql(test.e);
  537. });
  538. });
  539. });
  540. describe('#callServerSideValidation', function () {
  541. var cases = [
  542. {
  543. controllerName: 'installerController',
  544. hosts: [
  545. {
  546. hostName: 'h0'
  547. },
  548. {
  549. hostName: 'h1'
  550. }
  551. ],
  552. expected: [
  553. ['c0', 'c6'],
  554. ['c1', 'c3', 'c8']
  555. ]
  556. },
  557. {
  558. controllerName: 'addServiceController',
  559. hosts: [
  560. {
  561. hostName: 'h0'
  562. },
  563. {
  564. hostName: 'h1'
  565. }
  566. ],
  567. expected: [
  568. ['c0', 'c6'],
  569. ['c1', 'c3', 'c8']
  570. ]
  571. },
  572. {
  573. controllerName: 'addHostController',
  574. hosts: [
  575. {
  576. hostName: 'h0'
  577. }
  578. ],
  579. expected: [
  580. ['c0', 'c2', 'c5', 'c6'],
  581. ['c1', 'c2', 'c3', 'c5', 'c8']
  582. ]
  583. }
  584. ],
  585. expectedHostGroups = [
  586. {
  587. name: 'host-group-1',
  588. fqdn: 'h0'
  589. },
  590. {
  591. name: 'host-group-2',
  592. fqdn: 'h1'
  593. }
  594. ];
  595. beforeEach(function () {
  596. controller.get('content').setProperties({
  597. recommendations: {
  598. blueprint: {
  599. host_groups: [
  600. {
  601. components: [
  602. {
  603. name: 'c6'
  604. }
  605. ],
  606. name: 'host-group-1'
  607. },
  608. {
  609. components: [
  610. {
  611. name: 'c8'
  612. }
  613. ],
  614. name: 'host-group-2'
  615. }
  616. ]
  617. },
  618. blueprint_cluster_binding: {
  619. host_groups: [
  620. {
  621. hosts: [
  622. {
  623. fqdn: 'h0'
  624. }
  625. ],
  626. name: 'host-group-1'
  627. },
  628. {
  629. hosts: [
  630. {
  631. fqdn: 'h1'
  632. }
  633. ],
  634. name: 'host-group-2'
  635. }]
  636. }
  637. },
  638. clients: [
  639. {
  640. component_name: 'c3'
  641. }
  642. ]
  643. });
  644. sinon.stub(App.StackService, 'find', function () {
  645. return [
  646. Em.Object.create({
  647. serviceName: 's0',
  648. isSelected: true
  649. }),
  650. Em.Object.create({
  651. serviceName: 's1',
  652. isInstalled: true,
  653. isSelected: true
  654. })
  655. ];
  656. });
  657. sinon.stub(App.StackServiceComponent, 'find', function () {
  658. return [
  659. Em.Object.create({
  660. componentName: 'c0',
  661. isSlave: true
  662. }),
  663. Em.Object.create({
  664. componentName: 'c1',
  665. isSlave: true,
  666. isShownOnInstallerSlaveClientPage: true
  667. }),
  668. Em.Object.create({
  669. componentName: 'c2',
  670. isSlave: true,
  671. isShownOnInstallerSlaveClientPage: false
  672. }),
  673. Em.Object.create({
  674. componentName: 'c3',
  675. isClient: true
  676. }),
  677. Em.Object.create({
  678. componentName: 'c4',
  679. isClient: true,
  680. isRequiredOnAllHosts: false
  681. }),
  682. Em.Object.create({
  683. componentName: 'c5',
  684. isClient: true,
  685. isRequiredOnAllHosts: true
  686. }),
  687. Em.Object.create({
  688. componentName: 'c6',
  689. isMaster: true,
  690. isShownOnInstallerAssignMasterPage: true
  691. }),
  692. Em.Object.create({
  693. componentName: 'c7',
  694. isMaster: true,
  695. isShownOnInstallerAssignMasterPage: false
  696. }),
  697. Em.Object.create({
  698. componentName: 'c8',
  699. isMaster: true,
  700. isShownOnAddServiceAssignMasterPage: true
  701. }),
  702. Em.Object.create({
  703. componentName: 'c9',
  704. isMaster: true,
  705. isShownOnAddServiceAssignMasterPage: false
  706. })
  707. ];
  708. });
  709. sinon.stub(controller, 'getCurrentBlueprint', function () {
  710. return {
  711. blueprint: {
  712. host_groups: [
  713. {
  714. components: [
  715. {
  716. name: 'c0'
  717. }
  718. ],
  719. name: 'host-group-1'
  720. },
  721. {
  722. components: [
  723. {
  724. name: 'c1'
  725. },
  726. {
  727. name: 'c3'
  728. }
  729. ],
  730. name: 'host-group-2'
  731. }
  732. ]
  733. },
  734. blueprint_cluster_binding: {
  735. host_groups: [
  736. {
  737. hosts: [
  738. {
  739. fqdn: 'h0'
  740. }
  741. ],
  742. name: 'host-group-1'
  743. },
  744. {
  745. hosts: [
  746. {
  747. fqdn: 'h1'
  748. }
  749. ],
  750. name: 'host-group-2'
  751. }]
  752. }
  753. };
  754. });
  755. sinon.stub(controller, 'getCurrentMastersBlueprint', function () {
  756. return {
  757. blueprint: {
  758. host_groups: [
  759. {
  760. components: [
  761. {
  762. name: 'c6'
  763. }
  764. ],
  765. name: 'host-group-1'
  766. },
  767. {
  768. components: [
  769. {
  770. name: 'c8'
  771. }
  772. ],
  773. name: 'host-group-2'
  774. }
  775. ]
  776. },
  777. blueprint_cluster_binding: {
  778. host_groups: [
  779. {
  780. hosts: [
  781. {
  782. fqdn: 'h0'
  783. }
  784. ],
  785. name: 'host-group-1'
  786. },
  787. {
  788. hosts: [
  789. {
  790. fqdn: 'h1'
  791. }
  792. ],
  793. name: 'host-group-2'
  794. }]
  795. }
  796. };
  797. });
  798. sinon.stub(App, 'get').withArgs('components.clients').returns(['c3', 'c4']);
  799. sinon.stub(controller, 'getCurrentMasterSlaveBlueprint', function () {
  800. return {
  801. blueprint: {
  802. host_groups: [
  803. {
  804. components: [
  805. {
  806. name: 'c6'
  807. }
  808. ],
  809. name: 'host-group-1'
  810. },
  811. {
  812. components: [
  813. {
  814. name: 'c8'
  815. }
  816. ],
  817. name: 'host-group-2'
  818. }
  819. ]
  820. },
  821. blueprint_cluster_binding: {
  822. host_groups: [
  823. {
  824. hosts: [
  825. {
  826. fqdn: 'h0'
  827. }
  828. ],
  829. name: 'host-group-1'
  830. },
  831. {
  832. hosts: [
  833. {
  834. fqdn: 'h1'
  835. }
  836. ],
  837. name: 'host-group-2'
  838. }]
  839. }
  840. };
  841. });
  842. sinon.stub(App.Host, 'find', function () {
  843. return [
  844. {
  845. hostName: 'h1'
  846. }
  847. ];
  848. });
  849. sinon.stub(App.ajax, 'send', function () {
  850. return {
  851. then: Em.K
  852. };
  853. });
  854. });
  855. afterEach(function () {
  856. App.StackService.find.restore();
  857. App.StackServiceComponent.find.restore();
  858. controller.getCurrentBlueprint.restore();
  859. controller.getCurrentMastersBlueprint.restore();
  860. App.get.restore();
  861. controller.getCurrentMasterSlaveBlueprint.restore();
  862. App.Host.find.restore();
  863. App.ajax.send.restore();
  864. });
  865. cases.forEach(function (item) {
  866. it(item.controllerName, function () {
  867. controller.set('hosts', item.hosts);
  868. controller.set('content.controllerName', item.controllerName);
  869. controller.callServerSideValidation();
  870. expect(controller.get('content.recommendationsHostGroups.blueprint.host_groups.length')).to.equal(expectedHostGroups.length);
  871. expect(controller.get('content.recommendationsHostGroups.blueprint_cluster_binding.host_groups.length')).to.equal(expectedHostGroups.length);
  872. controller.get('content.recommendationsHostGroups.blueprint.host_groups').forEach(function (group, index) {
  873. expect(group.components.mapProperty('name').sort()).to.eql(item.expected[index]);
  874. });
  875. expectedHostGroups.forEach(function (group) {
  876. var bpGroup = controller.get('content.recommendationsHostGroups.blueprint_cluster_binding.host_groups').findProperty('name', group.name);
  877. expect(bpGroup.hosts).to.have.length(1);
  878. expect(bpGroup.hosts[0].fqdn).to.equal(group.fqdn);
  879. });
  880. });
  881. });
  882. });
  883. });