wizard_test.js 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643
  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. require('models/cluster');
  20. require('controllers/wizard');
  21. var c;
  22. function getSteps(start, count) {
  23. var steps = [];
  24. for (var j = start; j <= count; j++) {
  25. steps.push(Em.Object.create({step: j, value: false}));
  26. }
  27. return steps;
  28. }
  29. describe('App.WizardController', function () {
  30. var wizardController = App.WizardController.create({});
  31. var totalSteps = 11;
  32. var ruller = d3.range(0, totalSteps);
  33. var i;
  34. beforeEach(function () {
  35. c = App.WizardController.create({});
  36. });
  37. describe('#setLowerStepsDisable', function () {
  38. var steps = getSteps(1, 10);
  39. wizardController.set('isStepDisabled', steps);
  40. steps.forEach(function (step) {
  41. var index = step.get('step');
  42. it('Steps: 10 | Disabled: ' + (index - 1), function () {
  43. wizardController.setLowerStepsDisable(index);
  44. expect(wizardController.get('isStepDisabled').filterProperty('value', true).length).to.be.equal(index - 1);
  45. });
  46. });
  47. });
  48. // isStep0 ... isStep10 tests
  49. App.WizardController1 = App.WizardController.extend({currentStep:''});
  50. var tests = [];
  51. for (i = 0; i < totalSteps; i++) {
  52. var n = ruller.slice(0);
  53. n.splice(i, 1);
  54. tests.push({i: i, n: n});
  55. }
  56. tests.forEach(function (test) {
  57. describe('isStep' + test.i, function () {
  58. var w = App.WizardController1.create();
  59. w.set('currentStep', test.i);
  60. it('Current Step is {0}, so isStep{1} is TRUE'.format(test.i, test.i), function () {
  61. expect(w.get('isStep' + test.i)).to.equal(true);
  62. });
  63. test.n.forEach(function (indx) {
  64. it('Current Step is {0}, so isStep{1} is FALSE'.format(test.i, indx), function () {
  65. expect(w.get('isStep' + indx)).to.equal(false);
  66. });
  67. });
  68. });
  69. });
  70. // isStep0 ... isStep10 tests end
  71. describe('#gotoStep', function() {
  72. var w = App.WizardController1.create();
  73. var steps = getSteps(0, totalSteps - 1);
  74. steps.forEach(function(step, index) {
  75. step.set('value', true);
  76. w.set('isStepDisabled', steps);
  77. it('step {0} is disabled, so gotoStep({1}) is not possible'.format(index, index), function() {
  78. expect(w.gotoStep(index)).to.equal(false);
  79. });
  80. });
  81. });
  82. describe('#launchBootstrapSuccessCallback', function() {
  83. var params = {popup: {finishLoading: function(){}}};
  84. beforeEach(function () {
  85. sinon.spy(params.popup, "finishLoading");
  86. });
  87. afterEach(function () {
  88. params.popup.finishLoading.restore();
  89. });
  90. it('Save bootstrapRequestId', function() {
  91. var data = {requestId: 123, status: 'SUCCESS', log: 'ok'};
  92. wizardController.launchBootstrapSuccessCallback(data, {}, params);
  93. expect(params.popup.finishLoading.calledWith(123, null, 'SUCCESS', 'ok')).to.be.true;
  94. });
  95. });
  96. describe('#getInstallOptions', function () {
  97. var cases = [
  98. {
  99. isHadoopWindowsStack: true,
  100. expected: {
  101. useSsh: false
  102. }
  103. },
  104. {
  105. isHadoopWindowsStack: false,
  106. expected: {
  107. useSsh: true
  108. }
  109. }
  110. ],
  111. title = 'should return {0}';
  112. beforeEach(function () {
  113. sinon.stub(wizardController, 'get')
  114. .withArgs('installOptionsTemplate').returns({useSsh: true})
  115. .withArgs('installWindowsOptionsTemplate').returns({useSsh: false});
  116. this.stub = sinon.stub(App, 'get');
  117. });
  118. afterEach(function () {
  119. App.get.restore();
  120. wizardController.get.restore();
  121. });
  122. cases.forEach(function (item) {
  123. it(title.format(item.expected), function () {
  124. this.stub.withArgs('isHadoopWindowsStack').returns(item.isHadoopWindowsStack);
  125. expect(wizardController.getInstallOptions()).to.eql(item.expected);
  126. });
  127. });
  128. });
  129. describe('#clearInstallOptions', function () {
  130. wizardController.setProperties({
  131. content: {},
  132. name: 'wizardController'
  133. });
  134. beforeEach(function () {
  135. sinon.stub(App, 'get').withArgs('isHadoopWindowsStack').returns(false);
  136. });
  137. afterEach(function () {
  138. App.get.restore();
  139. });
  140. describe('should clear install options', function () {
  141. beforeEach(function () {
  142. wizardController.clearInstallOptions();
  143. });
  144. it('content.installOptions', function () {
  145. expect(wizardController.get('content.installOptions')).to.eql(wizardController.get('installOptionsTemplate'));
  146. });
  147. it('content.hosts', function () {
  148. expect(wizardController.get('content.hosts')).to.eql({});
  149. });
  150. it('installOptions', function () {
  151. expect(wizardController.getDBProperty('installOptions')).to.eql(wizardController.get('installOptionsTemplate'));
  152. });
  153. it('hosts', function () {
  154. expect(wizardController.getDBProperty('hosts')).to.eql({});
  155. });
  156. });
  157. });
  158. describe('#loadServiceConfigGroups', function () {
  159. beforeEach(function () {
  160. sinon.stub(wizardController, 'getDBProperties', function() {
  161. return {
  162. serviceConfigGroups: [
  163. {
  164. hosts: ['h1']
  165. }
  166. ],
  167. hosts: Em.Object.create({
  168. h1: Em.Object.create({
  169. id: 'h1'
  170. })
  171. })
  172. };
  173. });
  174. });
  175. afterEach(function () {
  176. wizardController.getDBProperties.restore();
  177. });
  178. it('should load service confgig group', function () {
  179. wizardController.loadServiceConfigGroups();
  180. expect(wizardController.get('content.configGroups')).to.eql([
  181. {
  182. "hosts": [
  183. "h1"
  184. ]
  185. }
  186. ]);
  187. });
  188. });
  189. describe('#saveTasksStatuses', function () {
  190. it('should set status', function () {
  191. wizardController.saveTasksStatuses('st');
  192. expect(wizardController.get('content.tasksStatuses')).to.equal('st');
  193. });
  194. });
  195. describe('#saveSlaveComponentHosts', function () {
  196. beforeEach(function(){
  197. sinon.stub(wizardController,'getDBProperty').returns(Em.A({
  198. 'h1': {
  199. id: 1
  200. }
  201. }));
  202. });
  203. afterEach(function(){
  204. wizardController.getDBProperty.restore();
  205. });
  206. it('should save slave components', function () {
  207. var stepController = Em.Object.create({
  208. hosts: Em.A([
  209. Em.Object.create({
  210. hostName: 'h1',
  211. checkboxes: Em.A([
  212. Em.Object.create({title: 'hl1', checked: true})
  213. ])
  214. })
  215. ]),
  216. headers: Em.A([
  217. Em.Object.create({name: 'header1', label: 'hl1'})
  218. ])
  219. });
  220. wizardController.saveSlaveComponentHosts(stepController);
  221. var res = JSON.parse(JSON.stringify(wizardController.get('content.slaveComponentHosts')));
  222. expect(res).to.eql([
  223. {
  224. "componentName": "header1",
  225. "displayName": "hl1",
  226. "hosts": [
  227. {
  228. "group": "Default",
  229. "host_id": 1
  230. }
  231. ]
  232. }
  233. ]);
  234. });
  235. });
  236. describe('#showLaunchBootstrapPopup', function () {
  237. afterEach(function(){
  238. App.ModalPopup.show.restore();
  239. });
  240. describe('errors', function () {
  241. beforeEach(function () {
  242. sinon.stub(App.ModalPopup,'show', function (data) {
  243. data.finishLoading.call(c);
  244. });
  245. });
  246. it('should set error', function () {
  247. c.showLaunchBootstrapPopup(Em.K);
  248. expect(c.get('isError')).to.be.true;
  249. });
  250. });
  251. describe('#finishLoading', function () {
  252. var stepController = App.get('router.wizardStep3Controller'),
  253. cases = [
  254. {
  255. requestId: null,
  256. serverError: 'error',
  257. wizardControllerProperties: {
  258. isError: true,
  259. showFooter: true,
  260. showCloseButton: true,
  261. serverError: 'error'
  262. },
  263. stepControllerProperties: {
  264. isRegistrationInProgress: false,
  265. isBootstrapFailed: true
  266. },
  267. bootStatus: 'FAILED',
  268. callbackCallCount: 0,
  269. hideCallCount: 0,
  270. title: 'no request id'
  271. },
  272. {
  273. requestId: 0,
  274. status: 'ERROR',
  275. log: 'log',
  276. wizardControllerProperties: {
  277. isError: true,
  278. showFooter: true,
  279. showCloseButton: true,
  280. serverError: 'log'
  281. },
  282. stepControllerProperties: {
  283. isRegistrationInProgress: false,
  284. isBootstrapFailed: true
  285. },
  286. bootStatus: 'FAILED',
  287. callbackCallCount: 0,
  288. hideCallCount: 0,
  289. title: 'ERROR status'
  290. },
  291. {
  292. requestId: 1,
  293. log: 'log',
  294. wizardControllerProperties: {
  295. isError: false,
  296. showFooter: false,
  297. showCloseButton: false,
  298. serverError: null
  299. },
  300. stepControllerProperties: {
  301. isRegistrationInProgress: true,
  302. isBootstrapFailed: false
  303. },
  304. bootStatus: 'PENDING',
  305. callbackCallCount: 1,
  306. hideCallCount: 1,
  307. title: 'request accepted'
  308. }
  309. ];
  310. beforeEach(function () {
  311. c.setProperties({
  312. isError: false,
  313. showFooter: false,
  314. showCloseButton: false,
  315. serverError: null,
  316. hide: Em.K,
  317. callback: Em.K
  318. });
  319. stepController.setProperties({
  320. isRegistrationInProgress: true,
  321. isBootstrapFailed: false,
  322. hosts: [
  323. {
  324. bootStatus: 'PENDING'
  325. },
  326. {
  327. bootStatus: 'PENDING'
  328. }
  329. ]
  330. });
  331. sinon.spy(c, 'hide');
  332. sinon.spy(c, 'callback');
  333. });
  334. afterEach(function () {
  335. c.hide.restore();
  336. c.callback.restore();
  337. });
  338. cases.forEach(function (item) {
  339. describe(item.title, function () {
  340. var wizardControllerProperties = Em.keys(item.wizardControllerProperties),
  341. stepControllerProperties = Em.keys(item.stepControllerProperties);
  342. beforeEach(function () {
  343. sinon.stub(App.ModalPopup,'show', function (data) {
  344. data.finishLoading.call(c, item.requestId, item.serverError, item.status, item.log);
  345. });
  346. c.showLaunchBootstrapPopup(c.callback);
  347. });
  348. it('wizardControllerProperties are valid', function () {
  349. expect(c.getProperties.apply(c, wizardControllerProperties)).to.eql(item.wizardControllerProperties);
  350. });
  351. it('stepControllerProperties are valid', function () {
  352. expect(stepController.getProperties.apply(stepController, stepControllerProperties)).to.eql(item.stepControllerProperties);
  353. });
  354. it('bootStatus is valid', function () {
  355. expect(stepController.get('hosts').mapProperty('bootStatus').uniq()).to.eql([item.bootStatus]);
  356. });
  357. it('callback is called needed number of times', function () {
  358. expect(c.callback.callCount).to.equal(item.callbackCallCount);
  359. });
  360. it('hide is called needed number of times', function () {
  361. expect(c.hide.callCount).to.equal(item.hideCallCount);
  362. });
  363. });
  364. });
  365. });
  366. });
  367. describe('#gotoStep0', function () {
  368. var res;
  369. beforeEach(function(){
  370. sinon.stub(wizardController,'gotoStep', function(step){
  371. res = step;
  372. });
  373. });
  374. afterEach(function(){
  375. wizardController.gotoStep.restore();
  376. });
  377. it('should go to 0 step', function () {
  378. wizardController.gotoStep0(Em.K);
  379. expect(res).to.be.equal(0);
  380. });
  381. });
  382. describe('#gotoStep1', function () {
  383. var res;
  384. beforeEach(function(){
  385. sinon.stub(wizardController,'gotoStep', function(step){
  386. res = step;
  387. });
  388. });
  389. afterEach(function(){
  390. wizardController.gotoStep.restore();
  391. });
  392. it('should go to 1 step', function () {
  393. wizardController.gotoStep1(Em.K);
  394. expect(res).to.be.equal(1);
  395. });
  396. });
  397. describe('#gotoStep2', function () {
  398. var res;
  399. beforeEach(function(){
  400. sinon.stub(wizardController,'gotoStep', function(step){
  401. res = step;
  402. });
  403. });
  404. afterEach(function(){
  405. wizardController.gotoStep.restore();
  406. });
  407. it('should go to 2 step', function () {
  408. wizardController.gotoStep2(Em.K);
  409. expect(res).to.be.equal(2);
  410. });
  411. });
  412. describe('#gotoSte3', function () {
  413. var res;
  414. beforeEach(function(){
  415. sinon.stub(wizardController,'gotoStep', function(step){
  416. res = step;
  417. });
  418. });
  419. afterEach(function(){
  420. wizardController.gotoStep.restore();
  421. });
  422. it('should go to 3 step', function () {
  423. wizardController.gotoStep3(Em.K);
  424. expect(res).to.be.equal(3);
  425. });
  426. });
  427. describe('#gotoStep4', function () {
  428. var res;
  429. beforeEach(function(){
  430. sinon.stub(wizardController,'gotoStep', function(step){
  431. res = step;
  432. });
  433. });
  434. afterEach(function(){
  435. wizardController.gotoStep.restore();
  436. });
  437. it('should go to 4 step', function () {
  438. wizardController.gotoStep4(Em.K);
  439. expect(res).to.be.equal(4);
  440. });
  441. });
  442. describe('#gotoStep5', function () {
  443. var res;
  444. beforeEach(function(){
  445. sinon.stub(wizardController,'gotoStep', function(step){
  446. res = step;
  447. });
  448. });
  449. afterEach(function(){
  450. wizardController.gotoStep.restore();
  451. });
  452. it('should go to 5 step', function () {
  453. wizardController.gotoStep5(Em.K);
  454. expect(res).to.be.equal(5);
  455. });
  456. });
  457. describe('#gotoStep6', function () {
  458. var res;
  459. beforeEach(function(){
  460. sinon.stub(wizardController,'gotoStep', function(step){
  461. res = step;
  462. });
  463. });
  464. afterEach(function(){
  465. wizardController.gotoStep.restore();
  466. });
  467. it('should go to 6 step', function () {
  468. wizardController.gotoStep6(Em.K);
  469. expect(res).to.be.equal(6);
  470. });
  471. });
  472. describe('#gotoStep7', function () {
  473. var res;
  474. beforeEach(function(){
  475. sinon.stub(wizardController,'gotoStep', function(step){
  476. res = step;
  477. });
  478. });
  479. afterEach(function(){
  480. wizardController.gotoStep.restore();
  481. });
  482. it('should go to 7 step', function () {
  483. wizardController.gotoStep7(Em.K);
  484. expect(res).to.be.equal(7);
  485. });
  486. });
  487. describe('#gotoStep8', function () {
  488. var res;
  489. beforeEach(function(){
  490. sinon.stub(wizardController,'gotoStep', function(step){
  491. res = step;
  492. });
  493. });
  494. afterEach(function(){
  495. wizardController.gotoStep.restore();
  496. });
  497. it('should go to 8 step', function () {
  498. wizardController.gotoStep8(Em.K);
  499. expect(res).to.be.equal(8);
  500. });
  501. });
  502. describe('#gotoStep9', function () {
  503. var res;
  504. beforeEach(function(){
  505. sinon.stub(wizardController,'gotoStep', function(step){
  506. res = step;
  507. });
  508. });
  509. afterEach(function(){
  510. wizardController.gotoStep.restore();
  511. });
  512. it('should go to 9 step', function () {
  513. wizardController.gotoStep9(Em.K);
  514. expect(res).to.be.equal(9);
  515. });
  516. });
  517. describe('#gotoStep10', function () {
  518. var res;
  519. beforeEach(function(){
  520. sinon.stub(wizardController,'gotoStep', function(step){
  521. res = step;
  522. });
  523. });
  524. afterEach(function(){
  525. wizardController.gotoStep.restore();
  526. });
  527. it('should go to 10 step', function () {
  528. wizardController.gotoStep10(Em.K);
  529. expect(res).to.be.equal(10);
  530. });
  531. });
  532. describe('#gotoStep', function () {
  533. beforeEach(function(){
  534. sinon.stub(App.ModalPopup,'show', Em.K);
  535. sinon.stub(App.clusterStatus,'setClusterStatus', Em.K);
  536. sinon.stub(App.router,'send', Em.K);
  537. });
  538. afterEach(function(){
  539. App.ModalPopup.show.restore();
  540. App.clusterStatus.setClusterStatus.restore();
  541. App.router.send.restore();
  542. });
  543. it('should go to step', function () {
  544. wizardController.set('isStepDisabled', Em.A([
  545. Em.Object.create({
  546. step: '8',
  547. value: false
  548. })
  549. ]));
  550. wizardController.hide = Em.K;
  551. wizardController.set('content.controllerName','installerController');
  552. wizardController.set('currentStep','9');
  553. expect(wizardController.gotoStep('8')).to.be.true;
  554. });
  555. });
  556. describe('#launchBootstrap', function () {
  557. beforeEach(function(){
  558. sinon.stub(wizardController,'showLaunchBootstrapPopup').returns({
  559. name: 'popup'
  560. });
  561. });
  562. afterEach(function(){
  563. wizardController.showLaunchBootstrapPopup.restore();
  564. });
  565. it('should return popup', function () {
  566. expect(wizardController.launchBootstrap()).to.be.eql({
  567. name: 'popup'
  568. });
  569. });
  570. });
  571. describe('#save', function () {
  572. var res;
  573. beforeEach(function () {
  574. sinon.stub(wizardController,'setDBProperty', function(data){
  575. res = data;
  576. });
  577. sinon.stub(wizardController,'toJSInstance').returns('val');
  578. });
  579. afterEach(function () {
  580. wizardController.setDBProperty.restore();
  581. wizardController.toJSInstance.restore();
  582. });
  583. it('should save data', function () {
  584. wizardController.save('name');
  585. expect(res).to.be.equal('name');
  586. });
  587. });
  588. describe('#installServicesSuccessCallback', function () {
  589. var res;
  590. beforeEach(function(){
  591. sinon.stub(wizardController,'saveClusterStatus', function(data){
  592. res = JSON.parse(JSON.stringify(data));
  593. });
  594. sinon.stub(App,'dateTime').returns('22');
  595. });
  596. afterEach(function(){
  597. wizardController.saveClusterStatus.restore();
  598. App.dateTime.restore();
  599. });
  600. it('should call callbeck with data', function () {
  601. var jsonData = {
  602. Requests: {
  603. id: 1
  604. }
  605. };
  606. wizardController.installServicesSuccessCallback(jsonData);
  607. expect(res).to.be.eql({
  608. "status": "PENDING",
  609. "requestId": 1,
  610. "isInstallError": false,
  611. "isCompleted": false,
  612. "installStartTime": "22"
  613. });
  614. });
  615. });
  616. describe('#installServices', function () {
  617. var res;
  618. beforeEach(function(){
  619. sinon.stub(wizardController,'saveClusterStatus', function(data){
  620. res = JSON.parse(JSON.stringify(data));
  621. });
  622. });
  623. afterEach(function(){
  624. wizardController.saveClusterStatus.restore();
  625. });
  626. it('should call callbeck with data', function () {
  627. wizardController.set('content', Em.Object.create({
  628. cluster: {
  629. oldRequestsId: '1'
  630. }
  631. }));
  632. wizardController.installServices(true);
  633. expect(res).to.be.eql({
  634. "status": "PENDING"
  635. });
  636. });
  637. });
  638. describe('#saveInstalledHosts', function () {
  639. beforeEach(function(){
  640. sinon.stub(wizardController,'getDBProperty').returns({
  641. 'h1': {
  642. id: 1,
  643. status: '',
  644. name: 'h1'
  645. }
  646. });
  647. });
  648. afterEach(function(){
  649. wizardController.getDBProperty.restore();
  650. });
  651. it('should save installed hosts', function () {
  652. var stepController = Em.Object.create({
  653. hosts: Em.A([
  654. Em.Object.create({
  655. hostName: 'h1',
  656. name: 'h1',
  657. status: 'st',
  658. message: 'ms',
  659. checkboxes: Em.A([
  660. Em.Object.create({title: 'hl1', checked: true})
  661. ])
  662. })
  663. ])
  664. });
  665. wizardController.saveInstalledHosts(stepController);
  666. var res = JSON.parse(JSON.stringify(wizardController.get('content.hosts')));
  667. expect(res).to.eql({
  668. "h1": {
  669. "id": 1,
  670. "status": "st",
  671. "name": "h1",
  672. "message": "ms"
  673. }
  674. });
  675. });
  676. });
  677. describe('#saveConfirmedHosts', function () {
  678. beforeEach(function(){
  679. sinon.stub(wizardController,'getDBProperty').returns({
  680. 'h1': {
  681. id: 1,
  682. status: '',
  683. name: 'h1'
  684. }
  685. });
  686. });
  687. afterEach(function(){
  688. wizardController.getDBProperty.restore();
  689. });
  690. it('should save confirmed hosts', function () {
  691. var stepController = Em.Object.create({
  692. confirmedHosts: Em.A([
  693. {
  694. name: 'h2',
  695. cpu: '1',
  696. isInstalled: true
  697. }
  698. ])
  699. });
  700. wizardController.set('content.hosts', {
  701. 'h1': {
  702. isInstalled: false,
  703. bootStatus: 'REGISTERED'
  704. },
  705. 'h2': {
  706. isInstalled: true,
  707. bootStatus: 'REGISTERED'
  708. }
  709. });
  710. wizardController.saveConfirmedHosts(stepController);
  711. var res = JSON.parse(JSON.stringify(wizardController.get('content.hosts')));
  712. expect(res).to.eql({
  713. "h2": {
  714. "isInstalled": true,
  715. "bootStatus": "REGISTERED"
  716. }
  717. });
  718. });
  719. });
  720. describe('#loadTasksStatuses', function () {
  721. beforeEach(function () {
  722. sinon.stub(wizardController, 'getDBProperty').returns('st');
  723. });
  724. afterEach(function () {
  725. wizardController.getDBProperty.restore();
  726. });
  727. it('should load status', function () {
  728. wizardController.loadTasksStatuses();
  729. expect(wizardController.get('content.tasksStatuses')).to.equal('st');
  730. });
  731. });
  732. describe('#saveTasksRequestIds', function () {
  733. it('should save id', function () {
  734. wizardController.saveTasksRequestIds('st');
  735. expect(wizardController.get('content.tasksRequestIds')).to.equal('st');
  736. });
  737. });
  738. describe('#loadTasksRequestIds', function () {
  739. beforeEach(function () {
  740. sinon.stub(wizardController, 'getDBProperty').returns('st');
  741. });
  742. afterEach(function () {
  743. wizardController.getDBProperty.restore();
  744. });
  745. it('should load status', function () {
  746. wizardController.loadTasksRequestIds();
  747. expect(wizardController.get('content.tasksRequestIds')).to.equal('st');
  748. });
  749. });
  750. describe('#saveRequestIds', function () {
  751. it('should save id', function () {
  752. wizardController.saveRequestIds('st');
  753. expect(wizardController.get('content.requestIds')).to.equal('st');
  754. });
  755. });
  756. describe('#load', function () {
  757. it('should clear install options', function () {
  758. var name = 'Name';
  759. wizardController.set('get'+name.capitalize(), function() {return 'res';});
  760. wizardController.load(name, true);
  761. expect(wizardController.get('content.' + name)).to.equal('res');
  762. });
  763. });
  764. describe('#usersLoading', function () {
  765. beforeEach(function(){
  766. sinon.stub(App.MainAdminServiceAccountsController,'create').returns({
  767. loadUsers: function() {},
  768. get: function(type) {
  769. if (type === 'dataIsLoaded') {
  770. return true;
  771. }
  772. return Em.Object.create({
  773. hdfsUser: {
  774. name: 'user'
  775. }
  776. });
  777. }
  778. });
  779. });
  780. afterEach(function(){
  781. App.MainAdminServiceAccountsController.create.restore();
  782. });
  783. it('should load users', function () {
  784. wizardController.set('content.hdfsUser', true);
  785. wizardController.usersLoading().then(function(data){
  786. expect(data).to.be.undefined;
  787. });
  788. });
  789. });
  790. describe('#loadConfirmedHosts', function () {
  791. beforeEach(function(){
  792. sinon.stub(App.db, 'getHosts').returns(Em.A([
  793. Em.Object.create({
  794. name: 'h1'
  795. })
  796. ]));
  797. });
  798. afterEach(function(){
  799. App.db.getHosts.restore();
  800. });
  801. it('should load hosts from db', function () {
  802. wizardController.loadConfirmedHosts();
  803. var res = JSON.parse(JSON.stringify(wizardController.get('content.hosts')));
  804. expect(res).to.eql([
  805. {
  806. "name": "h1"
  807. }
  808. ]);
  809. });
  810. });
  811. describe('#loadServicesFromServer', function () {//TODO
  812. var res;
  813. beforeEach(function(){
  814. sinon.stub(App.StackService, 'find').returns(Em.A([
  815. Em.Object.create({
  816. isSelected: false,
  817. isInstalled: false,
  818. serviceName: 's1'
  819. })
  820. ]));
  821. sinon.stub(App.Service, 'find').returns(Em.A([
  822. Em.Object.create({
  823. isSelected: false,
  824. isInstalled: false,
  825. serviceName: 's1'
  826. })
  827. ]));
  828. sinon.stub(wizardController, 'setDBProperty', function(data) {
  829. res = data;
  830. });
  831. });
  832. afterEach(function () {
  833. App.StackService.find.restore();
  834. App.Service.find.restore();
  835. wizardController.setDBProperty.restore();
  836. });
  837. it('should load services from server', function () {
  838. wizardController.loadServicesFromServer();
  839. expect(res).to.be.equal('services');
  840. });
  841. });
  842. describe('#loadRequestIds', function () {
  843. beforeEach(function () {
  844. sinon.stub(wizardController, 'getDBProperty').returns('st');
  845. });
  846. afterEach(function () {
  847. wizardController.getDBProperty.restore();
  848. });
  849. it('should load status', function () {
  850. wizardController.loadRequestIds();
  851. expect(wizardController.get('content.requestIds')).to.equal('st');
  852. });
  853. });
  854. describe('#loadServiceComponentsSuccessCallback', function () {
  855. beforeEach(function () {
  856. sinon.stub(wizardController, 'getDBProperties', function() {
  857. return {
  858. selectedServiceNames: ['a','b'],
  859. installedServiceNames: ['c','d']
  860. };
  861. });
  862. sinon.stub(App.stackServiceMapper, 'mapStackServices', Em.K);
  863. });
  864. afterEach(function () {
  865. wizardController.getDBProperties.restore();
  866. App.stackServiceMapper.mapStackServices.restore();
  867. });
  868. it('should load json data', function () {
  869. var jsonData = {
  870. items: [
  871. {
  872. StackServices: {
  873. isSelected: false,
  874. service_name: 'a'
  875. }
  876. },
  877. {
  878. StackServices: {
  879. isSelected: false,
  880. service_name: 'none'
  881. }
  882. }
  883. ]
  884. };
  885. wizardController.loadServiceComponentsSuccessCallback(jsonData);
  886. var exp = {
  887. "items": [
  888. {
  889. "StackServices": {
  890. "isSelected": false,
  891. "service_name": "a",
  892. "is_selected": true,
  893. "is_installed": false
  894. }
  895. },
  896. {
  897. "StackServices": {
  898. "isSelected": false,
  899. "service_name": "none",
  900. "is_selected": false,
  901. "is_installed": false
  902. }
  903. }
  904. ]
  905. };
  906. expect(jsonData).to.eql(exp);
  907. });
  908. });
  909. describe('#setInfoForStep9', function () {
  910. var res;
  911. beforeEach(function () {
  912. sinon.stub(wizardController, 'getDBProperty').returns(Em.Object.create({
  913. status: {},
  914. message: {},
  915. logTasks: {},
  916. tasks: {},
  917. progress: {}
  918. }));
  919. sinon.stub(wizardController, 'setDBProperty', function(title,data) {
  920. res = data;
  921. });
  922. });
  923. afterEach(function () {
  924. wizardController.getDBProperty.restore();
  925. wizardController.setDBProperty.restore();
  926. });
  927. it('should return info for step 9', function () {
  928. wizardController.setInfoForStep9();
  929. var exp = {
  930. "status": {
  931. "status": "pending",
  932. "message": "Waiting",
  933. "logTasks": [],
  934. "tasks": [],
  935. "progress": "0"
  936. },
  937. "message": {
  938. "status": "pending",
  939. "message": "Waiting",
  940. "logTasks": [],
  941. "tasks": [],
  942. "progress": "0"
  943. },
  944. "logTasks": {
  945. "status": "pending",
  946. "message": "Waiting",
  947. "logTasks": [],
  948. "tasks": [],
  949. "progress": "0"
  950. },
  951. "tasks": {
  952. "status": "pending",
  953. "message": "Waiting",
  954. "logTasks": [],
  955. "tasks": [],
  956. "progress": "0"
  957. },
  958. "progress": {
  959. "status": "pending",
  960. "message": "Waiting",
  961. "logTasks": [],
  962. "tasks": [],
  963. "progress": "0"
  964. }
  965. };
  966. res = JSON.parse(JSON.stringify(res));
  967. expect(res).to.eql(exp);
  968. });
  969. });
  970. describe('#saveServiceConfigProperties', function () {
  971. beforeEach(function () {
  972. c.set('content', {});
  973. sinon.stub(c, 'setDBProperties', Em.K);
  974. sinon.stub(c, 'getDBProperty').withArgs('fileNamesToUpdate').returns([]);
  975. sinon.stub(App.config, 'shouldSupportFinal').returns(true);
  976. });
  977. afterEach(function () {
  978. c.setDBProperties.restore();
  979. c.getDBProperty.restore();
  980. App.config.shouldSupportFinal.restore();
  981. });
  982. var kerberosStepController = Em.Object.create({
  983. installedServiceNames: ['KERBEROS'],
  984. stepConfigs: [
  985. Em.Object.create({
  986. serviceName: 'KERBEROS',
  987. configs: [
  988. Em.Object.create({
  989. id: 'id',
  990. name: 'admin_password',
  991. value: 'value',
  992. defaultValue: 'defaultValue',
  993. description: 'description',
  994. serviceName: 'serviceName',
  995. domain: 'domain',
  996. isVisible: true,
  997. isNotDefaultValue: true,
  998. isFinal: true,
  999. defaultIsFinal: true,
  1000. supportsFinal: true,
  1001. filename: 'krb5-conf.xml',
  1002. displayType: 'string',
  1003. isRequiredByAgent: true,
  1004. hasInitialValue: true,
  1005. isRequired: true,
  1006. group: {name: 'group'},
  1007. showLabel: true,
  1008. category: 'some_category'
  1009. }),
  1010. Em.Object.create({
  1011. id: 'id',
  1012. name: 'admin_principal',
  1013. value: 'value',
  1014. defaultValue: 'defaultValue',
  1015. description: 'description',
  1016. serviceName: 'serviceName',
  1017. domain: 'domain',
  1018. isVisible: true,
  1019. isNotDefaultValue: true,
  1020. isFinal: true,
  1021. defaultIsFinal: true,
  1022. supportsFinal: true,
  1023. filename: 'krb5-conf.xml',
  1024. displayType: 'string',
  1025. isRequiredByAgent: true,
  1026. hasInitialValue: true,
  1027. isRequired: true,
  1028. group: {name: 'group'},
  1029. showLabel: true,
  1030. category: 'some_category'
  1031. })
  1032. ]
  1033. })
  1034. ]
  1035. });
  1036. var stepController = Em.Object.create({
  1037. installedServiceNames: ['HDFS'],
  1038. stepConfigs: [
  1039. Em.Object.create({
  1040. serviceName: 'HDFS',
  1041. configs: [
  1042. Em.Object.create({
  1043. id: 'id',
  1044. name: 'name',
  1045. value: 'value',
  1046. defaultValue: 'defaultValue',
  1047. description: 'description',
  1048. serviceName: 'serviceName',
  1049. domain: 'domain',
  1050. isVisible: true,
  1051. isNotDefaultValue: true,
  1052. isFinal: true,
  1053. defaultIsFinal: true,
  1054. supportsFinal: true,
  1055. filename: 'filename',
  1056. displayType: 'string',
  1057. isRequiredByAgent: true,
  1058. hasInitialValue: true,
  1059. isRequired: true,
  1060. group: {name: 'group'},
  1061. showLabel: true,
  1062. category: 'some_category'
  1063. })
  1064. ]
  1065. }),
  1066. Em.Object.create({
  1067. serviceName: 'YARN',
  1068. configs: [
  1069. Em.Object.create({
  1070. id: 'id',
  1071. name: 'name',
  1072. value: 'value',
  1073. defaultValue: 'defaultValue',
  1074. description: 'description',
  1075. serviceName: 'serviceName',
  1076. domain: 'domain',
  1077. isVisible: true,
  1078. isFinal: true,
  1079. defaultIsFinal: true,
  1080. supportsFinal: true,
  1081. filename: 'filename',
  1082. displayType: 'string',
  1083. isRequiredByAgent: true,
  1084. hasInitialValue: true,
  1085. isRequired: true,
  1086. group: {name: 'group'},
  1087. showLabel: true,
  1088. category: 'some_category'
  1089. })
  1090. ]
  1091. })
  1092. ]});
  1093. it('should save configs to content.serviceConfigProperties', function () {
  1094. c.saveServiceConfigProperties(stepController);
  1095. var saved = c.get('content.serviceConfigProperties');
  1096. expect(saved.length).to.equal(2);
  1097. expect(saved[0].category).to.equal('some_category');
  1098. });
  1099. it('should not save admin_principal or admin_password to the localStorage', function () {
  1100. c.saveServiceConfigProperties(kerberosStepController);
  1101. var saved = c.get('content.serviceConfigProperties');
  1102. expect(saved.everyProperty('value', '')).to.be.true;
  1103. });
  1104. });
  1105. describe('#enableStep', function () {
  1106. beforeEach(function () {
  1107. c.set('isStepDisabled', [
  1108. Em.Object.create({step: 1, value: true}),
  1109. Em.Object.create({step: 2, value: true}),
  1110. Em.Object.create({step: 3, value: true}),
  1111. Em.Object.create({step: 4, value: true}),
  1112. Em.Object.create({step: 5, value: true}),
  1113. Em.Object.create({step: 6, value: true}),
  1114. Em.Object.create({step: 7, value: true})
  1115. ]);
  1116. });
  1117. it('should update 1st value in isStepDisabled', function () {
  1118. c.enableStep(1);
  1119. expect(c.get('isStepDisabled')[0].get('value')).to.be.false;
  1120. });
  1121. it('should update 6th value in isStepDisabled', function () {
  1122. c.enableStep(7);
  1123. expect(c.get('isStepDisabled')[6].get('value')).to.be.false;
  1124. });
  1125. });
  1126. describe('#allHosts', function () {
  1127. it('should return all hosts', function () {
  1128. var hosts = {
  1129. 'h1': {hostComponents: ['c1', 'c2'], disk_info: [{size: 2, available: 1}]},
  1130. 'h2': {hostComponents: ['c3', 'c4'], disk_info: [{size: 2, available: 1}]}
  1131. };
  1132. var content = Em.Object.create({
  1133. hosts: hosts
  1134. });
  1135. c.set('content', content);
  1136. var exp = [
  1137. {
  1138. "id": "h1",
  1139. "hostName": "h1",
  1140. "publicHostName": "h1",
  1141. "diskInfo": [
  1142. {
  1143. "size": 2,
  1144. "available": 1
  1145. }
  1146. ],
  1147. "diskTotal": 0.0000019073486328125,
  1148. "diskFree": 9.5367431640625e-7,
  1149. "disksMounted": 1,
  1150. "osType": 0,
  1151. "osArch": 0,
  1152. "ip": 0,
  1153. "hostComponents": [
  1154. {
  1155. "componentName": "c1",
  1156. "displayName": "C1"
  1157. },
  1158. {
  1159. "componentName": "c2",
  1160. "displayName": "C2"
  1161. }
  1162. ]
  1163. },
  1164. {
  1165. "id": "h2",
  1166. "hostName": "h2",
  1167. "publicHostName": "h2",
  1168. "diskInfo": [
  1169. {
  1170. "size": 2,
  1171. "available": 1
  1172. }
  1173. ],
  1174. "diskTotal": 0.0000019073486328125,
  1175. "diskFree": 9.5367431640625e-7,
  1176. "disksMounted": 1,
  1177. "osType": 0,
  1178. "osArch": 0,
  1179. "ip": 0,
  1180. "hostComponents": [
  1181. {
  1182. "componentName": "c3",
  1183. "displayName": "C3"
  1184. },
  1185. {
  1186. "componentName": "c4",
  1187. "displayName": "C4"
  1188. }
  1189. ]
  1190. }
  1191. ];
  1192. var res = JSON.parse(JSON.stringify(c.get('allHosts')));
  1193. expect(res).to.be.eql(exp);
  1194. });
  1195. });
  1196. describe('#getSlaveComponentHosts', function () {
  1197. beforeEach(function () {
  1198. sinon.stub(App.Service, 'find').returns(Em.A([
  1199. Em.Object.create({
  1200. serviceName: 's1'
  1201. })
  1202. ]));
  1203. sinon.stub(App.StackService, 'find').returns(Em.A([
  1204. Em.Object.create({
  1205. serviceName: 's2',
  1206. isSelected: true
  1207. })
  1208. ]));
  1209. sinon.stub(App.StackServiceComponent, 'find').returns(Em.A([
  1210. Em.Object.create({componentName: 'DATANODE', serviceName: 's1', isSlave: true}),
  1211. Em.Object.create({componentName: 'c2', serviceName: 's2', isSlave: true})
  1212. ]));
  1213. sinon.stub(App.HostComponent, 'find').returns(Em.A([
  1214. Em.Object.create({
  1215. componentName: 'DATANODE',
  1216. hostName: 'h1'
  1217. })
  1218. ]));
  1219. });
  1220. afterEach(function () {
  1221. App.Service.find.restore();
  1222. App.HostComponent.find.restore();
  1223. App.StackService.find.restore();
  1224. App.StackServiceComponent.find.restore();
  1225. });
  1226. it('should return slave components', function () {
  1227. var res = JSON.parse(JSON.stringify(c.getSlaveComponentHosts()));
  1228. var exp = [
  1229. {
  1230. "componentName": "DATANODE",
  1231. "displayName": "DataNode",
  1232. "hosts": [
  1233. {
  1234. "group": "Default",
  1235. "hostName": "h1",
  1236. "isInstalled": true
  1237. }
  1238. ],
  1239. "isInstalled": true
  1240. },
  1241. {
  1242. "componentName": "CLIENT",
  1243. "displayName": "Client",
  1244. "hosts": [],
  1245. "isInstalled": true
  1246. },
  1247. {
  1248. "componentName": "c2",
  1249. "displayName": "C2",
  1250. "hosts": [
  1251. {
  1252. "group": "Default",
  1253. "hostName": "h1",
  1254. "isInstalled": false
  1255. }
  1256. ],
  1257. "isInstalled": false
  1258. }
  1259. ];
  1260. expect(res).to.be.eql(exp);
  1261. });
  1262. });
  1263. describe('#setSkipSlavesStep', function () {
  1264. var step = 6,
  1265. cases = [
  1266. {
  1267. services: [
  1268. {
  1269. hasSlave: true,
  1270. hasNonMastersWithCustomAssignment: true
  1271. }
  1272. ],
  1273. skipSlavesStep: false,
  1274. title: 'service with customizable slave selected'
  1275. },
  1276. {
  1277. services: [
  1278. {
  1279. hasClient: true,
  1280. hasNonMastersWithCustomAssignment: true
  1281. }
  1282. ],
  1283. skipSlavesStep: false,
  1284. title: 'service with customizable client selected'
  1285. },
  1286. {
  1287. services: [
  1288. {
  1289. hasSlave: true,
  1290. hasNonMastersWithCustomAssignment: false
  1291. },
  1292. {
  1293. hasClient: true,
  1294. hasNonMastersWithCustomAssignment: false
  1295. }
  1296. ],
  1297. skipSlavesStep: true,
  1298. title: 'no service with customizable slaves or clients selected'
  1299. },
  1300. {
  1301. services: [
  1302. {
  1303. hasSlave: false,
  1304. hasClient: false
  1305. }
  1306. ],
  1307. skipSlavesStep: true,
  1308. title: 'no service with slaves or clients selected'
  1309. }
  1310. ];
  1311. beforeEach(function () {
  1312. c.reopen({
  1313. isStepDisabled: [
  1314. Em.Object.create({
  1315. step: 6
  1316. })
  1317. ],
  1318. content: {}
  1319. });
  1320. });
  1321. cases.forEach(function (item) {
  1322. it(item.title, function () {
  1323. c.setSkipSlavesStep(item.services, step);
  1324. expect(Boolean(c.get('isStepDisabled').findProperty('step', step).get('value'))).to.equal(item.skipSlavesStep);
  1325. });
  1326. });
  1327. });
  1328. describe('#toJSInstance', function () {
  1329. var testCases = [
  1330. {
  1331. o: {'test': 'test'},
  1332. e: {'test': 'test'}
  1333. },
  1334. {
  1335. o: {'test': Em.Object.create()},
  1336. e: {'test': {}}
  1337. },
  1338. {
  1339. o: {'test': Em.Object.create({'test': {}})},
  1340. e: {'test': {'test': {}}}
  1341. },
  1342. {
  1343. o: [],
  1344. e: []
  1345. },
  1346. {
  1347. o: Em.A([[]]),
  1348. e: [[]]
  1349. },
  1350. {
  1351. o: 11,
  1352. e: 11
  1353. },
  1354. {
  1355. o: '11',
  1356. e: '11'
  1357. },
  1358. {
  1359. o: null,
  1360. e: null
  1361. }
  1362. ];
  1363. testCases.forEach(function (testCase, index) {
  1364. it('should convert objects and arrays to pure JS objects and arrays (' + (index + 1) + ')', function () {
  1365. expect(c.toJSInstance(testCase.o)).to.eql(testCase.e);
  1366. });
  1367. });
  1368. });
  1369. describe('#loadConfigThemes', function() {
  1370. beforeEach(function () {
  1371. sinon.stub(wizardController, 'loadConfigThemeForServices').returns({
  1372. always: Em.clb
  1373. });
  1374. sinon.stub(App.themesMapper, 'generateAdvancedTabs').returns(true);
  1375. sinon.stub(App.config, 'loadConfigsFromStack').returns({
  1376. done: Em.clb
  1377. });
  1378. sinon.stub(App.StackService, 'find').returns(Em.A([
  1379. Em.Object.create({
  1380. isSelected: true,
  1381. serviceName: 's1'
  1382. })
  1383. ]));
  1384. this.stub = sinon.stub(App, 'get');
  1385. });
  1386. afterEach(function () {
  1387. App.get.restore();
  1388. App.StackService.find.restore();
  1389. App.config.loadConfigsFromStack.restore();
  1390. App.themesMapper.generateAdvancedTabs.restore();
  1391. wizardController.loadConfigThemeForServices.restore();
  1392. });
  1393. it('Should load config themes', function(done) {
  1394. this.stub.returns(true);
  1395. wizardController.loadConfigThemes().then(function() {
  1396. done();
  1397. });
  1398. });
  1399. it('Should load config themes (2)', function(done) {
  1400. this.stub.returns(false);
  1401. wizardController.loadConfigThemes().then(function() {
  1402. done();
  1403. });
  1404. });
  1405. });
  1406. describe('#dataLoading', function () {
  1407. var clusterController = Em.Object.create({
  1408. isLoaded: false
  1409. });
  1410. beforeEach(function(){
  1411. sinon.stub(App.router,'get').returns(clusterController);
  1412. sinon.stub(wizardController, 'connectOutlet', Em.K);
  1413. clusterController.set('isLoaded', false);
  1414. });
  1415. afterEach(function(){
  1416. App.router.get.restore();
  1417. wizardController.connectOutlet.restore();
  1418. });
  1419. it('should load data', function () {
  1420. clusterController.set('isLoaded', true);
  1421. wizardController.dataLoading().then(function(data){
  1422. expect(data).to.be.undefined;
  1423. });
  1424. });
  1425. it('should load data after 25ms', function () {
  1426. clusterController.set('isLoaded', false);
  1427. setTimeout(function(){
  1428. clusterController.set('isLoaded', true);
  1429. },25);
  1430. wizardController.dataLoading().then(function(data){
  1431. expect(data).to.be.undefined;
  1432. });
  1433. });
  1434. });
  1435. describe('#saveMasterComponentHosts', function () {
  1436. var stepController = Em.Object.create({
  1437. selectedServicesMasters: [
  1438. Em.Object.create({
  1439. display_name: 'd0',
  1440. component_name: 'c0',
  1441. selectedHost: 'h0',
  1442. serviceId: 's0',
  1443. isInstalled: true
  1444. }),
  1445. Em.Object.create({
  1446. display_name: 'd1',
  1447. component_name: 'c1',
  1448. selectedHost: 'h1',
  1449. serviceId: 's1',
  1450. isInstalled: false
  1451. })
  1452. ]
  1453. }),
  1454. masterComponentHosts = [
  1455. {
  1456. display_name: 'd0',
  1457. component: 'c0',
  1458. hostName: 'h0',
  1459. serviceId: 's0',
  1460. isInstalled: true
  1461. },
  1462. {
  1463. display_name: 'd1',
  1464. component: 'c1',
  1465. hostName: 'h1',
  1466. serviceId: 's1',
  1467. isInstalled: false
  1468. }
  1469. ];
  1470. beforeEach(function () {
  1471. sinon.stub(wizardController, 'setDBProperty', Em.K);
  1472. });
  1473. afterEach(function () {
  1474. wizardController.setDBProperty.restore();
  1475. });
  1476. it('should save master component hosts', function () {
  1477. wizardController.saveMasterComponentHosts(stepController);
  1478. expect(wizardController.setDBProperty.calledOnce).to.be.true;
  1479. expect(wizardController.setDBProperty.calledWith('masterComponentHosts', masterComponentHosts)).to.be.true;
  1480. expect(wizardController.get('content.masterComponentHosts')).to.eql(masterComponentHosts);
  1481. });
  1482. });
  1483. describe('#clearMasterComponentHosts', function () {
  1484. beforeEach(function () {
  1485. sinon.stub(wizardController, 'setDBProperty', Em.K);
  1486. });
  1487. afterEach(function () {
  1488. wizardController.setDBProperty.restore();
  1489. });
  1490. it('should clear master component hosts', function () {
  1491. wizardController.set('content.masterComponentHosts', {});
  1492. wizardController.clearMasterComponentHosts();
  1493. expect(wizardController.setDBProperty.calledOnce).to.be.true;
  1494. expect(wizardController.setDBProperty.calledWith('masterComponentHosts', null)).to.be.true;
  1495. expect(wizardController.get('content.masterComponentHosts')).to.be.null;
  1496. });
  1497. });
  1498. describe('#loadRecommendations', function () {
  1499. beforeEach(function () {
  1500. sinon.stub(c, 'getDBProperty').returns({});
  1501. });
  1502. afterEach(function () {
  1503. c.getDBProperty.restore();
  1504. });
  1505. it('should set recommendations', function () {
  1506. c.set('content', {});
  1507. c.loadRecommendations();
  1508. expect(c.get('content.recommendations')).to.eql({});
  1509. });
  1510. });
  1511. });