step6_test.js 52 KB

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