step2_test.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. var Ember = require('ember');
  20. require('controllers/wizard/step2_controller');
  21. require('models/host');
  22. require('models/host_component');
  23. require('messages');
  24. var c;
  25. describe('App.WizardStep2Controller', function () {
  26. var userErrorTests = Em.A([
  27. {
  28. manualInstall: false,
  29. user: '',
  30. e: ''
  31. },
  32. {
  33. manualInstall: true,
  34. user: '',
  35. e: null
  36. },
  37. {
  38. manualInstall: true,
  39. user: 'nobody',
  40. e: null
  41. },
  42. {
  43. manualInstall: false,
  44. user: 'nobody',
  45. e: null
  46. }
  47. ]);
  48. beforeEach(function() {
  49. c = App.WizardStep2Controller.create();
  50. });
  51. describe('#isInstaller', function() {
  52. it('true if controllerName is installerController', function() {
  53. var controller = App.WizardStep2Controller.create({content: {controllerName: 'installerController'}});
  54. expect(controller.get('isInstaller')).to.equal(true);
  55. });
  56. it('false if controllerName isn\'t installerController', function() {
  57. var controller = App.WizardStep2Controller.create({content: {controllerName: 'addServiceController'}});
  58. expect(controller.get('isInstaller')).to.equal(false);
  59. });
  60. });
  61. describe('#manualInstall', function() {
  62. it('should be equal to content.installOptions.manualInstall', function() {
  63. var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: true}}});
  64. expect(controller.get('manualInstall')).to.equal(true);
  65. controller.toggleProperty('content.installOptions.manualInstall');
  66. expect(controller.get('manualInstall')).to.equal(false);
  67. });
  68. });
  69. describe('#hostNames', function() {
  70. it('should be equal to content.installOptions.hostNames', function() {
  71. var controller = App.WizardStep2Controller.create({content: {installOptions: {hostNames: 'A,b,C'}}});
  72. expect(controller.get('hostNames')).to.equal('a,b,c');
  73. controller.set('content.installOptions.hostNames', 'a,B');
  74. expect(controller.get('hostNames')).to.equal('a,b');
  75. });
  76. });
  77. describe('#sshKey', function() {
  78. it('should be equal to content.installOptions.sshKey', function() {
  79. var controller = App.WizardStep2Controller.create({content: {installOptions: {sshKey: '123'}}});
  80. expect(controller.get('sshKey')).to.equal('123');
  81. controller.set('content.installOptions.sshKey', '321');
  82. expect(controller.get('sshKey')).to.equal('321');
  83. });
  84. });
  85. describe('#sshUser', function() {
  86. it('should be equal to content.installOptions.sshUser', function() {
  87. var controller = App.WizardStep2Controller.create({content: {installOptions: {sshUser: '123'}}});
  88. expect(controller.get('sshUser')).to.equal('123');
  89. controller.set('content.installOptions.sshUser', '321');
  90. expect(controller.get('sshUser')).to.equal('321');
  91. });
  92. });
  93. describe('#agentUser', function() {
  94. it('should be equal to content.installOptions.agentUser', function() {
  95. var controller = App.WizardStep2Controller.create({content: {installOptions: {agentUser: '123'}}});
  96. expect(controller.get('agentUser')).to.equal('123');
  97. controller.set('content.installOptions.agentUser', '321');
  98. expect(controller.get('agentUser')).to.equal('321');
  99. });
  100. });
  101. describe('#installType', function() {
  102. it('should be manualDriven if manualInstall is selected', function() {
  103. var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: true}}});
  104. expect(controller.get('installType')).to.equal('manualDriven');
  105. });
  106. it('should be ambariDriven if manualInstall isn\'t selected', function() {
  107. var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: false}}});
  108. expect(controller.get('installType')).to.equal('ambariDriven');
  109. });
  110. });
  111. describe('#updateHostNameArr()', function () {
  112. var controller = App.WizardStep2Controller.create({
  113. hostNames: 'apache.ambari'
  114. });
  115. controller.updateHostNameArr();
  116. it('should push to hostNameArr only new host names', function(){
  117. expect(controller.get('hostNameArr').length).to.equal(1);
  118. });
  119. it('should push to inputtedAgainHostNames already installed host names', function(){
  120. expect(controller.get('inputtedAgainHostNames').length).to.equal(0);
  121. })
  122. });
  123. describe('#isAllHostNamesValid()', function () {
  124. var controller = App.WizardStep2Controller.create({
  125. hostNames: ''
  126. });
  127. it('should return true if all host names are valid', function(){
  128. controller.set('hostNames', 'amache.org ambari.com');
  129. expect(controller.isAllHostNamesValid()).to.equal(true);
  130. });
  131. var tests = Em.A([
  132. 'hostname',
  133. '-hostname.com',
  134. 'hostname-.com',
  135. 'host_name.com',
  136. '123.123.123.123',
  137. 'hostnamehostnamehostnamehostnamehostnamehostnamehostnamehostname.hostnamehostnamehostnamehostnamehostnamehostnamehostnamehostname.hostnamehostnamehostnamehostnamehostnamehostnamehostnamehostname.hostnamehostnamehostnamehostnamehostnamehostnamehostnamehostname',
  138. 'hostnamehostnamehostnamehostnamehostnamehostnamehostnamehostnamehostname.hostname'
  139. ]);
  140. tests.forEach(function (test) {
  141. it('should return false for invalid host names ' + test + ' ', function () {
  142. controller.set('hostNames', test);
  143. expect(controller.isAllHostNamesValid()).to.equal(false);
  144. });
  145. });
  146. });
  147. describe('#checkHostError()', function () {
  148. var controller = App.WizardStep2Controller.create();
  149. it('should set hostsError if hostNames is ""', function () {
  150. controller.set('content', {'installOptions': {'hostNames': ''}});
  151. controller.checkHostError();
  152. expect(controller.get('hostsError').length).to.be.above(2);
  153. });
  154. it('should set hostsError to null if hostNames is valid', function () {
  155. controller.set('content', {'installOptions': {'hostNames': 'ambari'}});
  156. controller.checkHostError();
  157. expect(controller.get('hostsError')).to.equal(null);
  158. })
  159. });
  160. describe('#checkHostAfterSubmitHandler()', function () {
  161. it('should be called after changing hasSubmitted', function (done) {
  162. var controller = App.WizardStep2Controller.create({
  163. checkHostError: function () {
  164. done();
  165. }
  166. });
  167. controller.set('hasSubmitted', true);
  168. });
  169. it('should be called after changing hostNames', function (done) {
  170. var controller = App.WizardStep2Controller.create({
  171. hasSubmitted: true,
  172. checkHostError: function () {
  173. done();
  174. }
  175. });
  176. controller.set('content', {'installOptions': {'hostNames': 'ambari'}});
  177. })
  178. });
  179. describe('#sshKeyError', function () {
  180. var tests = Em.A([
  181. {
  182. manualInstall: false,
  183. sshKey: '',
  184. hasSubmitted: false,
  185. e: null
  186. },
  187. {
  188. manualInstall: true,
  189. sshKey: '',
  190. hasSubmitted: false,
  191. e: null
  192. },
  193. {
  194. manualInstall: true,
  195. sshKey: 'nobody',
  196. hasSubmitted: false,
  197. e: null
  198. },
  199. {
  200. manualInstall: false,
  201. sshKey: 'nobody',
  202. hasSubmitted: false,
  203. e: null
  204. },
  205. {
  206. manualInstall: false,
  207. sshKey: '',
  208. hasSubmitted: true,
  209. e: null
  210. },
  211. {
  212. manualInstall: true,
  213. sshKey: '',
  214. hasSubmitted: true,
  215. e: null
  216. },
  217. {
  218. manualInstall: true,
  219. sshKey: 'nobody',
  220. hasSubmitted: true,
  221. e: null
  222. },
  223. {
  224. manualInstall: false,
  225. sshKey: 'nobody',
  226. hasSubmitted: true,
  227. e: null
  228. }
  229. ]);
  230. tests.forEach(function(test) {
  231. it(test.sshKey + ' ' + test.manualInstall.toString() + ' ' + test.hasSubmitted.toString(), function() {
  232. var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: test.manualInstall, sshKey: test.sshKey}}});
  233. if(Em.isNone(test.e)) {
  234. expect(controller.get('sshKeyError')).to.equal(null);
  235. }
  236. else {
  237. expect(controller.get('sshKeyError').length).to.be.above(2);
  238. }
  239. });
  240. });
  241. });
  242. describe('#sshUserError', function () {
  243. userErrorTests.forEach(function(test) {
  244. it('', function() {
  245. var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: test.manualInstall, sshUser: test.user}}});
  246. if(Em.isNone(test.e)) {
  247. expect(controller.get('sshUserError')).to.equal(null);
  248. }
  249. else {
  250. expect(controller.get('sshUserError').length).to.be.above(2);
  251. }
  252. });
  253. });
  254. });
  255. describe('#agentUserError', function () {
  256. userErrorTests.forEach(function(test) {
  257. it('', function() {
  258. var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: test.manualInstall, agentUser: test.user}}});
  259. if(Em.isNone(test.e)) {
  260. expect(controller.get('agentUserError')).to.equal(null);
  261. }
  262. else {
  263. expect(controller.get('agentUserError').length).to.be.above(2);
  264. }
  265. });
  266. });
  267. });
  268. describe('#getHostInfo()', function () {
  269. it('should return object with bootStatus, installType and name for every element in hostNameArr', function () {
  270. var controller = App.WizardStep2Controller.create({
  271. hostNameArr: ['apache', 'ambari'],
  272. installType: 'manualDriven'
  273. });
  274. var test = controller.getHostInfo();
  275. expect(test).to.eql({
  276. 'apache':{'name':'apache', 'installType': 'manualDriven', 'bootStatus': 'PENDING', isInstalled: false},
  277. 'ambari':{'name':'ambari', 'installType': 'manualDriven', 'bootStatus': 'PENDING', isInstalled: false}
  278. });
  279. })
  280. });
  281. describe('#setSshKey()', function () {
  282. it('should set content.installOptions.sshKey', function () {
  283. var controller = App.WizardStep2Controller.create({
  284. content: {'installOptions': {'sshKey': '111'}}
  285. });
  286. controller.setSshKey('222');
  287. expect(controller.get('content.installOptions.sshKey')).to.equal('222');
  288. })
  289. });
  290. describe('#evaluateStep()', function () {
  291. it('should return false if isSubmitDisabled is true', function () {
  292. var controller = App.WizardStep2Controller.create({
  293. hostNames: 'apache.ambari',
  294. parseHostNamesAsPatternExpression: Em.K
  295. });
  296. controller.reopen({isSubmitDisabled: true});
  297. expect(controller.evaluateStep()).to.equal(false);
  298. });
  299. it('should return false if hostsError is not empty', function () {
  300. var controller = App.WizardStep2Controller.create({
  301. hostNames: 'apache.ambari',
  302. parseHostNamesAsPatternExpression: Em.K
  303. });
  304. controller.set('hostsError', 'error');
  305. expect(controller.evaluateStep()).to.equal(false);
  306. });
  307. it('should return false if sshKeyError is not empty', function () {
  308. var controller = App.WizardStep2Controller.create({
  309. hostNames: 'apache.ambari',
  310. parseHostNamesAsPatternExpression: Em.K
  311. });
  312. controller.reopen({sshKeyError: 'error'});
  313. expect(controller.evaluateStep()).to.equal(false);
  314. });
  315. it('should return false if sshUserError is not empty', function () {
  316. var controller = App.WizardStep2Controller.create({
  317. hostNames: 'apache.ambari',
  318. parseHostNamesAsPatternExpression: Em.K
  319. });
  320. controller.reopen({sshUserError: 'error'});
  321. expect(controller.evaluateStep()).to.equal(false);
  322. });
  323. it('should return false if agentUserError is not empty', function () {
  324. var controller = App.WizardStep2Controller.create({
  325. hostNames: 'apache.ambari',
  326. parseHostNamesAsPatternExpression: Em.K
  327. });
  328. controller.reopen({agentUserError: 'error'});
  329. expect(controller.evaluateStep()).to.equal(false);
  330. });
  331. it('should return false if hostNameArr is empty', function () {
  332. var controller = App.WizardStep2Controller.create({
  333. hostNames: '',
  334. parseHostNamesAsPatternExpression: Em.K
  335. });
  336. expect(controller.evaluateStep()).to.equal(false);
  337. });
  338. it('should return false if isPattern is true', function () {
  339. var controller = App.WizardStep2Controller.create({
  340. hostNames: 'apache.ambari',
  341. isPattern: true,
  342. parseHostNamesAsPatternExpression: Em.K
  343. });
  344. expect(controller.evaluateStep()).to.equal(false);
  345. })
  346. });
  347. describe('#parseHostNamesAsPatternExpression()', function () {
  348. it('should parse hosts from pattern expression to hostNameArr', function () {
  349. var controller = App.WizardStep2Controller.create({
  350. hostNameArr: ['host[001-011]']
  351. });
  352. controller.parseHostNamesAsPatternExpression();
  353. var result = true;
  354. var hosts = controller.get('hostNameArr');
  355. for (var i = 1; i<12; i++) {
  356. var extra = (i.toString().length == 1) ? 0 : '';
  357. if (hosts[i-1] !== 'host0' + extra + i) {
  358. result = false;
  359. }
  360. }
  361. expect(result).to.equal(true);
  362. })
  363. });
  364. describe('#proceedNext()', function () {
  365. it('should call warningPopup if not isAllHostNamesValid and no warningConfirmed', function() {
  366. c.reopen({
  367. isAllHostNamesValid: function() {
  368. return false;
  369. },
  370. warningPopup: Em.K
  371. });
  372. sinon.spy(c, 'warningPopup');
  373. var r = c.proceedNext(false);
  374. expect(r).to.equal(false);
  375. expect(c.warningPopup.calledOnce).to.equal(true);
  376. });
  377. it('should call manualInstallPopup if manualInstall is true', function () {
  378. c.reopen({
  379. hostNames: '',
  380. manualInstall: true,
  381. manualInstallPopup: Em.K
  382. });
  383. sinon.spy(c, 'manualInstallPopup');
  384. var r = c.proceedNext(true);
  385. expect(r).to.equal(false);
  386. expect(c.manualInstallPopup.calledOnce).to.equal(true);
  387. });
  388. it ('should save hosts and proceed next if skipBootstrap is true', function() {
  389. sinon.stub(App, 'get', function(k) {
  390. if ('skipBootstrap' === k) {
  391. return true;
  392. }
  393. return Em.get(App, k);
  394. });
  395. sinon.stub(App.router, 'send', Em.K);
  396. c.reopen({
  397. hostNameArr: ['h1'],
  398. isAllHostNamesValid: function() {return true;},
  399. content: {
  400. installOptions: {},
  401. hosts: null
  402. }
  403. });
  404. var r = c.proceedNext();
  405. expect(r).to.equal(true);
  406. expect(Em.keys(c.get('content.hosts'))).to.eql(['h1']);
  407. expect(App.router.send.calledWith('next')).to.equal(true);
  408. App.get.restore();
  409. App.router.send.restore();
  410. });
  411. it('should call setupBootStrap', function() {
  412. sinon.stub(App, 'get', function(k) {
  413. if ('skipBootstrap' === k) {
  414. return false;
  415. }
  416. return Em.get(App, k);
  417. });
  418. c.reopen({
  419. hostNameArr: ['h1'],
  420. isAllHostNamesValid: function() {return true;},
  421. content: {
  422. installOptions: {},
  423. hosts: null
  424. }
  425. });
  426. sinon.stub(c, 'setupBootStrap', Em.K);
  427. var r = c.proceedNext();
  428. expect(r).to.equal(true);
  429. expect(c.setupBootStrap.calledOnce).to.eql(true);
  430. App.get.restore();
  431. c.setupBootStrap.restore();
  432. });
  433. });
  434. describe('#isSubmitDisabled', function () {
  435. var controller = App.WizardStep2Controller.create({
  436. hostsError: '',
  437. sshKeyError: '',
  438. sshUserError: '',
  439. agentUserError: ''
  440. });
  441. it('should return value if hostsError is not empty', function () {
  442. controller.set('hostsError', 'error');
  443. expect(controller.get('isSubmitDisabled').length).to.above(0);
  444. });
  445. it('should return value if sshKeyError is not empty', function () {
  446. controller.set('sshKeyError', 'error');
  447. controller.set('hostsError', '');
  448. expect(controller.get('isSubmitDisabled').length).to.above(0);
  449. });
  450. it('should return value if sshUserError is not empty', function () {
  451. controller.set('sshUserError', 'error');
  452. controller.set('sshKeyError', '');
  453. expect(controller.get('isSubmitDisabled').length).to.above(0);
  454. });
  455. it('should return value if agentUserError is not empty', function () {
  456. controller.set('agentUserError', 'error');
  457. controller.set('sshUserError', '');
  458. expect(controller.get('isSubmitDisabled').length).to.above(0);
  459. });
  460. });
  461. describe('#installedHostsPopup', function() {
  462. beforeEach(function() {
  463. sinon.spy(App.ModalPopup, 'show');
  464. sinon.stub(c, 'proceedNext', Em.K);
  465. });
  466. afterEach(function() {
  467. App.ModalPopup.show.restore();
  468. c.proceedNext.restore();
  469. });
  470. it('should call App.ModalPopup.show', function() {
  471. c.installedHostsPopup();
  472. expect(App.ModalPopup.show.calledOnce).to.equal(true);
  473. });
  474. it('should proceed next on primary', function() {
  475. c.installedHostsPopup().onPrimary();
  476. expect(c.proceedNext.calledOnce).to.equal(true);
  477. });
  478. });
  479. describe('#warningPopup', function() {
  480. beforeEach(function() {
  481. sinon.spy(App.ModalPopup, 'show');
  482. sinon.stub(c, 'proceedNext', Em.K);
  483. });
  484. afterEach(function() {
  485. App.ModalPopup.show.restore();
  486. c.proceedNext.restore();
  487. });
  488. it('should call App.ModalPopup.show', function() {
  489. c.warningPopup();
  490. expect(App.ModalPopup.show.calledOnce).to.equal(true);
  491. });
  492. it('should proceed next on primary', function() {
  493. c.warningPopup().onPrimary();
  494. expect(c.proceedNext.calledWith(true)).to.equal(true);
  495. });
  496. });
  497. describe('#hostNamePatternPopup', function() {
  498. beforeEach(function() {
  499. sinon.spy(App.ModalPopup, 'show');
  500. sinon.stub(c, 'proceedNext', Em.K);
  501. });
  502. afterEach(function() {
  503. App.ModalPopup.show.restore();
  504. c.proceedNext.restore();
  505. });
  506. it('should call App.ModalPopup.show', function() {
  507. c.hostNamePatternPopup();
  508. expect(App.ModalPopup.show.calledOnce).to.equal(true);
  509. });
  510. it('should proceed next on primary', function() {
  511. c.hostNamePatternPopup().onPrimary();
  512. expect(c.proceedNext.calledOnce).to.equal(true);
  513. });
  514. });
  515. describe('#manualInstallPopup', function() {
  516. beforeEach(function() {
  517. sinon.spy(App.ModalPopup, 'show');
  518. sinon.stub(App.router, 'send', Em.K);
  519. sinon.stub(c, 'saveHosts', Em.K);
  520. });
  521. afterEach(function() {
  522. App.ModalPopup.show.restore();
  523. App.router.send.restore();
  524. c.saveHosts.restore();
  525. });
  526. it('should call App.ModalPopup.show', function() {
  527. c.manualInstallPopup();
  528. expect(App.ModalPopup.show.calledOnce).to.equal(true);
  529. });
  530. it('should save hosts and go next on primary', function() {
  531. c.manualInstallPopup().onPrimary();
  532. expect(c.saveHosts.calledOnce).to.equal(true);
  533. expect(App.router.send.calledWith('next')).to.equal(true);
  534. });
  535. });
  536. describe('#manualInstallWarningPopup', function() {
  537. beforeEach(function() {
  538. sinon.spy(App.ModalPopup, 'show');
  539. });
  540. afterEach(function() {
  541. App.ModalPopup.show.restore();
  542. });
  543. it('should call App.ModalPopup.show if content.installOptions.useSsh is false', function() {
  544. var controller = App.WizardStep2Controller.create({content: {installOptions: {useSsh: false}}});
  545. controller.manualInstallWarningPopup();
  546. expect(App.ModalPopup.show.calledOnce).to.equal(true);
  547. });
  548. it('shouldn\'t call App.ModalPopup.show if content.installOptions.useSsh is true', function() {
  549. var controller = App.WizardStep2Controller.create({content: {installOptions: {useSsh: true}}});
  550. controller.manualInstallWarningPopup();
  551. expect(App.ModalPopup.show.called).to.equal(false);
  552. });
  553. });
  554. describe('#setAmbariJavaHome', function() {
  555. beforeEach(function() {
  556. sinon.spy($, 'ajax');
  557. });
  558. afterEach(function() {
  559. $.ajax.restore();
  560. });
  561. it('should do ajax-request', function() {
  562. var controller = App.WizardStep2Controller.create({onGetAmbariJavaHomeSuccess: Em.K, onGetAmbariJavaHomeError: Em.K});
  563. controller.setAmbariJavaHome();
  564. expect($.ajax.calledOnce).to.equal(true);
  565. });
  566. });
  567. describe('#onGetAmbariJavaHomeSuccess', function() {
  568. it('should set java.home value receiced from server', function() {
  569. var controller = App.WizardStep2Controller.create({content: {installOptions: {}}});
  570. var test = {RootServiceComponents: {properties: {'java.home': '/root'}}};
  571. controller.onGetAmbariJavaHomeSuccess(test);
  572. expect(controller.content.installOptions.javaHome).to.equal('/root');
  573. });
  574. });
  575. describe('#onGetAmbariJavaHomeError', function() {
  576. it('should set default java.home value', function() {
  577. var controller = App.WizardStep2Controller.create({content: {installOptions: {}}});
  578. controller.onGetAmbariJavaHomeError();
  579. expect(controller.content.installOptions.javaHome).to.equal(App.get('defaultJavaHome'));
  580. });
  581. });
  582. describe('#saveHosts', function() {
  583. beforeEach(function() {
  584. sinon.stub(c, 'setAmbariJavaHome', Em.K);
  585. c.reopen({
  586. hostNameArr: ['h1'],
  587. content: {
  588. hosts: null
  589. }
  590. });
  591. });
  592. afterEach(function() {
  593. c.setAmbariJavaHome.restore();
  594. });
  595. it('should call setAmbariJavaHome', function() {
  596. c.saveHosts();
  597. expect(c.setAmbariJavaHome.calledOnce).to.equal(true);
  598. });
  599. it('should set content.hosts', function() {
  600. c.saveHosts();
  601. expect(Em.keys(c.get('content.hosts'))).to.eql(['h1']);
  602. });
  603. });
  604. describe('#setupBootStrap', function () {
  605. var controller = App.WizardStep2Controller.create({
  606. sshKey: 'key',
  607. hostNameArr: ['host0', 'host1'],
  608. sshUser: 'root',
  609. agentUser: 'user',
  610. content: {
  611. controllerName: 'installerController'
  612. }
  613. });
  614. it('bootstrap data passed correctly', function () {
  615. sinon.spy(App.router.get('installerController'), 'launchBootstrap');
  616. controller.setupBootStrap();
  617. expect(App.router.get('installerController.launchBootstrap').firstCall.args[0]).to.equal(JSON.stringify({
  618. verbose: true,
  619. sshKey: 'key',
  620. hosts: ['host0', 'host1'],
  621. user: 'root',
  622. userRunAs: 'user'
  623. }));
  624. App.router.get('installerController.launchBootstrap').restore();
  625. });
  626. });
  627. });