wizard_test.js 44 KB

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