step7_test.js 85 KB

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