step7_test.js 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. require('mixins/common/localStorage');
  20. require('controllers/wizard/step7_controller');
  21. var testHelpers = require('test/helpers');
  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.config, 'setPreDefinedServiceConfigs', Em.K);
  108. installerStep7Controller = getController();
  109. App.router.nextBtnClickInProgress = false;
  110. });
  111. afterEach(function() {
  112. App.router.nextBtnClickInProgress = false;
  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('#checkDatabaseConnectionTest', function () {
  248. beforeEach(function () {
  249. installerStep7Controller.set('content', {
  250. services: Em.A([
  251. Em.Object.create({isSelected: true, isInstalled: false, serviceName: 'OOZIE', ignored: []}),
  252. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 'HIVE', ignored: []}),
  253. Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's3', ignored: []}),
  254. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's4', ignored: []}),
  255. Em.Object.create({isSelected: true, isInstalled: false, serviceName: 's5', ignored: []}),
  256. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's6', ignored: []}),
  257. Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's7', ignored: []}),
  258. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's8', ignored: []})
  259. ])
  260. });
  261. var obj = Em.Object.create({name:'oozie_database',value:"aa"});
  262. installerStep7Controller.set('stepConfigs',Em.A([Em.Object.create({serviceName: 'OOZIE', configs: Em.A([obj]) })]));
  263. this.deffer = installerStep7Controller.checkDatabaseConnectionTest();
  264. });
  265. it('should return promise in process', function () {
  266. expect(this.deffer.isResolved()).to.equal(false);
  267. this.deffer.resolve(true);
  268. this.deffer.done(function(data) {
  269. expect(data).to.equal(true);
  270. });
  271. });
  272. });
  273. describe.skip('#submit', function () {
  274. beforeEach(function () {
  275. sinon.stub(App, 'get').withArgs('supports.preInstallChecks').returns(false);
  276. });
  277. afterEach(function () {
  278. App.get.restore();
  279. });
  280. it('should return false if submit disabled', function () {
  281. installerStep7Controller.set('isSubmitDisabled',true);
  282. expect(installerStep7Controller.submit()).to.be.false;
  283. });
  284. it('sumbit button should be unclicked if no configs', function () {
  285. installerStep7Controller.set('isSubmitDisabled',false);
  286. installerStep7Controller.submit();
  287. expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
  288. });
  289. it('if Next button is clicked multiple times before the next step renders, it must not be processed',function(){
  290. installerStep7Controller.submit();
  291. expect(App.router.send.calledWith('next')).to.equal(true);
  292. App.router.send.reset();
  293. installerStep7Controller.submit();
  294. expect(App.router.send.calledWith('next')).to.equal(false);
  295. });
  296. });
  297. describe('#getConfigTagsSuccess', function () {
  298. beforeEach(function(){
  299. sinon.stub(App.StackService, 'find', function () {
  300. return [
  301. Em.Object.create({
  302. serviceName: 's0',
  303. isInstalled: true,
  304. configTypes: {
  305. site3: true,
  306. site1: true
  307. }
  308. }),
  309. Em.Object.create({
  310. serviceName: 's1',
  311. isInstalled: true,
  312. configTypes: {
  313. site1: true,
  314. site2: true
  315. }
  316. })
  317. ];
  318. });
  319. });
  320. afterEach(function(){
  321. App.StackService.find.restore();
  322. });
  323. it('should return serviceConfigTags', function () {
  324. var desiredConfigs = {
  325. site1: {
  326. tag: "tag1"
  327. },
  328. site2: {
  329. tag: "tag2"
  330. },
  331. site3: {
  332. tag: "tag3"
  333. }
  334. };
  335. var data = {
  336. Clusters: {
  337. desired_configs: desiredConfigs
  338. }
  339. };
  340. installerStep7Controller.getConfigTagsSuccess(data);
  341. expect(installerStep7Controller.get('serviceConfigTags')).to.eql([
  342. {
  343. "siteName": "site1",
  344. "tagName": "tag1",
  345. "newTagName": null
  346. },
  347. {
  348. "siteName": "site2",
  349. "tagName": "tag2",
  350. "newTagName": null
  351. },
  352. {
  353. "siteName": "site3",
  354. "tagName": "tag3",
  355. "newTagName": null
  356. }
  357. ]);
  358. expect(installerStep7Controller.get('isAppliedConfigLoaded')).to.equal(true);
  359. });
  360. });
  361. describe('#clearStep', function () {
  362. it('should clear stepConfigs', function () {
  363. installerStep7Controller.set('stepConfigs', [
  364. {},
  365. {}
  366. ]);
  367. installerStep7Controller.clearStep();
  368. expect(installerStep7Controller.get('stepConfigs.length')).to.equal(0);
  369. });
  370. it('should clear filter', function () {
  371. installerStep7Controller.set('filter', 'filter');
  372. installerStep7Controller.clearStep();
  373. expect(installerStep7Controller.get('filter')).to.equal('');
  374. });
  375. it('should set for each filterColumns "selected" false', function () {
  376. installerStep7Controller.set('filterColumns', [
  377. {selected: true},
  378. {selected: false},
  379. {selected: true}
  380. ]);
  381. installerStep7Controller.clearStep();
  382. expect(installerStep7Controller.get('filterColumns').everyProperty('selected', false)).to.equal(true);
  383. });
  384. });
  385. describe('#getConfigTags', function () {
  386. it('should do ajax-request', function () {
  387. installerStep7Controller.getConfigTags();
  388. var args = testHelpers.findAjaxRequest('name', 'config.tags');
  389. expect(args).exists;
  390. });
  391. });
  392. describe('#setGroupsToDelete', function () {
  393. beforeEach(function () {
  394. installerStep7Controller.set('wizardController', Em.Object.create(App.LocalStorage, {name: 'tdk'}));
  395. });
  396. it('should add new groups to groupsToDelete', function () {
  397. var groupsToDelete = [
  398. {configGroupId: '1'},
  399. {configGroupId: '2'}
  400. ],
  401. groups = [
  402. Em.Object.create({configGroupId: '3'}),
  403. Em.Object.create(),
  404. Em.Object.create({configGroupId: '5'})
  405. ],
  406. expected = [
  407. {configGroupId: "1"},
  408. {configGroupId: "2"},
  409. {configGroupId: "3"},
  410. {configGroupId: "5"}
  411. ];
  412. installerStep7Controller.set('groupsToDelete', groupsToDelete);
  413. installerStep7Controller.setGroupsToDelete(groups);
  414. expect(installerStep7Controller.get('groupsToDelete')).to.eql(expected);
  415. expect(installerStep7Controller.get('wizardController').getDBProperty('groupsToDelete')).to.eql(expected);
  416. });
  417. });
  418. describe('#checkMySQLHost', function () {
  419. it('should send query', function () {
  420. installerStep7Controller.checkMySQLHost();
  421. var args = testHelpers.findAjaxRequest('name', 'ambari.service');
  422. expect(args).exists;
  423. });
  424. });
  425. describe('#selectConfigGroup', function () {
  426. beforeEach(function () {
  427. installerStep7Controller.reopen({content: {services: []}});
  428. sinon.stub(installerStep7Controller, 'switchConfigGroupConfigs', Em.K);
  429. });
  430. afterEach(function () {
  431. installerStep7Controller.switchConfigGroupConfigs.restore();
  432. });
  433. it('should set selectedConfigGroup', function () {
  434. var group = {':': []};
  435. installerStep7Controller.selectConfigGroup({context: group});
  436. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(group);
  437. });
  438. });
  439. describe('#selectedServiceObserver', function () {
  440. beforeEach(function () {
  441. installerStep7Controller.reopen({content: {services: []}});
  442. sinon.stub(installerStep7Controller, 'switchConfigGroupConfigs', Em.K);
  443. });
  444. afterEach(function () {
  445. installerStep7Controller.switchConfigGroupConfigs.restore();
  446. });
  447. it('shouldn\'t do nothing if App.supports.hostOverridesInstaller is false', function () {
  448. App.set('supports.hostOverridesInstaller', false);
  449. var configGroups = [
  450. {},
  451. {}
  452. ],
  453. selectedConfigGroup = {};
  454. installerStep7Controller.reopen({configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
  455. installerStep7Controller.selectedServiceObserver();
  456. expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
  457. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
  458. });
  459. it('shouldn\'t do nothing if selectedService is null', function () {
  460. App.set('supports.hostOverridesInstaller', true);
  461. var configGroups = [
  462. {},
  463. {}
  464. ],
  465. selectedConfigGroup = {};
  466. installerStep7Controller.reopen({selectedService: null, configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
  467. installerStep7Controller.selectedServiceObserver();
  468. expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
  469. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
  470. });
  471. it('shouldn\'t do nothing if selectedService.serviceName is MISC', function () {
  472. App.set('supports.hostOverridesInstaller', true);
  473. var configGroups = [
  474. {},
  475. {}
  476. ],
  477. selectedConfigGroup = {};
  478. installerStep7Controller.reopen({selectedService: {serviceName: 'MISC'}, configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
  479. installerStep7Controller.selectedServiceObserver();
  480. expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
  481. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
  482. });
  483. it('should update configGroups and selectedConfigGroup', function () {
  484. App.set('supports.hostOverridesInstaller', true);
  485. var defaultGroup = {isDefault: true, n: 'n2'},
  486. configGroups = [
  487. {isDefault: false, n: 'n1'},
  488. defaultGroup,
  489. {n: 'n3'}
  490. ];
  491. installerStep7Controller.reopen({selectedService: {serviceName: 's1', configGroups: configGroups}});
  492. installerStep7Controller.selectedServiceObserver();
  493. expect(installerStep7Controller.get('configGroups').mapProperty('n')).to.eql(['n2', 'n1', 'n3']);
  494. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(defaultGroup);
  495. });
  496. });
  497. describe('#loadConfigGroups', function () {
  498. beforeEach(function () {
  499. installerStep7Controller.reopen({
  500. wizardController: Em.Object.create({
  501. allHosts: [
  502. {hostName: 'h1'},
  503. {hostName: 'h2'},
  504. {hostName: 'h3'}
  505. ]
  506. })
  507. });
  508. });
  509. afterEach(function () {
  510. App.ServiceConfigGroup.find().clear();
  511. });
  512. it('shouldn\'t do nothing if only MISC available', function () {
  513. var configGroups = [
  514. {}
  515. ];
  516. installerStep7Controller.reopen({
  517. stepConfigs: [Em.Object.create({serviceName: 'MISC', configGroups: configGroups})]
  518. });
  519. installerStep7Controller.loadConfigGroups([]);
  520. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups')).to.eql(configGroups);
  521. });
  522. });
  523. describe('#_getDisplayedConfigGroups', function () {
  524. it('should return [] if no selected group', function () {
  525. installerStep7Controller.reopen({
  526. content: {services: []},
  527. selectedConfigGroup: null
  528. });
  529. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([]);
  530. });
  531. it('should return default config group if another selected', function () {
  532. var defaultGroup = Em.Object.create({isDefault: false});
  533. installerStep7Controller.reopen({
  534. content: {services: []},
  535. selectedConfigGroup: defaultGroup
  536. });
  537. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([defaultGroup]);
  538. });
  539. it('should return other groups if default selected', function () {
  540. var defaultGroup = Em.Object.create({isDefault: true}),
  541. cfgG = Em.Object.create({isDefault: true}),
  542. configGroups = Em.A([
  543. Em.Object.create({isDefault: false}),
  544. Em.Object.create({isDefault: false}),
  545. cfgG,
  546. Em.Object.create({isDefault: false})
  547. ]);
  548. installerStep7Controller.reopen({
  549. content: {services: []},
  550. selectedConfigGroup: defaultGroup,
  551. selectedService: {configGroups: configGroups}
  552. });
  553. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql(configGroups.without(cfgG));
  554. });
  555. });
  556. describe('#_setEditableValue', function () {
  557. it('shouldn\'t update config if no selectedConfigGroup', function () {
  558. installerStep7Controller.reopen({
  559. selectedConfigGroup: null
  560. });
  561. var config = Em.Object.create({isEditable: null});
  562. var updatedConfig = installerStep7Controller._setEditableValue(config);
  563. expect(updatedConfig.get('isEditable')).to.be.null;
  564. });
  565. it('should set isEditable equal to selectedGroup.isDefault if service not installed', function () {
  566. var isDefault = true;
  567. installerStep7Controller.reopen({
  568. installedServiceNames: [],
  569. selectedService: {serviceName: 'abc'},
  570. selectedConfigGroup: Em.Object.create({isDefault: isDefault})
  571. });
  572. var config = Em.Object.create({isEditable: null});
  573. var updatedConfig = installerStep7Controller._setEditableValue(config);
  574. expect(updatedConfig.get('isEditable')).to.equal(isDefault);
  575. installerStep7Controller.toggleProperty('selectedConfigGroup.isDefault');
  576. updatedConfig = installerStep7Controller._setEditableValue(config);
  577. expect(updatedConfig.get('isEditable')).to.equal(!isDefault);
  578. });
  579. Em.A([
  580. {
  581. isEditable: false,
  582. isReconfigurable: false,
  583. isDefault: true,
  584. e: false
  585. },
  586. {
  587. isEditable: true,
  588. isReconfigurable: true,
  589. isDefault: true,
  590. e: true
  591. },
  592. {
  593. isEditable: false,
  594. isReconfigurable: true,
  595. isDefault: false,
  596. e: false
  597. },
  598. {
  599. isEditable: true,
  600. isReconfigurable: false,
  601. isDefault: false,
  602. e: false
  603. }
  604. ]).forEach(function (test) {
  605. it('service installed, isEditable = ' + test.isEditable.toString() + ', isReconfigurable = ' + test.isReconfigurable.toString(), function () {
  606. var config = Em.Object.create({
  607. isReconfigurable: test.isReconfigurable,
  608. isEditable: test.isEditable
  609. });
  610. installerStep7Controller.reopen({
  611. installedServiceNames: Em.A(['a']),
  612. selectedService: Em.Object.create({serviceName: 'a'}),
  613. selectedConfigGroup: Em.Object.create({isDefault: test.isDefault})
  614. });
  615. var updateConfig = installerStep7Controller._setEditableValue(config);
  616. expect(updateConfig.get('isEditable')).to.equal(test.e);
  617. });
  618. });
  619. });
  620. describe('#_setOverrides', function () {
  621. it('shouldn\'t update config if no selectedConfigGroup', function () {
  622. installerStep7Controller.reopen({
  623. selectedConfigGroup: null
  624. });
  625. var config = Em.Object.create({overrides: null});
  626. var updatedConfig = installerStep7Controller._setOverrides(config, []);
  627. expect(updatedConfig.get('overrides')).to.be.null;
  628. });
  629. describe('no overrideToAdd', function () {
  630. var isDefault;
  631. beforeEach(function () {
  632. isDefault = true;
  633. var name = 'n1',
  634. config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
  635. overrides = Em.A([
  636. Em.Object.create({name: name, value: 'v1'}),
  637. Em.Object.create({name: name, value: 'v2'}),
  638. Em.Object.create({name: 'n2', value: 'v3'})
  639. ]);
  640. installerStep7Controller.reopen({
  641. overrideToAdd: null,
  642. selectedConfigGroup: Em.Object.create({
  643. isDefault: isDefault
  644. })
  645. });
  646. this.updatedConfig = installerStep7Controller._setOverrides(config, overrides);
  647. });
  648. it('2 overrides', function () {
  649. expect(this.updatedConfig.get('overrides.length')).to.equal(2);
  650. });
  651. it('each isEditable is ' + !isDefault, function () {
  652. expect(this.updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
  653. });
  654. it('each parentSCP.flag is `flag`', function () {
  655. expect(this.updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
  656. });
  657. });
  658. describe('overrideToAdd exists', function () {
  659. var isDefault = true;
  660. beforeEach(function () {
  661. var name = 'n1',
  662. config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
  663. overrides = Em.A([
  664. Em.Object.create({name: name, value: 'v1'}),
  665. Em.Object.create({name: name, value: 'v2'}),
  666. Em.Object.create({name: 'n2', value: 'v3'})
  667. ]);
  668. installerStep7Controller.reopen({
  669. overrideToAdd: Em.Object.create({name: name}),
  670. selectedService: {configGroups: [Em.Object.create({name: 'n', properties: []})]},
  671. selectedConfigGroup: Em.Object.create({
  672. isDefault: isDefault,
  673. name: 'n'
  674. })
  675. });
  676. this.updatedConfig = installerStep7Controller._setOverrides(config, overrides);
  677. });
  678. it('3 overrides', function () {
  679. expect(this.updatedConfig.get('overrides.length')).to.equal(3);
  680. });
  681. it('each isEditable is ' + !isDefault, function () {
  682. expect(this.updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
  683. });
  684. it('each parentSCP.flag is `flag`', function () {
  685. expect(this.updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
  686. });
  687. });
  688. });
  689. describe('#switchConfigGroupConfigs', function () {
  690. it('if selectedConfigGroup is null, serviceConfigs shouldn\'t be changed', function () {
  691. installerStep7Controller.reopen({
  692. selectedConfigGroup: null,
  693. content: {services: []},
  694. serviceConfigs: {configs: [
  695. {overrides: []},
  696. {overrides: []}
  697. ]}
  698. });
  699. installerStep7Controller.switchConfigGroupConfigs();
  700. expect(installerStep7Controller.get('serviceConfigs.configs').everyProperty('overrides.length', 0)).to.equal(true);
  701. });
  702. describe('should set configs for serviceConfigs', function () {
  703. var configGroups = [
  704. Em.Object.create({
  705. properties: [
  706. {name: 'g1', value: 'v1'},
  707. {name: 'g2', value: 'v2'}
  708. ]
  709. })
  710. ];
  711. beforeEach(function () {
  712. sinon.stub(installerStep7Controller, '_getDisplayedConfigGroups', function () {
  713. return configGroups;
  714. });
  715. sinon.stub(installerStep7Controller, '_setEditableValue', function (config) {
  716. config.set('isEditable', true);
  717. return config;
  718. });
  719. installerStep7Controller.reopen({
  720. selectedConfigGroup: Em.Object.create({isDefault: true, name: 'g1'}),
  721. content: {services: []},
  722. selectedService: {configs: Em.A([Em.Object.create({name: 'g1', overrides: [], properties: []}), Em.Object.create({name: 'g2', overrides: []})])},
  723. serviceConfigs: {configs: [Em.Object.create({name: 'g1'})]}
  724. });
  725. installerStep7Controller.switchConfigGroupConfigs();
  726. this.configs = installerStep7Controller.get('selectedService.configs');
  727. });
  728. afterEach(function () {
  729. installerStep7Controller._getDisplayedConfigGroups.restore();
  730. installerStep7Controller._setEditableValue.restore();
  731. });
  732. it('g1 has 1 override', function () {
  733. expect(this.configs.findProperty('name', 'g1').get('overrides').length).to.equal(1);
  734. });
  735. it('g2 has 1 override', function () {
  736. expect(this.configs.findProperty('name', 'g2').get('overrides').length).to.equal(1);
  737. });
  738. it('all configs are editable', function () {
  739. expect(this.configs.everyProperty('isEditable', true)).to.equal(true);
  740. });
  741. });
  742. });
  743. describe('#selectProperService', function () {
  744. Em.A([
  745. {
  746. name: 'addServiceController',
  747. stepConfigs: [
  748. {selected: false, name: 'n1'},
  749. {selected: true, name: 'n2'},
  750. {selected: true, name: 'n3'}
  751. ],
  752. e: 'n2'
  753. },
  754. {
  755. name: 'installerController',
  756. stepConfigs: [
  757. {showConfig: false, name: 'n1'},
  758. {showConfig: false, name: 'n2'},
  759. {showConfig: true, name: 'n3'}
  760. ],
  761. e: 'n3'
  762. }
  763. ]).forEach(function (test) {
  764. describe(test.name, function () {
  765. beforeEach(function () {
  766. sinon.stub(installerStep7Controller, 'selectedServiceObserver', Em.K);
  767. installerStep7Controller.reopen({
  768. wizardController: Em.Object.create({
  769. name: test.name
  770. }),
  771. stepConfigs: test.stepConfigs
  772. });
  773. installerStep7Controller.selectProperService();
  774. });
  775. afterEach(function () {
  776. installerStep7Controller.selectedServiceObserver.restore();
  777. });
  778. it('selected service name is valid', function () {
  779. expect(installerStep7Controller.get('selectedService.name')).to.equal(test.e);
  780. });
  781. });
  782. });
  783. });
  784. describe.skip('#setStepConfigs', function () {
  785. var serviceConfigs;
  786. beforeEach(function () {
  787. installerStep7Controller.reopen({
  788. content: {services: []},
  789. wizardController: Em.Object.create({
  790. getDBProperty: function (key) {
  791. return this.get(key);
  792. }
  793. })
  794. });
  795. sinon.stub(installerStep7Controller, 'renderConfigs', function () {
  796. return serviceConfigs;
  797. });
  798. this.stub = sinon.stub(App, 'get');
  799. });
  800. afterEach(function () {
  801. installerStep7Controller.renderConfigs.restore();
  802. App.get.restore();
  803. });
  804. it('if wizard isn\'t addService, should set output of installerStep7Controller.renderConfigs', function () {
  805. serviceConfigs = Em.A([
  806. {serviceName:'HDFS', configs: []},
  807. {}
  808. ]);
  809. installerStep7Controller.set('wizardController.name', 'installerController');
  810. installerStep7Controller.setStepConfigs([], []);
  811. expect(installerStep7Controller.get('stepConfigs')).to.eql(serviceConfigs);
  812. });
  813. it('addServiceWizard used', function () {
  814. serviceConfigs = Em.A([Em.Object.create({serviceName: 'HDFS', configs: []}), Em.Object.create({serviceName: 's2'})]);
  815. installerStep7Controller.set('wizardController.name', 'addServiceController');
  816. installerStep7Controller.reopen({selectedServiceNames: ['s2']});
  817. installerStep7Controller.setStepConfigs([], []);
  818. expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
  819. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 's2').get('selected')).to.equal(true);
  820. });
  821. it('addServiceWizard used, HA enabled', function () {
  822. this.stub.withArgs('isHaEnabled').returns(true);
  823. serviceConfigs = Em.A([
  824. Em.Object.create({
  825. serviceName: 'HDFS',
  826. configs: [
  827. Em.Object.create({category: 'SECONDARY_NAMENODE'}),
  828. Em.Object.create({category: 'SECONDARY_NAMENODE'}),
  829. Em.Object.create({category: 'NameNode'}),
  830. Em.Object.create({category: 'NameNode'}),
  831. Em.Object.create({category: 'SECONDARY_NAMENODE'})
  832. ]
  833. }),
  834. Em.Object.create({serviceName: 's2'})]
  835. );
  836. installerStep7Controller.set('wizardController.name', 'addServiceController');
  837. installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
  838. installerStep7Controller.setStepConfigs([], []);
  839. expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
  840. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('selected')).to.equal(true);
  841. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(5);
  842. });
  843. it('not windows stack', function () {
  844. this.stub.withArgs('isHadoopWindowsStack').returns(false);
  845. this.stub.withArgs('isHaEnabled').returns(false);
  846. serviceConfigs = Em.A([
  847. Em.Object.create({
  848. serviceName: 'HDFS',
  849. configs: [
  850. {category: 'NameNode'},
  851. {category: 'NameNode'}
  852. ]
  853. }),
  854. Em.Object.create({serviceName: 's2'})]
  855. );
  856. installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
  857. installerStep7Controller.setStepConfigs([], []);
  858. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
  859. });
  860. it('windows stack', function () {
  861. this.stub.withArgs('isHadoopWindowsStack').returns(true);
  862. this.stub.withArgs('isHaEnabled').returns(false);
  863. serviceConfigs = Em.A([
  864. Em.Object.create({
  865. serviceName: 'HDFS',
  866. configs: [
  867. {category: 'NameNode'},
  868. {category: 'NameNode'}
  869. ]
  870. }),
  871. Em.Object.create({serviceName: 's2'})]
  872. );
  873. installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
  874. installerStep7Controller.set('installedServiceNames',['HDFS', 's2', 's3']);
  875. installerStep7Controller.setStepConfigs([], []);
  876. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
  877. });
  878. });
  879. describe('#loadStep', function () {
  880. beforeEach(function () {
  881. installerStep7Controller.reopen({
  882. content: {services: []},
  883. wizardController: Em.Object.create({
  884. getDBProperty: function (k) {
  885. return this.get(k);
  886. },
  887. stackConfigsLoaded: true
  888. })
  889. });
  890. sinon.stub(installerStep7Controller, 'clearStep', Em.K);
  891. sinon.stub(installerStep7Controller, 'getConfigTags', Em.K);
  892. sinon.stub(installerStep7Controller, 'setInstalledServiceConfigs', Em.K);
  893. sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
  894. sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
  895. sinon.stub(installerStep7Controller, 'applyServicesConfigs', Em.K);
  896. sinon.stub(App.router, 'send', Em.K);
  897. });
  898. afterEach(function () {
  899. installerStep7Controller.clearStep.restore();
  900. installerStep7Controller.getConfigTags.restore();
  901. installerStep7Controller.setInstalledServiceConfigs.restore();
  902. installerStep7Controller.checkHostOverrideInstaller.restore();
  903. installerStep7Controller.selectProperService.restore();
  904. installerStep7Controller.applyServicesConfigs.restore();
  905. App.router.send.restore();
  906. });
  907. it('should call clearStep', function () {
  908. installerStep7Controller.loadStep();
  909. expect(installerStep7Controller.clearStep.calledOnce).to.equal(true);
  910. });
  911. it('shouldn\'t do nothing if isAdvancedConfigLoaded is false', function () {
  912. installerStep7Controller.set('wizardController.stackConfigsLoaded', false);
  913. installerStep7Controller.loadStep();
  914. expect(installerStep7Controller.clearStep.called).to.equal(false);
  915. });
  916. it('should call setInstalledServiceConfigs for addServiceController', function () {
  917. installerStep7Controller.set('wizardController.name', 'addServiceController');
  918. installerStep7Controller.loadStep();
  919. expect(installerStep7Controller.setInstalledServiceConfigs.calledOnce).to.equal(true);
  920. });
  921. });
  922. describe('#applyServicesConfigs', function() {
  923. beforeEach(function() {
  924. installerStep7Controller.reopen({
  925. allSelectedServiceNames: []
  926. });
  927. sinon.stub(installerStep7Controller, 'loadConfigRecommendations', function(c, callback) {
  928. return callback();
  929. });
  930. sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
  931. sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
  932. sinon.stub(App.router, 'send', Em.K);
  933. sinon.stub(App.StackService, 'find', function () {
  934. return {
  935. findProperty: function () {
  936. return Em.Object.create({
  937. isInstalled: true,
  938. isSelected: false
  939. });
  940. },
  941. filterProperty: function () {
  942. return [];
  943. }
  944. }
  945. });
  946. installerStep7Controller.applyServicesConfigs([{name: 'configs'}]);
  947. });
  948. afterEach(function () {
  949. installerStep7Controller.loadConfigRecommendations.restore();
  950. installerStep7Controller.checkHostOverrideInstaller.restore();
  951. installerStep7Controller.selectProperService.restore();
  952. App.router.send.restore();
  953. App.StackService.find.restore();
  954. });
  955. it('loadConfigRecommendations is called once' , function () {
  956. expect(installerStep7Controller.loadConfigRecommendations.calledOnce).to.equal(true);
  957. });
  958. it('isRecommendedLoaded is true' , function () {
  959. expect(installerStep7Controller.get('isRecommendedLoaded')).to.equal(true);
  960. });
  961. it('checkHostOverrideInstalleris called once' , function () {
  962. expect(installerStep7Controller.checkHostOverrideInstaller.calledOnce).to.equal(true);
  963. });
  964. it('selectProperServiceis called once' , function () {
  965. expect(installerStep7Controller.selectProperService.calledOnce).to.equal(true);
  966. });
  967. });
  968. describe('#removeHawqStandbyHostAddressConfig', function() {
  969. installerStep7Controller = App.WizardStep7Controller.create({
  970. content: Em.Object.create({}),
  971. });
  972. var testHawqSiteConfigs = [
  973. {
  974. name: 'hawq_standby_address_host',
  975. value: 'h2'
  976. },
  977. {
  978. name: 'hawq_master_address_host',
  979. value: 'h1'
  980. }
  981. ];
  982. var oldHawqSiteLength = testHawqSiteConfigs.length;
  983. it('hawq_standby_address_host should be removed on single node cluster', function() {
  984. var hawqSiteConfigs = testHawqSiteConfigs.slice();
  985. installerStep7Controller.set('content.hosts', {'hostname': 'h1'});
  986. var updatedHawqSiteConfigs = installerStep7Controller.updateHawqConfigs(hawqSiteConfigs);
  987. expect(updatedHawqSiteConfigs.length).to.be.equal(oldHawqSiteLength-1);
  988. expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_standby_address_host')).to.not.exist;
  989. expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_master_address_host').value).to.be.equal('h1');
  990. });
  991. it('hawq_standby_address_host should not be removed on multi node clusters', function() {
  992. var hawqSiteConfigs = testHawqSiteConfigs.slice();
  993. installerStep7Controller.set('content.hosts', Em.A([{'hostname': 'h1'}, {'hostname': 'h2'}]));
  994. var updatedHawqSiteConfigs = installerStep7Controller.updateHawqConfigs(hawqSiteConfigs);
  995. expect(updatedHawqSiteConfigs.length).to.be.equal(oldHawqSiteLength);
  996. expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_standby_address_host').value).to.be.equal('h2');
  997. expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_master_address_host').value).to.be.equal('h1');
  998. });
  999. });
  1000. describe('#_updateIsEditableFlagForConfig', function () {
  1001. Em.A([
  1002. {
  1003. isAdmin: false,
  1004. isReconfigurable: false,
  1005. isHostsConfigsPage: true,
  1006. defaultGroupSelected: false,
  1007. m: 'false for non-admin users',
  1008. e: false
  1009. },
  1010. {
  1011. isAdmin: true,
  1012. isReconfigurable: false,
  1013. isHostsConfigsPage: true,
  1014. defaultGroupSelected: false,
  1015. m: 'false if defaultGroupSelected is false and isHostsConfigsPage is true',
  1016. e: false
  1017. },
  1018. {
  1019. isAdmin: true,
  1020. isReconfigurable: false,
  1021. isHostsConfigsPage: true,
  1022. defaultGroupSelected: true,
  1023. m: 'false if defaultGroupSelected is true and isHostsConfigsPage is true',
  1024. e: false
  1025. },
  1026. {
  1027. isAdmin: true,
  1028. isReconfigurable: false,
  1029. isHostsConfigsPage: false,
  1030. defaultGroupSelected: false,
  1031. m: 'false if defaultGroupSelected is false and isHostsConfigsPage is false',
  1032. e: false
  1033. }
  1034. ]).forEach(function (test) {
  1035. it(test.m, function () {
  1036. installerStep7Controller.reopen({isHostsConfigsPage: test.isHostsConfigsPage});
  1037. var serviceConfigProperty = Em.Object.create({
  1038. isReconfigurable: test.isReconfigurable
  1039. });
  1040. installerStep7Controller._updateIsEditableFlagForConfig(serviceConfigProperty, test.defaultGroupSelected);
  1041. expect(serviceConfigProperty.get('isEditable')).to.equal(test.e);
  1042. });
  1043. });
  1044. });
  1045. describe('#setInstalledServiceConfigs', function () {
  1046. var controller = App.WizardStep7Controller.create({
  1047. installedServiceNames: ['HBASE', 'AMBARI_METRICS']
  1048. }),
  1049. configs = [
  1050. {
  1051. name: 'hbase.client.scanner.caching',
  1052. value: '1000',
  1053. serviceName: 'HBASE',
  1054. filename: 'hbase-site.xml'
  1055. },
  1056. {
  1057. name: 'hbase.client.scanner.caching',
  1058. value: '2000',
  1059. serviceName: 'AMBARI_METRICS',
  1060. filename: 'ams-hbase-site.xml'
  1061. }
  1062. ],
  1063. configsByTags = [
  1064. {
  1065. type: 'hbase-site',
  1066. tag: 'version2',
  1067. properties: {
  1068. 'hbase.client.scanner.caching': '1500'
  1069. }
  1070. },
  1071. {
  1072. type: 'ams-hbase-site',
  1073. tag: 'version2',
  1074. properties: {
  1075. 'hbase.client.scanner.caching': '2500'
  1076. }
  1077. },
  1078. {
  1079. type: 'site-without-properties',
  1080. tag: 'version1'
  1081. }
  1082. ],
  1083. installedServiceNames = ['HBASE', 'AMBARI_METRICS'];
  1084. describe('should handle properties with the same name', function () {
  1085. var properties;
  1086. beforeEach(function () {
  1087. controller.setInstalledServiceConfigs(configs, configsByTags, installedServiceNames);
  1088. properties = configs.filterProperty('name', 'hbase.client.scanner.caching');
  1089. });
  1090. it('there are 2 properties', function () {
  1091. expect(properties).to.have.length(2);
  1092. });
  1093. it('hbase-site/ value is valid', function () {
  1094. expect(properties.findProperty('filename', 'hbase-site.xml').value).to.equal('1500');
  1095. });
  1096. it('hbase-site/ savedValue is valid', function () {
  1097. expect(properties.findProperty('filename', 'hbase-site.xml').savedValue).to.equal('1500');
  1098. });
  1099. it('ams-hbase-site/ value is valid', function () {
  1100. expect(properties.findProperty('filename', 'ams-hbase-site.xml').value).to.equal('2500');
  1101. });
  1102. it('ams-hbase-site/ savedValue is valid', function () {
  1103. expect(properties.findProperty('filename', 'ams-hbase-site.xml').savedValue).to.equal('2500');
  1104. });
  1105. });
  1106. });
  1107. describe('#getAmbariDatabaseSuccess', function () {
  1108. var controller = App.WizardStep7Controller.create({
  1109. stepConfigs: [
  1110. {
  1111. serviceName: 'HIVE',
  1112. configs: [
  1113. {
  1114. name: 'javax.jdo.option.ConnectionURL',
  1115. value: 'jdbc:mysql://h0/db_name?createDatabaseIfNotExist=true',
  1116. filename: 'hive-site.xml'
  1117. }
  1118. ]
  1119. }
  1120. ]
  1121. }),
  1122. cases = [
  1123. {
  1124. data: {
  1125. hostComponents: []
  1126. },
  1127. mySQLServerConflict: false,
  1128. title: 'no Ambari Server host components'
  1129. },
  1130. {
  1131. data: {
  1132. hostComponents: [
  1133. {
  1134. RootServiceHostComponents: {
  1135. host_name: 'h0',
  1136. properties: {
  1137. 'server.jdbc.database': 'postgres'
  1138. }
  1139. }
  1140. }
  1141. ]
  1142. },
  1143. mySQLServerConflict: false,
  1144. title: 'Ambari MySQL Server and Hive Server are on the same host but different database types'
  1145. },
  1146. {
  1147. data: {
  1148. hostComponents: [
  1149. {
  1150. RootServiceHostComponents: {
  1151. host_name: 'h0',
  1152. properties: {
  1153. 'server.jdbc.database': 'mysql'
  1154. }
  1155. }
  1156. }
  1157. ]
  1158. },
  1159. mySQLServerConflict: true,
  1160. title: 'Ambari MySQL Server and Hive Server are on the same host'
  1161. },
  1162. {
  1163. data: {
  1164. hostComponents: [
  1165. {
  1166. RootServiceHostComponents: {
  1167. host_name: 'h1',
  1168. properties: {
  1169. 'server.jdbc.database': 'mysql'
  1170. }
  1171. }
  1172. }
  1173. ]
  1174. },
  1175. mySQLServerConflict: false,
  1176. title: 'Ambari MySQL Server and Hive Server are on different hosts'
  1177. }
  1178. ];
  1179. cases.forEach(function (item) {
  1180. it(item.title, function () {
  1181. controller.getAmbariDatabaseSuccess(item.data);
  1182. expect(controller.get('mySQLServerConflict')).to.equal(item.mySQLServerConflict);
  1183. });
  1184. });
  1185. });
  1186. describe('#showDatabaseConnectionWarningPopup', function () {
  1187. var cases = [
  1188. {
  1189. method: 'onSecondary',
  1190. submitButtonClicked: false,
  1191. isRejected: true,
  1192. title: 'Cancel button clicked'
  1193. },
  1194. {
  1195. method: 'onPrimary',
  1196. submitButtonClicked: true,
  1197. isResolved: true,
  1198. title: 'Proceed Anyway button clicked'
  1199. }
  1200. ],
  1201. dfd,
  1202. testObject,
  1203. serviceNames = ['HIVE', 'OOZIE'],
  1204. bodyMessage = 'HIVE, OOZIE';
  1205. beforeEach(function () {
  1206. installerStep7Controller.set('submitButtonClicked', true);
  1207. dfd = $.Deferred(function (d) {
  1208. d.done(function () {
  1209. testObject.isResolved = true;
  1210. });
  1211. d.fail(function () {
  1212. testObject.isRejected = true;
  1213. })
  1214. });
  1215. testObject = {};
  1216. });
  1217. cases.forEach(function (item) {
  1218. describe(item.title, function () {
  1219. var popup;
  1220. beforeEach(function () {
  1221. popup = installerStep7Controller.showDatabaseConnectionWarningPopup(serviceNames, dfd);
  1222. });
  1223. it('popup body is valid', function () {
  1224. expect(popup.get('body')).to.equal(Em.I18n.t('installer.step7.popup.database.connection.body').format(bodyMessage));
  1225. });
  1226. it('after ' + item.method + ' execution', function () {
  1227. popup[item.method]();
  1228. expect(testObject.isResolved).to.equal(item.isResolved);
  1229. expect(testObject.isRejected).to.equal(item.isRejected);
  1230. expect(installerStep7Controller.get('submitButtonClicked')).to.equal(item.submitButtonClicked);
  1231. });
  1232. });
  1233. });
  1234. });
  1235. describe('#issuesFilterText', function () {
  1236. issuesFilterCases.forEach(function (item) {
  1237. it(item.title, function () {
  1238. issuesFilterTestSetup(installerStep7Controller, item);
  1239. expect(installerStep7Controller.get('issuesFilterText')).to.equal(item.issuesFilterText);
  1240. })
  1241. });
  1242. });
  1243. describe.skip('#loadServiceTagsSuccess', function () {
  1244. it('should create ClusterSiteToTagMap', function () {
  1245. var params = Em.Object.create({
  1246. serviceName: "OOZIE",
  1247. serviceConfigsDef: Em.Object.create({
  1248. configTypes: Em.Object.create({
  1249. site3: true,
  1250. site2: true,
  1251. site1: true
  1252. })
  1253. })
  1254. });
  1255. var wizardController = Em.Object.create({
  1256. allHosts: [
  1257. {hostName: 'h1'},
  1258. {hostName: 'h2'},
  1259. {hostName: 'h3'}
  1260. ]
  1261. });
  1262. installerStep7Controller.set('wizardController', wizardController);
  1263. installerStep7Controller.set('stepConfigs', Em.A([Em.Object.create({serviceName: 'OOZIE', configs: Em.A([]) })]));
  1264. var desiredConfigs = {
  1265. site1: {
  1266. tag: "tag1"
  1267. },
  1268. site2: {
  1269. tag: "tag2"
  1270. },
  1271. site3: {
  1272. tag: "tag3"
  1273. }
  1274. };
  1275. var data = {
  1276. config_groups: Em.A([Em.Object.create({
  1277. ConfigGroup: Em.Object.create({
  1278. tag: 'OOZIE',
  1279. hosts: Em.A([Em.Object.create({host_name: 'h1'})]),
  1280. id: 1,
  1281. group_name: "",
  1282. description: "",
  1283. desired_configs: Em.A([Em.Object.create({
  1284. type: '1',
  1285. tag: 'h1'
  1286. })])
  1287. })
  1288. })]),
  1289. Clusters: {
  1290. desired_configs: desiredConfigs
  1291. }
  1292. };
  1293. installerStep7Controller.loadServiceTagsSuccess(data, {}, params);
  1294. var result = installerStep7Controller.get("loadedClusterSiteToTagMap");
  1295. expect(JSON.parse(JSON.stringify(result))).to.eql(JSON.parse(JSON.stringify({"site1":"tag1","site2":"tag2","site3":"tag3"})));
  1296. })
  1297. });
  1298. describe('#issuesFilterLinkText', function () {
  1299. issuesFilterCases.forEach(function (item) {
  1300. it(item.title, function () {
  1301. issuesFilterTestSetup(installerStep7Controller, item);
  1302. expect(installerStep7Controller.get('issuesFilterLinkText')).to.equal(item.issuesFilterLinkText);
  1303. })
  1304. });
  1305. });
  1306. describe('#toggleIssuesFilter', function () {
  1307. it('should toggle issues filter', function () {
  1308. var issuesFilter = installerStep7Controller.get('filterColumns').findProperty('attributeName', 'hasIssues');
  1309. issuesFilter.set('selected', false);
  1310. installerStep7Controller.toggleIssuesFilter();
  1311. expect(issuesFilter.get('selected')).to.be.true;
  1312. installerStep7Controller.toggleIssuesFilter();
  1313. expect(issuesFilter.get('selected')).to.be.false;
  1314. });
  1315. it('selected service should be changed', function () {
  1316. installerStep7Controller.setProperties({
  1317. selectedService: {
  1318. errorCount: 0,
  1319. configGroups: []
  1320. },
  1321. stepConfigs: [
  1322. {
  1323. errorCount: 1,
  1324. configGroups: []
  1325. },
  1326. {
  1327. errorCount: 2,
  1328. configGroups: []
  1329. }
  1330. ]
  1331. });
  1332. installerStep7Controller.toggleIssuesFilter();
  1333. expect(installerStep7Controller.get('selectedService')).to.eql({
  1334. errorCount: 1,
  1335. configGroups: []
  1336. });
  1337. });
  1338. });
  1339. describe('#addKerberosDescriptorConfigs', function() {
  1340. var configs = [
  1341. { name: 'prop1', displayName: 'Prop1' },
  1342. { name: 'prop2', displayName: 'Prop2' },
  1343. { name: 'prop3', displayName: 'Prop3' }
  1344. ];
  1345. var descriptor = [
  1346. Em.Object.create({ name: 'prop4', filename: 'file-1'}),
  1347. Em.Object.create({ name: 'prop1', filename: 'file-1'})
  1348. ];
  1349. var propertiesAttrTests = [
  1350. {
  1351. attr: 'isUserProperty', val: false,
  1352. m: 'descriptor properties should not be marked as custom'
  1353. },
  1354. {
  1355. attr: 'category', val: 'Advanced file-1',
  1356. m: 'descriptor properties should be added to Advanced category'
  1357. },
  1358. {
  1359. attr: 'isOverridable', val: false,
  1360. m: 'descriptor properties should not be overriden'
  1361. }
  1362. ];
  1363. propertiesAttrTests.forEach(function(test) {
  1364. it(test.m, function() {
  1365. installerStep7Controller.addKerberosDescriptorConfigs(configs, descriptor);
  1366. expect(configs.findProperty('name', 'prop1')[test.attr]).to.be.eql(test.val);
  1367. });
  1368. });
  1369. });
  1370. describe('#addHawqConfigsOnNnHa', function () {
  1371. var configs = [
  1372. {
  1373. id: 'dfs.nameservices__hdfs-site',
  1374. description: 'dfs.nameservices__hdfs-site',
  1375. displayName: 'dfs.nameservices',
  1376. displayType: 'string',
  1377. name: 'dfs.nameservices',
  1378. value: 'haservice',
  1379. recommendedValue: 'haservice'
  1380. },
  1381. {
  1382. id: 'dfs.ha.namenodes.haservice__hdfs-site',
  1383. description: 'dfs.ha.namenodes.haservice__hdfs-site',
  1384. displayName: 'dfs.ha.namenodes.haservice',
  1385. displayType: 'string',
  1386. name: 'dfs.ha.namenodes.haservice',
  1387. value: 'nn1,nn2',
  1388. recommendedValue: 'nn1,nn2'
  1389. },
  1390. {
  1391. id: 'dfs.namenode.rpc-address.haservice.nn1__hdfs-site',
  1392. description: 'dfs.namenode.rpc-address.haservice.nn1__hdfs-site',
  1393. displayName: 'dfs.namenode.rpc-address.haservice.nn1',
  1394. displayType: 'string',
  1395. name: 'dfs.namenode.rpc-address.haservice.nn1',
  1396. value: 'c6401.ambari.apache.org:8020',
  1397. recommendedValue: 'c6401.ambari.apache.org:8020'
  1398. },
  1399. {
  1400. id: 'dfs.namenode.rpc-address.haservice.nn2__hdfs-site',
  1401. description: 'dfs.namenode.rpc-address.haservice.nn2__hdfs-site',
  1402. displayName: 'dfs.namenode.rpc-address.haservice.nn2',
  1403. displayType: 'string',
  1404. name: 'dfs.namenode.rpc-address.haservice.nn2',
  1405. value: 'c6402.ambari.apache.org:8020',
  1406. recommendedValue: 'c6402.ambari.apache.org:8020'
  1407. },
  1408. {
  1409. id: 'dfs.namenode.http-address.haservice.nn1__hdfs-site',
  1410. description: 'dfs.namenode.http-address.haservice.nn1__hdfs-site',
  1411. displayName: 'dfs.namenode.http-address.haservice.nn1',
  1412. displayType: 'string',
  1413. name: 'dfs.namenode.http-address.haservice.nn1',
  1414. value: 'c6401.ambari.apache.org:50070',
  1415. recommendedValue: 'c6401.ambari.apache.org:50070'
  1416. },
  1417. {
  1418. id: 'dfs.namenode.http-address.haservice.nn2__hdfs-site',
  1419. description: 'dfs.namenode.http-address.haservice.nn2__hdfs-site',
  1420. displayName: 'dfs.namenode.http-address.haservice.nn2',
  1421. displayType: 'string',
  1422. name: 'dfs.namenode.http-address.haservice.nn2',
  1423. value: 'c6402.ambari.apache.org:50070',
  1424. recommendedValue: 'c6402.ambari.apache.org:50070'
  1425. }
  1426. ];
  1427. var oldConfigs = configs.slice();
  1428. it('should copy properties from hdfs-site to hdfs-client for HAWQ', function() {
  1429. installerStep7Controller.addHawqConfigsOnNnHa(configs);
  1430. // ensure 6 new configs were added
  1431. expect(configs.length).to.be.equal(oldConfigs.length + 6);
  1432. });
  1433. describe('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', function () {
  1434. oldConfigs.forEach(function(property) {
  1435. var id = property.name + '__hdfs-client';
  1436. it(id, function () {
  1437. expect(configs.findProperty('id', id).description).to.be.equal(property.description);
  1438. expect(configs.findProperty('id', id).displayName).to.be.equal(property.displayName);
  1439. expect(configs.findProperty('id', id).value).to.be.equal(property.value);
  1440. expect(configs.findProperty('id', id).recommendedValue).to.be.equal(property.recommendedValue);
  1441. });
  1442. });
  1443. });
  1444. });
  1445. describe('#addHawqConfigsOnRMHa', function () {
  1446. var configs = [
  1447. {
  1448. id: 'yarn.resourcemanager.hostname.rm1__yarn-site',
  1449. name: 'yarn.resourcemanager.hostname.rm1',
  1450. value: 'c6401.ambari.apache.org',
  1451. recommendedValue: 'c6401.ambari.apache.org'
  1452. },
  1453. {
  1454. id: 'yarn.resourcemanager.hostname.rm2__yarn-site',
  1455. name: 'yarn.resourcemanager.hostname.rm2',
  1456. value: 'c6402.ambari.apache.org',
  1457. recommendedValue: 'c6402.ambari.apache.org'
  1458. }
  1459. ];
  1460. beforeEach(function () {
  1461. this.inputConfigsCount = configs.length;
  1462. installerStep7Controller.addHawqConfigsOnRMHa(configs);
  1463. this.yarnRmDetails = configs.findProperty('id', 'yarn.resourcemanager.ha__yarn-client');
  1464. this.yarnRmSchedulerDetails = configs.findProperty('id', 'yarn.resourcemanager.scheduler.ha__yarn-client');
  1465. });
  1466. it('should update properties in yarn-client for HAWQ if yarn ha is enabled', function() {
  1467. var noOfConfigsAdded = 2;
  1468. expect(configs.length).to.be.equal(this.inputConfigsCount + noOfConfigsAdded);
  1469. });
  1470. it('yarn.resourcemanager.ha__yarn-client', function() {
  1471. var expectedYarnRmHaValue = 'c6401.ambari.apache.org:8032,c6402.ambari.apache.org:8032';
  1472. expect(this.yarnRmDetails.value).to.be.equal(expectedYarnRmHaValue);
  1473. expect(this.yarnRmDetails.recommendedValue).to.be.equal(expectedYarnRmHaValue);
  1474. expect(this.yarnRmDetails.displayName).to.be.equal('yarn.resourcemanager.ha');
  1475. expect(this.yarnRmDetails.description).to.be.equal('Comma separated yarn resourcemanager host addresses with port');
  1476. });
  1477. it('yarn.resourcemanager.scheduler.ha__yarn-client', function() {
  1478. var expectedYarnRmSchedulerValue = 'c6401.ambari.apache.org:8030,c6402.ambari.apache.org:8030';
  1479. expect(this.yarnRmSchedulerDetails.value).to.be.equal(expectedYarnRmSchedulerValue);
  1480. expect(this.yarnRmSchedulerDetails.recommendedValue).to.be.equal(expectedYarnRmSchedulerValue);
  1481. expect(this.yarnRmSchedulerDetails.displayName).to.be.equal('yarn.resourcemanager.scheduler.ha');
  1482. expect(this.yarnRmSchedulerDetails.description).to.be.equal('Comma separated yarn resourcemanager scheduler addresses with port');
  1483. });
  1484. });
  1485. describe('#errorsCount', function () {
  1486. it('should ignore configs with widgets (enhanced configs)', function () {
  1487. installerStep7Controller.reopen({selectedService: Em.Object.create({
  1488. configsWithErrors: Em.A([
  1489. Em.Object.create({widget: {}}),
  1490. Em.Object.create({widget: null})
  1491. ])
  1492. })
  1493. });
  1494. expect(installerStep7Controller.get('errorsCount')).to.equal(1);
  1495. });
  1496. });
  1497. describe('#_reconfigureServicesOnNnHa', function () {
  1498. var dfsNameservices = 'some_cluster';
  1499. Em.A([
  1500. {
  1501. serviceName: 'HBASE',
  1502. configToUpdate: 'hbase.rootdir',
  1503. oldValue: 'hdfs://nameserv:8020/apps/hbase/data',
  1504. expectedNewValue: 'hdfs://' + dfsNameservices + '/apps/hbase/data'
  1505. },
  1506. {
  1507. serviceName: 'ACCUMULO',
  1508. configToUpdate: 'instance.volumes',
  1509. oldValue: 'hdfs://localhost:8020/apps/accumulo/data',
  1510. expectedNewValue: 'hdfs://' + dfsNameservices + '/apps/accumulo/data'
  1511. },
  1512. {
  1513. serviceName: 'HAWQ',
  1514. configToUpdate: 'hawq_dfs_url',
  1515. oldValue: 'localhost:8020/hawq_data',
  1516. expectedNewValue: dfsNameservices + '/hawq_data'
  1517. }
  1518. ]).forEach(function (test) {
  1519. var serviceConfigs = [App.ServiceConfig.create({
  1520. serviceName: test.serviceName,
  1521. configs: [
  1522. Em.Object.create({
  1523. name: test.configToUpdate,
  1524. value: test.oldValue
  1525. })
  1526. ]
  1527. }),
  1528. App.ServiceConfig.create({
  1529. serviceName: 'HDFS',
  1530. configs: [
  1531. Em.Object.create({
  1532. name: 'dfs.nameservices',
  1533. value: dfsNameservices
  1534. })
  1535. ]
  1536. })];
  1537. it(test.serviceName + ' ' + test.configToUpdate, function () {
  1538. installerStep7Controller.reopen({
  1539. selectedServiceNames: [test.serviceName, 'HDFS']
  1540. });
  1541. serviceConfigs = installerStep7Controller._reconfigureServicesOnNnHa(serviceConfigs);
  1542. expect(serviceConfigs.findProperty('serviceName', test.serviceName).configs.findProperty('name', test.configToUpdate).get('value')).to.equal(test.expectedNewValue);
  1543. });
  1544. });
  1545. });
  1546. describe('#showOozieDerbyWarning', function() {
  1547. var controller;
  1548. beforeEach(function() {
  1549. controller = App.WizardStep7Controller.create({});
  1550. sinon.stub(App.ModalPopup, 'show', Em.K);
  1551. });
  1552. afterEach(function() {
  1553. App.ModalPopup.show.restore();
  1554. });
  1555. Em.A([
  1556. {
  1557. selectedServiceNames: ['HDFS', 'OOZIE'],
  1558. databaseType: Em.I18n.t('installer.step7.oozie.database.new'),
  1559. e: true,
  1560. m: 'Oozie selected with derby database, warning popup should be shown'
  1561. },
  1562. {
  1563. selectedServiceNames: ['HDFS'],
  1564. databaseType: Em.I18n.t('installer.step7.oozie.database.new'),
  1565. e: false,
  1566. m: 'Oozie not selected warning popup should be skipped'
  1567. },
  1568. {
  1569. selectedServiceNames: ['HDFS', 'OOZIE'],
  1570. databaseType: 'New Mysql Database',
  1571. e: false,
  1572. m: 'Oozie selected, mysql database used, warning popup should be sk'
  1573. }
  1574. ]).forEach(function(test) {
  1575. describe(test.m, function() {
  1576. beforeEach(function () {
  1577. sinon.stub(App.config, 'findConfigProperty').returns(Em.Object.create({ value: test.databaseType}));
  1578. controller.reopen({
  1579. selectedServiceNames: test.selectedServiceNames
  1580. });
  1581. controller.showOozieDerbyWarningPopup(Em.K);
  1582. });
  1583. afterEach(function () {
  1584. App.config.findConfigProperty.restore();
  1585. });
  1586. it('modal popup is shown needed number of times', function () {
  1587. expect(App.ModalPopup.show.calledOnce).to.equal(test.e);
  1588. });
  1589. });
  1590. });
  1591. });
  1592. describe('#addHostNamesToConfigs', function() {
  1593. beforeEach(function () {
  1594. sinon.stub(App.StackServiceComponent, 'find', function () {
  1595. return Em.Object.create({
  1596. id: 'NAMENODE',
  1597. displayName: 'NameNode'
  1598. });
  1599. });
  1600. });
  1601. afterEach(function () {
  1602. App.StackServiceComponent.find.restore();
  1603. });
  1604. it('should not create duplicate configs', function () {
  1605. var serviceConfig = Em.Object.create({
  1606. configs: [],
  1607. serviceName: 'HDFS',
  1608. configCategories: [
  1609. {
  1610. showHost: true,
  1611. name: 'NAMENODE'
  1612. }
  1613. ]
  1614. });
  1615. var masterComponents = [
  1616. {component: 'NAMENODE', hostName: 'h1'}
  1617. ];
  1618. var slaveComponents = [];
  1619. installerStep7Controller.addHostNamesToConfigs(serviceConfig, masterComponents, slaveComponents);
  1620. expect(serviceConfig.get('configs').filterProperty('name', 'namenode_host').length).to.equal(1);
  1621. installerStep7Controller.addHostNamesToConfigs(serviceConfig, masterComponents, slaveComponents);
  1622. expect(serviceConfig.get('configs').filterProperty('name', 'namenode_host').length).to.equal(1);
  1623. });
  1624. });
  1625. describe('#resolveHiveMysqlDatabase', function () {
  1626. beforeEach(function () {
  1627. installerStep7Controller.get('content').setProperties({
  1628. services: Em.A([
  1629. Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false})
  1630. ])
  1631. });
  1632. installerStep7Controller.setProperties({
  1633. stepConfigs: Em.A([
  1634. Em.Object.create({serviceName: 'HIVE', configs: [{name: 'hive_database', value: 'New MySQL Database'}]})
  1635. ]),
  1636. mySQLServerConflict: true
  1637. });
  1638. sinon.stub(installerStep7Controller, 'moveNext', Em.K);
  1639. sinon.stub(installerStep7Controller, 'checkMySQLHost', function () {
  1640. return $.Deferred().resolve();
  1641. });
  1642. sinon.spy(App.ModalPopup, 'show');
  1643. });
  1644. afterEach(function () {
  1645. installerStep7Controller.moveNext.restore();
  1646. installerStep7Controller.checkMySQLHost.restore();
  1647. App.ModalPopup.show.restore();
  1648. });
  1649. it('no HIVE service', function () {
  1650. installerStep7Controller.set('content.services', Em.A([]));
  1651. installerStep7Controller.resolveHiveMysqlDatabase();
  1652. expect(installerStep7Controller.moveNext.calledOnce).to.be.true;
  1653. expect(App.ModalPopup.show.called).to.be.false;
  1654. });
  1655. it('if mySQLServerConflict, popup is shown', function () {
  1656. installerStep7Controller.resolveHiveMysqlDatabase();
  1657. expect(installerStep7Controller.moveNext.called).to.be.false;
  1658. expect(App.ModalPopup.show.calledOnce).to.be.true;
  1659. });
  1660. });
  1661. describe('#mySQLWarningHandler', function () {
  1662. beforeEach(function () {
  1663. installerStep7Controller.set('mySQLServerConflict', true);
  1664. sinon.spy(App.ModalPopup, 'show');
  1665. sinon.stub(App.router, 'get').returns({gotoStep: Em.K});
  1666. sinon.stub(App.router.get(), 'gotoStep', Em.K);
  1667. });
  1668. afterEach(function () {
  1669. App.ModalPopup.show.restore();
  1670. App.router.get().gotoStep.restore();
  1671. App.router.get.restore();
  1672. });
  1673. it('warning popup is shown', function () {
  1674. installerStep7Controller.mySQLWarningHandler();
  1675. expect(App.ModalPopup.show.calledOnce).to.be.true;
  1676. });
  1677. it('submitButtonClicked is set to false on primary click', function () {
  1678. installerStep7Controller.mySQLWarningHandler().onPrimary();
  1679. expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
  1680. });
  1681. it('second popup is shown on secondary click', function () {
  1682. installerStep7Controller.mySQLWarningHandler().onSecondary();
  1683. expect(App.ModalPopup.show.calledTwice).to.be.true;
  1684. });
  1685. it('submitButtonClicked is set to false on secondary click on the second popup', function () {
  1686. installerStep7Controller.mySQLWarningHandler().onSecondary().onSecondary();
  1687. expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
  1688. });
  1689. it('user is moved to step5 on primary click on the second popup (installerController)', function () {
  1690. installerStep7Controller.set('content.controllerName', 'installerController');
  1691. installerStep7Controller.mySQLWarningHandler().onSecondary().onPrimary();
  1692. expect(App.router.get('installerController').gotoStep.calledWith(5, true)).to.be.true;
  1693. });
  1694. it('user is moved to step2 on primary click on the second popup (addSeviceController)', function () {
  1695. installerStep7Controller.set('content.controllerName', 'addServiceController');
  1696. installerStep7Controller.mySQLWarningHandler().onSecondary().onPrimary();
  1697. expect(App.router.get('addSeviceController').gotoStep.calledWith(2, true)).to.be.true;
  1698. });
  1699. });
  1700. describe('#supportsPreInstallChecks', function () {
  1701. beforeEach(function () {
  1702. this.stub = sinon.stub(App, 'get');
  1703. });
  1704. afterEach(function () {
  1705. this.stub.restore();
  1706. });
  1707. Em.A([
  1708. {preInstallChecks: true, controllerName: 'installerController', e: true},
  1709. {preInstallChecks: true, controllerName: '', e: false},
  1710. {preInstallChecks: false, controllerName: 'installerController', e: false},
  1711. {preInstallChecks: false, controllerName: '', e: false}
  1712. ]).forEach(function (test) {
  1713. it(JSON.stringify(test), function () {
  1714. this.stub.withArgs('supports.preInstallChecks').returns(test.preInstallChecks);
  1715. installerStep7Controller.set('content', {controllerName: test.controllerName});
  1716. installerStep7Controller.propertyDidChange('supportsPreInstallChecks');
  1717. expect(installerStep7Controller.get('supportsPreInstallChecks')).to.be.equal(test.e);
  1718. });
  1719. });
  1720. });
  1721. describe('#getHash', function () {
  1722. var stepConfigs = [
  1723. {
  1724. configs: [
  1725. Em.Object.create({name: 's1c1', isFinal: true, value: 'v11'}),
  1726. Em.Object.create({name: 's1c2', isFinal: false, value: 'v12', overrides: []}),
  1727. Em.Object.create({name: 's1c3', isFinal: true, value: 'v13', overrides: [
  1728. Em.Object.create({value: 'v131'})
  1729. ]})
  1730. ]
  1731. },
  1732. {
  1733. configs: [
  1734. Em.Object.create({name: 's2c1', isFinal: true, value: 'v21'}),
  1735. Em.Object.create({name: 's2c2', isFinal: false, value: 'v22', overrides: []}),
  1736. Em.Object.create({name: 's2c3', isFinal: true, value: 'v23', overrides: [
  1737. Em.Object.create({value: 'v231'})
  1738. ]})
  1739. ]
  1740. }
  1741. ];
  1742. beforeEach(function () {
  1743. installerStep7Controller.set('stepConfigs', stepConfigs);
  1744. this.hash = installerStep7Controller.getHash();
  1745. });
  1746. it('should map value, isFinal and overrides values', function () {
  1747. var expected = JSON.stringify({
  1748. s1c1: {
  1749. value: 'v11',
  1750. overrides: [],
  1751. isFinal: true
  1752. },
  1753. s1c2: {
  1754. value: 'v12',
  1755. overrides: [],
  1756. isFinal: false
  1757. },
  1758. s1c3: {
  1759. value: 'v13',
  1760. overrides: ['v131'],
  1761. isFinal: true
  1762. },
  1763. s2c1: {
  1764. value: 'v21',
  1765. overrides: [],
  1766. isFinal: true
  1767. },
  1768. s2c2: {
  1769. value: 'v22',
  1770. overrides: [],
  1771. isFinal: false
  1772. },
  1773. s2c3: {
  1774. value: 'v23',
  1775. overrides: ['v231'],
  1776. isFinal: true
  1777. }
  1778. });
  1779. expect(this.hash).to.be.equal(expected);
  1780. });
  1781. });
  1782. describe('#updateHostOverrides', function () {
  1783. var configProperty;
  1784. var storedConfigProperty;
  1785. beforeEach(function () {
  1786. configProperty = Em.Object.create({});
  1787. storedConfigProperty = {
  1788. overrides: [
  1789. {value: 'v1'}
  1790. ]
  1791. };
  1792. installerStep7Controller.updateHostOverrides(configProperty, storedConfigProperty);
  1793. });
  1794. it('override is valid', function () {
  1795. var override = configProperty.get('overrides.0');
  1796. expect(override.get('value')).to.be.equal('v1');
  1797. expect(override.get('isOriginalSCP')).to.be.false;
  1798. expect(override.get('parentSCP')).to.be.eql(configProperty);
  1799. });
  1800. });
  1801. describe('#allowUpdateProperty', function () {
  1802. it('true if it is installer', function () {
  1803. installerStep7Controller.set('wizardController', {name: 'installerController'});
  1804. expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.true;
  1805. });
  1806. it('true if it is parentProperties are not empty', function () {
  1807. installerStep7Controller.set('wizardController', {name: 'some'});
  1808. expect(installerStep7Controller.allowUpdateProperty([{}], '', '')).to.be.true;
  1809. });
  1810. describe('#addServiceController', function () {
  1811. beforeEach(function () {
  1812. installerStep7Controller.set('wizardController', {name: 'addServiceController'});
  1813. this.stub = sinon.stub(App.configsCollection, 'getConfigByName');
  1814. sinon.stub(App.config, 'get').withArgs('serviceByConfigTypeMap').returns({
  1815. 't1': Em.Object.create({serviceName: 's1'}),
  1816. 't2': Em.Object.create({serviceName: 's2'})
  1817. })
  1818. });
  1819. afterEach(function () {
  1820. App.configsCollection.getConfigByName.restore();
  1821. App.config.get.restore();
  1822. });
  1823. it('stackProperty does not exist', function () {
  1824. this.stub.returns(null);
  1825. expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.true;
  1826. });
  1827. it('installedServices does not contain stackProperty.serviceName', function () {
  1828. this.stub.returns({serviceName: 's1'});
  1829. installerStep7Controller.set('installedServices', {});
  1830. expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.true;
  1831. });
  1832. it('stackProperty.propertyDependsOn is empty', function () {
  1833. installerStep7Controller.reopen({installedServices: {s1: true}});
  1834. this.stub.returns({serviceName: 's1', propertyDependsOn: []});
  1835. expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.false;
  1836. });
  1837. it('stackProperty.propertyDependsOn is not empty', function () {
  1838. installerStep7Controller.reopen({installedServices: {s1: true}});
  1839. this.stub.returns({serviceName: 's1', propertyDependsOn: [
  1840. {type: 't1'},
  1841. {type: 't2'}
  1842. ]});
  1843. expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.true;
  1844. });
  1845. it('stackProperty.propertyDependsOn is not empty (2)', function () {
  1846. installerStep7Controller.reopen({installedServices: {s1: true}});
  1847. this.stub.returns({serviceName: 's1', propertyDependsOn: [
  1848. {type: 't1'},
  1849. {type: 't1'}
  1850. ]});
  1851. expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.false;
  1852. });
  1853. });
  1854. it('true if it is not installer or addService', function () {
  1855. installerStep7Controller.set('wizardController', {name: 'some'});
  1856. expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.true;
  1857. });
  1858. });
  1859. });