step7_test.js 64 KB

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