step7_test.js 85 KB

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