step6_test.js 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592
  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. var validationUtils = require('utils/validator');
  21. require('utils/helper');
  22. require('controllers/wizard/step6_controller');
  23. var controller,
  24. services = [
  25. Em.Object.create({
  26. serviceName: 'YARN',
  27. isSelected: true
  28. }),
  29. Em.Object.create({
  30. serviceName: 'HBASE',
  31. isSelected: true
  32. }),
  33. Em.Object.create({
  34. serviceName: 'HDFS',
  35. isSelected: true
  36. }),
  37. Em.Object.create({
  38. serviceName: 'STORM',
  39. isSelected: true
  40. }),
  41. Em.Object.create({
  42. serviceName: 'FLUME',
  43. isSelected: true
  44. })
  45. ];
  46. function getController() {
  47. var controller = App.WizardStep6Controller.create({
  48. content: Em.Object.create({
  49. hosts: {},
  50. masterComponentHosts: {},
  51. services: services,
  52. controllerName: ''
  53. })
  54. });
  55. var h = {}, m = [];
  56. Em.A(['host0', 'host1', 'host2', 'host3']).forEach(function (hostName) {
  57. var obj = Em.Object.create({
  58. name: hostName,
  59. hostName: hostName,
  60. bootStatus: 'REGISTERED'
  61. });
  62. h[hostName] = obj;
  63. m.push(obj);
  64. });
  65. controller.set('content.hosts', h);
  66. controller.set('content.masterComponentHosts', m);
  67. controller.set('isMasters', false);
  68. return controller;
  69. }
  70. describe('App.WizardStep6Controller', function () {
  71. beforeEach(function () {
  72. controller = getController();
  73. sinon.stub(App.ajax, 'send', function () {
  74. return {
  75. then: Em.K
  76. };
  77. });
  78. });
  79. afterEach(function () {
  80. App.ajax.send.restore();
  81. });
  82. App.TestAliases.testAsComputedEqual(getController(), 'isAddHostWizard', 'content.controllerName', 'addHostController');
  83. describe('#installedServiceNames', function () {
  84. it(' should filter content.services by isInstalled property', function () {
  85. var services = Em.A([]);
  86. services.pushObjects(Em.A([{isInstalled: true, serviceName: "service1"},
  87. {isInstalled: false, serviceName: "service2"},
  88. {isInstalled: true, serviceName: "service3"},
  89. {isInstalled: false, serviceName: "service4"},
  90. {isInstalled: true, serviceName: "service5"}]));
  91. controller.set('content.services', services);
  92. expect(controller.get('installedServiceNames')).to.eql(["service1", "service3", "service5"]);
  93. });
  94. });
  95. describe('#showValidationIssuesAcceptBox', function () {
  96. it('should return true if success callback', function () {
  97. var deffer = jQuery.Deferred();
  98. function callback() {
  99. deffer.resolve(true);
  100. }
  101. controller.showValidationIssuesAcceptBox(callback);
  102. jQuery.when(deffer.promise()).then(function(data) {
  103. expect(data).to.equal(true);
  104. });
  105. });
  106. });
  107. describe('#selectAllNodes', function () {
  108. it('should make checkbox checked', function () {
  109. var hostsObj = Em.A([Em.Object.create({
  110. hasMaster: false,
  111. isInstalled: false,
  112. checkboxes: Em.A([
  113. Em.Object.create({
  114. title: 'l1',
  115. component: 'name',
  116. isInstalled: false,
  117. checked: false
  118. })
  119. ])
  120. })]);
  121. var obj = Em.Object.create({
  122. context: {
  123. name: "name"
  124. }
  125. });
  126. var clientComponents = Em.A([{component_name: "name1"}]);
  127. controller.set('hosts', hostsObj);
  128. controller.set('content.clients', clientComponents);
  129. controller.selectAllNodes(obj);
  130. expect(controller.get('hosts')).to.eql(Em.A([Em.Object.create({
  131. hasMaster: false,
  132. isInstalled: false,
  133. checkboxes: Em.A([
  134. Em.Object.create({
  135. title: 'l1',
  136. component: 'name',
  137. isInstalled: false,
  138. checked: true
  139. })
  140. ])
  141. })]));
  142. });
  143. });
  144. describe('#deselectAllNodes', function () {
  145. it('should uncheck checkbox', function () {
  146. var hostsObj = Em.A([Em.Object.create({
  147. hasMaster: false,
  148. isInstalled: false,
  149. checkboxes: Em.A([
  150. Em.Object.create({
  151. title: 'l1',
  152. component: 'name',
  153. isInstalled: false,
  154. checked: true
  155. })
  156. ])
  157. })]);
  158. var obj = Em.Object.create({
  159. context: {
  160. name: "name"
  161. }
  162. });
  163. var clientComponents = Em.A([{component_name: "name1"}]);
  164. controller.set('hosts', hostsObj);
  165. controller.set('content.clients', clientComponents);
  166. controller.deselectAllNodes(obj);
  167. expect(controller.get('hosts')).to.eql(Em.A([Em.Object.create({
  168. hasMaster: false,
  169. isInstalled: false,
  170. checkboxes: Em.A([
  171. Em.Object.create({
  172. title: 'l1',
  173. component: 'name',
  174. isInstalled: false,
  175. checked: false
  176. })
  177. ])
  178. })]));
  179. });
  180. });
  181. describe('#renderSlaves()', function () {
  182. var hostsObj = [{}];
  183. beforeEach(function() {
  184. sinon.stub(controller, 'selectRecommendedComponents');
  185. sinon.stub(controller, 'setInstalledComponents');
  186. sinon.stub(controller, 'restoreComponentsSelection');
  187. sinon.stub(controller, 'selectClientHost');
  188. });
  189. afterEach(function() {
  190. controller.selectRecommendedComponents.restore();
  191. controller.setInstalledComponents.restore();
  192. controller.restoreComponentsSelection.restore();
  193. controller.selectClientHost.restore();
  194. });
  195. describe("slaveComponents is null", function() {
  196. beforeEach(function() {
  197. controller.set('content.slaveComponentHosts', null);
  198. });
  199. it("selectRecommendedComponents should be called", function() {
  200. expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
  201. expect(controller.selectRecommendedComponents.calledWith(hostsObj)).to.be.true;
  202. });
  203. it("setInstalledComponents should be called", function() {
  204. expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
  205. expect(controller.setInstalledComponents.calledWith(hostsObj)).to.be.true;
  206. });
  207. it("restoreComponentsSelection should not be called", function() {
  208. expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
  209. expect(controller.restoreComponentsSelection.called).to.be.false;
  210. });
  211. it("selectClientHost should be called", function() {
  212. expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
  213. expect(controller.selectClientHost.calledWith(hostsObj)).to.be.true;
  214. });
  215. });
  216. describe("slaveComponents is defined", function() {
  217. var slaveComponentHosts = [{}];
  218. beforeEach(function() {
  219. controller.set('content.slaveComponentHosts', slaveComponentHosts);
  220. });
  221. it("selectRecommendedComponents should not be called", function() {
  222. expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
  223. expect(controller.selectRecommendedComponents.called).to.be.false;
  224. });
  225. it("setInstalledComponents should not be called", function() {
  226. expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
  227. expect(controller.setInstalledComponents.called).to.be.false;
  228. });
  229. it("restoreComponentsSelection should be called", function() {
  230. expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
  231. expect(controller.restoreComponentsSelection.calledWith(hostsObj, slaveComponentHosts)).to.be.true;
  232. });
  233. it("selectClientHost should be called", function() {
  234. expect(controller.renderSlaves(hostsObj)).to.eql(hostsObj);
  235. expect(controller.selectClientHost.calledWith(hostsObj)).to.be.true;
  236. });
  237. });
  238. });
  239. describe("#setInstalledComponents()", function() {
  240. var hostsObj = [{
  241. hostName: 'host1',
  242. checkboxes: [
  243. {
  244. component: 'C1',
  245. isInstalled: false
  246. },
  247. {
  248. component: 'C2',
  249. isInstalled: false
  250. }
  251. ]
  252. }];
  253. it("installedHosts is null", function() {
  254. controller.set('content.installedHosts', null);
  255. expect(controller.setInstalledComponents(hostsObj)).to.be.false;
  256. });
  257. it("installedHosts is defined", function() {
  258. controller.set('content.installedHosts', {
  259. 'host1': {
  260. hostComponents: [
  261. {
  262. HostRoles: {
  263. component_name: 'C1'
  264. }
  265. }
  266. ]
  267. }
  268. });
  269. controller.setInstalledComponents(hostsObj);
  270. expect(hostsObj[0].checkboxes[0].isInstalled).to.be.true;
  271. expect(hostsObj[0].checkboxes[1].isInstalled).to.be.false;
  272. });
  273. });
  274. describe("#restoreComponentsSelection()", function() {
  275. var getHostsObj = function() {
  276. return [{
  277. hostName: 'host1',
  278. checkboxes: [
  279. {
  280. component: 'C1',
  281. title: 'c1',
  282. isInstalled: false,
  283. checked: false
  284. },
  285. {
  286. component: 'C2',
  287. title: 'c1',
  288. isInstalled: true,
  289. checked: false
  290. },
  291. {
  292. component: 'C3',
  293. title: 'c3',
  294. isInstalled: false,
  295. checked: false
  296. }
  297. ]
  298. }];
  299. };
  300. var slaveComponents = [
  301. {
  302. componentName: 'C1',
  303. hosts: [{hostName: 'host1', isInstalled: true}]
  304. }
  305. ];
  306. beforeEach(function() {
  307. controller.set('headers', [
  308. Em.Object.create({
  309. name: 'C1',
  310. label: 'c1'
  311. }),
  312. Em.Object.create({
  313. name: 'C2',
  314. label: 'c2'
  315. }),
  316. Em.Object.create({
  317. name: 'C3',
  318. label: 'c3'
  319. })
  320. ]);
  321. });
  322. it("C1 components should be checked and installed", function() {
  323. var hostsObj = getHostsObj();
  324. controller.restoreComponentsSelection(hostsObj, slaveComponents);
  325. expect(hostsObj[0].checkboxes[0].isInstalled).to.be.true;
  326. expect(hostsObj[0].checkboxes[0].checked).to.be.true;
  327. });
  328. it("C2 components should not be checked and should be installed", function() {
  329. var hostsObj = getHostsObj();
  330. controller.restoreComponentsSelection(hostsObj, slaveComponents);
  331. expect(hostsObj[0].checkboxes[1].isInstalled).to.be.true;
  332. expect(hostsObj[0].checkboxes[1].checked).to.be.false;
  333. });
  334. it("C3 components should not be checked and should not be installed", function() {
  335. var hostsObj = getHostsObj();
  336. controller.restoreComponentsSelection(hostsObj, slaveComponents);
  337. expect(hostsObj[0].checkboxes[2].isInstalled).to.be.false;
  338. expect(hostsObj[0].checkboxes[2].checked).to.be.false;
  339. });
  340. });
  341. describe("#selectRecommendedComponents()", function() {
  342. var hostsObj = [{
  343. hostName: 'host1',
  344. checkboxes: [
  345. {
  346. component: 'C1',
  347. checked: false
  348. },
  349. {
  350. component: 'C2',
  351. checked: false
  352. },
  353. {
  354. component: 'CLIENT',
  355. checked: false
  356. }
  357. ]
  358. }];
  359. var recommendations = {
  360. blueprint: {
  361. host_groups: [
  362. {
  363. name: 'g1',
  364. components: [
  365. {name: 'C1'},
  366. {name: 'C_CLIENT'}
  367. ]
  368. }
  369. ]
  370. },
  371. blueprint_cluster_binding: {
  372. host_groups: [
  373. {
  374. name: 'g1',
  375. hosts: [{fqdn: 'host1'}]
  376. }
  377. ]
  378. }
  379. };
  380. beforeEach(function() {
  381. sinon.stub(App, 'get').returns(['C_CLIENT']);
  382. });
  383. afterEach(function() {
  384. App.get.restore();
  385. });
  386. it("C1 should be checked", function() {
  387. controller.set('content.recommendations', recommendations);
  388. controller.selectRecommendedComponents(hostsObj);
  389. expect(hostsObj[0].checkboxes[0].checked).to.be.true;
  390. });
  391. it("C2 should not be checked", function() {
  392. controller.set('content.recommendations', recommendations);
  393. controller.selectRecommendedComponents(hostsObj);
  394. expect(hostsObj[0].checkboxes[1].checked).to.be.false;
  395. });
  396. it("CLIENT should be checked", function() {
  397. controller.set('content.recommendations', recommendations);
  398. controller.selectRecommendedComponents(hostsObj);
  399. expect(hostsObj[0].checkboxes[2].checked).to.be.true;
  400. });
  401. });
  402. App.TestAliases.testAsComputedOr(getController(), 'anyGeneralErrors', ['errorMessage', 'generalErrorMessages.length']);
  403. describe('#render', function () {
  404. it('true if loaded', function () {
  405. var hosts = {
  406. h1: {bootStatus: 'REGISTERED', name: 'h1'},
  407. h2: {bootStatus: 'REGISTERED', name: 'h2'},
  408. h3: {bootStatus: 'REGISTERED', name: 'h3'}
  409. };
  410. var headers = Em.A([
  411. Em.Object.create({name: "c1", label: 'l1', isDisabled: true}),
  412. Em.Object.create({name: "c2", label: 'l2', isDisabled: false})
  413. ]);
  414. var masterComponentHosts = Em.A([
  415. {hostName: 'h1', component: 'c1'}
  416. ]);
  417. var recommendations = {
  418. blueprint: {
  419. host_groups: [
  420. {
  421. components: [
  422. {
  423. name: 'c6'
  424. }
  425. ],
  426. name: 'host-group-1'
  427. },
  428. {
  429. components: [
  430. {
  431. name: 'c8'
  432. }
  433. ],
  434. name: 'host-group-2'
  435. }
  436. ]
  437. },
  438. blueprint_cluster_binding: {
  439. host_groups: [
  440. {
  441. hosts: [
  442. {
  443. fqdn: 'h0'
  444. }
  445. ],
  446. name: 'host-group-1'
  447. },
  448. {
  449. hosts: [
  450. {
  451. fqdn: 'h1'
  452. }
  453. ],
  454. name: 'host-group-2'
  455. }]
  456. }
  457. };
  458. controller.set('content.hosts', hosts);
  459. controller.set('content.masterComponentHosts', masterComponentHosts);
  460. controller.set('content.recommendations', recommendations);
  461. controller.set('headers', headers);
  462. controller.render();
  463. expect(controller.get('isLoaded')).to.equal(true);
  464. });
  465. });
  466. describe('#anyGeneralWarnings', function () {
  467. it('true if generalWarningMessages is non empty array and warningMessage is undefined', function () {
  468. controller.set('generalWarningMessages', ["warning1", "warning2"]);
  469. expect(controller.get('anyGeneralWarnings')).to.equal(true);
  470. });
  471. it('false if generalWarningMessages is empty array', function () {
  472. controller.set('generalWarningMessages', []);
  473. expect(controller.get('anyGeneralWarnings')).to.equal(false);
  474. });
  475. it('undefined if generalWarningMessages is undefined', function () {
  476. controller.set('generalWarningMessages', false);
  477. expect(controller.get('anyGeneralWarnings')).to.equal(false);
  478. });
  479. });
  480. App.TestAliases.testAsComputedOr(getController(), 'anyGeneralIssues', ['anyGeneralErrors', 'anyGeneralWarnings']);
  481. App.TestAliases.testAsComputedOr(getController(), 'anyErrors', ['anyGeneralErrors', 'anyHostErrors']);
  482. App.TestAliases.testAsComputedOr(getController(), 'anyWarnings', ['anyGeneralWarnings', 'anyHostWarnings']);
  483. describe('#anyWarnings', function () {
  484. it('true if generalWarningMessages is non empty', function () {
  485. controller.set('generalWarningMessages', ["error 404", "error"]);
  486. expect(controller.get('anyWarnings')).to.equal(true);
  487. });
  488. it('false if generalWarningMessages is empty', function () {
  489. controller.set('generalWarningMessages', []);
  490. expect(controller.get('anyWarnings')).to.equal(false);
  491. });
  492. });
  493. App.TestAliases.testAsComputedEqual(getController(), 'isInstallerWizard', 'content.controllerName', 'installerController');
  494. App.TestAliases.testAsComputedEqual(getController(), 'isAddServiceWizard', 'content.controllerName', 'addServiceController');
  495. describe('#selectClientHost', function () {
  496. it('true if isClientsSet false', function () {
  497. var hostsObj = Em.A([Em.Object.create({
  498. hasMaster: false,
  499. checkboxes: Em.A([
  500. Em.Object.create({
  501. component: 'c1',
  502. isInstalled: false,
  503. checked: true
  504. })
  505. ])
  506. })]);
  507. controller.set('isClientsSet', false);
  508. controller.selectClientHost(hostsObj);
  509. expect(controller.get('isClientsSet')).to.equal(true);
  510. });
  511. });
  512. describe('#updateValidationsSuccessCallback', function () {
  513. beforeEach(function () {
  514. sinon.stub(validationUtils, 'filterNotInstalledComponents', function () {
  515. return Em.A([Em.Object.create({
  516. componentName: 'c0',
  517. isSlave: true,
  518. type: 'host-component',
  519. level: 'ERROR'
  520. }),
  521. Em.Object.create({
  522. componentName: 'c1',
  523. isSlave: true,
  524. type: 'host-component',
  525. level: 'WARN',
  526. isShownOnInstallerSlaveClientPage: true
  527. })]);
  528. });
  529. sinon.stub(App.StackServiceComponent, 'find', function () {
  530. return [
  531. Em.Object.create({
  532. componentName: 'c0',
  533. isSlave: true
  534. }),
  535. Em.Object.create({
  536. componentName: 'c1',
  537. isSlave: true,
  538. isShownOnInstallerSlaveClientPage: true
  539. }),
  540. Em.Object.create({
  541. componentName: 'c2',
  542. isSlave: true,
  543. isShownOnInstallerSlaveClientPage: false
  544. }),
  545. Em.Object.create({
  546. componentName: 'c3',
  547. isClient: true
  548. }),
  549. Em.Object.create({
  550. componentName: 'c4',
  551. isClient: true,
  552. isRequiredOnAllHosts: false
  553. }),
  554. Em.Object.create({
  555. componentName: 'c5',
  556. isClient: true,
  557. isRequiredOnAllHosts: true
  558. }),
  559. Em.Object.create({
  560. componentName: 'c6',
  561. isMaster: true,
  562. isShownOnInstallerAssignMasterPage: true
  563. }),
  564. Em.Object.create({
  565. componentName: 'c7',
  566. isMaster: true,
  567. isShownOnInstallerAssignMasterPage: false
  568. }),
  569. Em.Object.create({
  570. componentName: 'HDFS_CLIENT',
  571. isMaster: true,
  572. isShownOnAddServiceAssignMasterPage: true
  573. }),
  574. Em.Object.create({
  575. componentName: 'c9',
  576. isMaster: true,
  577. isShownOnAddServiceAssignMasterPage: false
  578. })
  579. ];
  580. });
  581. });
  582. afterEach(function () {
  583. App.StackServiceComponent.find.restore();
  584. validationUtils.filterNotInstalledComponents.restore();
  585. });
  586. it('should return modified hosts', function () {
  587. var hosts = Em.A([Em.Object.create({
  588. warnMessages: "warn",
  589. errorMessages: "error",
  590. anyMessage: true,
  591. checkboxes: Em.A([Em.Object.create({
  592. hasWarnMessage: true,
  593. hasErrorMessage: true
  594. })])
  595. })]);
  596. controller.set('hosts', hosts);
  597. var validationData = Em.Object.create({
  598. resources: Em.A([
  599. Em.Object.create({
  600. items: Em.A([
  601. Em.Object.create({
  602. "component-name": 'HDFS_CLIENT',
  603. host: "1",
  604. isMaster: true
  605. })
  606. ])
  607. })
  608. ])
  609. });
  610. controller.updateValidationsSuccessCallback(validationData);
  611. expect(controller.get('generalErrorMessages').length).to.equal(0);
  612. expect(controller.get('generalWarningMessages').length).to.equal(0);
  613. expect(JSON.parse(JSON.stringify(controller.get('hosts')))).to.eql(JSON.parse(JSON.stringify(Em.A([Em.Object.create({
  614. warnMessages: [null],
  615. errorMessages: [null],
  616. anyMessage: true,
  617. checkboxes: Em.A([Em.Object.create({
  618. hasWarnMessage: true,
  619. hasErrorMessage: true
  620. })])
  621. })]))));
  622. });
  623. });
  624. describe('#clearError', function () {
  625. it('both checkboxes are checked', function () {
  626. var hosts = Em.A([
  627. Em.Object.create({
  628. checkboxes: Em.A([
  629. Em.Object.create({
  630. component: 'c1',
  631. isInstalled: false,
  632. checked: true
  633. }),
  634. Em.Object.create({
  635. component: 'c2',
  636. isInstalled: false,
  637. checked: true
  638. })])
  639. })
  640. ]);
  641. var headers = Em.A([
  642. Em.Object.create({name: "c1"}),
  643. Em.Object.create({name: "c2"})]);
  644. controller.set('errorMessage', 'error');
  645. controller.set('hosts', hosts);
  646. controller.set('headers', headers);
  647. controller.clearError();
  648. expect(controller.get('errorMessage')).to.equal('');
  649. });
  650. it('true if is one of checkboxes checked false', function () {
  651. var hosts = Em.A([
  652. Em.Object.create({
  653. checkboxes: Em.A([
  654. Em.Object.create({
  655. title: "t1",
  656. component: 'c1',
  657. isInstalled: false,
  658. checked: false
  659. }),
  660. Em.Object.create({
  661. title: "t2",
  662. component: 'c2',
  663. isInstalled: false,
  664. checked: true
  665. })])
  666. })
  667. ]);
  668. var headers = Em.A([
  669. Em.Object.create({name: "c1", label: 't1'}),
  670. Em.Object.create({name: "c2", label: 't2'})]);
  671. controller.set('errorMessage', 'error');
  672. controller.set('hosts', hosts);
  673. controller.set('headers', headers);
  674. controller.set('isAddHostWizard', true);
  675. controller.clearError();
  676. expect(controller.get('errorMessage')).to.equal('error');
  677. });
  678. });
  679. describe('#clearStep', function () {
  680. beforeEach(function () {
  681. sinon.stub(controller, 'clearError', Em.K);
  682. });
  683. afterEach(function () {
  684. controller.clearError.restore();
  685. });
  686. it('should call clearError', function () {
  687. controller.clearStep();
  688. expect(controller.clearError.calledOnce).to.equal(true);
  689. });
  690. it('should clear hosts', function () {
  691. controller.set('hosts', [
  692. {},
  693. {}
  694. ]);
  695. controller.clearStep();
  696. expect(controller.get('hosts')).to.eql([]);
  697. });
  698. it('should clear headers', function () {
  699. controller.set('headers', [
  700. {},
  701. {}
  702. ]);
  703. controller.clearStep();
  704. expect(controller.get('headers')).to.eql([]);
  705. });
  706. it('should set isLoaded to false', function () {
  707. controller.set('isLoaded', true);
  708. controller.clearStep();
  709. expect(controller.get('isLoaded')).to.equal(false);
  710. });
  711. });
  712. describe('#checkCallback', function () {
  713. beforeEach(function () {
  714. sinon.stub(controller, 'clearError', Em.K);
  715. });
  716. afterEach(function () {
  717. controller.clearError.restore();
  718. });
  719. it('should call clearError', function () {
  720. controller.checkCallback('');
  721. expect(controller.clearError.calledOnce).to.equal(true);
  722. });
  723. Em.A([
  724. {
  725. m: 'all checked, isInstalled false',
  726. headers: Em.A([
  727. Em.Object.create({name: 'c1'})
  728. ]),
  729. hosts: Em.A([
  730. Em.Object.create({
  731. checkboxes: Em.A([
  732. Em.Object.create({
  733. component: 'c1',
  734. isInstalled: false,
  735. checked: true
  736. })
  737. ])
  738. })
  739. ]),
  740. component: 'c1',
  741. e: {
  742. allChecked: true,
  743. noChecked: false
  744. }
  745. },
  746. {
  747. m: 'all checked, isInstalled true',
  748. headers: Em.A([
  749. Em.Object.create({name: 'c1'})
  750. ]),
  751. hosts: Em.A([
  752. Em.Object.create({
  753. checkboxes: Em.A([
  754. Em.Object.create({
  755. component: 'c1',
  756. isInstalled: true,
  757. checked: true
  758. })
  759. ])
  760. })
  761. ]),
  762. component: 'c1',
  763. e: {
  764. allChecked: true,
  765. noChecked: true
  766. }
  767. },
  768. {
  769. m: 'no one checked',
  770. headers: Em.A([
  771. Em.Object.create({name: 'c1'})
  772. ]),
  773. hosts: Em.A([
  774. Em.Object.create({
  775. checkboxes: Em.A([
  776. Em.Object.create({
  777. component: 'c1',
  778. isInstalled: false,
  779. checked: false
  780. })
  781. ])
  782. })
  783. ]),
  784. component: 'c1',
  785. e: {
  786. allChecked: false,
  787. noChecked: true
  788. }
  789. },
  790. {
  791. m: 'some checked',
  792. headers: Em.A([
  793. Em.Object.create({name: 'c1'})
  794. ]),
  795. hosts: Em.A([
  796. Em.Object.create({
  797. checkboxes: Em.A([
  798. Em.Object.create({
  799. component: 'c1',
  800. isInstalled: false,
  801. checked: true
  802. }),
  803. Em.Object.create({
  804. component: 'c1',
  805. isInstalled: false,
  806. checked: false
  807. })
  808. ])
  809. })
  810. ]),
  811. component: 'c1',
  812. e: {
  813. allChecked: false,
  814. noChecked: false
  815. }
  816. },
  817. {
  818. m: 'some checked, some isInstalled true',
  819. headers: Em.A([
  820. Em.Object.create({name: 'c1'})
  821. ]),
  822. hosts: Em.A([
  823. Em.Object.create({
  824. checkboxes: Em.A([
  825. Em.Object.create({
  826. component: 'c1',
  827. isInstalled: true,
  828. checked: true
  829. }),
  830. Em.Object.create({
  831. component: 'c1',
  832. isInstalled: true,
  833. checked: true
  834. })
  835. ])
  836. })
  837. ]),
  838. component: 'c1',
  839. e: {
  840. allChecked: true,
  841. noChecked: true
  842. }
  843. },
  844. {
  845. m: 'some checked, some isInstalled true (2)',
  846. headers: Em.A([
  847. Em.Object.create({name: 'c1'})
  848. ]),
  849. hosts: Em.A([
  850. Em.Object.create({
  851. checkboxes: Em.A([
  852. Em.Object.create({
  853. component: 'c1',
  854. isInstalled: false,
  855. checked: false
  856. }),
  857. Em.Object.create({
  858. component: 'c1',
  859. isInstalled: true,
  860. checked: true
  861. })
  862. ])
  863. })
  864. ]),
  865. component: 'c1',
  866. e: {
  867. allChecked: false,
  868. noChecked: true
  869. }
  870. }
  871. ]).forEach(function (test) {
  872. it(test.m, function () {
  873. controller.clearStep();
  874. controller.set('headers', test.headers);
  875. controller.set('hosts', test.hosts);
  876. controller.checkCallback(test.component);
  877. var header = controller.get('headers').findProperty('name', test.component);
  878. expect(header.get('allChecked')).to.equal(test.e.allChecked);
  879. expect(header.get('noChecked')).to.equal(test.e.noChecked);
  880. });
  881. });
  882. });
  883. describe('#getHostNames', function () {
  884. var tests = Em.A([
  885. {
  886. hosts: {
  887. h1: {bootStatus: 'REGISTERED', name: 'h1'},
  888. h2: {bootStatus: 'REGISTERED', name: 'h2'},
  889. h3: {bootStatus: 'REGISTERED', name: 'h3'}
  890. },
  891. m: 'All REGISTERED',
  892. e: ['h1', 'h2', 'h3']
  893. },
  894. {
  895. hosts: {
  896. h1: {bootStatus: 'REGISTERED', name: 'h1'},
  897. h2: {bootStatus: 'FAILED', name: 'h2'},
  898. h3: {bootStatus: 'REGISTERED', name: 'h3'}
  899. },
  900. m: 'Some REGISTERED',
  901. e: ['h1', 'h3']
  902. },
  903. {
  904. hosts: {
  905. h1: {bootStatus: 'FAILED', name: 'h1'},
  906. h2: {bootStatus: 'FAILED', name: 'h2'},
  907. h3: {bootStatus: 'FAILED', name: 'h3'}
  908. },
  909. m: 'No one REGISTERED',
  910. e: []
  911. },
  912. {
  913. hosts: {},
  914. m: 'Empty hosts',
  915. e: []
  916. }
  917. ]);
  918. tests.forEach(function (test) {
  919. it(test.m, function () {
  920. controller.set('content.hosts', test.hosts);
  921. var r = controller.getHostNames();
  922. expect(r).to.eql(test.e);
  923. });
  924. });
  925. });
  926. describe('#getMasterComponentsForHost', function () {
  927. var tests = Em.A([
  928. {
  929. masterComponentHosts: Em.A([
  930. {hostName: 'h1', component: 'c1'}
  931. ]),
  932. hostName: 'h1',
  933. m: 'host exists',
  934. e: ['c1']
  935. },
  936. {
  937. masterComponentHosts: Em.A([
  938. {hostName: 'h1', component: 'c1'}
  939. ]),
  940. hostName: 'h2',
  941. m: 'host donesn\'t exists',
  942. e: []
  943. }
  944. ]);
  945. tests.forEach(function (test) {
  946. it(test.m, function () {
  947. controller.set('content.masterComponentHosts', test.masterComponentHosts);
  948. var r = controller.getMasterComponentsForHost(test.hostName);
  949. expect(r).to.eql(test.e);
  950. });
  951. });
  952. });
  953. describe('#selectMasterComponents', function () {
  954. var tests = Em.A([
  955. {
  956. masterComponentHosts: Em.A([
  957. {
  958. hostName: 'h1',
  959. component: 'c1'
  960. }
  961. ]),
  962. hostsObj: [
  963. Em.Object.create({
  964. hostName: 'h1',
  965. checkboxes: [
  966. Em.Object.create({
  967. component: 'c1',
  968. checked: false
  969. })
  970. ]
  971. })
  972. ],
  973. e: true,
  974. m: 'host and component exist'
  975. },
  976. {
  977. masterComponentHosts: Em.A([
  978. {
  979. hostName: 'h1',
  980. component: 'c2'
  981. }
  982. ]),
  983. hostsObj: [
  984. Em.Object.create({
  985. hostName: 'h1',
  986. checkboxes: [
  987. Em.Object.create({
  988. component: 'c1',
  989. checked: false
  990. })
  991. ]
  992. })
  993. ],
  994. e: false,
  995. m: 'host exists'
  996. },
  997. {
  998. masterComponentHosts: Em.A([
  999. {
  1000. hostName: 'h2',
  1001. component: 'c2'
  1002. }
  1003. ]),
  1004. hostsObj: [
  1005. Em.Object.create({
  1006. hostName: 'h1',
  1007. checkboxes: [
  1008. Em.Object.create({
  1009. component: 'c1',
  1010. checked: false
  1011. })
  1012. ]
  1013. })
  1014. ],
  1015. e: false,
  1016. m: 'host and component don\'t exist'
  1017. }
  1018. ]);
  1019. tests.forEach(function (test) {
  1020. it(test.m, function () {
  1021. controller.set('content.masterComponentHosts', test.masterComponentHosts);
  1022. var r = controller.selectMasterComponents(test.hostsObj);
  1023. expect(r.findProperty('hostName', 'h1').get('checkboxes').findProperty('component', 'c1').get('checked')).to.equal(test.e);
  1024. });
  1025. });
  1026. });
  1027. describe('#getCurrentMastersBlueprint', function () {
  1028. var tests = Em.A([
  1029. {
  1030. masterComponentHosts: Em.A([
  1031. {hostName: 'h1', component: 'c1'}
  1032. ]),
  1033. hosts: {'h1': {}},
  1034. m: 'one host and one component',
  1035. e:{
  1036. blueprint: {
  1037. host_groups: [
  1038. {
  1039. name: 'host-group-1',
  1040. components: [
  1041. { name: 'c1' }
  1042. ]
  1043. }
  1044. ]
  1045. },
  1046. blueprint_cluster_binding: {
  1047. host_groups: [
  1048. {
  1049. name: 'host-group-1',
  1050. hosts: [
  1051. { fqdn: 'h1' }
  1052. ]
  1053. }
  1054. ]
  1055. }
  1056. }
  1057. },
  1058. {
  1059. masterComponentHosts: Em.A([
  1060. {hostName: 'h1', component: 'c1'},
  1061. {hostName: 'h2', component: 'c2'},
  1062. {hostName: 'h2', component: 'c3'}
  1063. ]),
  1064. hosts: {'h1': {}, 'h2': {}, 'h3': {}},
  1065. m: 'multiple hosts and multiple components',
  1066. e: {
  1067. blueprint: {
  1068. host_groups: [
  1069. {
  1070. name: 'host-group-1',
  1071. components: [
  1072. { name: 'c1' }
  1073. ]
  1074. },
  1075. {
  1076. name: 'host-group-2',
  1077. components: [
  1078. { name: 'c2' },
  1079. { name: 'c3' }
  1080. ]
  1081. },
  1082. {
  1083. name: 'host-group-3',
  1084. components: []
  1085. }
  1086. ]
  1087. },
  1088. blueprint_cluster_binding: {
  1089. host_groups: [
  1090. {
  1091. name: 'host-group-1',
  1092. hosts: [
  1093. { fqdn: 'h1' }
  1094. ]
  1095. },
  1096. {
  1097. name: 'host-group-2',
  1098. hosts: [
  1099. { fqdn: 'h2' }
  1100. ]
  1101. },
  1102. {
  1103. name: 'host-group-3',
  1104. hosts: [
  1105. { fqdn: 'h3' }
  1106. ]
  1107. }
  1108. ]
  1109. }
  1110. }
  1111. }
  1112. ]);
  1113. tests.forEach(function (test) {
  1114. it(test.m, function () {
  1115. controller.set('content.masterComponentHosts', test.masterComponentHosts);
  1116. controller.set('content.hosts', test.hosts);
  1117. var r = controller.getCurrentMastersBlueprint();
  1118. expect(r).to.eql(test.e);
  1119. });
  1120. });
  1121. });
  1122. describe('#getCurrentBlueprint', function () {
  1123. var tests = Em.A([
  1124. {
  1125. clientComponents: Em.A([{component_name: "name1"}]),
  1126. hosts: Em.A([
  1127. Em.Object.create({
  1128. checkboxes: Em.A([
  1129. Em.Object.create({
  1130. component: 'c1',
  1131. checked: true
  1132. }),
  1133. Em.Object.create({
  1134. component: 'CLIENT',
  1135. checked: true
  1136. })
  1137. ])
  1138. })
  1139. ]),
  1140. m: 'one host and one component',
  1141. e:{
  1142. blueprint: {
  1143. host_groups: [
  1144. {
  1145. name: 'host-group-1',
  1146. components: [
  1147. { name: 'c1' },
  1148. { name: 'name1' }
  1149. ]
  1150. }
  1151. ]
  1152. },
  1153. blueprint_cluster_binding: {
  1154. host_groups: [
  1155. {
  1156. name: 'host-group-1',
  1157. hosts: [
  1158. {}
  1159. ]
  1160. }
  1161. ]
  1162. }
  1163. }
  1164. }
  1165. ]);
  1166. tests.forEach(function (test) {
  1167. it(test.m, function () {
  1168. controller.set('content.clients', test.clientComponents);
  1169. controller.set('hosts', test.hosts);
  1170. var r = controller.getCurrentBlueprint();
  1171. expect(JSON.parse(JSON.stringify(r))).to.eql(JSON.parse(JSON.stringify(test.e)));
  1172. });
  1173. });
  1174. });
  1175. describe('#callServerSideValidation', function () {
  1176. var cases = [
  1177. {
  1178. controllerName: 'installerController',
  1179. hosts: [
  1180. {
  1181. hostName: 'h0'
  1182. },
  1183. {
  1184. hostName: 'h1'
  1185. }
  1186. ],
  1187. expected: [
  1188. ['c0', 'c6'],
  1189. ['c1', 'c3', 'c8']
  1190. ]
  1191. },
  1192. {
  1193. controllerName: 'addServiceController',
  1194. hosts: [
  1195. {
  1196. hostName: 'h0'
  1197. },
  1198. {
  1199. hostName: 'h1'
  1200. }
  1201. ],
  1202. expected: [
  1203. ['c0', 'c6'],
  1204. ['c1', 'c3', 'c8']
  1205. ]
  1206. },
  1207. {
  1208. controllerName: 'addHostController',
  1209. hosts: [
  1210. {
  1211. hostName: 'h0'
  1212. }
  1213. ],
  1214. expected: [
  1215. ['c0', 'c2', 'c5', 'c6'],
  1216. ['c1', 'c2', 'c3', 'c5', 'c8']
  1217. ]
  1218. }
  1219. ],
  1220. expectedHostGroups = [
  1221. {
  1222. name: 'host-group-1',
  1223. fqdn: 'h0'
  1224. },
  1225. {
  1226. name: 'host-group-2',
  1227. fqdn: 'h1'
  1228. }
  1229. ];
  1230. beforeEach(function () {
  1231. controller.get('content').setProperties({
  1232. recommendations: {
  1233. blueprint: {
  1234. host_groups: [
  1235. {
  1236. components: [
  1237. {
  1238. name: 'c6'
  1239. }
  1240. ],
  1241. name: 'host-group-1'
  1242. },
  1243. {
  1244. components: [
  1245. {
  1246. name: 'c8'
  1247. }
  1248. ],
  1249. name: 'host-group-2'
  1250. }
  1251. ]
  1252. },
  1253. blueprint_cluster_binding: {
  1254. host_groups: [
  1255. {
  1256. hosts: [
  1257. {
  1258. fqdn: 'h0'
  1259. }
  1260. ],
  1261. name: 'host-group-1'
  1262. },
  1263. {
  1264. hosts: [
  1265. {
  1266. fqdn: 'h1'
  1267. }
  1268. ],
  1269. name: 'host-group-2'
  1270. }]
  1271. }
  1272. },
  1273. clients: [
  1274. {
  1275. component_name: 'c3'
  1276. }
  1277. ]
  1278. });
  1279. sinon.stub(App.StackService, 'find', function () {
  1280. return [
  1281. Em.Object.create({
  1282. serviceName: 's0',
  1283. isSelected: true
  1284. }),
  1285. Em.Object.create({
  1286. serviceName: 's1',
  1287. isInstalled: true,
  1288. isSelected: true
  1289. })
  1290. ];
  1291. });
  1292. sinon.stub(App.StackServiceComponent, 'find', function () {
  1293. return [
  1294. Em.Object.create({
  1295. componentName: 'c0',
  1296. isSlave: true
  1297. }),
  1298. Em.Object.create({
  1299. componentName: 'c1',
  1300. isSlave: true,
  1301. isShownOnInstallerSlaveClientPage: true
  1302. }),
  1303. Em.Object.create({
  1304. componentName: 'c2',
  1305. isSlave: true,
  1306. isShownOnInstallerSlaveClientPage: false
  1307. }),
  1308. Em.Object.create({
  1309. componentName: 'c3',
  1310. isClient: true
  1311. }),
  1312. Em.Object.create({
  1313. componentName: 'c4',
  1314. isClient: true,
  1315. isRequiredOnAllHosts: false
  1316. }),
  1317. Em.Object.create({
  1318. componentName: 'c5',
  1319. isClient: true,
  1320. isRequiredOnAllHosts: true
  1321. }),
  1322. Em.Object.create({
  1323. componentName: 'c6',
  1324. isMaster: true,
  1325. isShownOnInstallerAssignMasterPage: true
  1326. }),
  1327. Em.Object.create({
  1328. componentName: 'c7',
  1329. isMaster: true,
  1330. isShownOnInstallerAssignMasterPage: false
  1331. }),
  1332. Em.Object.create({
  1333. componentName: 'c8',
  1334. isMaster: true,
  1335. isShownOnAddServiceAssignMasterPage: true
  1336. }),
  1337. Em.Object.create({
  1338. componentName: 'c9',
  1339. isMaster: true,
  1340. isShownOnAddServiceAssignMasterPage: false
  1341. })
  1342. ];
  1343. });
  1344. sinon.stub(controller, 'getCurrentBlueprint', function () {
  1345. return {
  1346. blueprint: {
  1347. host_groups: [
  1348. {
  1349. components: [
  1350. {
  1351. name: 'c0'
  1352. }
  1353. ],
  1354. name: 'host-group-1'
  1355. },
  1356. {
  1357. components: [
  1358. {
  1359. name: 'c1'
  1360. },
  1361. {
  1362. name: 'c3'
  1363. }
  1364. ],
  1365. name: 'host-group-2'
  1366. }
  1367. ]
  1368. },
  1369. blueprint_cluster_binding: {
  1370. host_groups: [
  1371. {
  1372. hosts: [
  1373. {
  1374. fqdn: 'h0'
  1375. }
  1376. ],
  1377. name: 'host-group-1'
  1378. },
  1379. {
  1380. hosts: [
  1381. {
  1382. fqdn: 'h1'
  1383. }
  1384. ],
  1385. name: 'host-group-2'
  1386. }]
  1387. }
  1388. };
  1389. });
  1390. sinon.stub(controller, 'getCurrentMastersBlueprint', function () {
  1391. return {
  1392. blueprint: {
  1393. host_groups: [
  1394. {
  1395. components: [
  1396. {
  1397. name: 'c6'
  1398. }
  1399. ],
  1400. name: 'host-group-1'
  1401. },
  1402. {
  1403. components: [
  1404. {
  1405. name: 'c8'
  1406. }
  1407. ],
  1408. name: 'host-group-2'
  1409. }
  1410. ]
  1411. },
  1412. blueprint_cluster_binding: {
  1413. host_groups: [
  1414. {
  1415. hosts: [
  1416. {
  1417. fqdn: 'h0'
  1418. }
  1419. ],
  1420. name: 'host-group-1'
  1421. },
  1422. {
  1423. hosts: [
  1424. {
  1425. fqdn: 'h1'
  1426. }
  1427. ],
  1428. name: 'host-group-2'
  1429. }]
  1430. }
  1431. };
  1432. });
  1433. sinon.stub(App, 'get').withArgs('components.clients').returns(['c3', 'c4']);
  1434. sinon.stub(controller, 'getCurrentMasterSlaveBlueprint', function () {
  1435. return {
  1436. blueprint: {
  1437. host_groups: [
  1438. {
  1439. components: [
  1440. {
  1441. name: 'c6'
  1442. }
  1443. ],
  1444. name: 'host-group-1'
  1445. },
  1446. {
  1447. components: [
  1448. {
  1449. name: 'c8'
  1450. }
  1451. ],
  1452. name: 'host-group-2'
  1453. }
  1454. ]
  1455. },
  1456. blueprint_cluster_binding: {
  1457. host_groups: [
  1458. {
  1459. hosts: [
  1460. {
  1461. fqdn: 'h0'
  1462. }
  1463. ],
  1464. name: 'host-group-1'
  1465. },
  1466. {
  1467. hosts: [
  1468. {
  1469. fqdn: 'h1'
  1470. }
  1471. ],
  1472. name: 'host-group-2'
  1473. }]
  1474. }
  1475. };
  1476. });
  1477. sinon.stub(App.Host, 'find', function () {
  1478. return [
  1479. {
  1480. hostName: 'h1'
  1481. }
  1482. ];
  1483. });
  1484. });
  1485. afterEach(function () {
  1486. App.StackService.find.restore();
  1487. App.StackServiceComponent.find.restore();
  1488. controller.getCurrentBlueprint.restore();
  1489. controller.getCurrentMastersBlueprint.restore();
  1490. App.get.restore();
  1491. controller.getCurrentMasterSlaveBlueprint.restore();
  1492. App.Host.find.restore();
  1493. });
  1494. cases.forEach(function (item) {
  1495. describe(item.controllerName, function () {
  1496. beforeEach(function () {
  1497. controller.set('hosts', item.hosts);
  1498. controller.set('content.controllerName', item.controllerName);
  1499. controller.callServerSideValidation();
  1500. });
  1501. it('blueprint.host_groups count is correct', function () {
  1502. expect(controller.get('content.recommendationsHostGroups.blueprint.host_groups.length')).to.equal(expectedHostGroups.length);
  1503. });
  1504. it('blueprint_cluster_binding.host_groups count is correct', function () {
  1505. expect(controller.get('content.recommendationsHostGroups.blueprint_cluster_binding.host_groups.length')).to.equal(expectedHostGroups.length);
  1506. });
  1507. it('components are valid for each group', function () {
  1508. controller.get('content.recommendationsHostGroups.blueprint.host_groups').forEach(function (group, index) {
  1509. expect(group.components.mapProperty('name').sort()).to.eql(item.expected[index]);
  1510. });
  1511. });
  1512. expectedHostGroups.forEach(function (group) {
  1513. it(group.name, function () {
  1514. var bpGroup = controller.get('content.recommendationsHostGroups.blueprint_cluster_binding.host_groups').findProperty('name', group.name);
  1515. expect(bpGroup.hosts).to.have.length(1);
  1516. expect(bpGroup.hosts[0].fqdn).to.equal(group.fqdn);
  1517. });
  1518. });
  1519. });
  1520. });
  1521. });
  1522. });