step7_test.js 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560
  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 installerStep7Controller,
  22. issuesFilterCases = [
  23. {
  24. isSubmitDisabled: true,
  25. submitButtonClicked: true,
  26. isIssuesFilterActive: true,
  27. issuesFilterText: '',
  28. issuesFilterLinkText: Em.I18n.t('installer.step7.showAllProperties'),
  29. title: 'issues filter on, submit button clicked'
  30. },
  31. {
  32. isSubmitDisabled: true,
  33. submitButtonClicked: false,
  34. isIssuesFilterActive: true,
  35. issuesFilterText: Em.I18n.t('installer.step7.showingPropertiesWithIssues'),
  36. issuesFilterLinkText: Em.I18n.t('installer.step7.showAllProperties'),
  37. title: 'issues filter on, submit button disabled'
  38. },
  39. {
  40. isSubmitDisabled: true,
  41. submitButtonClicked: true,
  42. isIssuesFilterActive: false,
  43. issuesFilterText: '',
  44. issuesFilterLinkText: '',
  45. title: 'issues filter off, submit button clicked'
  46. },
  47. {
  48. isSubmitDisabled: true,
  49. submitButtonClicked: false,
  50. isIssuesFilterActive: false,
  51. issuesFilterText: '',
  52. issuesFilterLinkText: Em.I18n.t('installer.step7.showPropertiesWithIssues'),
  53. title: 'issues filter off, submit button disabled'
  54. },
  55. {
  56. isSubmitDisabled: false,
  57. submitButtonClicked: false,
  58. isIssuesFilterActive: true,
  59. issuesFilterText: '',
  60. issuesFilterLinkText: Em.I18n.t('installer.step7.showAllProperties'),
  61. title: 'issues filter on, submit button enabled'
  62. },
  63. {
  64. isSubmitDisabled: false,
  65. submitButtonClicked: false,
  66. isIssuesFilterActive: false,
  67. issuesFilterText: '',
  68. issuesFilterLinkText: '',
  69. title: 'issues filter off, submit button enabled'
  70. },
  71. {
  72. isSubmitDisabled: false,
  73. submitButtonClicked: false,
  74. isIssuesFilterActive: true,
  75. issuesFilterText: '',
  76. issuesFilterLinkText: Em.I18n.t('installer.step7.showAllProperties'),
  77. title: 'issues filter on, submit button not clicked but active'
  78. },
  79. {
  80. isSubmitDisabled: false,
  81. submitButtonClicked: true,
  82. isIssuesFilterActive: true,
  83. issuesFilterText: '',
  84. issuesFilterLinkText: Em.I18n.t('installer.step7.showAllProperties'),
  85. title: 'issues filter on, submit button clicked and active'
  86. }
  87. ],
  88. issuesFilterTestSetup = function (controller, testCase) {
  89. controller.set('submitButtonClicked', testCase.submitButtonClicked);
  90. controller.reopen({
  91. isSubmitDisabled: testCase.isSubmitDisabled
  92. });
  93. controller.get('filterColumns').findProperty('attributeName', 'hasIssues').set('selected', testCase.isIssuesFilterActive);
  94. };
  95. function getController() {
  96. return App.WizardStep7Controller.create({
  97. content: Em.Object.create({
  98. services: [],
  99. advancedServiceConfig: [],
  100. serviceConfigProperties: []
  101. })
  102. });
  103. }
  104. describe('App.InstallerStep7Controller', function () {
  105. beforeEach(function () {
  106. sinon.stub(App.ajax, 'send', function () {
  107. return {
  108. then: Em.K
  109. }
  110. });
  111. sinon.stub(App.config, 'setPreDefinedServiceConfigs', Em.K);
  112. installerStep7Controller = getController();
  113. });
  114. afterEach(function() {
  115. App.ajax.send.restore();
  116. App.config.setPreDefinedServiceConfigs.restore();
  117. installerStep7Controller.destroy();
  118. });
  119. App.TestAliases.testAsComputedAlias(getController(), 'masterComponentHosts', 'content.masterComponentHosts', 'array');
  120. App.TestAliases.testAsComputedAlias(getController(), 'slaveComponentHosts', 'content.slaveGroupProperties', 'array');
  121. App.TestAliases.testAsComputedAnd(getController(), 'isConfigsLoaded', ['wizardController.stackConfigsLoaded', 'isAppliedConfigLoaded']);
  122. describe('#installedServiceNames', function () {
  123. var tests = Em.A([
  124. {
  125. content: Em.Object.create({
  126. controllerName: 'installerController',
  127. services: Em.A([
  128. Em.Object.create({
  129. isInstalled: true,
  130. serviceName: 'SQOOP'
  131. }),
  132. Em.Object.create({
  133. isInstalled: true,
  134. serviceName: 'HDFS'
  135. })
  136. ])
  137. }),
  138. e: ['SQOOP', 'HDFS'],
  139. m: 'installerController with SQOOP'
  140. },
  141. {
  142. content: Em.Object.create({
  143. controllerName: 'installerController',
  144. services: Em.A([
  145. Em.Object.create({
  146. isInstalled: true,
  147. serviceName: 'HIVE'
  148. }),
  149. Em.Object.create({
  150. isInstalled: true,
  151. serviceName: 'HDFS'
  152. })
  153. ])
  154. }),
  155. e: ['HIVE', 'HDFS'],
  156. m: 'installerController without SQOOP'
  157. },
  158. {
  159. content: Em.Object.create({
  160. controllerName: 'addServiceController',
  161. services: Em.A([
  162. Em.Object.create({
  163. isInstalled: true,
  164. serviceName: 'HIVE'
  165. }),
  166. Em.Object.create({
  167. isInstalled: true,
  168. serviceName: 'HDFS'
  169. })
  170. ])
  171. }),
  172. e: ['HIVE', 'HDFS'],
  173. m: 'addServiceController without SQOOP'
  174. }
  175. ]);
  176. tests.forEach(function (test) {
  177. it(test.m, function () {
  178. installerStep7Controller.set('content', test.content);
  179. expect(installerStep7Controller.get('installedServiceNames')).to.include.members(test.e);
  180. expect(test.e).to.include.members(installerStep7Controller.get('installedServiceNames'));
  181. });
  182. });
  183. });
  184. describe('#isSubmitDisabled', function () {
  185. it('should be true if miscModalVisible', function () {
  186. installerStep7Controller.reopen({miscModalVisible: true});
  187. expect(installerStep7Controller.get('isSubmitDisabled')).to.equal(true);
  188. });
  189. it('should be true if some of stepConfigs has errors', function () {
  190. installerStep7Controller.reopen({
  191. miscModalVisible: false,
  192. stepConfigs: [
  193. {
  194. showConfig: true,
  195. errorCount: 1
  196. }
  197. ]
  198. });
  199. expect(installerStep7Controller.get('isSubmitDisabled')).to.equal(true);
  200. });
  201. it('should be false if all of stepConfigs don\'t have errors and miscModalVisible is false', function () {
  202. installerStep7Controller.reopen({
  203. miscModalVisible: false,
  204. stepConfigs: [
  205. {
  206. showConfig: true,
  207. errorCount: 0
  208. }
  209. ]
  210. });
  211. expect(installerStep7Controller.get('isSubmitDisabled')).to.equal(false);
  212. });
  213. });
  214. describe('#selectedServiceNames', function () {
  215. it('should use content.services as source of data', function () {
  216. installerStep7Controller.set('content', {
  217. services: [
  218. {isSelected: true, isInstalled: false, serviceName: 's1'},
  219. {isSelected: false, isInstalled: false, serviceName: 's2'},
  220. {isSelected: true, isInstalled: true, serviceName: 's3'},
  221. {isSelected: false, isInstalled: false, serviceName: 's4'},
  222. {isSelected: true, isInstalled: false, serviceName: 's5'},
  223. {isSelected: false, isInstalled: false, serviceName: 's6'},
  224. {isSelected: true, isInstalled: true, serviceName: 's7'},
  225. {isSelected: false, isInstalled: false, serviceName: 's8'}
  226. ]
  227. });
  228. var expected = ['s1', 's5'];
  229. expect(installerStep7Controller.get('selectedServiceNames')).to.eql(expected);
  230. });
  231. });
  232. describe('#allSelectedServiceNames', function () {
  233. it('should use content.services as source of data', function () {
  234. installerStep7Controller.set('content', {
  235. services: [
  236. Em.Object.create({isSelected: true, isInstalled: false, serviceName: 's1'}),
  237. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's2'}),
  238. Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's3'}),
  239. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's4'}),
  240. Em.Object.create({isSelected: true, isInstalled: false, serviceName: 's5'}),
  241. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's6'}),
  242. Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's7'}),
  243. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's8'})
  244. ]
  245. });
  246. var expected = ['s1', 's3', 's5', 's7'];
  247. expect(installerStep7Controller.get('allSelectedServiceNames')).to.eql(expected);
  248. });
  249. });
  250. describe('#_createSiteToTagMap', function () {
  251. it('should return filtered map', function () {
  252. var desiredConfigs = {
  253. site1: {
  254. tag: "tag1"
  255. },
  256. site2: {
  257. tag: "tag2"
  258. },
  259. site3: {
  260. tag: "tag3"
  261. }
  262. };
  263. var sites = {
  264. site1: true,
  265. site3: true
  266. };
  267. var siteToTagMap = installerStep7Controller._createSiteToTagMap(desiredConfigs,sites);
  268. expect(siteToTagMap).to.eql({
  269. site1: "tag1",
  270. site3: "tag3"
  271. });
  272. });
  273. });
  274. describe('#checkDatabaseConnectionTest', function () {
  275. beforeEach(function () {
  276. installerStep7Controller.set('content', {
  277. services: Em.A([
  278. Em.Object.create({isSelected: true, isInstalled: false, serviceName: 'OOZIE', ignored: []}),
  279. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 'HIVE', ignored: []}),
  280. Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's3', ignored: []}),
  281. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's4', ignored: []}),
  282. Em.Object.create({isSelected: true, isInstalled: false, serviceName: 's5', ignored: []}),
  283. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's6', ignored: []}),
  284. Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's7', ignored: []}),
  285. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's8', ignored: []})
  286. ])
  287. });
  288. var obj = Em.Object.create({name:'oozie_database',value:"aa"});
  289. installerStep7Controller.set('stepConfigs',Em.A([Em.Object.create({serviceName: 'OOZIE', configs: Em.A([obj]) })]));
  290. this.deffer = installerStep7Controller.checkDatabaseConnectionTest();
  291. });
  292. it('should return promise in process', function () {
  293. expect(this.deffer.isResolved()).to.equal(false);
  294. this.deffer.resolve(true);
  295. this.deffer.done(function(data) {
  296. expect(data).to.equal(true);
  297. });
  298. });
  299. });
  300. describe.skip('#submit', function () {
  301. beforeEach(function () {
  302. sinon.stub(App, 'get').withArgs('supports.preInstallChecks').returns(false);
  303. });
  304. afterEach(function () {
  305. App.get.restore();
  306. });
  307. it('should return false if submit disabled', function () {
  308. installerStep7Controller.set('isSubmitDisabled',true);
  309. expect(installerStep7Controller.submit()).to.be.false;
  310. });
  311. it('sumbit button should be unclicked if no configs', function () {
  312. installerStep7Controller.set('isSubmitDisabled',false);
  313. installerStep7Controller.submit();
  314. expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
  315. });
  316. });
  317. describe('#getConfigTagsSuccess', function () {
  318. beforeEach(function(){
  319. sinon.stub(App.StackService, 'find', function () {
  320. return [
  321. Em.Object.create({
  322. serviceName: 's0',
  323. isInstalled: true,
  324. configTypes: {
  325. site3: true,
  326. site1: true
  327. }
  328. }),
  329. Em.Object.create({
  330. serviceName: 's1',
  331. isInstalled: true,
  332. configTypes: {
  333. site1: true,
  334. site2: true
  335. }
  336. })
  337. ];
  338. });
  339. });
  340. afterEach(function(){
  341. App.StackService.find.restore();
  342. });
  343. it('should return serviceConfigTags', function () {
  344. var desiredConfigs = {
  345. site1: {
  346. tag: "tag1"
  347. },
  348. site2: {
  349. tag: "tag2"
  350. },
  351. site3: {
  352. tag: "tag3"
  353. }
  354. };
  355. var data = {
  356. Clusters: {
  357. desired_configs: desiredConfigs
  358. }
  359. };
  360. installerStep7Controller.getConfigTagsSuccess(data);
  361. expect(installerStep7Controller.get('serviceConfigTags')).to.eql([
  362. {
  363. "siteName": "site1",
  364. "tagName": "tag1",
  365. "newTagName": null
  366. },
  367. {
  368. "siteName": "site2",
  369. "tagName": "tag2",
  370. "newTagName": null
  371. },
  372. {
  373. "siteName": "site3",
  374. "tagName": "tag3",
  375. "newTagName": null
  376. }
  377. ]);
  378. expect(installerStep7Controller.get('isAppliedConfigLoaded')).to.equal(true);
  379. });
  380. });
  381. describe('#clearStep', function () {
  382. it('should clear stepConfigs', function () {
  383. installerStep7Controller.set('stepConfigs', [
  384. {},
  385. {}
  386. ]);
  387. installerStep7Controller.clearStep();
  388. expect(installerStep7Controller.get('stepConfigs.length')).to.equal(0);
  389. });
  390. it('should clear filter', function () {
  391. installerStep7Controller.set('filter', 'filter');
  392. installerStep7Controller.clearStep();
  393. expect(installerStep7Controller.get('filter')).to.equal('');
  394. });
  395. it('should set for each filterColumns "selected" false', function () {
  396. installerStep7Controller.set('filterColumns', [
  397. {selected: true},
  398. {selected: false},
  399. {selected: true}
  400. ]);
  401. installerStep7Controller.clearStep();
  402. expect(installerStep7Controller.get('filterColumns').everyProperty('selected', false)).to.equal(true);
  403. });
  404. });
  405. describe('#loadInstalledServicesConfigGroups', function () {
  406. it('should do ajax request for each received service name', function () {
  407. var serviceNames = ['s1', 's2', 's3'];
  408. installerStep7Controller.loadInstalledServicesConfigGroups(serviceNames);
  409. expect(App.ajax.send.callCount).to.equal(serviceNames.length);
  410. });
  411. });
  412. describe('#getConfigTags', function () {
  413. it('should do ajax-request', function () {
  414. installerStep7Controller.getConfigTags();
  415. expect(App.ajax.send.calledOnce).to.equal(true);
  416. });
  417. });
  418. describe('#setGroupsToDelete', function () {
  419. beforeEach(function () {
  420. installerStep7Controller.set('wizardController', Em.Object.create(App.LocalStorage, {name: 'tdk'}));
  421. });
  422. it('should add new groups to groupsToDelete', function () {
  423. var groupsToDelete = [
  424. {id: '1'},
  425. {id: '2'}
  426. ],
  427. groups = [
  428. Em.Object.create({id: '3'}),
  429. Em.Object.create(),
  430. Em.Object.create({id: '5'})
  431. ],
  432. expected = [
  433. {id: "1"},
  434. {id: "2"},
  435. {id: "3"},
  436. {id: "5"}
  437. ];
  438. installerStep7Controller.set('groupsToDelete', groupsToDelete);
  439. installerStep7Controller.setGroupsToDelete(groups);
  440. expect(installerStep7Controller.get('groupsToDelete')).to.eql(expected);
  441. expect(installerStep7Controller.get('wizardController').getDBProperty('groupsToDelete')).to.eql(expected);
  442. });
  443. });
  444. describe('#checkMySQLHost', function () {
  445. it('should send query', function () {
  446. installerStep7Controller.checkMySQLHost();
  447. expect(App.ajax.send.calledOnce).to.be.true;
  448. });
  449. });
  450. describe('#selectConfigGroup', function () {
  451. beforeEach(function () {
  452. installerStep7Controller.reopen({content: {services: []}});
  453. sinon.stub(installerStep7Controller, 'switchConfigGroupConfigs', Em.K);
  454. });
  455. afterEach(function () {
  456. installerStep7Controller.switchConfigGroupConfigs.restore();
  457. });
  458. it('should set selectedConfigGroup', function () {
  459. var group = {':': []};
  460. installerStep7Controller.selectConfigGroup({context: group});
  461. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(group);
  462. });
  463. });
  464. describe('#selectedServiceObserver', function () {
  465. beforeEach(function () {
  466. installerStep7Controller.reopen({content: {services: []}});
  467. sinon.stub(installerStep7Controller, 'switchConfigGroupConfigs', Em.K);
  468. });
  469. afterEach(function () {
  470. installerStep7Controller.switchConfigGroupConfigs.restore();
  471. });
  472. it('shouldn\'t do nothing if App.supports.hostOverridesInstaller is false', function () {
  473. App.set('supports.hostOverridesInstaller', false);
  474. var configGroups = [
  475. {},
  476. {}
  477. ],
  478. selectedConfigGroup = {};
  479. installerStep7Controller.reopen({configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
  480. installerStep7Controller.selectedServiceObserver();
  481. expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
  482. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
  483. });
  484. it('shouldn\'t do nothing if selectedService is null', function () {
  485. App.set('supports.hostOverridesInstaller', true);
  486. var configGroups = [
  487. {},
  488. {}
  489. ],
  490. selectedConfigGroup = {};
  491. installerStep7Controller.reopen({selectedService: null, configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
  492. installerStep7Controller.selectedServiceObserver();
  493. expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
  494. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
  495. });
  496. it('shouldn\'t do nothing if selectedService.serviceName is MISC', function () {
  497. App.set('supports.hostOverridesInstaller', true);
  498. var configGroups = [
  499. {},
  500. {}
  501. ],
  502. selectedConfigGroup = {};
  503. installerStep7Controller.reopen({selectedService: {serviceName: 'MISC'}, configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
  504. installerStep7Controller.selectedServiceObserver();
  505. expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
  506. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
  507. });
  508. it('should update configGroups and selectedConfigGroup', function () {
  509. App.set('supports.hostOverridesInstaller', true);
  510. var defaultGroup = {isDefault: true, n: 'n2'},
  511. configGroups = [
  512. {isDefault: false, n: 'n1'},
  513. defaultGroup,
  514. {n: 'n3'}
  515. ];
  516. installerStep7Controller.reopen({selectedService: {serviceName: 's1', configGroups: configGroups}});
  517. installerStep7Controller.selectedServiceObserver();
  518. expect(installerStep7Controller.get('configGroups').mapProperty('n')).to.eql(['n2', 'n1', 'n3']);
  519. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(defaultGroup);
  520. });
  521. });
  522. describe('#loadConfigGroups', function () {
  523. beforeEach(function () {
  524. installerStep7Controller.reopen({
  525. wizardController: Em.Object.create({
  526. allHosts: [
  527. {hostName: 'h1'},
  528. {hostName: 'h2'},
  529. {hostName: 'h3'}
  530. ]
  531. })
  532. });
  533. });
  534. afterEach(function () {
  535. App.ServiceConfigGroup.find().clear();
  536. });
  537. it('shouldn\'t do nothing if only MISC available', function () {
  538. var configGroups = [
  539. {}
  540. ];
  541. installerStep7Controller.reopen({
  542. stepConfigs: [Em.Object.create({serviceName: 'MISC', configGroups: configGroups})]
  543. });
  544. installerStep7Controller.loadConfigGroups([]);
  545. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups')).to.eql(configGroups);
  546. });
  547. });
  548. describe('#_getDisplayedConfigGroups', function () {
  549. it('should return [] if no selected group', function () {
  550. installerStep7Controller.reopen({
  551. content: {services: []},
  552. selectedConfigGroup: null
  553. });
  554. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([]);
  555. });
  556. it('should return default config group if another selected', function () {
  557. var defaultGroup = Em.Object.create({isDefault: false});
  558. installerStep7Controller.reopen({
  559. content: {services: []},
  560. selectedConfigGroup: defaultGroup
  561. });
  562. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([defaultGroup]);
  563. });
  564. it('should return other groups if default selected', function () {
  565. var defaultGroup = Em.Object.create({isDefault: true}),
  566. cfgG = Em.Object.create({isDefault: true}),
  567. configGroups = Em.A([
  568. Em.Object.create({isDefault: false}),
  569. Em.Object.create({isDefault: false}),
  570. cfgG,
  571. Em.Object.create({isDefault: false})
  572. ]);
  573. installerStep7Controller.reopen({
  574. content: {services: []},
  575. selectedConfigGroup: defaultGroup,
  576. selectedService: {configGroups: configGroups}
  577. });
  578. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql(configGroups.without(cfgG));
  579. });
  580. });
  581. describe('#_setEditableValue', function () {
  582. it('shouldn\'t update config if no selectedConfigGroup', function () {
  583. installerStep7Controller.reopen({
  584. selectedConfigGroup: null
  585. });
  586. var config = Em.Object.create({isEditable: null});
  587. var updatedConfig = installerStep7Controller._setEditableValue(config);
  588. expect(updatedConfig.get('isEditable')).to.be.null;
  589. });
  590. it('should set isEditable equal to selectedGroup.isDefault if service not installed', function () {
  591. var isDefault = true;
  592. installerStep7Controller.reopen({
  593. installedServiceNames: [],
  594. selectedService: {serviceName: 'abc'},
  595. selectedConfigGroup: Em.Object.create({isDefault: isDefault})
  596. });
  597. var config = Em.Object.create({isEditable: null});
  598. var updatedConfig = installerStep7Controller._setEditableValue(config);
  599. expect(updatedConfig.get('isEditable')).to.equal(isDefault);
  600. installerStep7Controller.toggleProperty('selectedConfigGroup.isDefault');
  601. updatedConfig = installerStep7Controller._setEditableValue(config);
  602. expect(updatedConfig.get('isEditable')).to.equal(!isDefault);
  603. });
  604. Em.A([
  605. {
  606. isEditable: false,
  607. isReconfigurable: false,
  608. isDefault: true,
  609. e: false
  610. },
  611. {
  612. isEditable: true,
  613. isReconfigurable: true,
  614. isDefault: true,
  615. e: true
  616. },
  617. {
  618. isEditable: false,
  619. isReconfigurable: true,
  620. isDefault: false,
  621. e: false
  622. },
  623. {
  624. isEditable: true,
  625. isReconfigurable: false,
  626. isDefault: false,
  627. e: false
  628. }
  629. ]).forEach(function (test) {
  630. it('service installed, isEditable = ' + test.isEditable.toString() + ', isReconfigurable = ' + test.isReconfigurable.toString(), function () {
  631. var config = Em.Object.create({
  632. isReconfigurable: test.isReconfigurable,
  633. isEditable: test.isEditable
  634. });
  635. installerStep7Controller.reopen({
  636. installedServiceNames: Em.A(['a']),
  637. selectedService: Em.Object.create({serviceName: 'a'}),
  638. selectedConfigGroup: Em.Object.create({isDefault: test.isDefault})
  639. });
  640. var updateConfig = installerStep7Controller._setEditableValue(config);
  641. expect(updateConfig.get('isEditable')).to.equal(test.e);
  642. });
  643. });
  644. });
  645. describe('#_setOverrides', function () {
  646. it('shouldn\'t update config if no selectedConfigGroup', function () {
  647. installerStep7Controller.reopen({
  648. selectedConfigGroup: null
  649. });
  650. var config = Em.Object.create({overrides: null});
  651. var updatedConfig = installerStep7Controller._setOverrides(config, []);
  652. expect(updatedConfig.get('overrides')).to.be.null;
  653. });
  654. describe('no overrideToAdd', function () {
  655. var isDefault;
  656. beforeEach(function () {
  657. isDefault = true;
  658. var name = 'n1',
  659. config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
  660. overrides = Em.A([
  661. Em.Object.create({name: name, value: 'v1'}),
  662. Em.Object.create({name: name, value: 'v2'}),
  663. Em.Object.create({name: 'n2', value: 'v3'})
  664. ]);
  665. installerStep7Controller.reopen({
  666. overrideToAdd: null,
  667. selectedConfigGroup: Em.Object.create({
  668. isDefault: isDefault
  669. })
  670. });
  671. this.updatedConfig = installerStep7Controller._setOverrides(config, overrides);
  672. });
  673. it('2 overrides', function () {
  674. expect(this.updatedConfig.get('overrides.length')).to.equal(2);
  675. });
  676. it('each isEditable is ' + !isDefault, function () {
  677. expect(this.updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
  678. });
  679. it('each parentSCP.flag is `flag`', function () {
  680. expect(this.updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
  681. });
  682. });
  683. describe('overrideToAdd exists', function () {
  684. var isDefault = true;
  685. beforeEach(function () {
  686. var name = 'n1',
  687. config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
  688. overrides = Em.A([
  689. Em.Object.create({name: name, value: 'v1'}),
  690. Em.Object.create({name: name, value: 'v2'}),
  691. Em.Object.create({name: 'n2', value: 'v3'})
  692. ]);
  693. installerStep7Controller.reopen({
  694. overrideToAdd: Em.Object.create({name: name}),
  695. selectedService: {configGroups: [Em.Object.create({name: 'n', properties: []})]},
  696. selectedConfigGroup: Em.Object.create({
  697. isDefault: isDefault,
  698. name: 'n'
  699. })
  700. });
  701. this.updatedConfig = installerStep7Controller._setOverrides(config, overrides);
  702. });
  703. it('3 overrides', function () {
  704. expect(this.updatedConfig.get('overrides.length')).to.equal(3);
  705. });
  706. it('each isEditable is ' + !isDefault, function () {
  707. expect(this.updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
  708. });
  709. it('each parentSCP.flag is `flag`', function () {
  710. expect(this.updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
  711. });
  712. });
  713. });
  714. describe('#switchConfigGroupConfigs', function () {
  715. it('if selectedConfigGroup is null, serviceConfigs shouldn\'t be changed', function () {
  716. installerStep7Controller.reopen({
  717. selectedConfigGroup: null,
  718. content: {services: []},
  719. serviceConfigs: {configs: [
  720. {overrides: []},
  721. {overrides: []}
  722. ]}
  723. });
  724. installerStep7Controller.switchConfigGroupConfigs();
  725. expect(installerStep7Controller.get('serviceConfigs.configs').everyProperty('overrides.length', 0)).to.equal(true);
  726. });
  727. describe('should set configs for serviceConfigs', function () {
  728. var configGroups = [
  729. Em.Object.create({
  730. properties: [
  731. {name: 'g1', value: 'v1'},
  732. {name: 'g2', value: 'v2'}
  733. ]
  734. })
  735. ];
  736. beforeEach(function () {
  737. sinon.stub(installerStep7Controller, '_getDisplayedConfigGroups', function () {
  738. return configGroups;
  739. });
  740. sinon.stub(installerStep7Controller, '_setEditableValue', function (config) {
  741. config.set('isEditable', true);
  742. return config;
  743. });
  744. installerStep7Controller.reopen({
  745. selectedConfigGroup: Em.Object.create({isDefault: true, name: 'g1'}),
  746. content: {services: []},
  747. selectedService: {configs: Em.A([Em.Object.create({name: 'g1', overrides: [], properties: []}), Em.Object.create({name: 'g2', overrides: []})])},
  748. serviceConfigs: {configs: [Em.Object.create({name: 'g1'})]}
  749. });
  750. installerStep7Controller.switchConfigGroupConfigs();
  751. this.configs = installerStep7Controller.get('selectedService.configs');
  752. });
  753. afterEach(function () {
  754. installerStep7Controller._getDisplayedConfigGroups.restore();
  755. installerStep7Controller._setEditableValue.restore();
  756. });
  757. it('g1 has 1 override', function () {
  758. expect(this.configs.findProperty('name', 'g1').get('overrides').length).to.equal(1);
  759. });
  760. it('g2 has 1 override', function () {
  761. expect(this.configs.findProperty('name', 'g2').get('overrides').length).to.equal(1);
  762. });
  763. it('all configs are editable', function () {
  764. expect(this.configs.everyProperty('isEditable', true)).to.equal(true);
  765. });
  766. });
  767. });
  768. describe('#selectProperService', function () {
  769. Em.A([
  770. {
  771. name: 'addServiceController',
  772. stepConfigs: [
  773. {selected: false, name: 'n1'},
  774. {selected: true, name: 'n2'},
  775. {selected: true, name: 'n3'}
  776. ],
  777. e: 'n2'
  778. },
  779. {
  780. name: 'installerController',
  781. stepConfigs: [
  782. {showConfig: false, name: 'n1'},
  783. {showConfig: false, name: 'n2'},
  784. {showConfig: true, name: 'n3'}
  785. ],
  786. e: 'n3'
  787. }
  788. ]).forEach(function (test) {
  789. describe(test.name, function () {
  790. beforeEach(function () {
  791. sinon.stub(installerStep7Controller, 'selectedServiceObserver', Em.K);
  792. installerStep7Controller.reopen({
  793. wizardController: Em.Object.create({
  794. name: test.name
  795. }),
  796. stepConfigs: test.stepConfigs
  797. });
  798. installerStep7Controller.selectProperService();
  799. });
  800. afterEach(function () {
  801. installerStep7Controller.selectedServiceObserver.restore();
  802. });
  803. it('selected service name is valid', function () {
  804. expect(installerStep7Controller.get('selectedService.name')).to.equal(test.e);
  805. });
  806. });
  807. });
  808. });
  809. describe.skip('#setStepConfigs', function () {
  810. var serviceConfigs;
  811. beforeEach(function () {
  812. installerStep7Controller.reopen({
  813. content: {services: []},
  814. wizardController: Em.Object.create({
  815. getDBProperty: function (key) {
  816. return this.get(key);
  817. }
  818. })
  819. });
  820. sinon.stub(installerStep7Controller, 'renderConfigs', function () {
  821. return serviceConfigs;
  822. });
  823. this.stub = sinon.stub(App, 'get');
  824. });
  825. afterEach(function () {
  826. installerStep7Controller.renderConfigs.restore();
  827. App.get.restore();
  828. });
  829. it('if wizard isn\'t addService, should set output of installerStep7Controller.renderConfigs', function () {
  830. serviceConfigs = Em.A([
  831. {serviceName:'HDFS', configs: []},
  832. {}
  833. ]);
  834. installerStep7Controller.set('wizardController.name', 'installerController');
  835. installerStep7Controller.setStepConfigs([], []);
  836. expect(installerStep7Controller.get('stepConfigs')).to.eql(serviceConfigs);
  837. });
  838. it('addServiceWizard used', function () {
  839. serviceConfigs = Em.A([Em.Object.create({serviceName: 'HDFS', configs: []}), Em.Object.create({serviceName: 's2'})]);
  840. installerStep7Controller.set('wizardController.name', 'addServiceController');
  841. installerStep7Controller.reopen({selectedServiceNames: ['s2']});
  842. installerStep7Controller.setStepConfigs([], []);
  843. expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
  844. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 's2').get('selected')).to.equal(true);
  845. });
  846. it('addServiceWizard used, HA enabled', function () {
  847. this.stub.withArgs('isHaEnabled').returns(true);
  848. serviceConfigs = Em.A([
  849. Em.Object.create({
  850. serviceName: 'HDFS',
  851. configs: [
  852. Em.Object.create({category: 'SECONDARY_NAMENODE'}),
  853. Em.Object.create({category: 'SECONDARY_NAMENODE'}),
  854. Em.Object.create({category: 'NameNode'}),
  855. Em.Object.create({category: 'NameNode'}),
  856. Em.Object.create({category: 'SECONDARY_NAMENODE'})
  857. ]
  858. }),
  859. Em.Object.create({serviceName: 's2'})]
  860. );
  861. installerStep7Controller.set('wizardController.name', 'addServiceController');
  862. installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
  863. installerStep7Controller.setStepConfigs([], []);
  864. expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
  865. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('selected')).to.equal(true);
  866. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(5);
  867. });
  868. it('not windows stack', function () {
  869. this.stub.withArgs('isHadoopWindowsStack').returns(false);
  870. this.stub.withArgs('isHaEnabled').returns(false);
  871. serviceConfigs = Em.A([
  872. Em.Object.create({
  873. serviceName: 'HDFS',
  874. configs: [
  875. {category: 'NameNode'},
  876. {category: 'NameNode'}
  877. ]
  878. }),
  879. Em.Object.create({serviceName: 's2'})]
  880. );
  881. installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
  882. installerStep7Controller.setStepConfigs([], []);
  883. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
  884. });
  885. it('windows stack', function () {
  886. this.stub.withArgs('isHadoopWindowsStack').returns(true);
  887. this.stub.withArgs('isHaEnabled').returns(false);
  888. serviceConfigs = Em.A([
  889. Em.Object.create({
  890. serviceName: 'HDFS',
  891. configs: [
  892. {category: 'NameNode'},
  893. {category: 'NameNode'}
  894. ]
  895. }),
  896. Em.Object.create({serviceName: 's2'})]
  897. );
  898. installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
  899. installerStep7Controller.set('installedServiceNames',['HDFS', 's2', 's3']);
  900. installerStep7Controller.setStepConfigs([], []);
  901. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
  902. });
  903. });
  904. describe('#checkHostOverrideInstaller', function () {
  905. beforeEach(function () {
  906. sinon.stub(installerStep7Controller, 'loadConfigGroups', Em.K);
  907. sinon.stub(installerStep7Controller, 'loadInstalledServicesConfigGroups', Em.K);
  908. sinon.stub(App, 'get', function (k) {
  909. if (k === 'supports.hostOverridesInstaller') return false;
  910. return Em.get(App, k);
  911. });
  912. });
  913. afterEach(function () {
  914. installerStep7Controller.loadConfigGroups.restore();
  915. installerStep7Controller.loadInstalledServicesConfigGroups.restore();
  916. App.get.restore();
  917. });
  918. Em.A([
  919. {
  920. installedServiceNames: [],
  921. m: 'installedServiceNames is empty',
  922. e: {
  923. loadConfigGroups: true,
  924. loadInstalledServicesConfigGroups: false
  925. }
  926. },
  927. {
  928. installedServiceNames: ['s1', 's2', 's3'],
  929. areInstalledConfigGroupsLoaded: false,
  930. m: 'installedServiceNames isn\'t empty, config groups not yet loaded',
  931. e: {
  932. loadConfigGroups: true,
  933. loadInstalledServicesConfigGroups: true
  934. }
  935. },
  936. {
  937. installedServiceNames: ['s1', 's2', 's3'],
  938. areInstalledConfigGroupsLoaded: true,
  939. m: 'installedServiceNames isn\'t empty, config groups already loaded',
  940. e: {
  941. loadConfigGroups: true,
  942. loadInstalledServicesConfigGroups: false
  943. }
  944. }
  945. ]).forEach(function (test) {
  946. describe(test.m, function () {
  947. beforeEach(function () {
  948. installerStep7Controller.reopen({
  949. installedServiceNames: test.installedServiceNames,
  950. wizardController: {
  951. areInstalledConfigGroupsLoaded: test.areInstalledConfigGroupsLoaded
  952. }
  953. });
  954. installerStep7Controller.checkHostOverrideInstaller();
  955. });
  956. if (test.e.loadConfigGroups) {
  957. it('loadConfigGroups is called once', function () {
  958. expect(installerStep7Controller.loadConfigGroups.calledOnce).to.equal(true);
  959. });
  960. }
  961. else {
  962. it('loadConfigGroups is not called', function () {
  963. expect(installerStep7Controller.loadConfigGroups.called).to.equal(false);
  964. });
  965. }
  966. if (test.e.loadInstalledServicesConfigGroups) {
  967. it('loadInstalledServicesConfigGroups is called once', function () {
  968. expect(installerStep7Controller.loadInstalledServicesConfigGroups.calledOnce).to.equal(true);
  969. });
  970. }
  971. else {
  972. it('loadInstalledServicesConfigGroups is not called', function () {
  973. expect(installerStep7Controller.loadInstalledServicesConfigGroups.called).to.equal(false);
  974. });
  975. }
  976. });
  977. });
  978. });
  979. describe('#loadStep', function () {
  980. beforeEach(function () {
  981. installerStep7Controller.reopen({
  982. content: {services: []},
  983. wizardController: Em.Object.create({
  984. getDBProperty: function (k) {
  985. return this.get(k);
  986. },
  987. stackConfigsLoaded: true
  988. })
  989. });
  990. sinon.stub(App.config, 'fileConfigsIntoTextarea', Em.K);
  991. sinon.stub(installerStep7Controller, 'clearStep', Em.K);
  992. sinon.stub(installerStep7Controller, 'getConfigTags', Em.K);
  993. sinon.stub(installerStep7Controller, 'setInstalledServiceConfigs', Em.K);
  994. sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
  995. sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
  996. sinon.stub(installerStep7Controller, 'applyServicesConfigs', Em.K);
  997. sinon.stub(App.router, 'send', Em.K);
  998. });
  999. afterEach(function () {
  1000. App.config.fileConfigsIntoTextarea.restore();
  1001. installerStep7Controller.clearStep.restore();
  1002. installerStep7Controller.getConfigTags.restore();
  1003. installerStep7Controller.setInstalledServiceConfigs.restore();
  1004. installerStep7Controller.checkHostOverrideInstaller.restore();
  1005. installerStep7Controller.selectProperService.restore();
  1006. installerStep7Controller.applyServicesConfigs.restore();
  1007. App.router.send.restore();
  1008. });
  1009. it('should call clearStep', function () {
  1010. installerStep7Controller.loadStep();
  1011. expect(installerStep7Controller.clearStep.calledOnce).to.equal(true);
  1012. });
  1013. it('shouldn\'t do nothing if isAdvancedConfigLoaded is false', function () {
  1014. installerStep7Controller.set('wizardController.stackConfigsLoaded', false);
  1015. installerStep7Controller.loadStep();
  1016. expect(installerStep7Controller.clearStep.called).to.equal(false);
  1017. });
  1018. it('should call setInstalledServiceConfigs for addServiceController', function () {
  1019. installerStep7Controller.set('wizardController.name', 'addServiceController');
  1020. installerStep7Controller.loadStep();
  1021. expect(installerStep7Controller.setInstalledServiceConfigs.calledOnce).to.equal(true);
  1022. });
  1023. });
  1024. describe('#applyServicesConfigs', function() {
  1025. beforeEach(function() {
  1026. installerStep7Controller.reopen({
  1027. allSelectedServiceNames: []
  1028. });
  1029. sinon.stub(App.config, 'fileConfigsIntoTextarea', function(configs) {
  1030. return configs;
  1031. });
  1032. sinon.stub(installerStep7Controller, 'loadConfigRecommendations', function(c, callback) {
  1033. return callback();
  1034. });
  1035. sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
  1036. sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
  1037. sinon.stub(App.router, 'send', Em.K);
  1038. sinon.stub(App.StackService, 'find', function () {
  1039. return {
  1040. findProperty: function () {
  1041. return Em.Object.create({
  1042. isInstalled: true,
  1043. isSelected: false
  1044. });
  1045. },
  1046. filterProperty: function () {
  1047. return [];
  1048. }
  1049. }
  1050. });
  1051. installerStep7Controller.applyServicesConfigs([{name: 'configs'}]);
  1052. });
  1053. afterEach(function () {
  1054. App.config.fileConfigsIntoTextarea.restore();
  1055. installerStep7Controller.loadConfigRecommendations.restore();
  1056. installerStep7Controller.checkHostOverrideInstaller.restore();
  1057. installerStep7Controller.selectProperService.restore();
  1058. App.router.send.restore();
  1059. App.StackService.find.restore();
  1060. });
  1061. it('loadConfigRecommendations is called once' , function () {
  1062. expect(installerStep7Controller.loadConfigRecommendations.calledOnce).to.equal(true);
  1063. });
  1064. it('isRecommendedLoaded is true' , function () {
  1065. expect(installerStep7Controller.get('isRecommendedLoaded')).to.equal(true);
  1066. });
  1067. it('checkHostOverrideInstalleris called once' , function () {
  1068. expect(installerStep7Controller.checkHostOverrideInstaller.calledOnce).to.equal(true);
  1069. });
  1070. it('selectProperServiceis called once' , function () {
  1071. expect(installerStep7Controller.selectProperService.calledOnce).to.equal(true);
  1072. });
  1073. Em.A([
  1074. {
  1075. allSelectedServiceNames: ['YARN'],
  1076. fileConfigsIntoTextarea: true,
  1077. m: 'should run fileConfigsIntoTextarea'
  1078. }
  1079. ]).forEach(function(t) {
  1080. it(t.m, function () {
  1081. installerStep7Controller.reopen({
  1082. allSelectedServiceNames: t.allSelectedServiceNames
  1083. });
  1084. installerStep7Controller.applyServicesConfigs([{name: 'configs'}]);
  1085. if (t.fileConfigsIntoTextarea) {
  1086. expect(App.config.fileConfigsIntoTextarea.calledWith([{name: 'configs'}], 'capacity-scheduler.xml')).to.equal(true);
  1087. } else {
  1088. expect(App.config.fileConfigsIntoTextarea.calledOnce).to.equal(false);
  1089. }
  1090. });
  1091. });
  1092. });
  1093. describe('#updateHawqConfigs', function() {
  1094. var isSingleNode = false;
  1095. var testHawqSiteConfigs = [
  1096. {
  1097. name: 'hawq_standby_address_host',
  1098. value: 'h2'
  1099. },
  1100. {
  1101. name: 'hawq_master_address_host',
  1102. value: 'h1'
  1103. }
  1104. ];
  1105. var oldHawqSiteLength = testHawqSiteConfigs.length;
  1106. beforeEach(function () {
  1107. sinon.stub(App, 'get', function () {
  1108. return isSingleNode;
  1109. });
  1110. });
  1111. afterEach(function () {
  1112. App.get.restore()
  1113. });
  1114. it('hawq_standby_address_host should be removed on single node cluster', function() {
  1115. isSingleNode = true;
  1116. var hawqSiteConfigs = testHawqSiteConfigs.slice();
  1117. var updatedHawqSiteConfigs = installerStep7Controller.updateHawqConfigs(hawqSiteConfigs);
  1118. expect(updatedHawqSiteConfigs.length).to.be.equal(oldHawqSiteLength-1);
  1119. expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_standby_address_host')).to.not.exist;
  1120. expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_master_address_host').value).to.be.equal('h1');
  1121. });
  1122. it('hawq_standby_address_host should not be removed on multi node clusters', function() {
  1123. isSingleNode = false;
  1124. var hawqSiteConfigs = testHawqSiteConfigs.slice();
  1125. var updatedHawqSiteConfigs = installerStep7Controller.updateHawqConfigs(hawqSiteConfigs);
  1126. expect(updatedHawqSiteConfigs.length).to.be.equal(oldHawqSiteLength);
  1127. expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_standby_address_host').value).to.be.equal('h2');
  1128. expect(updatedHawqSiteConfigs.findProperty('name', 'hawq_master_address_host').value).to.be.equal('h1');
  1129. });
  1130. });
  1131. describe('#_updateIsEditableFlagForConfig', function () {
  1132. Em.A([
  1133. {
  1134. isAdmin: false,
  1135. isReconfigurable: false,
  1136. isHostsConfigsPage: true,
  1137. defaultGroupSelected: false,
  1138. m: 'false for non-admin users',
  1139. e: false
  1140. },
  1141. {
  1142. isAdmin: true,
  1143. isReconfigurable: false,
  1144. isHostsConfigsPage: true,
  1145. defaultGroupSelected: false,
  1146. m: 'false if defaultGroupSelected is false and isHostsConfigsPage is true',
  1147. e: false
  1148. },
  1149. {
  1150. isAdmin: true,
  1151. isReconfigurable: false,
  1152. isHostsConfigsPage: true,
  1153. defaultGroupSelected: true,
  1154. m: 'false if defaultGroupSelected is true and isHostsConfigsPage is true',
  1155. e: false
  1156. },
  1157. {
  1158. isAdmin: true,
  1159. isReconfigurable: false,
  1160. isHostsConfigsPage: false,
  1161. defaultGroupSelected: false,
  1162. m: 'false if defaultGroupSelected is false and isHostsConfigsPage is false',
  1163. e: false
  1164. }
  1165. ]).forEach(function (test) {
  1166. it(test.m, function () {
  1167. installerStep7Controller.reopen({isHostsConfigsPage: test.isHostsConfigsPage});
  1168. var serviceConfigProperty = Em.Object.create({
  1169. isReconfigurable: test.isReconfigurable
  1170. });
  1171. installerStep7Controller._updateIsEditableFlagForConfig(serviceConfigProperty, test.defaultGroupSelected);
  1172. expect(serviceConfigProperty.get('isEditable')).to.equal(test.e);
  1173. });
  1174. });
  1175. });
  1176. describe('#_updateOverridesForConfig', function () {
  1177. it('should set empty array', function () {
  1178. var serviceConfigProperty = Em.Object.create({
  1179. overrides: null
  1180. }), component = Em.Object.create();
  1181. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1182. expect(serviceConfigProperty.get('overrides')).to.eql(Em.A([]));
  1183. });
  1184. describe('host overrides not supported', function () {
  1185. var serviceConfigProperty = Em.Object.create({
  1186. overrides: [
  1187. {value: 'new value'}
  1188. ]
  1189. });
  1190. var component = Em.Object.create({selectedConfigGroup: {isDefault: false}});
  1191. beforeEach(function () {
  1192. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1193. });
  1194. it('there is 1 override', function () {
  1195. expect(serviceConfigProperty.get('overrides').length).to.equal(1);
  1196. });
  1197. it('override value is valid', function () {
  1198. expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
  1199. });
  1200. it('override is not original SCP', function () {
  1201. expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
  1202. });
  1203. it('override is linked to parent', function () {
  1204. expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
  1205. });
  1206. });
  1207. describe('host overrides supported', function () {
  1208. var serviceConfigProperty;
  1209. var component;
  1210. beforeEach(function () {
  1211. sinon.stub(App, 'get', function (k) {
  1212. if (k === 'supports.hostOverrides') return true;
  1213. return Em.get(App, k);
  1214. });
  1215. serviceConfigProperty = Em.Object.create({
  1216. overrides: [
  1217. {value: 'new value', group: Em.Object.create({name: 'n1'})}
  1218. ]
  1219. });
  1220. component = Em.Object.create({
  1221. selectedConfigGroup: {isDefault: true},
  1222. configGroups: Em.A([
  1223. Em.Object.create({name: 'n1', properties: []})
  1224. ])
  1225. });
  1226. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1227. });
  1228. afterEach(function () {
  1229. App.get.restore();
  1230. });
  1231. it('there is 1 override', function () {
  1232. expect(serviceConfigProperty.get('overrides').length).to.equal(1);
  1233. });
  1234. it('override.value is valid', function () {
  1235. expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
  1236. });
  1237. it('override is not original SCP', function () {
  1238. expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
  1239. });
  1240. it('override.parentSCP is valid', function () {
  1241. expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
  1242. });
  1243. it('there is 1 property in the config group', function () {
  1244. expect(component.get('configGroups.firstObject.properties').length).to.equal(1);
  1245. });
  1246. it('property in the config group is not editable', function () {
  1247. expect(component.get('configGroups.firstObject.properties.firstObject.isEditable')).to.equal(false);
  1248. });
  1249. it('property in the config group is linked to it', function () {
  1250. expect(component.get('configGroups.firstObject.properties.firstObject.group')).to.be.object;
  1251. });
  1252. });
  1253. });
  1254. describe('#setInstalledServiceConfigs', function () {
  1255. var controller = App.WizardStep7Controller.create({
  1256. installedServiceNames: ['HBASE', 'AMBARI_METRICS']
  1257. }),
  1258. configs = [
  1259. {
  1260. name: 'hbase.client.scanner.caching',
  1261. value: '1000',
  1262. serviceName: 'HBASE',
  1263. filename: 'hbase-site.xml'
  1264. },
  1265. {
  1266. name: 'hbase.client.scanner.caching',
  1267. value: '2000',
  1268. serviceName: 'AMBARI_METRICS',
  1269. filename: 'ams-hbase-site.xml'
  1270. }
  1271. ],
  1272. configsByTags = [
  1273. {
  1274. type: 'hbase-site',
  1275. tag: 'version2',
  1276. properties: {
  1277. 'hbase.client.scanner.caching': '1500'
  1278. }
  1279. },
  1280. {
  1281. type: 'ams-hbase-site',
  1282. tag: 'version2',
  1283. properties: {
  1284. 'hbase.client.scanner.caching': '2500'
  1285. }
  1286. },
  1287. {
  1288. type: 'site-without-properties',
  1289. tag: 'version1'
  1290. }
  1291. ],
  1292. installedServiceNames = ['HBASE', 'AMBARI_METRICS'];
  1293. describe('should handle properties with the same name', function () {
  1294. var properties;
  1295. beforeEach(function () {
  1296. controller.setInstalledServiceConfigs(configs, configsByTags, installedServiceNames);
  1297. properties = configs.filterProperty('name', 'hbase.client.scanner.caching');
  1298. });
  1299. it('there are 2 properties', function () {
  1300. expect(properties).to.have.length(2);
  1301. });
  1302. it('hbase-site/ value is valid', function () {
  1303. expect(properties.findProperty('filename', 'hbase-site.xml').value).to.equal('1500');
  1304. });
  1305. it('hbase-site/ savedValue is valid', function () {
  1306. expect(properties.findProperty('filename', 'hbase-site.xml').savedValue).to.equal('1500');
  1307. });
  1308. it('ams-hbase-site/ value is valid', function () {
  1309. expect(properties.findProperty('filename', 'ams-hbase-site.xml').value).to.equal('2500');
  1310. });
  1311. it('ams-hbase-site/ savedValue is valid', function () {
  1312. expect(properties.findProperty('filename', 'ams-hbase-site.xml').savedValue).to.equal('2500');
  1313. });
  1314. });
  1315. });
  1316. describe('#getAmbariDatabaseSuccess', function () {
  1317. var controller = App.WizardStep7Controller.create({
  1318. stepConfigs: [
  1319. {
  1320. serviceName: 'HIVE',
  1321. configs: [
  1322. {
  1323. name: 'hive_hostname',
  1324. value: 'h0'
  1325. }
  1326. ]
  1327. }
  1328. ]
  1329. }),
  1330. cases = [
  1331. {
  1332. data: {
  1333. hostComponents: []
  1334. },
  1335. mySQLServerConflict: false,
  1336. title: 'no Ambari Server host components'
  1337. },
  1338. {
  1339. data: {
  1340. hostComponents: [
  1341. {
  1342. RootServiceHostComponents: {
  1343. properties: {
  1344. 'server.jdbc.url': 'jdbc:mysql://h0/db0?createDatabaseIfNotExist=true'
  1345. }
  1346. }
  1347. }
  1348. ]
  1349. },
  1350. mySQLServerConflict: true,
  1351. title: 'Ambari MySQL Server and Hive Server are on the same host'
  1352. },
  1353. {
  1354. data: {
  1355. hostComponents: [
  1356. {
  1357. RootServiceHostComponents: {
  1358. properties: {
  1359. 'server.jdbc.url': 'jdbc:mysql://h1/db1?createDatabaseIfNotExist=true'
  1360. }
  1361. }
  1362. }
  1363. ]
  1364. },
  1365. mySQLServerConflict: false,
  1366. title: 'Ambari MySQL Server and Hive Server are on different hosts'
  1367. }
  1368. ];
  1369. cases.forEach(function (item) {
  1370. it(item.title, function () {
  1371. controller.getAmbariDatabaseSuccess(item.data);
  1372. expect(controller.get('mySQLServerConflict')).to.equal(item.mySQLServerConflict);
  1373. });
  1374. });
  1375. });
  1376. describe('#showDatabaseConnectionWarningPopup', function () {
  1377. var cases = [
  1378. {
  1379. method: 'onSecondary',
  1380. submitButtonClicked: false,
  1381. isRejected: true,
  1382. title: 'Cancel button clicked'
  1383. },
  1384. {
  1385. method: 'onPrimary',
  1386. submitButtonClicked: true,
  1387. isResolved: true,
  1388. title: 'Proceed Anyway button clicked'
  1389. }
  1390. ],
  1391. dfd,
  1392. testObject,
  1393. serviceNames = ['HIVE', 'OOZIE'],
  1394. bodyMessage = 'HIVE, OOZIE';
  1395. beforeEach(function () {
  1396. installerStep7Controller.set('submitButtonClicked', true);
  1397. dfd = $.Deferred(function (d) {
  1398. d.done(function () {
  1399. testObject.isResolved = true;
  1400. });
  1401. d.fail(function () {
  1402. testObject.isRejected = true;
  1403. })
  1404. });
  1405. testObject = {};
  1406. });
  1407. cases.forEach(function (item) {
  1408. describe(item.title, function () {
  1409. var popup;
  1410. beforeEach(function () {
  1411. popup = installerStep7Controller.showDatabaseConnectionWarningPopup(serviceNames, dfd);
  1412. });
  1413. it('popup body is valid', function () {
  1414. expect(popup.get('body')).to.equal(Em.I18n.t('installer.step7.popup.database.connection.body').format(bodyMessage));
  1415. });
  1416. it('after ' + item.method + ' execution', function () {
  1417. popup[item.method]();
  1418. expect(testObject.isResolved).to.equal(item.isResolved);
  1419. expect(testObject.isRejected).to.equal(item.isRejected);
  1420. expect(installerStep7Controller.get('submitButtonClicked')).to.equal(item.submitButtonClicked);
  1421. });
  1422. });
  1423. });
  1424. });
  1425. describe('#issuesFilterText', function () {
  1426. issuesFilterCases.forEach(function (item) {
  1427. it(item.title, function () {
  1428. issuesFilterTestSetup(installerStep7Controller, item);
  1429. expect(installerStep7Controller.get('issuesFilterText')).to.equal(item.issuesFilterText);
  1430. })
  1431. });
  1432. });
  1433. describe.skip('#loadServiceTagsSuccess', function () {
  1434. it('should create ClusterSiteToTagMap', function () {
  1435. var params = Em.Object.create({
  1436. serviceName: "OOZIE",
  1437. serviceConfigsDef: Em.Object.create({
  1438. configTypes: Em.Object.create({
  1439. site3: true,
  1440. site2: true,
  1441. site1: true
  1442. })
  1443. })
  1444. });
  1445. var wizardController = Em.Object.create({
  1446. allHosts: [
  1447. {hostName: 'h1'},
  1448. {hostName: 'h2'},
  1449. {hostName: 'h3'}
  1450. ]
  1451. });
  1452. installerStep7Controller.set('wizardController', wizardController);
  1453. installerStep7Controller.set('stepConfigs', Em.A([Em.Object.create({serviceName: 'OOZIE', configs: Em.A([]) })]));
  1454. var desiredConfigs = {
  1455. site1: {
  1456. tag: "tag1"
  1457. },
  1458. site2: {
  1459. tag: "tag2"
  1460. },
  1461. site3: {
  1462. tag: "tag3"
  1463. }
  1464. };
  1465. var data = {
  1466. config_groups: Em.A([Em.Object.create({
  1467. ConfigGroup: Em.Object.create({
  1468. tag: 'OOZIE',
  1469. hosts: Em.A([Em.Object.create({host_name: 'h1'})]),
  1470. id: 1,
  1471. group_name: "",
  1472. description: "",
  1473. desired_configs: Em.A([Em.Object.create({
  1474. type: '1',
  1475. tag: 'h1'
  1476. })])
  1477. })
  1478. })]),
  1479. Clusters: {
  1480. desired_configs: desiredConfigs
  1481. }
  1482. };
  1483. installerStep7Controller.loadServiceTagsSuccess(data, {}, params);
  1484. var result = installerStep7Controller.get("loadedClusterSiteToTagMap");
  1485. expect(JSON.parse(JSON.stringify(result))).to.eql(JSON.parse(JSON.stringify({"site1":"tag1","site2":"tag2","site3":"tag3"})));
  1486. })
  1487. });
  1488. describe('#issuesFilterLinkText', function () {
  1489. issuesFilterCases.forEach(function (item) {
  1490. it(item.title, function () {
  1491. issuesFilterTestSetup(installerStep7Controller, item);
  1492. expect(installerStep7Controller.get('issuesFilterLinkText')).to.equal(item.issuesFilterLinkText);
  1493. })
  1494. });
  1495. });
  1496. describe('#toggleIssuesFilter', function () {
  1497. it('should toggle issues filter', function () {
  1498. var issuesFilter = installerStep7Controller.get('filterColumns').findProperty('attributeName', 'hasIssues');
  1499. issuesFilter.set('selected', false);
  1500. installerStep7Controller.toggleIssuesFilter();
  1501. expect(issuesFilter.get('selected')).to.be.true;
  1502. installerStep7Controller.toggleIssuesFilter();
  1503. expect(issuesFilter.get('selected')).to.be.false;
  1504. });
  1505. it('selected service should be changed', function () {
  1506. installerStep7Controller.setProperties({
  1507. selectedService: {
  1508. errorCount: 0,
  1509. configGroups: []
  1510. },
  1511. stepConfigs: [
  1512. {
  1513. errorCount: 1,
  1514. configGroups: []
  1515. },
  1516. {
  1517. errorCount: 2,
  1518. configGroups: []
  1519. }
  1520. ]
  1521. });
  1522. installerStep7Controller.toggleIssuesFilter();
  1523. expect(installerStep7Controller.get('selectedService')).to.eql({
  1524. errorCount: 1,
  1525. configGroups: []
  1526. });
  1527. });
  1528. });
  1529. describe('#addKerberosDescriptorConfigs', function() {
  1530. var configs = [
  1531. { name: 'prop1', displayName: 'Prop1' },
  1532. { name: 'prop2', displayName: 'Prop2' },
  1533. { name: 'prop3', displayName: 'Prop3' }
  1534. ];
  1535. var descriptor = [
  1536. Em.Object.create({ name: 'prop4', filename: 'file-1'}),
  1537. Em.Object.create({ name: 'prop1', filename: 'file-1'})
  1538. ];
  1539. var propertiesAttrTests = [
  1540. {
  1541. attr: 'isUserProperty', val: false,
  1542. m: 'descriptor properties should not be marked as custom'
  1543. },
  1544. {
  1545. attr: 'category', val: 'Advanced file-1',
  1546. m: 'descriptor properties should be added to Advanced category'
  1547. },
  1548. {
  1549. attr: 'isOverridable', val: false,
  1550. m: 'descriptor properties should not be overriden'
  1551. }
  1552. ];
  1553. propertiesAttrTests.forEach(function(test) {
  1554. it(test.m, function() {
  1555. installerStep7Controller.addKerberosDescriptorConfigs(configs, descriptor);
  1556. expect(configs.findProperty('name', 'prop1')[test.attr]).to.be.eql(test.val);
  1557. });
  1558. });
  1559. });
  1560. describe('#addHawqConfigsOnNnHa', function () {
  1561. var configs = [
  1562. {
  1563. id: 'dfs.nameservices__hdfs-site',
  1564. description: 'dfs.nameservices__hdfs-site',
  1565. displayName: 'dfs.nameservices',
  1566. displayType: 'string',
  1567. name: 'dfs.nameservices',
  1568. value: 'haservice',
  1569. recommendedValue: 'haservice'
  1570. },
  1571. {
  1572. id: 'dfs.ha.namenodes.haservice__hdfs-site',
  1573. description: 'dfs.ha.namenodes.haservice__hdfs-site',
  1574. displayName: 'dfs.ha.namenodes.haservice',
  1575. displayType: 'string',
  1576. name: 'dfs.ha.namenodes.haservice',
  1577. value: 'nn1,nn2',
  1578. recommendedValue: 'nn1,nn2'
  1579. },
  1580. {
  1581. id: 'dfs.namenode.rpc-address.haservice.nn1__hdfs-site',
  1582. description: 'dfs.namenode.rpc-address.haservice.nn1__hdfs-site',
  1583. displayName: 'dfs.namenode.rpc-address.haservice.nn1',
  1584. displayType: 'string',
  1585. name: 'dfs.namenode.rpc-address.haservice.nn1',
  1586. value: 'c6401.ambari.apache.org:8020',
  1587. recommendedValue: 'c6401.ambari.apache.org:8020'
  1588. },
  1589. {
  1590. id: 'dfs.namenode.rpc-address.haservice.nn2__hdfs-site',
  1591. description: 'dfs.namenode.rpc-address.haservice.nn2__hdfs-site',
  1592. displayName: 'dfs.namenode.rpc-address.haservice.nn2',
  1593. displayType: 'string',
  1594. name: 'dfs.namenode.rpc-address.haservice.nn2',
  1595. value: 'c6402.ambari.apache.org:8020',
  1596. recommendedValue: 'c6402.ambari.apache.org:8020'
  1597. },
  1598. {
  1599. id: 'dfs.namenode.http-address.haservice.nn1__hdfs-site',
  1600. description: 'dfs.namenode.http-address.haservice.nn1__hdfs-site',
  1601. displayName: 'dfs.namenode.http-address.haservice.nn1',
  1602. displayType: 'string',
  1603. name: 'dfs.namenode.http-address.haservice.nn1',
  1604. value: 'c6401.ambari.apache.org:50070',
  1605. recommendedValue: 'c6401.ambari.apache.org:50070'
  1606. },
  1607. {
  1608. id: 'dfs.namenode.http-address.haservice.nn2__hdfs-site',
  1609. description: 'dfs.namenode.http-address.haservice.nn2__hdfs-site',
  1610. displayName: 'dfs.namenode.http-address.haservice.nn2',
  1611. displayType: 'string',
  1612. name: 'dfs.namenode.http-address.haservice.nn2',
  1613. value: 'c6402.ambari.apache.org:50070',
  1614. recommendedValue: 'c6402.ambari.apache.org:50070'
  1615. }
  1616. ];
  1617. var oldConfigs = configs.slice();
  1618. it('should copy properties from hdfs-site to hdfs-client for HAWQ', function() {
  1619. installerStep7Controller.addHawqConfigsOnNnHa(configs);
  1620. // ensure 6 new configs were added
  1621. expect(configs.length - oldConfigs.length).to.be.eql(6);
  1622. });
  1623. it('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 () {
  1624. oldConfigs.forEach(function(property) {
  1625. expect(configs.findProperty('id', property.name + '__hdfs-client').description).to.be.eql(property.description);
  1626. expect(configs.findProperty('id', property.name + '__hdfs-client').displayName).to.be.eql(property.displayName);
  1627. expect(configs.findProperty('id', property.name + '__hdfs-client').value).to.be.eql(property.value);
  1628. expect(configs.findProperty('id', property.name + '__hdfs-client').recommendedValue).to.be.eql(property.recommendedValue);
  1629. });
  1630. });
  1631. });
  1632. describe('#addHawqConfigsOnRMHa', function () {
  1633. var configs = [
  1634. {
  1635. id: 'yarn.resourcemanager.hostname.rm1__yarn-site',
  1636. name: 'yarn.resourcemanager.hostname.rm1',
  1637. value: 'c6401.ambari.apache.org',
  1638. recommendedValue: 'c6401.ambari.apache.org'
  1639. },
  1640. {
  1641. id: 'yarn.resourcemanager.hostname.rm2__yarn-site',
  1642. name: 'yarn.resourcemanager.hostname.rm2',
  1643. value: 'c6402.ambari.apache.org',
  1644. recommendedValue: 'c6402.ambari.apache.org'
  1645. }
  1646. ];
  1647. beforeEach(function () {
  1648. this.inputConfigsCount = configs.length;
  1649. installerStep7Controller.addHawqConfigsOnRMHa(configs);
  1650. this.yarnRmDetails = configs.findProperty('id', 'yarn.resourcemanager.ha__yarn-client');
  1651. this.yarnRmSchedulerDetails = configs.findProperty('id', 'yarn.resourcemanager.scheduler.ha__yarn-client');
  1652. });
  1653. it('should update properties in yarn-client for HAWQ if yarn ha is enabled', function() {
  1654. var noOfConfigsAdded = 2;
  1655. expect(configs.length).to.be.equal(this.inputConfigsCount + noOfConfigsAdded);
  1656. });
  1657. it('yarn.resourcemanager.ha__yarn-client', function() {
  1658. var expectedYarnRmHaValue = 'c6401.ambari.apache.org:8032,c6402.ambari.apache.org:8032';
  1659. expect(this.yarnRmDetails.value).to.be.equal(expectedYarnRmHaValue);
  1660. expect(this.yarnRmDetails.recommendedValue).to.be.equal(expectedYarnRmHaValue);
  1661. expect(this.yarnRmDetails.displayName).to.be.equal('yarn.resourcemanager.ha');
  1662. expect(this.yarnRmDetails.description).to.be.equal('Comma separated yarn resourcemanager host addresses with port');
  1663. });
  1664. it('yarn.resourcemanager.scheduler.ha__yarn-client', function() {
  1665. var expectedYarnRmSchedulerValue = 'c6401.ambari.apache.org:8030,c6402.ambari.apache.org:8030';
  1666. expect(this.yarnRmSchedulerDetails.value).to.be.equal(expectedYarnRmSchedulerValue);
  1667. expect(this.yarnRmSchedulerDetails.recommendedValue).to.be.equal(expectedYarnRmSchedulerValue);
  1668. expect(this.yarnRmSchedulerDetails.displayName).to.be.equal('yarn.resourcemanager.scheduler.ha');
  1669. expect(this.yarnRmSchedulerDetails.description).to.be.equal('Comma separated yarn resourcemanager scheduler addresses with port');
  1670. });
  1671. });
  1672. describe('#addHawqConfigsOnKerberizedCluster', function () {
  1673. var secureProperties = [
  1674. {
  1675. name: 'hadoop.security.authentication',
  1676. value: 'kerberos',
  1677. file: 'hdfs-client',
  1678. isOverridable: false,
  1679. isReconfigurable: false
  1680. }, {
  1681. name: 'enable_secure_filesystem',
  1682. value: 'ON',
  1683. file: 'hawq-site',
  1684. isOverridable: false,
  1685. isReconfigurable: false
  1686. }, {
  1687. name: 'krb_server_keyfile',
  1688. value: '/etc/security/keytabs/hawq.service.keytab',
  1689. file: 'hawq-site',
  1690. isOverridable: true,
  1691. isReconfigurable: true
  1692. }
  1693. ];
  1694. var configs = [
  1695. {
  1696. id: 'dummy__dummy-site',
  1697. description: 'dummy__dummy-site',
  1698. displayName: 'dummy',
  1699. displayType: 'string',
  1700. name: 'dummy',
  1701. value: 'dummy'
  1702. }
  1703. ];
  1704. beforeEach(function () {
  1705. this.originalConfigsLength = configs.length;
  1706. installerStep7Controller.addHawqConfigsOnKerberizedCluster(configs);
  1707. });
  1708. it('should add three security related configs for HAWQ if Kerberos is enabled', function () {
  1709. // ensure 3 new configs are added
  1710. expect(configs.length - this.originalConfigsLength).to.be.eql(3);
  1711. });
  1712. // check if all three new properties were added
  1713. secureProperties.forEach(function (newProperty) {
  1714. var id = newProperty.name + '__' + newProperty.file;
  1715. describe(id, function () {
  1716. beforeEach(function () {
  1717. this.newPropertyAdded = configs.findProperty('id', id);
  1718. });
  1719. it('#name', function () {
  1720. expect(this.newPropertyAdded.name).to.be.equal(newProperty.name);
  1721. });
  1722. it('#displayName', function () {
  1723. expect(this.newPropertyAdded.displayName).to.be.equal(newProperty.name);
  1724. });
  1725. it('#value', function () {
  1726. expect(this.newPropertyAdded.value).to.be.equal(newProperty.value);
  1727. });
  1728. it('#recommendedValue', function () {
  1729. expect(this.newPropertyAdded.recommendedValue).to.be.equal(newProperty.value);
  1730. });
  1731. it('#isOverridable', function () {
  1732. expect(this.newPropertyAdded.isOverridable).to.be.equal(newProperty.isOverridable);
  1733. });
  1734. it('#isReconfigurable', function () {
  1735. expect(this.newPropertyAdded.isReconfigurable).to.be.equal(newProperty.isReconfigurable);
  1736. });
  1737. });
  1738. });
  1739. });
  1740. describe('#errorsCount', function () {
  1741. it('should ignore configs with widgets (enhanced configs)', function () {
  1742. installerStep7Controller.reopen({selectedService: Em.Object.create({
  1743. configsWithErrors: Em.A([
  1744. Em.Object.create({widget: {}}),
  1745. Em.Object.create({widget: null})
  1746. ])
  1747. })
  1748. });
  1749. expect(installerStep7Controller.get('errorsCount')).to.equal(1);
  1750. });
  1751. });
  1752. describe('#_reconfigureServicesOnNnHa', function () {
  1753. var dfsNameservices = 'some_cluster';
  1754. Em.A([
  1755. {
  1756. serviceName: 'HBASE',
  1757. configToUpdate: 'hbase.rootdir',
  1758. oldValue: 'hdfs://nameserv:8020/apps/hbase/data',
  1759. expectedNewValue: 'hdfs://' + dfsNameservices + '/apps/hbase/data'
  1760. },
  1761. {
  1762. serviceName: 'ACCUMULO',
  1763. configToUpdate: 'instance.volumes',
  1764. oldValue: 'hdfs://localhost:8020/apps/accumulo/data',
  1765. expectedNewValue: 'hdfs://' + dfsNameservices + '/apps/accumulo/data'
  1766. },
  1767. {
  1768. serviceName: 'HAWQ',
  1769. configToUpdate: 'hawq_dfs_url',
  1770. oldValue: 'localhost:8020/hawq_data',
  1771. expectedNewValue: dfsNameservices + '/hawq_data'
  1772. }
  1773. ]).forEach(function (test) {
  1774. var serviceConfigs = [App.ServiceConfig.create({
  1775. serviceName: test.serviceName,
  1776. configs: [
  1777. Em.Object.create({
  1778. name: test.configToUpdate,
  1779. value: test.oldValue
  1780. })
  1781. ]
  1782. }),
  1783. App.ServiceConfig.create({
  1784. serviceName: 'HDFS',
  1785. configs: [
  1786. Em.Object.create({
  1787. name: 'dfs.nameservices',
  1788. value: dfsNameservices
  1789. })
  1790. ]
  1791. })];
  1792. it(test.serviceName + ' ' + test.configToUpdate, function () {
  1793. installerStep7Controller.reopen({
  1794. selectedServiceNames: [test.serviceName, 'HDFS']
  1795. });
  1796. serviceConfigs = installerStep7Controller._reconfigureServicesOnNnHa(serviceConfigs);
  1797. expect(serviceConfigs.findProperty('serviceName', test.serviceName).configs.findProperty('name', test.configToUpdate).get('value')).to.equal(test.expectedNewValue);
  1798. });
  1799. });
  1800. });
  1801. describe('#showOozieDerbyWarning', function() {
  1802. var controller;
  1803. beforeEach(function() {
  1804. controller = App.WizardStep7Controller.create({});
  1805. sinon.stub(App.ModalPopup, 'show', Em.K);
  1806. });
  1807. afterEach(function() {
  1808. App.ModalPopup.show.restore();
  1809. });
  1810. Em.A([
  1811. {
  1812. selectedServiceNames: ['HDFS', 'OOZIE'],
  1813. databaseType: Em.I18n.t('installer.step7.oozie.database.new'),
  1814. e: true,
  1815. m: 'Oozie selected with derby database, warning popup should be shown'
  1816. },
  1817. {
  1818. selectedServiceNames: ['HDFS'],
  1819. databaseType: Em.I18n.t('installer.step7.oozie.database.new'),
  1820. e: false,
  1821. m: 'Oozie not selected warning popup should be skipped'
  1822. },
  1823. {
  1824. selectedServiceNames: ['HDFS', 'OOZIE'],
  1825. databaseType: 'New Mysql Database',
  1826. e: false,
  1827. m: 'Oozie selected, mysql database used, warning popup should be sk'
  1828. }
  1829. ]).forEach(function(test) {
  1830. describe(test.m, function() {
  1831. beforeEach(function () {
  1832. sinon.stub(App.config, 'findConfigProperty').returns(Em.Object.create({ value: test.databaseType}));
  1833. controller.reopen({
  1834. selectedServiceNames: test.selectedServiceNames
  1835. });
  1836. controller.showOozieDerbyWarningPopup(Em.K);
  1837. });
  1838. afterEach(function () {
  1839. App.config.findConfigProperty.restore();
  1840. });
  1841. it('modal popup is shown needed number of times', function () {
  1842. expect(App.ModalPopup.show.calledOnce).to.equal(test.e);
  1843. });
  1844. });
  1845. });
  1846. });
  1847. describe('#addHostNamesToConfigs', function() {
  1848. beforeEach(function () {
  1849. sinon.stub(App.StackServiceComponent, 'find', function () {
  1850. return Em.Object.create({
  1851. id: 'NAMENODE',
  1852. displayName: 'NameNode'
  1853. });
  1854. });
  1855. });
  1856. afterEach(function () {
  1857. App.StackServiceComponent.find.restore();
  1858. });
  1859. it('should not create duplicate configs', function () {
  1860. var serviceConfig = Em.Object.create({
  1861. configs: [],
  1862. serviceName: 'HDFS',
  1863. configCategories: [
  1864. {
  1865. showHost: true,
  1866. name: 'NAMENODE'
  1867. }
  1868. ]
  1869. });
  1870. var masterComponents = [
  1871. {component: 'NAMENODE', hostName: 'h1'}
  1872. ];
  1873. var slaveComponents = [];
  1874. installerStep7Controller.addHostNamesToConfigs(serviceConfig, masterComponents, slaveComponents);
  1875. expect(serviceConfig.get('configs').filterProperty('name', 'namenode_host').length).to.equal(1);
  1876. installerStep7Controller.addHostNamesToConfigs(serviceConfig, masterComponents, slaveComponents);
  1877. expect(serviceConfig.get('configs').filterProperty('name', 'namenode_host').length).to.equal(1);
  1878. });
  1879. });
  1880. describe('#resolveHiveMysqlDatabase', function () {
  1881. beforeEach(function () {
  1882. installerStep7Controller.get('content').setProperties({
  1883. services: Em.A([
  1884. Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false})
  1885. ])
  1886. });
  1887. installerStep7Controller.setProperties({
  1888. stepConfigs: Em.A([
  1889. Em.Object.create({serviceName: 'HIVE', configs: [{name: 'hive_database', value: 'New MySQL Database'}]})
  1890. ]),
  1891. mySQLServerConflict: true
  1892. });
  1893. sinon.stub(installerStep7Controller, 'moveNext', Em.K);
  1894. sinon.stub(installerStep7Controller, 'checkMySQLHost', function () {
  1895. return $.Deferred().resolve();
  1896. });
  1897. sinon.spy(App.ModalPopup, 'show');
  1898. });
  1899. afterEach(function () {
  1900. installerStep7Controller.moveNext.restore();
  1901. installerStep7Controller.checkMySQLHost.restore();
  1902. App.ModalPopup.show.restore();
  1903. });
  1904. it('no HIVE service', function () {
  1905. installerStep7Controller.set('content.services', Em.A([]));
  1906. installerStep7Controller.resolveHiveMysqlDatabase();
  1907. expect(installerStep7Controller.moveNext.calledOnce).to.be.true;
  1908. expect(App.ModalPopup.show.called).to.be.false;
  1909. });
  1910. it('if mySQLServerConflict, popup is shown', function () {
  1911. installerStep7Controller.resolveHiveMysqlDatabase();
  1912. expect(installerStep7Controller.moveNext.called).to.be.false;
  1913. expect(App.ModalPopup.show.calledOnce).to.be.true;
  1914. });
  1915. });
  1916. describe('#mySQLWarningHandler', function () {
  1917. beforeEach(function () {
  1918. installerStep7Controller.set('mySQLServerConflict', true);
  1919. sinon.spy(App.ModalPopup, 'show');
  1920. sinon.stub(App.router, 'get').returns({gotoStep: Em.K});
  1921. sinon.stub(App.router.get(), 'gotoStep', Em.K);
  1922. });
  1923. afterEach(function () {
  1924. App.ModalPopup.show.restore();
  1925. App.router.get().gotoStep.restore();
  1926. App.router.get.restore();
  1927. });
  1928. it('warning popup is shown', function () {
  1929. installerStep7Controller.mySQLWarningHandler();
  1930. expect(App.ModalPopup.show.calledOnce).to.be.true;
  1931. });
  1932. it('submitButtonClicked is set to false on primary click', function () {
  1933. installerStep7Controller.mySQLWarningHandler().onPrimary();
  1934. expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
  1935. });
  1936. it('second popup is shown on secondary click', function () {
  1937. installerStep7Controller.mySQLWarningHandler().onSecondary();
  1938. expect(App.ModalPopup.show.calledTwice).to.be.true;
  1939. });
  1940. it('submitButtonClicked is set to false on secondary click on the second popup', function () {
  1941. installerStep7Controller.mySQLWarningHandler().onSecondary().onSecondary();
  1942. expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
  1943. });
  1944. it('user is moved to step5 on primary click on the second popup (installerController)', function () {
  1945. installerStep7Controller.set('content.controllerName', 'installerController');
  1946. installerStep7Controller.mySQLWarningHandler().onSecondary().onPrimary();
  1947. expect(App.router.get('installerController').gotoStep.calledWith(5, true)).to.be.true;
  1948. });
  1949. it('user is moved to step2 on primary click on the second popup (addSeviceController)', function () {
  1950. installerStep7Controller.set('content.controllerName', 'addServiceController');
  1951. installerStep7Controller.mySQLWarningHandler().onSecondary().onPrimary();
  1952. expect(App.router.get('addSeviceController').gotoStep.calledWith(2, true)).to.be.true;
  1953. });
  1954. });
  1955. describe('#supportsPreInstallChecks', function () {
  1956. beforeEach(function () {
  1957. this.stub = sinon.stub(App, 'get');
  1958. });
  1959. afterEach(function () {
  1960. this.stub.restore();
  1961. });
  1962. Em.A([
  1963. {preInstallChecks: true, controllerName: 'installerController', e: true},
  1964. {preInstallChecks: true, controllerName: '', e: false},
  1965. {preInstallChecks: false, controllerName: 'installerController', e: false},
  1966. {preInstallChecks: false, controllerName: '', e: false}
  1967. ]).forEach(function (test) {
  1968. it(JSON.stringify(test), function () {
  1969. this.stub.withArgs('supports.preInstallChecks').returns(test.preInstallChecks);
  1970. installerStep7Controller.set('content', {controllerName: test.controllerName});
  1971. installerStep7Controller.propertyDidChange('supportsPreInstallChecks');
  1972. expect(installerStep7Controller.get('supportsPreInstallChecks')).to.be.equal(test.e);
  1973. });
  1974. });
  1975. });
  1976. describe('#getHash', function () {
  1977. var stepConfigs = [
  1978. {
  1979. configs: [
  1980. Em.Object.create({name: 's1c1', isFinal: true, value: 'v11'}),
  1981. Em.Object.create({name: 's1c2', isFinal: false, value: 'v12', overrides: []}),
  1982. Em.Object.create({name: 's1c3', isFinal: true, value: 'v13', overrides: [
  1983. Em.Object.create({value: 'v131'})
  1984. ]})
  1985. ]
  1986. },
  1987. {
  1988. configs: [
  1989. Em.Object.create({name: 's2c1', isFinal: true, value: 'v21'}),
  1990. Em.Object.create({name: 's2c2', isFinal: false, value: 'v22', overrides: []}),
  1991. Em.Object.create({name: 's2c3', isFinal: true, value: 'v23', overrides: [
  1992. Em.Object.create({value: 'v231'})
  1993. ]})
  1994. ]
  1995. }
  1996. ];
  1997. beforeEach(function () {
  1998. installerStep7Controller.set('stepConfigs', stepConfigs);
  1999. this.hash = installerStep7Controller.getHash();
  2000. });
  2001. it('should map value, isFinal and overrides values', function () {
  2002. var expected = JSON.stringify({
  2003. s1c1: {
  2004. value: 'v11',
  2005. overrides: [],
  2006. isFinal: true
  2007. },
  2008. s1c2: {
  2009. value: 'v12',
  2010. overrides: [],
  2011. isFinal: false
  2012. },
  2013. s1c3: {
  2014. value: 'v13',
  2015. overrides: ['v131'],
  2016. isFinal: true
  2017. },
  2018. s2c1: {
  2019. value: 'v21',
  2020. overrides: [],
  2021. isFinal: true
  2022. },
  2023. s2c2: {
  2024. value: 'v22',
  2025. overrides: [],
  2026. isFinal: false
  2027. },
  2028. s2c3: {
  2029. value: 'v23',
  2030. overrides: ['v231'],
  2031. isFinal: true
  2032. }
  2033. });
  2034. expect(this.hash).to.be.equal(expected);
  2035. });
  2036. });
  2037. describe('#loadServiceConfigGroupOverrides', function () {
  2038. var serviceConfigs = [
  2039. {filename: 'f1', name: 'n1'}
  2040. ];
  2041. var configGroups = [
  2042. {
  2043. "name": "Default",
  2044. "description": "desc",
  2045. "isDefault": true,
  2046. "hosts": ['h1', 'h2', 'h3'],
  2047. "parentConfigGroup": null,
  2048. "service": {"id": "YARN"},
  2049. "serviceName": "YARN",
  2050. "configSiteTags": [],
  2051. "clusterHosts": []
  2052. }
  2053. ];
  2054. var loadedGroupToOverrideSiteToTagMap = {
  2055. Default: {
  2056. type1: 'tag1',
  2057. type2: 'tag2',
  2058. type3: 'tag3'
  2059. }
  2060. };
  2061. beforeEach(function () {
  2062. installerStep7Controller.loadServiceConfigGroupOverrides(serviceConfigs, loadedGroupToOverrideSiteToTagMap, configGroups);
  2063. this.args = App.ajax.send.args[0][0].data;
  2064. });
  2065. it('url params are valid', function () {
  2066. expect(this.args.params).to.be.equal('(type=type1&tag=tag1)|(type=type2&tag=tag2)|(type=type3&tag=tag3)');
  2067. });
  2068. it('configKeyToConfigMap is valid', function () {
  2069. var expected = {
  2070. "f1": {
  2071. "n1": {
  2072. "filename": "f1",
  2073. "name": "n1"
  2074. }
  2075. }
  2076. };
  2077. expect(this.args.configKeyToConfigMap).to.be.eql(expected);
  2078. });
  2079. describe('typeTagToGroupMap is valid', function () {
  2080. it('type1///tag1', function () {
  2081. var expected = {
  2082. "name": "Default",
  2083. "description": "desc",
  2084. "isDefault": true,
  2085. "hosts": [
  2086. "h1",
  2087. "h2",
  2088. "h3"
  2089. ],
  2090. "parentConfigGroup": null,
  2091. "service": {
  2092. "id": "YARN"
  2093. },
  2094. "serviceName": "YARN",
  2095. "configSiteTags": [],
  2096. "clusterHosts": []
  2097. };
  2098. expect(this.args.typeTagToGroupMap['type1///tag1']).to.be.eql(expected);
  2099. });
  2100. it('type2///tag2', function () {
  2101. var expected = {
  2102. "name": "Default",
  2103. "description": "desc",
  2104. "isDefault": true,
  2105. "hosts": [
  2106. "h1",
  2107. "h2",
  2108. "h3"
  2109. ],
  2110. "parentConfigGroup": null,
  2111. "service": {
  2112. "id": "YARN"
  2113. },
  2114. "serviceName": "YARN",
  2115. "configSiteTags": [],
  2116. "clusterHosts": []
  2117. };
  2118. expect(this.args.typeTagToGroupMap['type2///tag2']).to.be.eql(expected);
  2119. });
  2120. it('type3///tag3', function () {
  2121. var expected = {
  2122. "name": "Default",
  2123. "description": "desc",
  2124. "isDefault": true,
  2125. "hosts": [
  2126. "h1",
  2127. "h2",
  2128. "h3"
  2129. ],
  2130. "parentConfigGroup": null,
  2131. "service": {
  2132. "id": "YARN"
  2133. },
  2134. "serviceName": "YARN",
  2135. "configSiteTags": [],
  2136. "clusterHosts": []
  2137. };
  2138. expect(this.args.typeTagToGroupMap['type3///tag3']).to.be.eql(expected);
  2139. });
  2140. });
  2141. it('serviceConfigs is valid', function () {
  2142. var expected = [
  2143. {
  2144. "filename": "f1",
  2145. "name": "n1"
  2146. }
  2147. ];
  2148. expect(this.args.serviceConfigs).to.be.eql(expected);
  2149. });
  2150. });
  2151. describe('#updateHostOverrides', function () {
  2152. var configProperty;
  2153. var storedConfigProperty;
  2154. beforeEach(function () {
  2155. configProperty = Em.Object.create({});
  2156. storedConfigProperty = {
  2157. overrides: [
  2158. {value: 'v1'}
  2159. ]
  2160. };
  2161. installerStep7Controller.updateHostOverrides(configProperty, storedConfigProperty);
  2162. });
  2163. it('override is valid', function () {
  2164. var override = configProperty.get('overrides.0');
  2165. expect(override.get('value')).to.be.equal('v1');
  2166. expect(override.get('isOriginalSCP')).to.be.false;
  2167. expect(override.get('parentSCP')).to.be.eql(configProperty);
  2168. });
  2169. });
  2170. describe('#allowUpdateProperty', function () {
  2171. it('true if it is installer', function () {
  2172. installerStep7Controller.set('wizardController', {name: 'installerController'});
  2173. expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.true;
  2174. });
  2175. it('true if it is parentProperties are not empty', function () {
  2176. installerStep7Controller.set('wizardController', {name: 'some'});
  2177. expect(installerStep7Controller.allowUpdateProperty([{}], '', '')).to.be.true;
  2178. });
  2179. describe('#addServiceController', function () {
  2180. beforeEach(function () {
  2181. installerStep7Controller.set('wizardController', {name: 'addServiceController'});
  2182. this.stub = sinon.stub(App.configsCollection, 'getConfigByName');
  2183. sinon.stub(App.config, 'getServiceByConfigType', function (type) {
  2184. return Em.Object.create({serviceName: type === 't1' ? 's1' : 's2'});
  2185. })
  2186. });
  2187. afterEach(function () {
  2188. App.configsCollection.getConfigByName.restore();
  2189. App.config.getServiceByConfigType.restore();
  2190. });
  2191. it('stackProperty does not exist', function () {
  2192. this.stub.returns(null);
  2193. expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.true;
  2194. });
  2195. it('installedServices does not contain stackProperty.serviceName', function () {
  2196. this.stub.returns({serviceName: 's1'});
  2197. installerStep7Controller.set('installedServices', {});
  2198. expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.true;
  2199. });
  2200. it('stackProperty.propertyDependsOn is empty', function () {
  2201. installerStep7Controller.reopen({installedServices: {s1: true}});
  2202. this.stub.returns({serviceName: 's1', propertyDependsOn: []});
  2203. expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.false;
  2204. });
  2205. it('stackProperty.propertyDependsOn is not empty', function () {
  2206. installerStep7Controller.reopen({installedServices: {s1: true}});
  2207. this.stub.returns({serviceName: 's1', propertyDependsOn: [
  2208. {type: 't1'},
  2209. {type: 't2'}
  2210. ]});
  2211. expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.true;
  2212. });
  2213. it('stackProperty.propertyDependsOn is not empty (2)', function () {
  2214. installerStep7Controller.reopen({installedServices: {s1: true}});
  2215. this.stub.returns({serviceName: 's1', propertyDependsOn: [
  2216. {type: 't1'},
  2217. {type: 't1'}
  2218. ]});
  2219. expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.false;
  2220. });
  2221. });
  2222. it('true if it is not installer or addService', function () {
  2223. installerStep7Controller.set('wizardController', {name: 'some'});
  2224. expect(installerStep7Controller.allowUpdateProperty([], '', '')).to.be.true;
  2225. });
  2226. });
  2227. describe('#loadServiceConfigGroupOverridesSuccess', function () {
  2228. var data = {
  2229. items: [
  2230. {
  2231. type: 'type1',
  2232. tag: 'tag1',
  2233. properties: {
  2234. p1: 'v1',
  2235. p3: 'v3'
  2236. },
  2237. properties_attributes: {
  2238. final: {
  2239. p1: true,
  2240. p3: true
  2241. }
  2242. }
  2243. },
  2244. {
  2245. type: 'type2',
  2246. tag: 'tag1',
  2247. properties: {
  2248. p2: 'v2',
  2249. p4: 'v4'
  2250. },
  2251. properties_attributes: {}
  2252. }
  2253. ]
  2254. };
  2255. var params;
  2256. beforeEach(function () {
  2257. params = {
  2258. serviceConfigs: [],
  2259. typeTagToGroupMap: {
  2260. 'type1///tag1': Em.Object.create({
  2261. name: 't1t1'
  2262. }),
  2263. 'type2///tag1': Em.Object.create({
  2264. name: 't2t1'
  2265. })
  2266. },
  2267. configKeyToConfigMap: {
  2268. type1: {},
  2269. type2: {
  2270. p4: {}
  2271. }
  2272. }
  2273. };
  2274. sinon.stub(installerStep7Controller, 'onLoadOverrides', Em.K);
  2275. sinon.stub(App.config, 'getOriginalFileName', function (type) {return type;});
  2276. sinon.stub(App.config, 'formatPropertyValue', function (serviceConfigProperty, originalValue) {
  2277. return Em.isNone(originalValue) ? Em.get(serviceConfigProperty, 'value') : originalValue;
  2278. });
  2279. installerStep7Controller.loadServiceConfigGroupOverridesSuccess(data, {}, params);
  2280. this.serviceConfigs = installerStep7Controller.onLoadOverrides.args[0][0];
  2281. });
  2282. afterEach(function () {
  2283. installerStep7Controller.onLoadOverrides.restore();
  2284. App.config.getOriginalFileName.restore();
  2285. App.config.formatPropertyValue.restore();
  2286. });
  2287. it('type2/p4 is mapped to the params.configKeyToConfigMap', function () {
  2288. expect(params).to.have.deep.property('configKeyToConfigMap.type2.p4').that.is.an('object').with.deep.property('overrides');
  2289. });
  2290. it('type2/p4 has 1 override', function () {
  2291. expect(params.configKeyToConfigMap.type2.p4.overrides).to.have.property('length').equal(1);
  2292. });
  2293. it('type2/p4 override is valid', function () {
  2294. var override = params.configKeyToConfigMap.type2.p4.overrides[0];
  2295. expect(override.value).to.be.equal('v4');
  2296. expect(override.group.name).to.be.equal('t2t1');
  2297. expect(override.isFinal).to.be.false;
  2298. });
  2299. it('onLoadOverrides is called for 3 configs', function () {
  2300. expect(this.serviceConfigs).to.have.property('length').equal(3);
  2301. });
  2302. it('serviceConfigs ids are valid', function () {
  2303. expect(this.serviceConfigs.mapProperty('id')).to.be.eql(['p1__type1', 'p3__type1', 'p2__type2']);
  2304. });
  2305. it('serviceConfigs groups are valid', function () {
  2306. expect(this.serviceConfigs.mapProperty('group.name')).to.be.eql(['t1t1', 't1t1', 't2t1']);
  2307. });
  2308. it('serviceConfigs filenames are valid', function () {
  2309. expect(this.serviceConfigs.mapProperty('filename')).to.be.eql(['type1', 'type1', 'type2']);
  2310. });
  2311. });
  2312. });