wizard_test.js 45 KB

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