step7_test.js 75 KB

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