step7_test.js 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936
  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('#addHawqConfigsOnNnHa', function () {
  1502. var configs = [
  1503. {
  1504. id: 'dfs.nameservices__hdfs-site',
  1505. description: 'dfs.nameservices__hdfs-site',
  1506. displayName: 'dfs.nameservices',
  1507. displayType: 'string',
  1508. name: 'dfs.nameservices',
  1509. value: 'haservice',
  1510. recommendedValue: 'haservice'
  1511. },
  1512. {
  1513. id: 'dfs.ha.namenodes.haservice__hdfs-site',
  1514. description: 'dfs.ha.namenodes.haservice__hdfs-site',
  1515. displayName: 'dfs.ha.namenodes.haservice',
  1516. displayType: 'string',
  1517. name: 'dfs.ha.namenodes.haservice',
  1518. value: 'nn1,nn2',
  1519. recommendedValue: 'nn1,nn2'
  1520. },
  1521. {
  1522. id: 'dfs.namenode.rpc-address.haservice.nn1__hdfs-site',
  1523. description: 'dfs.namenode.rpc-address.haservice.nn1__hdfs-site',
  1524. displayName: 'dfs.namenode.rpc-address.haservice.nn1',
  1525. displayType: 'string',
  1526. name: 'dfs.namenode.rpc-address.haservice.nn1',
  1527. value: 'c6401.ambari.apache.org:8020',
  1528. recommendedValue: 'c6401.ambari.apache.org:8020'
  1529. },
  1530. {
  1531. id: 'dfs.namenode.rpc-address.haservice.nn2__hdfs-site',
  1532. description: 'dfs.namenode.rpc-address.haservice.nn2__hdfs-site',
  1533. displayName: 'dfs.namenode.rpc-address.haservice.nn2',
  1534. displayType: 'string',
  1535. name: 'dfs.namenode.rpc-address.haservice.nn2',
  1536. value: 'c6402.ambari.apache.org:8020',
  1537. recommendedValue: 'c6402.ambari.apache.org:8020'
  1538. },
  1539. {
  1540. id: 'dfs.namenode.http-address.haservice.nn1__hdfs-site',
  1541. description: 'dfs.namenode.http-address.haservice.nn1__hdfs-site',
  1542. displayName: 'dfs.namenode.http-address.haservice.nn1',
  1543. displayType: 'string',
  1544. name: 'dfs.namenode.http-address.haservice.nn1',
  1545. value: 'c6401.ambari.apache.org:50070',
  1546. recommendedValue: 'c6401.ambari.apache.org:50070'
  1547. },
  1548. {
  1549. id: 'dfs.namenode.http-address.haservice.nn2__hdfs-site',
  1550. description: 'dfs.namenode.http-address.haservice.nn2__hdfs-site',
  1551. displayName: 'dfs.namenode.http-address.haservice.nn2',
  1552. displayType: 'string',
  1553. name: 'dfs.namenode.http-address.haservice.nn2',
  1554. value: 'c6402.ambari.apache.org:50070',
  1555. recommendedValue: 'c6402.ambari.apache.org:50070'
  1556. }
  1557. ];
  1558. it('should copy properties from hdfs-site to hdfs-client for HAWQ', function() {
  1559. var oldConfigs = configs.slice();
  1560. installerStep7Controller.addHawqConfigsOnNnHa(configs);
  1561. oldConfigs.forEach(function(property){
  1562. // find the same property in hdfs-client for HAWQ and see if attribute value matches with the corresponding property's attribute value in hdfs-site
  1563. expect(configs.findProperty('id', property.name + '__hdfs-client').description).to.be.eql(property.description);
  1564. expect(configs.findProperty('id', property.name + '__hdfs-client').displayName).to.be.eql(property.displayName);
  1565. expect(configs.findProperty('id', property.name + '__hdfs-client').value).to.be.eql(property.value);
  1566. expect(configs.findProperty('id', property.name + '__hdfs-client').recommendedValue).to.be.eql(property.recommendedValue);
  1567. });
  1568. });
  1569. });
  1570. describe('#errorsCount', function () {
  1571. it('should ignore configs with widgets (enhanced configs)', function () {
  1572. installerStep7Controller.reopen({selectedService: Em.Object.create({
  1573. configsWithErrors: Em.A([
  1574. Em.Object.create({widget: {}}),
  1575. Em.Object.create({widget: null})
  1576. ])
  1577. })
  1578. });
  1579. expect(installerStep7Controller.get('errorsCount')).to.equal(1);
  1580. });
  1581. });
  1582. describe('#_reconfigureServicesOnNnHa', function () {
  1583. var dfsNameservices = 'some_cluster';
  1584. Em.A([
  1585. {
  1586. serviceName: 'HBASE',
  1587. configToUpdate: 'hbase.rootdir',
  1588. oldValue: 'hdfs://nameserv:8020/apps/hbase/data',
  1589. expectedNewValue: 'hdfs://' + dfsNameservices + '/apps/hbase/data'
  1590. },
  1591. {
  1592. serviceName: 'ACCUMULO',
  1593. configToUpdate: 'instance.volumes',
  1594. oldValue: 'hdfs://localhost:8020/apps/accumulo/data',
  1595. expectedNewValue: 'hdfs://' + dfsNameservices + '/apps/accumulo/data'
  1596. },
  1597. {
  1598. serviceName: 'HAWQ',
  1599. configToUpdate: 'hawq_dfs_url',
  1600. oldValue: 'localhost:8020/hawq_data',
  1601. expectedNewValue: dfsNameservices + '/hawq_data'
  1602. }
  1603. ]).forEach(function (test) {
  1604. it(test.serviceName + ' ' + test.configToUpdate, function () {
  1605. var serviceConfigs = [App.ServiceConfig.create({
  1606. serviceName: test.serviceName,
  1607. configs: [
  1608. Em.Object.create({
  1609. name: test.configToUpdate,
  1610. value: test.oldValue
  1611. })
  1612. ]
  1613. }),
  1614. App.ServiceConfig.create({
  1615. serviceName: 'HDFS',
  1616. configs: [
  1617. Em.Object.create({
  1618. name: 'dfs.nameservices',
  1619. value: dfsNameservices
  1620. })
  1621. ]
  1622. })];
  1623. installerStep7Controller.reopen({
  1624. selectedServiceNames: [test.serviceName, 'HDFS']
  1625. });
  1626. serviceConfigs = installerStep7Controller._reconfigureServicesOnNnHa(serviceConfigs);
  1627. expect(serviceConfigs.findProperty('serviceName', test.serviceName).configs.findProperty('name', test.configToUpdate).get('value')).to.equal(test.expectedNewValue);
  1628. });
  1629. });
  1630. });
  1631. describe('#showOozieDerbyWarning', function() {
  1632. var controller;
  1633. beforeEach(function() {
  1634. controller = App.WizardStep7Controller.create({});
  1635. sinon.stub(App.ModalPopup, 'show', Em.K);
  1636. });
  1637. afterEach(function() {
  1638. App.ModalPopup.show.restore();
  1639. });
  1640. Em.A([
  1641. {
  1642. selectedServiceNames: ['HDFS', 'OOZIE'],
  1643. databaseType: Em.I18n.t('installer.step7.oozie.database.new'),
  1644. e: true,
  1645. m: 'Oozie selected with derby database, warning popup should be shown'
  1646. },
  1647. {
  1648. selectedServiceNames: ['HDFS'],
  1649. databaseType: Em.I18n.t('installer.step7.oozie.database.new'),
  1650. e: false,
  1651. m: 'Oozie not selected warning popup should be skipped'
  1652. },
  1653. {
  1654. selectedServiceNames: ['HDFS', 'OOZIE'],
  1655. databaseType: 'New Mysql Database',
  1656. e: false,
  1657. m: 'Oozie selected, mysql database used, warning popup should be sk'
  1658. }
  1659. ]).forEach(function(test) {
  1660. describe(test.m, function() {
  1661. beforeEach(function () {
  1662. sinon.stub(controller, 'findConfigProperty').returns(Em.Object.create({ value: test.databaseType}));
  1663. controller.reopen({
  1664. selectedServiceNames: test.selectedServiceNames
  1665. });
  1666. controller.showOozieDerbyWarningPopup(Em.K);
  1667. });
  1668. afterEach(function () {
  1669. controller.findConfigProperty.restore();
  1670. });
  1671. it('modal popup is shown needed number of times', function () {
  1672. expect(App.ModalPopup.show.calledOnce).to.equal(test.e);
  1673. });
  1674. });
  1675. });
  1676. });
  1677. describe('#addHostNamesToConfigs', function() {
  1678. beforeEach(function () {
  1679. sinon.stub(App.StackServiceComponent, 'find', function () {
  1680. return Em.Object.create({
  1681. id: 'NAMENODE',
  1682. displayName: 'NameNode'
  1683. });
  1684. });
  1685. });
  1686. afterEach(function () {
  1687. App.StackServiceComponent.find.restore();
  1688. });
  1689. it('should not create duplicate configs', function () {
  1690. var serviceConfig = Em.Object.create({
  1691. configs: [],
  1692. serviceName: 'HDFS',
  1693. configCategories: [
  1694. {
  1695. showHost: true,
  1696. name: 'NAMENODE'
  1697. }
  1698. ]
  1699. });
  1700. var masterComponents = [
  1701. {component: 'NAMENODE', hostName: 'h1'}
  1702. ];
  1703. var slaveComponents = [];
  1704. installerStep7Controller.addHostNamesToConfigs(serviceConfig, masterComponents, slaveComponents);
  1705. expect(serviceConfig.get('configs').filterProperty('name', 'namenode_host').length).to.equal(1);
  1706. installerStep7Controller.addHostNamesToConfigs(serviceConfig, masterComponents, slaveComponents);
  1707. expect(serviceConfig.get('configs').filterProperty('name', 'namenode_host').length).to.equal(1);
  1708. });
  1709. });
  1710. describe('#resolveHiveMysqlDatabase', function () {
  1711. beforeEach(function () {
  1712. installerStep7Controller.get('content').setProperties({
  1713. services: Em.A([
  1714. Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false})
  1715. ])
  1716. });
  1717. installerStep7Controller.setProperties({
  1718. stepConfigs: Em.A([
  1719. Em.Object.create({serviceName: 'HIVE', configs: [{name: 'hive_database', value: 'New MySQL Database'}]})
  1720. ]),
  1721. mySQLServerConflict: true
  1722. });
  1723. sinon.stub(installerStep7Controller, 'moveNext', Em.K);
  1724. sinon.stub(installerStep7Controller, 'checkMySQLHost', function () {
  1725. return $.Deferred().resolve();
  1726. });
  1727. sinon.spy(App.ModalPopup, 'show');
  1728. });
  1729. afterEach(function () {
  1730. installerStep7Controller.moveNext.restore();
  1731. installerStep7Controller.checkMySQLHost.restore();
  1732. App.ModalPopup.show.restore();
  1733. });
  1734. it('no HIVE service', function () {
  1735. installerStep7Controller.set('content.services', Em.A([]));
  1736. installerStep7Controller.resolveHiveMysqlDatabase();
  1737. expect(installerStep7Controller.moveNext.calledOnce).to.be.true;
  1738. expect(App.ModalPopup.show.called).to.be.false;
  1739. });
  1740. it('if mySQLServerConflict, popup is shown', function () {
  1741. installerStep7Controller.resolveHiveMysqlDatabase();
  1742. expect(installerStep7Controller.moveNext.called).to.be.false;
  1743. expect(App.ModalPopup.show.calledOnce).to.be.true;
  1744. });
  1745. });
  1746. describe('#mySQLWarningHandler', function () {
  1747. beforeEach(function () {
  1748. installerStep7Controller.set('mySQLServerConflict', true);
  1749. sinon.spy(App.ModalPopup, 'show');
  1750. sinon.stub(App.router, 'get').returns({gotoStep: Em.K});
  1751. sinon.stub(App.router.get(), 'gotoStep', Em.K);
  1752. });
  1753. afterEach(function () {
  1754. App.ModalPopup.show.restore();
  1755. App.router.get().gotoStep.restore();
  1756. App.router.get.restore();
  1757. });
  1758. it('warning popup is shown', function () {
  1759. installerStep7Controller.mySQLWarningHandler();
  1760. expect(App.ModalPopup.show.calledOnce).to.be.true;
  1761. });
  1762. it('submitButtonClicked is set to false on primary click', function () {
  1763. installerStep7Controller.mySQLWarningHandler().onPrimary();
  1764. expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
  1765. });
  1766. it('second popup is shown on secondary click', function () {
  1767. installerStep7Controller.mySQLWarningHandler().onSecondary();
  1768. expect(App.ModalPopup.show.calledTwice).to.be.true;
  1769. });
  1770. it('submitButtonClicked is set to false on secondary click on the second popup', function () {
  1771. installerStep7Controller.mySQLWarningHandler().onSecondary().onSecondary();
  1772. expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
  1773. });
  1774. it('user is moved to step5 on primary click on the second popup (installerController)', function () {
  1775. installerStep7Controller.set('content.controllerName', 'installerController');
  1776. installerStep7Controller.mySQLWarningHandler().onSecondary().onPrimary();
  1777. expect(App.router.get('installerController').gotoStep.calledWith(5, true)).to.be.true;
  1778. });
  1779. it('user is moved to step2 on primary click on the second popup (addSeviceController)', function () {
  1780. installerStep7Controller.set('content.controllerName', 'addServiceController');
  1781. installerStep7Controller.mySQLWarningHandler().onSecondary().onPrimary();
  1782. expect(App.router.get('addSeviceController').gotoStep.calledWith(2, true)).to.be.true;
  1783. });
  1784. });
  1785. });