step7_test.js 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865
  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 numberUtils = require('utils/number_utils');
  20. require('mixins/common/localStorage');
  21. require('controllers/wizard/step7_controller');
  22. var installerStep7Controller,
  23. issuesFilterCases = [
  24. {
  25. isSubmitDisabled: true,
  26. submitButtonClicked: true,
  27. isIssuesFilterActive: true,
  28. issuesFilterText: '',
  29. issuesFilterLinkText: Em.I18n.t('installer.step7.showAllProperties'),
  30. title: 'issues filter on, submit button clicked'
  31. },
  32. {
  33. isSubmitDisabled: true,
  34. submitButtonClicked: false,
  35. isIssuesFilterActive: true,
  36. issuesFilterText: Em.I18n.t('installer.step7.showingPropertiesWithIssues'),
  37. issuesFilterLinkText: Em.I18n.t('installer.step7.showAllProperties'),
  38. title: 'issues filter on, submit button disabled'
  39. },
  40. {
  41. isSubmitDisabled: true,
  42. submitButtonClicked: true,
  43. isIssuesFilterActive: false,
  44. issuesFilterText: '',
  45. issuesFilterLinkText: '',
  46. title: 'issues filter off, submit button clicked'
  47. },
  48. {
  49. isSubmitDisabled: true,
  50. submitButtonClicked: false,
  51. isIssuesFilterActive: false,
  52. issuesFilterText: '',
  53. issuesFilterLinkText: Em.I18n.t('installer.step7.showPropertiesWithIssues'),
  54. title: 'issues filter off, submit button disabled'
  55. },
  56. {
  57. isSubmitDisabled: false,
  58. submitButtonClicked: false,
  59. isIssuesFilterActive: true,
  60. issuesFilterText: '',
  61. issuesFilterLinkText: Em.I18n.t('installer.step7.showAllProperties'),
  62. title: 'issues filter on, submit button enabled'
  63. },
  64. {
  65. isSubmitDisabled: false,
  66. submitButtonClicked: false,
  67. isIssuesFilterActive: false,
  68. issuesFilterText: '',
  69. issuesFilterLinkText: '',
  70. title: 'issues filter off, submit button enabled'
  71. },
  72. {
  73. isSubmitDisabled: false,
  74. submitButtonClicked: false,
  75. isIssuesFilterActive: true,
  76. issuesFilterText: '',
  77. issuesFilterLinkText: Em.I18n.t('installer.step7.showAllProperties'),
  78. title: 'issues filter on, submit button not clicked but active'
  79. },
  80. {
  81. isSubmitDisabled: false,
  82. submitButtonClicked: true,
  83. isIssuesFilterActive: true,
  84. issuesFilterText: '',
  85. issuesFilterLinkText: Em.I18n.t('installer.step7.showAllProperties'),
  86. title: 'issues filter on, submit button clicked and active'
  87. }
  88. ],
  89. issuesFilterTestSetup = function (controller, testCase) {
  90. controller.set('submitButtonClicked', testCase.submitButtonClicked);
  91. controller.reopen({
  92. isSubmitDisabled: testCase.isSubmitDisabled
  93. });
  94. controller.get('filterColumns').findProperty('attributeName', 'hasIssues').set('selected', testCase.isIssuesFilterActive);
  95. };
  96. function getController() {
  97. return App.WizardStep7Controller.create({
  98. content: Em.Object.create({
  99. services: [],
  100. advancedServiceConfig: [],
  101. serviceConfigProperties: []
  102. })
  103. });
  104. }
  105. describe('App.InstallerStep7Controller', function () {
  106. beforeEach(function () {
  107. sinon.stub(App.ajax, 'send', Em.K);
  108. sinon.stub(App.config, 'setPreDefinedServiceConfigs', Em.K);
  109. installerStep7Controller = getController();
  110. });
  111. afterEach(function() {
  112. App.ajax.send.restore();
  113. App.config.setPreDefinedServiceConfigs.restore();
  114. installerStep7Controller.destroy();
  115. });
  116. App.TestAliases.testAsComputedAlias(getController(), 'masterComponentHosts', 'content.masterComponentHosts', 'array');
  117. App.TestAliases.testAsComputedAlias(getController(), 'slaveComponentHosts', 'content.slaveGroupProperties', 'array');
  118. App.TestAliases.testAsComputedAnd(getController(), 'isConfigsLoaded', ['wizardController.stackConfigsLoaded', 'isAppliedConfigLoaded']);
  119. describe('#installedServiceNames', function () {
  120. var tests = Em.A([
  121. {
  122. content: Em.Object.create({
  123. controllerName: 'installerController',
  124. services: Em.A([
  125. Em.Object.create({
  126. isInstalled: true,
  127. serviceName: 'SQOOP'
  128. }),
  129. Em.Object.create({
  130. isInstalled: true,
  131. serviceName: 'HDFS'
  132. })
  133. ])
  134. }),
  135. e: ['SQOOP', 'HDFS'],
  136. m: 'installerController with SQOOP'
  137. },
  138. {
  139. content: Em.Object.create({
  140. controllerName: 'installerController',
  141. services: Em.A([
  142. Em.Object.create({
  143. isInstalled: true,
  144. serviceName: 'HIVE'
  145. }),
  146. Em.Object.create({
  147. isInstalled: true,
  148. serviceName: 'HDFS'
  149. })
  150. ])
  151. }),
  152. e: ['HIVE', 'HDFS'],
  153. m: 'installerController without SQOOP'
  154. },
  155. {
  156. content: Em.Object.create({
  157. controllerName: 'addServiceController',
  158. services: Em.A([
  159. Em.Object.create({
  160. isInstalled: true,
  161. serviceName: 'HIVE'
  162. }),
  163. Em.Object.create({
  164. isInstalled: true,
  165. serviceName: 'HDFS'
  166. })
  167. ])
  168. }),
  169. e: ['HIVE', 'HDFS'],
  170. m: 'addServiceController without SQOOP'
  171. }
  172. ]);
  173. tests.forEach(function (test) {
  174. it(test.m, function () {
  175. installerStep7Controller.set('content', test.content);
  176. expect(installerStep7Controller.get('installedServiceNames')).to.include.members(test.e);
  177. expect(test.e).to.include.members(installerStep7Controller.get('installedServiceNames'));
  178. });
  179. });
  180. });
  181. describe('#isSubmitDisabled', function () {
  182. it('should be true if miscModalVisible', function () {
  183. installerStep7Controller.reopen({miscModalVisible: true});
  184. expect(installerStep7Controller.get('isSubmitDisabled')).to.equal(true);
  185. });
  186. it('should be true if some of stepConfigs has errors', function () {
  187. installerStep7Controller.reopen({
  188. miscModalVisible: false,
  189. stepConfigs: [
  190. {
  191. showConfig: true,
  192. errorCount: 1
  193. }
  194. ]
  195. });
  196. expect(installerStep7Controller.get('isSubmitDisabled')).to.equal(true);
  197. });
  198. it('should be false if all of stepConfigs don\'t have errors and miscModalVisible is false', function () {
  199. installerStep7Controller.reopen({
  200. miscModalVisible: false,
  201. stepConfigs: [
  202. {
  203. showConfig: true,
  204. errorCount: 0
  205. }
  206. ]
  207. });
  208. expect(installerStep7Controller.get('isSubmitDisabled')).to.equal(false);
  209. });
  210. });
  211. describe('#selectedServiceNames', function () {
  212. it('should use content.services as source of data', function () {
  213. installerStep7Controller.set('content', {
  214. services: [
  215. {isSelected: true, isInstalled: false, serviceName: 's1'},
  216. {isSelected: false, isInstalled: false, serviceName: 's2'},
  217. {isSelected: true, isInstalled: true, serviceName: 's3'},
  218. {isSelected: false, isInstalled: false, serviceName: 's4'},
  219. {isSelected: true, isInstalled: false, serviceName: 's5'},
  220. {isSelected: false, isInstalled: false, serviceName: 's6'},
  221. {isSelected: true, isInstalled: true, serviceName: 's7'},
  222. {isSelected: false, isInstalled: false, serviceName: 's8'}
  223. ]
  224. });
  225. var expected = ['s1', 's5'];
  226. expect(installerStep7Controller.get('selectedServiceNames')).to.eql(expected);
  227. });
  228. });
  229. describe('#allSelectedServiceNames', function () {
  230. it('should use content.services as source of data', function () {
  231. installerStep7Controller.set('content', {
  232. services: [
  233. Em.Object.create({isSelected: true, isInstalled: false, serviceName: 's1'}),
  234. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's2'}),
  235. Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's3'}),
  236. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's4'}),
  237. Em.Object.create({isSelected: true, isInstalled: false, serviceName: 's5'}),
  238. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's6'}),
  239. Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's7'}),
  240. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's8'})
  241. ]
  242. });
  243. var expected = ['s1', 's3', 's5', 's7'];
  244. expect(installerStep7Controller.get('allSelectedServiceNames')).to.eql(expected);
  245. });
  246. });
  247. describe('#_createSiteToTagMap', function () {
  248. it('should return filtered map', function () {
  249. var desired_configs = {
  250. site1: {
  251. tag: "tag1"
  252. },
  253. site2: {
  254. tag: "tag2"
  255. },
  256. site3: {
  257. tag: "tag3"
  258. }
  259. };
  260. var sites = {
  261. site1: true,
  262. site3: true
  263. };
  264. var siteToTagMap = installerStep7Controller._createSiteToTagMap(desired_configs,sites);
  265. expect(siteToTagMap).to.eql({
  266. site1: "tag1",
  267. site3: "tag3"
  268. });
  269. });
  270. });
  271. describe('#checkDatabaseConnectionTest', function () {
  272. it('should return promise in process', function () {
  273. installerStep7Controller.set('content', {
  274. services: Em.A([
  275. Em.Object.create({isSelected: true, isInstalled: false, serviceName: 'OOZIE', ignored: []}),
  276. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 'HIVE', ignored: []}),
  277. Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's3', ignored: []}),
  278. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's4', ignored: []}),
  279. Em.Object.create({isSelected: true, isInstalled: false, serviceName: 's5', ignored: []}),
  280. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's6', ignored: []}),
  281. Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's7', ignored: []}),
  282. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's8', ignored: []})
  283. ])
  284. });
  285. var obj = Em.Object.create({name:'oozie_database',value:"aa"});
  286. installerStep7Controller.set('stepConfigs',Em.A([Em.Object.create({serviceName: 'OOZIE', configs: Em.A([obj]) })]));
  287. var deffer = installerStep7Controller.checkDatabaseConnectionTest();
  288. expect(deffer.isResolved()).to.equal(false);
  289. deffer.resolve(true);
  290. deffer.done(function(data) {
  291. expect(data).to.equal(true);
  292. });
  293. });
  294. });
  295. describe.skip('#submit', function () {
  296. beforeEach(function () {
  297. sinon.stub(App, 'get').withArgs('supports.preInstallChecks').returns(false);
  298. });
  299. afterEach(function () {
  300. App.get.restore();
  301. });
  302. it('should return false if submit disabled', function () {
  303. installerStep7Controller.set('isSubmitDisabled',true);
  304. expect(installerStep7Controller.submit()).to.be.false;
  305. });
  306. it('sumbit button should be unclicked if no configs', function () {
  307. installerStep7Controller.set('isSubmitDisabled',false);
  308. installerStep7Controller.submit();
  309. expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
  310. });
  311. });
  312. describe('#getConfigTagsSuccess', function () {
  313. beforeEach(function(){
  314. sinon.stub(App.StackService, 'find', function () {
  315. return [
  316. Em.Object.create({
  317. serviceName: 's0',
  318. isInstalled: true,
  319. configTypes: {
  320. site3: true,
  321. site1: true
  322. }
  323. }),
  324. Em.Object.create({
  325. serviceName: 's1',
  326. isInstalled: true,
  327. configTypes: {
  328. site1: true,
  329. site2: true
  330. }
  331. })
  332. ];
  333. });
  334. });
  335. afterEach(function(){
  336. App.StackService.find.restore();
  337. });
  338. it('should return serviceConfigTags', function () {
  339. var desired_configs = {
  340. site1: {
  341. tag: "tag1"
  342. },
  343. site2: {
  344. tag: "tag2"
  345. },
  346. site3: {
  347. tag: "tag3"
  348. }
  349. };
  350. var data = {
  351. Clusters: {
  352. desired_configs: desired_configs
  353. }
  354. };
  355. var siteToTagMap = installerStep7Controller.getConfigTagsSuccess(data);
  356. expect(installerStep7Controller.get('serviceConfigTags')).to.eql([
  357. {
  358. "siteName": "site1",
  359. "tagName": "tag1",
  360. "newTagName": null
  361. },
  362. {
  363. "siteName": "site2",
  364. "tagName": "tag2",
  365. "newTagName": null
  366. },
  367. {
  368. "siteName": "site3",
  369. "tagName": "tag3",
  370. "newTagName": null
  371. }
  372. ]);
  373. expect(installerStep7Controller.get('isAppliedConfigLoaded')).to.equal(true);
  374. });
  375. });
  376. describe('#clearStep', function () {
  377. it('should clear stepConfigs', function () {
  378. installerStep7Controller.set('stepConfigs', [
  379. {},
  380. {}
  381. ]);
  382. installerStep7Controller.clearStep();
  383. expect(installerStep7Controller.get('stepConfigs.length')).to.equal(0);
  384. });
  385. it('should clear filter', function () {
  386. installerStep7Controller.set('filter', 'filter');
  387. installerStep7Controller.clearStep();
  388. expect(installerStep7Controller.get('filter')).to.equal('');
  389. });
  390. it('should set for each filterColumns "selected" false', function () {
  391. installerStep7Controller.set('filterColumns', [
  392. {selected: true},
  393. {selected: false},
  394. {selected: true}
  395. ]);
  396. installerStep7Controller.clearStep();
  397. expect(installerStep7Controller.get('filterColumns').everyProperty('selected', false)).to.equal(true);
  398. });
  399. });
  400. describe('#loadInstalledServicesConfigGroups', function () {
  401. it('should do ajax request for each received service name', function () {
  402. var serviceNames = ['s1', 's2', 's3'];
  403. installerStep7Controller.loadInstalledServicesConfigGroups(serviceNames);
  404. expect(App.ajax.send.callCount).to.equal(serviceNames.length);
  405. });
  406. });
  407. describe('#getConfigTags', function () {
  408. it('should do ajax-request', function () {
  409. installerStep7Controller.getConfigTags();
  410. expect(App.ajax.send.calledOnce).to.equal(true);
  411. });
  412. });
  413. describe('#setGroupsToDelete', function () {
  414. beforeEach(function () {
  415. installerStep7Controller.set('wizardController', Em.Object.create(App.LocalStorage, {name: 'tdk'}));
  416. });
  417. it('should add new groups to groupsToDelete', function () {
  418. var groupsToDelete = [
  419. {id: '1'},
  420. {id: '2'}
  421. ],
  422. groups = [
  423. Em.Object.create({id: '3'}),
  424. Em.Object.create(),
  425. Em.Object.create({id: '5'})
  426. ],
  427. expected = [
  428. {id: "1"},
  429. {id: "2"},
  430. {id: "3"},
  431. {id: "5"}
  432. ];
  433. installerStep7Controller.set('groupsToDelete', groupsToDelete);
  434. installerStep7Controller.setGroupsToDelete(groups);
  435. expect(installerStep7Controller.get('groupsToDelete')).to.eql(expected);
  436. expect(installerStep7Controller.get('wizardController').getDBProperty('groupsToDelete')).to.eql(expected);
  437. });
  438. });
  439. describe('#checkMySQLHost', function () {
  440. it('should send query', function () {
  441. installerStep7Controller.checkMySQLHost();
  442. expect(App.ajax.send.calledOnce).to.be.true;
  443. });
  444. });
  445. describe('#selectConfigGroup', function () {
  446. beforeEach(function () {
  447. installerStep7Controller.reopen({content: {services: []}});
  448. sinon.stub(installerStep7Controller, 'switchConfigGroupConfigs', Em.K);
  449. });
  450. afterEach(function () {
  451. installerStep7Controller.switchConfigGroupConfigs.restore();
  452. });
  453. it('should set selectedConfigGroup', function () {
  454. var group = {':': []};
  455. installerStep7Controller.selectConfigGroup({context: group});
  456. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(group);
  457. });
  458. });
  459. describe('#selectedServiceObserver', function () {
  460. beforeEach(function () {
  461. installerStep7Controller.reopen({content: {services: []}});
  462. sinon.stub(installerStep7Controller, 'switchConfigGroupConfigs', Em.K);
  463. });
  464. afterEach(function () {
  465. installerStep7Controller.switchConfigGroupConfigs.restore();
  466. });
  467. it('shouldn\'t do nothing if App.supports.hostOverridesInstaller is false', function () {
  468. App.set('supports.hostOverridesInstaller', false);
  469. var configGroups = [
  470. {},
  471. {}
  472. ],
  473. selectedConfigGroup = {};
  474. installerStep7Controller.reopen({configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
  475. installerStep7Controller.selectedServiceObserver();
  476. expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
  477. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
  478. });
  479. it('shouldn\'t do nothing if selectedService is null', function () {
  480. App.set('supports.hostOverridesInstaller', true);
  481. var configGroups = [
  482. {},
  483. {}
  484. ],
  485. selectedConfigGroup = {};
  486. installerStep7Controller.reopen({selectedService: null, configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
  487. installerStep7Controller.selectedServiceObserver();
  488. expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
  489. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
  490. });
  491. it('shouldn\'t do nothing if selectedService.serviceName is MISC', function () {
  492. App.set('supports.hostOverridesInstaller', true);
  493. var configGroups = [
  494. {},
  495. {}
  496. ],
  497. selectedConfigGroup = {};
  498. installerStep7Controller.reopen({selectedService: {serviceName: 'MISC'}, configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
  499. installerStep7Controller.selectedServiceObserver();
  500. expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
  501. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
  502. });
  503. it('should update configGroups and selectedConfigGroup', function () {
  504. App.set('supports.hostOverridesInstaller', true);
  505. var defaultGroup = {isDefault: true, n: 'n2'},
  506. configGroups = [
  507. {isDefault: false, n: 'n1'},
  508. defaultGroup,
  509. {n: 'n3'}
  510. ],
  511. selectedConfigGroup = {};
  512. installerStep7Controller.reopen({selectedService: {serviceName: 's1', configGroups: configGroups}});
  513. installerStep7Controller.selectedServiceObserver();
  514. expect(installerStep7Controller.get('configGroups').mapProperty('n')).to.eql(['n2', 'n1', 'n3']);
  515. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(defaultGroup);
  516. });
  517. });
  518. describe('#loadConfigGroups', function () {
  519. beforeEach(function () {
  520. installerStep7Controller.reopen({
  521. wizardController: Em.Object.create({
  522. allHosts: [
  523. {hostName: 'h1'},
  524. {hostName: 'h2'},
  525. {hostName: 'h3'}
  526. ]
  527. })
  528. });
  529. });
  530. afterEach(function () {
  531. App.ServiceConfigGroup.find().clear();
  532. });
  533. it('shouldn\'t do nothing if only MISC available', function () {
  534. var configGroups = [
  535. {}
  536. ];
  537. installerStep7Controller.reopen({
  538. stepConfigs: [Em.Object.create({serviceName: 'MISC', configGroups: configGroups})]
  539. });
  540. installerStep7Controller.loadConfigGroups([]);
  541. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups')).to.eql(configGroups);
  542. });
  543. });
  544. describe('#_getDisplayedConfigGroups', function () {
  545. it('should return [] if no selected group', function () {
  546. installerStep7Controller.reopen({
  547. content: {services: []},
  548. selectedConfigGroup: null
  549. });
  550. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([]);
  551. });
  552. it('should return default config group if another selected', function () {
  553. var defaultGroup = Em.Object.create({isDefault: false});
  554. installerStep7Controller.reopen({
  555. content: {services: []},
  556. selectedConfigGroup: defaultGroup
  557. });
  558. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([defaultGroup]);
  559. });
  560. it('should return other groups if default selected', function () {
  561. var defaultGroup = Em.Object.create({isDefault: true}),
  562. cfgG = Em.Object.create({isDefault: true}),
  563. configGroups = Em.A([
  564. Em.Object.create({isDefault: false}),
  565. Em.Object.create({isDefault: false}),
  566. cfgG,
  567. Em.Object.create({isDefault: false})
  568. ]);
  569. installerStep7Controller.reopen({
  570. content: {services: []},
  571. selectedConfigGroup: defaultGroup,
  572. selectedService: {configGroups: configGroups}
  573. });
  574. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql(configGroups.without(cfgG));
  575. });
  576. });
  577. describe('#_setEditableValue', function () {
  578. it('shouldn\'t update config if no selectedConfigGroup', function () {
  579. installerStep7Controller.reopen({
  580. selectedConfigGroup: null
  581. });
  582. var config = Em.Object.create({isEditable: null});
  583. var updatedConfig = installerStep7Controller._setEditableValue(config);
  584. expect(updatedConfig.get('isEditable')).to.be.null;
  585. });
  586. it('should set isEditable equal to selectedGroup.isDefault if service not installed', function () {
  587. var isDefault = true;
  588. installerStep7Controller.reopen({
  589. installedServiceNames: [],
  590. selectedService: {serviceName: 'abc'},
  591. selectedConfigGroup: Em.Object.create({isDefault: isDefault})
  592. });
  593. var config = Em.Object.create({isEditable: null});
  594. var updatedConfig = installerStep7Controller._setEditableValue(config);
  595. expect(updatedConfig.get('isEditable')).to.equal(isDefault);
  596. installerStep7Controller.toggleProperty('selectedConfigGroup.isDefault');
  597. updatedConfig = installerStep7Controller._setEditableValue(config);
  598. expect(updatedConfig.get('isEditable')).to.equal(!isDefault);
  599. });
  600. Em.A([
  601. {
  602. isEditable: false,
  603. isReconfigurable: false,
  604. isDefault: true,
  605. e: false
  606. },
  607. {
  608. isEditable: true,
  609. isReconfigurable: true,
  610. isDefault: true,
  611. e: true
  612. },
  613. {
  614. isEditable: false,
  615. isReconfigurable: true,
  616. isDefault: false,
  617. e: false
  618. },
  619. {
  620. isEditable: true,
  621. isReconfigurable: false,
  622. isDefault: false,
  623. e: false
  624. }
  625. ]).forEach(function (test) {
  626. it('service installed, isEditable = ' + test.isEditable.toString() + ', isReconfigurable = ' + test.isReconfigurable.toString(), function () {
  627. var config = Em.Object.create({
  628. isReconfigurable: test.isReconfigurable,
  629. isEditable: test.isEditable
  630. });
  631. installerStep7Controller.reopen({
  632. installedServiceNames: Em.A(['a']),
  633. selectedService: Em.Object.create({serviceName: 'a'}),
  634. selectedConfigGroup: Em.Object.create({isDefault: test.isDefault})
  635. });
  636. var updateConfig = installerStep7Controller._setEditableValue(config);
  637. expect(updateConfig.get('isEditable')).to.equal(test.e);
  638. });
  639. });
  640. });
  641. describe('#_setOverrides', function () {
  642. it('shouldn\'t update config if no selectedConfigGroup', function () {
  643. installerStep7Controller.reopen({
  644. selectedConfigGroup: null
  645. });
  646. var config = Em.Object.create({overrides: null});
  647. var updatedConfig = installerStep7Controller._setOverrides(config, []);
  648. expect(updatedConfig.get('overrides')).to.be.null;
  649. });
  650. it('no overrideToAdd', function () {
  651. var isDefault = true,
  652. name = 'n1',
  653. config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
  654. overrides = Em.A([
  655. Em.Object.create({name: name, value: 'v1'}),
  656. Em.Object.create({name: name, value: 'v2'}),
  657. Em.Object.create({name: 'n2', value: 'v3'})
  658. ]);
  659. installerStep7Controller.reopen({
  660. overrideToAdd: null,
  661. selectedConfigGroup: Em.Object.create({
  662. isDefault: isDefault
  663. })
  664. });
  665. var updatedConfig = installerStep7Controller._setOverrides(config, overrides);
  666. expect(updatedConfig.get('overrides.length')).to.equal(2);
  667. expect(updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
  668. expect(updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
  669. });
  670. it('overrideToAdd exists', function () {
  671. var isDefault = true,
  672. name = 'n1',
  673. config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
  674. overrides = Em.A([
  675. Em.Object.create({name: name, value: 'v1'}),
  676. Em.Object.create({name: name, value: 'v2'}),
  677. Em.Object.create({name: 'n2', value: 'v3'})
  678. ]);
  679. installerStep7Controller.reopen({
  680. overrideToAdd: Em.Object.create({name: name}),
  681. selectedService: {configGroups: [Em.Object.create({name: 'n', properties: []})]},
  682. selectedConfigGroup: Em.Object.create({
  683. isDefault: isDefault,
  684. name: 'n'
  685. })
  686. });
  687. var updatedConfig = installerStep7Controller._setOverrides(config, overrides);
  688. expect(updatedConfig.get('overrides.length')).to.equal(3);
  689. expect(updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
  690. expect(updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
  691. });
  692. });
  693. describe('#switchConfigGroupConfigs', function () {
  694. it('if selectedConfigGroup is null, serviceConfigs shouldn\'t be changed', function () {
  695. installerStep7Controller.reopen({
  696. selectedConfigGroup: null,
  697. content: {services: []},
  698. serviceConfigs: {configs: [
  699. {overrides: []},
  700. {overrides: []}
  701. ]}
  702. });
  703. installerStep7Controller.switchConfigGroupConfigs();
  704. expect(installerStep7Controller.get('serviceConfigs.configs').everyProperty('overrides.length', 0)).to.equal(true);
  705. });
  706. describe('should set configs for serviceConfigs', function () {
  707. var configGroups = [
  708. Em.Object.create({
  709. properties: [
  710. {name: 'g1', value: 'v1'},
  711. {name: 'g2', value: 'v2'}
  712. ]
  713. })
  714. ];
  715. beforeEach(function () {
  716. sinon.stub(installerStep7Controller, '_getDisplayedConfigGroups', function () {
  717. return configGroups;
  718. });
  719. sinon.stub(installerStep7Controller, '_setEditableValue', function (config) {
  720. config.set('isEditable', true);
  721. return config;
  722. });
  723. installerStep7Controller.reopen({
  724. selectedConfigGroup: Em.Object.create({isDefault: true, name: 'g1'}),
  725. content: {services: []},
  726. selectedService: {configs: Em.A([Em.Object.create({name: 'g1', overrides: [], properties: []}), Em.Object.create({name: 'g2', overrides: []})])},
  727. serviceConfigs: {configs: [Em.Object.create({name: 'g1'})]}
  728. });
  729. installerStep7Controller.switchConfigGroupConfigs();
  730. this.configs = installerStep7Controller.get('selectedService.configs');
  731. });
  732. afterEach(function () {
  733. installerStep7Controller._getDisplayedConfigGroups.restore();
  734. installerStep7Controller._setEditableValue.restore();
  735. });
  736. it('g1 has 1 override', function () {
  737. expect(this.configs.findProperty('name', 'g1').get('overrides').length).to.equal(1);
  738. });
  739. it('g2 has 1 override', function () {
  740. expect(this.configs.findProperty('name', 'g2').get('overrides').length).to.equal(1);
  741. });
  742. it('all configs are editable', function () {
  743. expect(this.configs.everyProperty('isEditable', true)).to.equal(true);
  744. });
  745. });
  746. });
  747. describe('#selectProperService', function () {
  748. Em.A([
  749. {
  750. name: 'addServiceController',
  751. stepConfigs: [
  752. {selected: false, name: 'n1'},
  753. {selected: true, name: 'n2'},
  754. {selected: true, name: 'n3'}
  755. ],
  756. e: 'n2'
  757. },
  758. {
  759. name: 'installerController',
  760. stepConfigs: [
  761. {showConfig: false, name: 'n1'},
  762. {showConfig: false, name: 'n2'},
  763. {showConfig: true, name: 'n3'}
  764. ],
  765. e: 'n3'
  766. }
  767. ]).forEach(function (test) {
  768. describe(test.name, function () {
  769. beforeEach(function () {
  770. sinon.stub(installerStep7Controller, 'selectedServiceObserver', Em.K);
  771. installerStep7Controller.reopen({
  772. wizardController: Em.Object.create({
  773. name: test.name
  774. }),
  775. stepConfigs: test.stepConfigs
  776. });
  777. installerStep7Controller.selectProperService();
  778. });
  779. afterEach(function () {
  780. installerStep7Controller.selectedServiceObserver.restore();
  781. });
  782. it('selected service name is valid', function () {
  783. expect(installerStep7Controller.get('selectedService.name')).to.equal(test.e);
  784. });
  785. });
  786. });
  787. });
  788. describe.skip('#setStepConfigs', function () {
  789. var serviceConfigs;
  790. beforeEach(function () {
  791. installerStep7Controller.reopen({
  792. content: {services: []},
  793. wizardController: Em.Object.create({
  794. getDBProperty: function (key) {
  795. return this.get(key);
  796. }
  797. })
  798. });
  799. sinon.stub(installerStep7Controller, 'renderConfigs', function () {
  800. return serviceConfigs;
  801. });
  802. this.stub = sinon.stub(App, 'get');
  803. });
  804. afterEach(function () {
  805. installerStep7Controller.renderConfigs.restore();
  806. App.get.restore();
  807. });
  808. it('if wizard isn\'t addService, should set output of installerStep7Controller.renderConfigs', function () {
  809. serviceConfigs = Em.A([
  810. {serviceName:'HDFS', configs: []},
  811. {}
  812. ]);
  813. installerStep7Controller.set('wizardController.name', 'installerController');
  814. installerStep7Controller.setStepConfigs([], []);
  815. expect(installerStep7Controller.get('stepConfigs')).to.eql(serviceConfigs);
  816. });
  817. it('addServiceWizard used', function () {
  818. serviceConfigs = Em.A([Em.Object.create({serviceName: 'HDFS', configs: []}), Em.Object.create({serviceName: 's2'})]);
  819. installerStep7Controller.set('wizardController.name', 'addServiceController');
  820. installerStep7Controller.reopen({selectedServiceNames: ['s2']});
  821. installerStep7Controller.setStepConfigs([], []);
  822. expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
  823. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 's2').get('selected')).to.equal(true);
  824. });
  825. it('addServiceWizard used, HA enabled', function () {
  826. this.stub.withArgs('isHaEnabled').returns(true);
  827. serviceConfigs = Em.A([
  828. Em.Object.create({
  829. serviceName: 'HDFS',
  830. configs: [
  831. Em.Object.create({category: 'SECONDARY_NAMENODE'}),
  832. Em.Object.create({category: 'SECONDARY_NAMENODE'}),
  833. Em.Object.create({category: 'NameNode'}),
  834. Em.Object.create({category: 'NameNode'}),
  835. Em.Object.create({category: 'SECONDARY_NAMENODE'})
  836. ]
  837. }),
  838. Em.Object.create({serviceName: 's2'})]
  839. );
  840. installerStep7Controller.set('wizardController.name', 'addServiceController');
  841. installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
  842. installerStep7Controller.setStepConfigs([], []);
  843. expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
  844. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('selected')).to.equal(true);
  845. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(5);
  846. });
  847. it('not windows stack', function () {
  848. this.stub.withArgs('isHadoopWindowsStack').returns(false);
  849. this.stub.withArgs('isHaEnabled').returns(false);
  850. serviceConfigs = Em.A([
  851. Em.Object.create({
  852. serviceName: 'HDFS',
  853. configs: [
  854. {category: 'NameNode'},
  855. {category: 'NameNode'}
  856. ]
  857. }),
  858. Em.Object.create({serviceName: 's2'})]
  859. );
  860. installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
  861. installerStep7Controller.setStepConfigs([], []);
  862. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
  863. });
  864. it('windows stack', function () {
  865. this.stub.withArgs('isHadoopWindowsStack').returns(true);
  866. this.stub.withArgs('isHaEnabled').returns(false);
  867. serviceConfigs = Em.A([
  868. Em.Object.create({
  869. serviceName: 'HDFS',
  870. configs: [
  871. {category: 'NameNode'},
  872. {category: 'NameNode'}
  873. ]
  874. }),
  875. Em.Object.create({serviceName: 's2'})]
  876. );
  877. installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
  878. installerStep7Controller.set('installedServiceNames',['HDFS', 's2', 's3']);
  879. installerStep7Controller.setStepConfigs([], []);
  880. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
  881. });
  882. });
  883. describe('#checkHostOverrideInstaller', function () {
  884. beforeEach(function () {
  885. sinon.stub(installerStep7Controller, 'loadConfigGroups', Em.K);
  886. sinon.stub(installerStep7Controller, 'loadInstalledServicesConfigGroups', Em.K);
  887. sinon.stub(App, 'get', function (k) {
  888. if (k === 'supports.hostOverridesInstaller') return false;
  889. return Em.get(App, k);
  890. });
  891. });
  892. afterEach(function () {
  893. installerStep7Controller.loadConfigGroups.restore();
  894. installerStep7Controller.loadInstalledServicesConfigGroups.restore();
  895. App.get.restore();
  896. });
  897. Em.A([
  898. {
  899. installedServiceNames: [],
  900. m: 'installedServiceNames is empty',
  901. e: {
  902. loadConfigGroups: true,
  903. loadInstalledServicesConfigGroups: false
  904. }
  905. },
  906. {
  907. installedServiceNames: ['s1', 's2', 's3'],
  908. areInstalledConfigGroupsLoaded: false,
  909. m: 'installedServiceNames isn\'t empty, config groups not yet loaded',
  910. e: {
  911. loadConfigGroups: true,
  912. loadInstalledServicesConfigGroups: true
  913. }
  914. },
  915. {
  916. installedServiceNames: ['s1', 's2', 's3'],
  917. areInstalledConfigGroupsLoaded: true,
  918. m: 'installedServiceNames isn\'t empty, config groups already loaded',
  919. e: {
  920. loadConfigGroups: true,
  921. loadInstalledServicesConfigGroups: false
  922. }
  923. }
  924. ]).forEach(function (test) {
  925. describe(test.m, function () {
  926. beforeEach(function () {
  927. installerStep7Controller.reopen({
  928. installedServiceNames: test.installedServiceNames,
  929. wizardController: {
  930. areInstalledConfigGroupsLoaded: test.areInstalledConfigGroupsLoaded
  931. }
  932. });
  933. installerStep7Controller.checkHostOverrideInstaller();
  934. });
  935. if (test.e.loadConfigGroups) {
  936. it('loadConfigGroups is called once', function () {
  937. expect(installerStep7Controller.loadConfigGroups.calledOnce).to.equal(true);
  938. });
  939. }
  940. else {
  941. it('loadConfigGroups is not called', function () {
  942. expect(installerStep7Controller.loadConfigGroups.called).to.equal(false);
  943. });
  944. }
  945. if (test.e.loadInstalledServicesConfigGroups) {
  946. it('loadInstalledServicesConfigGroups is called once', function () {
  947. expect(installerStep7Controller.loadInstalledServicesConfigGroups.calledOnce).to.equal(true);
  948. });
  949. }
  950. else {
  951. it('loadInstalledServicesConfigGroups is not called', function () {
  952. expect(installerStep7Controller.loadInstalledServicesConfigGroups.called).to.equal(false);
  953. });
  954. }
  955. });
  956. });
  957. });
  958. describe('#loadStep', function () {
  959. beforeEach(function () {
  960. installerStep7Controller.reopen({
  961. content: {services: []},
  962. wizardController: Em.Object.create({
  963. getDBProperty: function (k) {
  964. return this.get(k);
  965. },
  966. stackConfigsLoaded: true
  967. })
  968. });
  969. sinon.stub(App.config, 'fileConfigsIntoTextarea', Em.K);
  970. sinon.stub(installerStep7Controller, 'clearStep', Em.K);
  971. sinon.stub(installerStep7Controller, 'getConfigTags', Em.K);
  972. sinon.stub(installerStep7Controller, 'setInstalledServiceConfigs', Em.K);
  973. sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
  974. sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
  975. sinon.stub(installerStep7Controller, 'applyServicesConfigs', Em.K);
  976. sinon.stub(App.router, 'send', Em.K);
  977. });
  978. afterEach(function () {
  979. App.config.fileConfigsIntoTextarea.restore();
  980. installerStep7Controller.clearStep.restore();
  981. installerStep7Controller.getConfigTags.restore();
  982. installerStep7Controller.setInstalledServiceConfigs.restore();
  983. installerStep7Controller.checkHostOverrideInstaller.restore();
  984. installerStep7Controller.selectProperService.restore();
  985. installerStep7Controller.applyServicesConfigs.restore();
  986. App.router.send.restore();
  987. });
  988. it('should call clearStep', function () {
  989. installerStep7Controller.loadStep();
  990. expect(installerStep7Controller.clearStep.calledOnce).to.equal(true);
  991. });
  992. it('shouldn\'t do nothing if isAdvancedConfigLoaded is false', function () {
  993. installerStep7Controller.set('wizardController.stackConfigsLoaded', false);
  994. installerStep7Controller.loadStep();
  995. expect(installerStep7Controller.clearStep.called).to.equal(false);
  996. });
  997. it('should call setInstalledServiceConfigs for addServiceController', function () {
  998. installerStep7Controller.set('wizardController.name', 'addServiceController');
  999. installerStep7Controller.loadStep();
  1000. expect(installerStep7Controller.setInstalledServiceConfigs.calledOnce).to.equal(true);
  1001. });
  1002. });
  1003. describe('#applyServicesConfigs', function() {
  1004. beforeEach(function() {
  1005. installerStep7Controller.reopen({
  1006. allSelectedServiceNames: []
  1007. });
  1008. sinon.stub(App.config, 'fileConfigsIntoTextarea', function(configs) {
  1009. return configs;
  1010. });
  1011. sinon.stub(installerStep7Controller, 'loadServerSideConfigsRecommendations', function() {
  1012. return $.Deferred().resolve();
  1013. });
  1014. sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
  1015. sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
  1016. sinon.stub(App.router, 'send', Em.K);
  1017. sinon.stub(App.StackService, 'find', function () {
  1018. return {
  1019. findProperty: function () {
  1020. return Em.Object.create({
  1021. isInstalled: true,
  1022. isSelected: false
  1023. });
  1024. },
  1025. filterProperty: function () {
  1026. return [];
  1027. }
  1028. }
  1029. });
  1030. installerStep7Controller.applyServicesConfigs([{name: 'configs'}]);
  1031. });
  1032. afterEach(function () {
  1033. App.config.fileConfigsIntoTextarea.restore();
  1034. installerStep7Controller.loadServerSideConfigsRecommendations.restore();
  1035. installerStep7Controller.checkHostOverrideInstaller.restore();
  1036. installerStep7Controller.selectProperService.restore();
  1037. App.router.send.restore();
  1038. App.StackService.find.restore();
  1039. });
  1040. it('loadServerSideConfigsRecommendations is called once' , function () {
  1041. expect(installerStep7Controller.loadServerSideConfigsRecommendations.calledOnce).to.equal(true);
  1042. });
  1043. it('isRecommendedLoaded is true' , function () {
  1044. expect(installerStep7Controller.get('isRecommendedLoaded')).to.equal(true);
  1045. });
  1046. it('checkHostOverrideInstalleris called once' , function () {
  1047. expect(installerStep7Controller.checkHostOverrideInstaller.calledOnce).to.equal(true);
  1048. });
  1049. it('selectProperServiceis called once' , function () {
  1050. expect(installerStep7Controller.selectProperService.calledOnce).to.equal(true);
  1051. });
  1052. Em.A([
  1053. {
  1054. allSelectedServiceNames: ['YARN'],
  1055. fileConfigsIntoTextarea: true,
  1056. m: 'should run fileConfigsIntoTextarea'
  1057. }
  1058. ]).forEach(function(t) {
  1059. it(t.m, function () {
  1060. installerStep7Controller.reopen({
  1061. allSelectedServiceNames: t.allSelectedServiceNames
  1062. });
  1063. installerStep7Controller.applyServicesConfigs([{name: 'configs'}]);
  1064. if (t.fileConfigsIntoTextarea) {
  1065. expect(App.config.fileConfigsIntoTextarea.calledWith([{name: 'configs'}], 'capacity-scheduler.xml')).to.equal(true);
  1066. } else {
  1067. expect(App.config.fileConfigsIntoTextarea.calledOnce).to.equal(false);
  1068. }
  1069. });
  1070. });
  1071. });
  1072. describe('#_updateIsEditableFlagForConfig', function () {
  1073. Em.A([
  1074. {
  1075. isAdmin: false,
  1076. isReconfigurable: false,
  1077. isHostsConfigsPage: true,
  1078. defaultGroupSelected: false,
  1079. m: 'false for non-admin users',
  1080. e: false
  1081. },
  1082. {
  1083. isAdmin: true,
  1084. isReconfigurable: false,
  1085. isHostsConfigsPage: true,
  1086. defaultGroupSelected: false,
  1087. m: 'false if defaultGroupSelected is false and isHostsConfigsPage is true',
  1088. e: false
  1089. },
  1090. {
  1091. isAdmin: true,
  1092. isReconfigurable: false,
  1093. isHostsConfigsPage: true,
  1094. defaultGroupSelected: true,
  1095. m: 'false if defaultGroupSelected is true and isHostsConfigsPage is true',
  1096. e: false
  1097. },
  1098. {
  1099. isAdmin: true,
  1100. isReconfigurable: false,
  1101. isHostsConfigsPage: false,
  1102. defaultGroupSelected: false,
  1103. m: 'false if defaultGroupSelected is false and isHostsConfigsPage is false',
  1104. e: false
  1105. }
  1106. ]).forEach(function (test) {
  1107. it(test.m, function () {
  1108. installerStep7Controller.reopen({isHostsConfigsPage: test.isHostsConfigsPage});
  1109. var serviceConfigProperty = Em.Object.create({
  1110. isReconfigurable: test.isReconfigurable
  1111. });
  1112. installerStep7Controller._updateIsEditableFlagForConfig(serviceConfigProperty, test.defaultGroupSelected);
  1113. expect(serviceConfigProperty.get('isEditable')).to.equal(test.e);
  1114. });
  1115. });
  1116. });
  1117. describe('#_updateOverridesForConfig', function () {
  1118. it('should set empty array', function () {
  1119. var serviceConfigProperty = Em.Object.create({
  1120. overrides: null
  1121. }), component = Em.Object.create();
  1122. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1123. expect(serviceConfigProperty.get('overrides')).to.eql(Em.A([]));
  1124. });
  1125. describe('host overrides not supported', function () {
  1126. var serviceConfigProperty = Em.Object.create({
  1127. overrides: [
  1128. {value: 'new value'}
  1129. ]
  1130. });
  1131. var component = Em.Object.create({selectedConfigGroup: {isDefault: false}});
  1132. beforeEach(function () {
  1133. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1134. });
  1135. it('there is 1 override', function () {
  1136. expect(serviceConfigProperty.get('overrides').length).to.equal(1);
  1137. });
  1138. it('override value is valid', function () {
  1139. expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
  1140. });
  1141. it('override is not original SCP', function () {
  1142. expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
  1143. });
  1144. it('override is linked to parent', function () {
  1145. expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
  1146. });
  1147. });
  1148. describe('host overrides supported', function () {
  1149. var serviceConfigProperty;
  1150. var component;
  1151. beforeEach(function () {
  1152. sinon.stub(App, 'get', function (k) {
  1153. if (k === 'supports.hostOverrides') return true;
  1154. return Em.get(App, k);
  1155. });
  1156. serviceConfigProperty = Em.Object.create({
  1157. overrides: [
  1158. {value: 'new value', group: Em.Object.create({name: 'n1'})}
  1159. ]
  1160. });
  1161. component = Em.Object.create({
  1162. selectedConfigGroup: {isDefault: true},
  1163. configGroups: Em.A([
  1164. Em.Object.create({name: 'n1', properties: []})
  1165. ])
  1166. });
  1167. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1168. });
  1169. afterEach(function () {
  1170. App.get.restore();
  1171. });
  1172. it('there is 1 override', function () {
  1173. expect(serviceConfigProperty.get('overrides').length).to.equal(1);
  1174. });
  1175. it('override.value is valid', function () {
  1176. expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
  1177. });
  1178. it('override is not original SCP', function () {
  1179. expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
  1180. });
  1181. it('override.parentSCP is valid', function () {
  1182. expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
  1183. });
  1184. it('there is 1 property in the config group', function () {
  1185. expect(component.get('configGroups.firstObject.properties').length).to.equal(1);
  1186. });
  1187. it('property in the config group is not editable', function () {
  1188. expect(component.get('configGroups.firstObject.properties.firstObject.isEditable')).to.equal(false);
  1189. });
  1190. it('property in the config group is linked to it', function () {
  1191. expect(component.get('configGroups.firstObject.properties.firstObject.group')).to.be.object;
  1192. });
  1193. });
  1194. });
  1195. describe('#setInstalledServiceConfigs', function () {
  1196. var controller = App.WizardStep7Controller.create({
  1197. installedServiceNames: ['HBASE', 'AMBARI_METRICS']
  1198. }),
  1199. configs = [
  1200. {
  1201. name: 'hbase.client.scanner.caching',
  1202. value: '1000',
  1203. serviceName: 'HBASE',
  1204. filename: 'hbase-site.xml'
  1205. },
  1206. {
  1207. name: 'hbase.client.scanner.caching',
  1208. value: '2000',
  1209. serviceName: 'AMBARI_METRICS',
  1210. filename: 'ams-hbase-site.xml'
  1211. }
  1212. ],
  1213. configsByTags = [
  1214. {
  1215. type: 'hbase-site',
  1216. tag: 'version2',
  1217. properties: {
  1218. 'hbase.client.scanner.caching': '1500'
  1219. }
  1220. },
  1221. {
  1222. type: 'ams-hbase-site',
  1223. tag: 'version2',
  1224. properties: {
  1225. 'hbase.client.scanner.caching': '2500'
  1226. }
  1227. },
  1228. {
  1229. type: 'site-without-properties',
  1230. tag: 'version1'
  1231. }
  1232. ],
  1233. installedServiceNames = ['HBASE', 'AMBARI_METRICS'];
  1234. describe('should handle properties with the same name', function () {
  1235. var properties;
  1236. beforeEach(function () {
  1237. controller.setInstalledServiceConfigs(configs, configsByTags, installedServiceNames);
  1238. properties = configs.filterProperty('name', 'hbase.client.scanner.caching');
  1239. });
  1240. it('there are 2 properties', function () {
  1241. expect(properties).to.have.length(2);
  1242. });
  1243. it('hbase-site/ value is valid', function () {
  1244. expect(properties.findProperty('filename', 'hbase-site.xml').value).to.equal('1500');
  1245. });
  1246. it('hbase-site/ savedValue is valid', function () {
  1247. expect(properties.findProperty('filename', 'hbase-site.xml').savedValue).to.equal('1500');
  1248. });
  1249. it('ams-hbase-site/ value is valid', function () {
  1250. expect(properties.findProperty('filename', 'ams-hbase-site.xml').value).to.equal('2500');
  1251. });
  1252. it('ams-hbase-site/ savedValue is valid', function () {
  1253. expect(properties.findProperty('filename', 'ams-hbase-site.xml').savedValue).to.equal('2500');
  1254. });
  1255. });
  1256. });
  1257. describe('#getAmbariDatabaseSuccess', function () {
  1258. var controller = App.WizardStep7Controller.create({
  1259. stepConfigs: [
  1260. {
  1261. serviceName: 'HIVE',
  1262. configs: [
  1263. {
  1264. name: 'hive_hostname',
  1265. value: 'h0'
  1266. }
  1267. ]
  1268. }
  1269. ]
  1270. }),
  1271. cases = [
  1272. {
  1273. data: {
  1274. hostComponents: []
  1275. },
  1276. mySQLServerConflict: false,
  1277. title: 'no Ambari Server host components'
  1278. },
  1279. {
  1280. data: {
  1281. hostComponents: [
  1282. {
  1283. RootServiceHostComponents: {
  1284. properties: {
  1285. 'server.jdbc.url': 'jdbc:mysql://h0/db0?createDatabaseIfNotExist=true'
  1286. }
  1287. }
  1288. }
  1289. ]
  1290. },
  1291. mySQLServerConflict: true,
  1292. title: 'Ambari MySQL Server and Hive Server are on the same host'
  1293. },
  1294. {
  1295. data: {
  1296. hostComponents: [
  1297. {
  1298. RootServiceHostComponents: {
  1299. properties: {
  1300. 'server.jdbc.url': 'jdbc:mysql://h1/db1?createDatabaseIfNotExist=true'
  1301. }
  1302. }
  1303. }
  1304. ]
  1305. },
  1306. mySQLServerConflict: false,
  1307. title: 'Ambari MySQL Server and Hive Server are on different hosts'
  1308. }
  1309. ];
  1310. cases.forEach(function (item) {
  1311. it(item.title, function () {
  1312. controller.getAmbariDatabaseSuccess(item.data);
  1313. expect(controller.get('mySQLServerConflict')).to.equal(item.mySQLServerConflict);
  1314. });
  1315. });
  1316. });
  1317. describe('#showDatabaseConnectionWarningPopup', function () {
  1318. var cases = [
  1319. {
  1320. method: 'onSecondary',
  1321. submitButtonClicked: false,
  1322. isRejected: true,
  1323. title: 'Cancel button clicked'
  1324. },
  1325. {
  1326. method: 'onPrimary',
  1327. submitButtonClicked: true,
  1328. isResolved: true,
  1329. title: 'Proceed Anyway button clicked'
  1330. }
  1331. ],
  1332. dfd,
  1333. testObject,
  1334. serviceNames = ['HIVE', 'OOZIE'],
  1335. bodyMessage = 'HIVE, OOZIE';
  1336. beforeEach(function () {
  1337. installerStep7Controller.set('submitButtonClicked', true);
  1338. dfd = $.Deferred(function (d) {
  1339. d.done(function () {
  1340. testObject.isResolved = true;
  1341. });
  1342. d.fail(function () {
  1343. testObject.isRejected = true;
  1344. })
  1345. });
  1346. testObject = {};
  1347. });
  1348. cases.forEach(function (item) {
  1349. describe(item.title, function () {
  1350. var popup;
  1351. beforeEach(function () {
  1352. popup = installerStep7Controller.showDatabaseConnectionWarningPopup(serviceNames, dfd);
  1353. });
  1354. it('popup body is valid', function () {
  1355. expect(popup.get('body')).to.equal(Em.I18n.t('installer.step7.popup.database.connection.body').format(bodyMessage));
  1356. });
  1357. it('after ' + item.method + ' execution', function () {
  1358. popup[item.method]();
  1359. expect(testObject.isResolved).to.equal(item.isResolved);
  1360. expect(testObject.isRejected).to.equal(item.isRejected);
  1361. expect(installerStep7Controller.get('submitButtonClicked')).to.equal(item.submitButtonClicked);
  1362. });
  1363. });
  1364. });
  1365. });
  1366. describe('#issuesFilterText', function () {
  1367. issuesFilterCases.forEach(function (item) {
  1368. it(item.title, function () {
  1369. issuesFilterTestSetup(installerStep7Controller, item);
  1370. expect(installerStep7Controller.get('issuesFilterText')).to.equal(item.issuesFilterText);
  1371. })
  1372. });
  1373. });
  1374. describe.skip('#loadServiceTagsSuccess', function () {
  1375. it('should create ClusterSiteToTagMap', function () {
  1376. var params = Em.Object.create({
  1377. serviceName: "OOZIE",
  1378. serviceConfigsDef: Em.Object.create({
  1379. configTypes: Em.Object.create({
  1380. site3: true,
  1381. site2: true,
  1382. site1: true
  1383. })
  1384. })
  1385. });
  1386. var wizardController = Em.Object.create({
  1387. allHosts: [
  1388. {hostName: 'h1'},
  1389. {hostName: 'h2'},
  1390. {hostName: 'h3'}
  1391. ]
  1392. });
  1393. installerStep7Controller.set('wizardController', wizardController);
  1394. installerStep7Controller.set('stepConfigs', Em.A([Em.Object.create({serviceName: 'OOZIE', configs: Em.A([]) })]));
  1395. var desired_configs = {
  1396. site1: {
  1397. tag: "tag1"
  1398. },
  1399. site2: {
  1400. tag: "tag2"
  1401. },
  1402. site3: {
  1403. tag: "tag3"
  1404. }
  1405. };
  1406. var data = {
  1407. config_groups: Em.A([Em.Object.create({
  1408. ConfigGroup: Em.Object.create({
  1409. tag: 'OOZIE',
  1410. hosts: Em.A([Em.Object.create({host_name: 'h1'})]),
  1411. id: 1,
  1412. group_name: "",
  1413. description: "",
  1414. desired_configs: Em.A([Em.Object.create({
  1415. type: '1',
  1416. tag: 'h1'
  1417. })])
  1418. })
  1419. })]),
  1420. Clusters: {
  1421. desired_configs: desired_configs
  1422. }
  1423. };
  1424. installerStep7Controller.loadServiceTagsSuccess(data, {}, params);
  1425. var result = installerStep7Controller.get("loadedClusterSiteToTagMap");
  1426. expect(JSON.parse(JSON.stringify(result))).to.eql(JSON.parse(JSON.stringify({"site1":"tag1","site2":"tag2","site3":"tag3"})));
  1427. })
  1428. });
  1429. describe('#issuesFilterLinkText', function () {
  1430. issuesFilterCases.forEach(function (item) {
  1431. it(item.title, function () {
  1432. issuesFilterTestSetup(installerStep7Controller, item);
  1433. expect(installerStep7Controller.get('issuesFilterLinkText')).to.equal(item.issuesFilterLinkText);
  1434. })
  1435. });
  1436. });
  1437. describe('#toggleIssuesFilter', function () {
  1438. it('should toggle issues filter', function () {
  1439. var issuesFilter = installerStep7Controller.get('filterColumns').findProperty('attributeName', 'hasIssues');
  1440. issuesFilter.set('selected', false);
  1441. installerStep7Controller.toggleIssuesFilter();
  1442. expect(issuesFilter.get('selected')).to.be.true;
  1443. installerStep7Controller.toggleIssuesFilter();
  1444. expect(issuesFilter.get('selected')).to.be.false;
  1445. });
  1446. it('selected service should be changed', function () {
  1447. installerStep7Controller.setProperties({
  1448. selectedService: {
  1449. errorCount: 0,
  1450. configGroups: []
  1451. },
  1452. stepConfigs: [
  1453. {
  1454. errorCount: 1,
  1455. configGroups: []
  1456. },
  1457. {
  1458. errorCount: 2,
  1459. configGroups: []
  1460. }
  1461. ]
  1462. });
  1463. installerStep7Controller.toggleIssuesFilter();
  1464. expect(installerStep7Controller.get('selectedService')).to.eql({
  1465. errorCount: 1,
  1466. configGroups: []
  1467. });
  1468. });
  1469. });
  1470. describe('#addKerberosDescriptorConfigs', function() {
  1471. var configs = [
  1472. { name: 'prop1', displayName: 'Prop1' },
  1473. { name: 'prop2', displayName: 'Prop2' },
  1474. { name: 'prop3', displayName: 'Prop3' }
  1475. ];
  1476. var descriptor = [
  1477. Em.Object.create({ name: 'prop4', filename: 'file-1'}),
  1478. Em.Object.create({ name: 'prop1', filename: 'file-1'})
  1479. ];
  1480. var propertiesAttrTests = [
  1481. {
  1482. attr: 'isUserProperty', val: false,
  1483. m: 'descriptor properties should not be marked as custom'
  1484. },
  1485. {
  1486. attr: 'category', val: 'Advanced file-1',
  1487. m: 'descriptor properties should be added to Advanced category'
  1488. },
  1489. {
  1490. attr: 'isOverridable', val: false,
  1491. m: 'descriptor properties should not be overriden'
  1492. }
  1493. ];
  1494. propertiesAttrTests.forEach(function(test) {
  1495. it(test.m, function() {
  1496. installerStep7Controller.addKerberosDescriptorConfigs(configs, descriptor);
  1497. expect(configs.findProperty('name', 'prop1')[test.attr]).to.be.eql(test.val);
  1498. });
  1499. });
  1500. });
  1501. describe('#errorsCount', function () {
  1502. it('should ignore configs with widgets (enhanced configs)', function () {
  1503. installerStep7Controller.reopen({selectedService: Em.Object.create({
  1504. configsWithErrors: Em.A([
  1505. Em.Object.create({widget: {}}),
  1506. Em.Object.create({widget: null})
  1507. ])
  1508. })
  1509. });
  1510. expect(installerStep7Controller.get('errorsCount')).to.equal(1);
  1511. });
  1512. });
  1513. describe('#_reconfigureServicesOnNnHa', function () {
  1514. var dfsNameservices = 'some_cluster';
  1515. Em.A([
  1516. {
  1517. serviceName: 'HBASE',
  1518. configToUpdate: 'hbase.rootdir',
  1519. oldValue: 'hdfs://nameserv:8020/apps/hbase/data',
  1520. expectedNewValue: 'hdfs://' + dfsNameservices + '/apps/hbase/data'
  1521. },
  1522. {
  1523. serviceName: 'ACCUMULO',
  1524. configToUpdate: 'instance.volumes',
  1525. oldValue: 'hdfs://localhost:8020/apps/accumulo/data',
  1526. expectedNewValue: 'hdfs://' + dfsNameservices + '/apps/accumulo/data'
  1527. },
  1528. {
  1529. serviceName: 'HAWQ',
  1530. configToUpdate: 'hawq_dfs_url',
  1531. oldValue: 'localhost:8020/hawq_data',
  1532. expectedNewValue: dfsNameservices + '/hawq_data'
  1533. }
  1534. ]).forEach(function (test) {
  1535. it(test.serviceName + ' ' + test.configToUpdate, function () {
  1536. var serviceConfigs = [App.ServiceConfig.create({
  1537. serviceName: test.serviceName,
  1538. configs: [
  1539. Em.Object.create({
  1540. name: test.configToUpdate,
  1541. value: test.oldValue
  1542. })
  1543. ]
  1544. }),
  1545. App.ServiceConfig.create({
  1546. serviceName: 'HDFS',
  1547. configs: [
  1548. Em.Object.create({
  1549. name: 'dfs.nameservices',
  1550. value: dfsNameservices
  1551. })
  1552. ]
  1553. })];
  1554. installerStep7Controller.reopen({
  1555. selectedServiceNames: [test.serviceName, 'HDFS']
  1556. });
  1557. serviceConfigs = installerStep7Controller._reconfigureServicesOnNnHa(serviceConfigs);
  1558. expect(serviceConfigs.findProperty('serviceName', test.serviceName).configs.findProperty('name', test.configToUpdate).get('value')).to.equal(test.expectedNewValue);
  1559. });
  1560. });
  1561. });
  1562. describe('#showOozieDerbyWarning', function() {
  1563. var controller;
  1564. beforeEach(function() {
  1565. controller = App.WizardStep7Controller.create({});
  1566. sinon.stub(App.ModalPopup, 'show', Em.K);
  1567. });
  1568. afterEach(function() {
  1569. App.ModalPopup.show.restore();
  1570. });
  1571. Em.A([
  1572. {
  1573. selectedServiceNames: ['HDFS', 'OOZIE'],
  1574. databaseType: Em.I18n.t('installer.step7.oozie.database.new'),
  1575. e: true,
  1576. m: 'Oozie selected with derby database, warning popup should be shown'
  1577. },
  1578. {
  1579. selectedServiceNames: ['HDFS'],
  1580. databaseType: Em.I18n.t('installer.step7.oozie.database.new'),
  1581. e: false,
  1582. m: 'Oozie not selected warning popup should be skipped'
  1583. },
  1584. {
  1585. selectedServiceNames: ['HDFS', 'OOZIE'],
  1586. databaseType: 'New Mysql Database',
  1587. e: false,
  1588. m: 'Oozie selected, mysql database used, warning popup should be sk'
  1589. }
  1590. ]).forEach(function(test) {
  1591. describe(test.m, function() {
  1592. beforeEach(function () {
  1593. sinon.stub(controller, 'findConfigProperty').returns(Em.Object.create({ value: test.databaseType}));
  1594. controller.reopen({
  1595. selectedServiceNames: test.selectedServiceNames
  1596. });
  1597. controller.showOozieDerbyWarningPopup(Em.K);
  1598. });
  1599. afterEach(function () {
  1600. controller.findConfigProperty.restore();
  1601. });
  1602. it('modal popup is shown needed number of times', function () {
  1603. expect(App.ModalPopup.show.calledOnce).to.equal(test.e);
  1604. });
  1605. });
  1606. });
  1607. });
  1608. describe('#addHostNamesToConfigs', function() {
  1609. beforeEach(function () {
  1610. sinon.stub(App.StackServiceComponent, 'find', function () {
  1611. return Em.Object.create({
  1612. id: 'NAMENODE',
  1613. displayName: 'NameNode'
  1614. });
  1615. });
  1616. });
  1617. afterEach(function () {
  1618. App.StackServiceComponent.find.restore();
  1619. });
  1620. it('should not create duplicate configs', function () {
  1621. var serviceConfig = Em.Object.create({
  1622. configs: [],
  1623. serviceName: 'HDFS',
  1624. configCategories: [
  1625. {
  1626. showHost: true,
  1627. name: 'NAMENODE'
  1628. }
  1629. ]
  1630. });
  1631. var masterComponents = [
  1632. {component: 'NAMENODE', hostName: 'h1'}
  1633. ];
  1634. var slaveComponents = [];
  1635. installerStep7Controller.addHostNamesToConfigs(serviceConfig, masterComponents, slaveComponents);
  1636. expect(serviceConfig.get('configs').filterProperty('name', 'namenode_host').length).to.equal(1);
  1637. installerStep7Controller.addHostNamesToConfigs(serviceConfig, masterComponents, slaveComponents);
  1638. expect(serviceConfig.get('configs').filterProperty('name', 'namenode_host').length).to.equal(1);
  1639. });
  1640. });
  1641. describe('#resolveHiveMysqlDatabase', function () {
  1642. beforeEach(function () {
  1643. installerStep7Controller.get('content').setProperties({
  1644. services: Em.A([
  1645. Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false})
  1646. ])
  1647. });
  1648. installerStep7Controller.setProperties({
  1649. stepConfigs: Em.A([
  1650. Em.Object.create({serviceName: 'HIVE', configs: [{name: 'hive_database', value: 'New MySQL Database'}]})
  1651. ]),
  1652. mySQLServerConflict: true
  1653. });
  1654. sinon.stub(installerStep7Controller, 'moveNext', Em.K);
  1655. sinon.stub(installerStep7Controller, 'checkMySQLHost', function () {
  1656. return $.Deferred().resolve();
  1657. });
  1658. sinon.spy(App.ModalPopup, 'show');
  1659. });
  1660. afterEach(function () {
  1661. installerStep7Controller.moveNext.restore();
  1662. installerStep7Controller.checkMySQLHost.restore();
  1663. App.ModalPopup.show.restore();
  1664. });
  1665. it('no HIVE service', function () {
  1666. installerStep7Controller.set('content.services', Em.A([]));
  1667. installerStep7Controller.resolveHiveMysqlDatabase();
  1668. expect(installerStep7Controller.moveNext.calledOnce).to.be.true;
  1669. expect(App.ModalPopup.show.called).to.be.false;
  1670. });
  1671. it('if mySQLServerConflict, popup is shown', function () {
  1672. installerStep7Controller.resolveHiveMysqlDatabase();
  1673. expect(installerStep7Controller.moveNext.called).to.be.false;
  1674. expect(App.ModalPopup.show.calledOnce).to.be.true;
  1675. });
  1676. });
  1677. describe('#mySQLWarningHandler', function () {
  1678. beforeEach(function () {
  1679. installerStep7Controller.set('mySQLServerConflict', true);
  1680. sinon.spy(App.ModalPopup, 'show');
  1681. sinon.stub(App.router, 'get').returns({gotoStep: Em.K});
  1682. sinon.stub(App.router.get(), 'gotoStep', Em.K);
  1683. });
  1684. afterEach(function () {
  1685. App.ModalPopup.show.restore();
  1686. App.router.get().gotoStep.restore();
  1687. App.router.get.restore();
  1688. });
  1689. it('warning popup is shown', function () {
  1690. installerStep7Controller.mySQLWarningHandler();
  1691. expect(App.ModalPopup.show.calledOnce).to.be.true;
  1692. });
  1693. it('submitButtonClicked is set to false on primary click', function () {
  1694. installerStep7Controller.mySQLWarningHandler().onPrimary();
  1695. expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
  1696. });
  1697. it('second popup is shown on secondary click', function () {
  1698. installerStep7Controller.mySQLWarningHandler().onSecondary();
  1699. expect(App.ModalPopup.show.calledTwice).to.be.true;
  1700. });
  1701. it('submitButtonClicked is set to false on secondary click on the second popup', function () {
  1702. installerStep7Controller.mySQLWarningHandler().onSecondary().onSecondary();
  1703. expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
  1704. });
  1705. it('user is moved to step5 on primary click on the second popup (installerController)', function () {
  1706. installerStep7Controller.set('content.controllerName', 'installerController');
  1707. installerStep7Controller.mySQLWarningHandler().onSecondary().onPrimary();
  1708. expect(App.router.get('installerController').gotoStep.calledWith(5, true)).to.be.true;
  1709. });
  1710. it('user is moved to step2 on primary click on the second popup (addSeviceController)', function () {
  1711. installerStep7Controller.set('content.controllerName', 'addServiceController');
  1712. installerStep7Controller.mySQLWarningHandler().onSecondary().onPrimary();
  1713. expect(App.router.get('addSeviceController').gotoStep.calledWith(2, true)).to.be.true;
  1714. });
  1715. });
  1716. });