step7_test.js 85 KB

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