step7_test.js 79 KB

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