step7_test.js 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099
  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('#resolveYarnConfigs', function () {
  620. it('should set property to true', function () {
  621. var allSelectedServiceNames = ['SLIDER', 'YARN'],
  622. configs = [
  623. {name: 'hadoop.registry.rm.enabled', value: false, recommendedValue: false}
  624. ],
  625. expected = [
  626. {name: 'hadoop.registry.rm.enabled', value: true, recommendedValue: true}
  627. ];
  628. installerStep7Controller.reopen({allSelectedServiceNames: allSelectedServiceNames});
  629. installerStep7Controller.resolveYarnConfigs(configs);
  630. expect(configs[0]).to.eql(expected[0]);
  631. });
  632. it('should set property to false', function () {
  633. var allSelectedServiceNames = ['YARN'],
  634. configs = [
  635. {name: 'hadoop.registry.rm.enabled', value: true, recommendedValue: true}
  636. ],
  637. expected = [
  638. {name: 'hadoop.registry.rm.enabled', value: false, recommendedValue: false}
  639. ];
  640. installerStep7Controller.reopen({allSelectedServiceNames: allSelectedServiceNames});
  641. installerStep7Controller.resolveYarnConfigs(configs);
  642. expect(configs[0]).to.eql(expected[0]);
  643. });
  644. it('should skip setting property', function () {
  645. var allSelectedServiceNames = ['YARN', 'SLIDER'],
  646. configs = [
  647. {name: 'hadoop.registry.rm.enabled', value: true, recommendedValue: true}
  648. ],
  649. expected = [
  650. {name: 'hadoop.registry.rm.enabled', value: true, recommendedValue: true}
  651. ];
  652. installerStep7Controller.reopen({allSelectedServiceNames: allSelectedServiceNames});
  653. installerStep7Controller.resolveYarnConfigs(configs);
  654. expect(configs[0]).to.eql(expected[0]);
  655. });
  656. });
  657. describe('#resolveStormConfigs', function () {
  658. beforeEach(function () {
  659. installerStep7Controller.reopen({
  660. content: {services: []},
  661. wizardController: Em.Object.create({
  662. hosts: {'h1': {name: 'host1', id: 'h1'}},
  663. masterComponentHosts: [{component: 'GANGLIA_SERVER', host_id: 'h1'}],
  664. getDBProperty: function (k) {
  665. return this.get(k);
  666. }
  667. })
  668. });
  669. });
  670. it('shouldn\'t do nothing if Ganglia and Storm are installed', function () {
  671. var installedServiceNames = ['GANGLIA', 'STORM'],
  672. configs = [
  673. {name: 'nimbus.childopts', value: '.jar=host=host2', recommendedValue: ''},
  674. {name: 'supervisor.childopts', value: '.jar=host=host2', recommendedValue: ''},
  675. {name: 'worker.childopts', value: '.jar=host=host2', recommendedValue: ''}
  676. ],
  677. expected = [
  678. {name: 'nimbus.childopts', value: '.jar=host=host2', recommendedValue: ''},
  679. {name: 'supervisor.childopts', value: '.jar=host=host2', recommendedValue: ''},
  680. {name: 'worker.childopts', value: '.jar=host=host2', recommendedValue: ''}
  681. ];
  682. installerStep7Controller.reopen({installedServiceNames: installedServiceNames});
  683. installerStep7Controller.resolveStormConfigs(configs);
  684. expect(configs).to.eql(expected);
  685. });
  686. it('shouldn\'t do nothing if Ganglia is in allSelectedServiceNames', function () {
  687. var allSelectedServiceNames = ['GANGLIA'],
  688. configs = [
  689. {name: 'nimbus.childopts', value: '.jar=host=host2', recommendedValue: ''},
  690. {name: 'supervisor.childopts', value: '.jar=host=host2', recommendedValue: ''},
  691. {name: 'worker.childopts', value: '.jar=host=host2', recommendedValue: ''}
  692. ],
  693. expected = [
  694. {name: 'nimbus.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'},
  695. {name: 'supervisor.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'},
  696. {name: 'worker.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'}
  697. ];
  698. installerStep7Controller.reopen({allSelectedServiceNames: allSelectedServiceNames});
  699. installerStep7Controller.resolveStormConfigs(configs);
  700. Em.keys(expected[0]).forEach(function (k) {
  701. expect(configs.mapProperty(k)).to.eql(expected.mapProperty(k));
  702. });
  703. });
  704. it('shouldn\'t do nothing if Ganglia is in installedServiceNames (2)', function () {
  705. var installedServiceNames = ['GANGLIA'],
  706. configs = [
  707. {name: 'nimbus.childopts', value: '.jar=host=host2', recommendedValue: ''},
  708. {name: 'supervisor.childopts', value: '.jar=host=host2', recommendedValue: ''},
  709. {name: 'worker.childopts', value: '.jar=host=host2', recommendedValue: ''}
  710. ],
  711. expected = [
  712. {name: 'nimbus.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'},
  713. {name: 'supervisor.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'},
  714. {name: 'worker.childopts', value: '.jar=host=host1', recommendedValue: '.jar=host=host1'}
  715. ];
  716. installerStep7Controller.reopen({installedServiceNames: installedServiceNames});
  717. installerStep7Controller.resolveStormConfigs(configs);
  718. Em.keys(expected[0]).forEach(function (k) {
  719. expect(configs.mapProperty(k)).to.eql(expected.mapProperty(k));
  720. });
  721. });
  722. it('should replace host name for *.childopts properties if Ganglia is in installedServiceNames for Add Service Wizard', function () {
  723. var installedServiceNames = ['GANGLIA'],
  724. configs = [
  725. {name: 'nimbus.childopts', value: '.jar=host=host2', recommendedValue: ''},
  726. {name: 'supervisor.childopts', value: '.jar=host=host2', recommendedValue: ''},
  727. {name: 'worker.childopts', value: '.jar=host=host2', recommendedValue: ''}
  728. ],
  729. expected = [
  730. {name: 'nimbus.childopts', value: '.jar=host=realhost1', recommendedValue: '.jar=host=realhost1'},
  731. {name: 'supervisor.childopts', value: '.jar=host=realhost1', recommendedValue: '.jar=host=realhost1'},
  732. {name: 'worker.childopts', value: '.jar=host=realhost1', recommendedValue: '.jar=host=realhost1'}
  733. ];
  734. installerStep7Controller.reopen({
  735. installedServiceNames: installedServiceNames,
  736. wizardController: Em.Object.create({
  737. name: 'addServiceController',
  738. masterComponentHosts: [{component: 'GANGLIA_SERVER', hostName: 'realhost1'}],
  739. getDBProperty: function (k) {
  740. return this.get(k);
  741. }
  742. })
  743. });
  744. installerStep7Controller.resolveStormConfigs(configs);
  745. Em.keys(expected[0]).forEach(function (k) {
  746. expect(configs.mapProperty(k)).to.eql(expected.mapProperty(k));
  747. });
  748. });
  749. });
  750. describe('#resolveServiceDependencyConfigs', function () {
  751. beforeEach(function () {
  752. sinon.stub(installerStep7Controller, 'resolveStormConfigs', Em.K);
  753. sinon.stub(installerStep7Controller, 'resolveYarnConfigs', Em.K);
  754. });
  755. afterEach(function () {
  756. installerStep7Controller.resolveStormConfigs.restore();
  757. installerStep7Controller.resolveYarnConfigs.restore();
  758. });
  759. [
  760. {serviceName: 'STORM', method: "resolveStormConfigs"},
  761. {serviceName: 'YARN', method: "resolveYarnConfigs"}
  762. ].forEach(function(t) {
  763. it("should call " + t.method + " if serviceName is " + t.serviceName, function () {
  764. var configs = [
  765. {},
  766. {}
  767. ];
  768. installerStep7Controller.resolveServiceDependencyConfigs(t.serviceName, configs);
  769. expect(installerStep7Controller[t.method].calledWith(configs)).to.equal(true);
  770. });
  771. });
  772. });
  773. describe('#selectedServiceObserver', function () {
  774. beforeEach(function () {
  775. installerStep7Controller.reopen({content: {services: []}});
  776. sinon.stub(installerStep7Controller, 'switchConfigGroupConfigs', Em.K);
  777. });
  778. afterEach(function () {
  779. installerStep7Controller.switchConfigGroupConfigs.restore();
  780. });
  781. it('shouldn\'t do nothing if App.supports.hostOverridesInstaller is false', function () {
  782. App.set('supports.hostOverridesInstaller', false);
  783. var configGroups = [
  784. {},
  785. {}
  786. ],
  787. selectedConfigGroup = {};
  788. installerStep7Controller.reopen({configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
  789. installerStep7Controller.selectedServiceObserver();
  790. expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
  791. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
  792. });
  793. it('shouldn\'t do nothing if selectedService is null', function () {
  794. App.set('supports.hostOverridesInstaller', true);
  795. var configGroups = [
  796. {},
  797. {}
  798. ],
  799. selectedConfigGroup = {};
  800. installerStep7Controller.reopen({selectedService: null, configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
  801. installerStep7Controller.selectedServiceObserver();
  802. expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
  803. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
  804. });
  805. it('shouldn\'t do nothing if selectedService.serviceName is MISC', function () {
  806. App.set('supports.hostOverridesInstaller', true);
  807. var configGroups = [
  808. {},
  809. {}
  810. ],
  811. selectedConfigGroup = {};
  812. installerStep7Controller.reopen({selectedService: {serviceName: 'MISC'}, configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
  813. installerStep7Controller.selectedServiceObserver();
  814. expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
  815. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
  816. });
  817. it('should update configGroups and selectedConfigGroup', function () {
  818. App.set('supports.hostOverridesInstaller', true);
  819. var defaultGroup = {isDefault: true, n: 'n2'},
  820. configGroups = [
  821. {isDefault: false, n: 'n1'},
  822. defaultGroup,
  823. {n: 'n3'}
  824. ],
  825. selectedConfigGroup = {};
  826. installerStep7Controller.reopen({selectedService: {serviceName: 's1', configGroups: configGroups}});
  827. installerStep7Controller.selectedServiceObserver();
  828. expect(installerStep7Controller.get('configGroups').mapProperty('n')).to.eql(['n2', 'n1', 'n3']);
  829. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(defaultGroup);
  830. });
  831. });
  832. describe('#loadConfigGroups', function () {
  833. beforeEach(function () {
  834. installerStep7Controller.reopen({
  835. wizardController: Em.Object.create({
  836. allHosts: [
  837. {hostName: 'h1'},
  838. {hostName: 'h2'},
  839. {hostName: 'h3'}
  840. ]
  841. })
  842. });
  843. });
  844. it('shouldn\'t do nothing if only MISC available', function () {
  845. var configGroups = [
  846. {}
  847. ];
  848. installerStep7Controller.reopen({
  849. stepConfigs: [Em.Object.create({serviceName: 'MISC', configGroups: configGroups})]
  850. });
  851. installerStep7Controller.loadConfigGroups([]);
  852. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups')).to.eql(configGroups);
  853. });
  854. it('should set configGroups for service if they don\'t exist', function () {
  855. var configGroups = [],
  856. serviceName = 'HDFS',
  857. serviceConfigGroups = [
  858. {service: {id: 's1'}}
  859. ];
  860. installerStep7Controller.reopen({
  861. stepConfigs: [Em.Object.create({serviceName: serviceName, displayName: serviceName, configGroups: configGroups})]
  862. });
  863. installerStep7Controller.loadConfigGroups(serviceConfigGroups);
  864. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups.length')).to.equal(1);
  865. var group = installerStep7Controller.get('stepConfigs.firstObject.configGroups.firstObject');
  866. expect(group.get('name')).to.equal(serviceName + ' Default');
  867. expect(group.get('description').contains(serviceName)).to.equal(true);
  868. expect(group.get('isDefault')).to.equal(true);
  869. expect(group.get('hosts')).to.eql(['h1', 'h2', 'h3']);
  870. expect(group.get('service.id')).to.equal(serviceName);
  871. expect(group.get('serviceName')).to.equal(serviceName);
  872. });
  873. it('should update configGroups for service (only default group)', function () {
  874. var configGroups = [],
  875. serviceName = 'HDFS',
  876. serviceConfigGroups = [
  877. {service: {id: 'HDFS'}, isDefault: true, n: 'n1'}
  878. ];
  879. installerStep7Controller.reopen({
  880. stepConfigs: [Em.Object.create({serviceName: serviceName, displayName: serviceName, configGroups: configGroups})]
  881. });
  882. installerStep7Controller.loadConfigGroups(serviceConfigGroups);
  883. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault').get('n')).to.equal('n1');
  884. });
  885. it('should update configGroups for service', function () {
  886. var configGroups = [],
  887. serviceName = 'HDFS',
  888. properties = [
  889. { name: "p1", filename: "file.xml" },
  890. { name: "p2", filename: "file.xml" }
  891. ],
  892. serviceConfigGroups = [
  893. {service: {id: 'HDFS'}, properties: properties.slice(), isDefault: true, n: 'n1'},
  894. {service: {id: 'HDFS'}, properties: properties.slice(), isDefault: false, n: 'n2'}
  895. ];
  896. installerStep7Controller.reopen({
  897. stepConfigs: [Em.Object.create({serviceName: serviceName, configGroups: configGroups, configs: properties})]
  898. });
  899. installerStep7Controller.loadConfigGroups(serviceConfigGroups);
  900. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups.length')).to.equal(2);
  901. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault').get('n')).to.equal('n1');
  902. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault', false).get('properties').everyProperty('group.n', 'n2')).to.equal(true);
  903. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault', false).get('parentConfigGroup.n')).to.equal('n1');
  904. });
  905. });
  906. describe('#_getDisplayedConfigGroups', function () {
  907. it('should return [] if no selected group', function () {
  908. installerStep7Controller.reopen({
  909. content: {services: []},
  910. selectedConfigGroup: null
  911. });
  912. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([]);
  913. });
  914. it('should return default config group if another selected', function () {
  915. var defaultGroup = Em.Object.create({isDefault: false});
  916. installerStep7Controller.reopen({
  917. content: {services: []},
  918. selectedConfigGroup: defaultGroup
  919. });
  920. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([defaultGroup]);
  921. });
  922. it('should return other groups if default selected', function () {
  923. var defaultGroup = Em.Object.create({isDefault: true}),
  924. cfgG = Em.Object.create({isDefault: true}),
  925. configGroups = Em.A([
  926. Em.Object.create({isDefault: false}),
  927. Em.Object.create({isDefault: false}),
  928. cfgG,
  929. Em.Object.create({isDefault: false})
  930. ]);
  931. installerStep7Controller.reopen({
  932. content: {services: []},
  933. selectedConfigGroup: defaultGroup,
  934. selectedService: {configGroups: configGroups}
  935. });
  936. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql(configGroups.without(cfgG));
  937. });
  938. });
  939. describe('#_setEditableValue', function () {
  940. it('shouldn\'t update config if no selectedConfigGroup', function () {
  941. installerStep7Controller.reopen({
  942. selectedConfigGroup: null
  943. });
  944. var config = Em.Object.create({isEditable: null});
  945. var updatedConfig = installerStep7Controller._setEditableValue(config);
  946. expect(updatedConfig.get('isEditable')).to.be.null;
  947. });
  948. it('should set isEditable equal to selectedGroup.isDefault if service not installed', function () {
  949. var isDefault = true;
  950. installerStep7Controller.reopen({
  951. installedServiceNames: [],
  952. selectedService: {serviceName: 'abc'},
  953. selectedConfigGroup: Em.Object.create({isDefault: isDefault})
  954. });
  955. var config = Em.Object.create({isEditable: null});
  956. var updatedConfig = installerStep7Controller._setEditableValue(config);
  957. expect(updatedConfig.get('isEditable')).to.equal(isDefault);
  958. installerStep7Controller.toggleProperty('selectedConfigGroup.isDefault');
  959. updatedConfig = installerStep7Controller._setEditableValue(config);
  960. expect(updatedConfig.get('isEditable')).to.equal(!isDefault);
  961. });
  962. Em.A([
  963. {
  964. isEditable: false,
  965. isReconfigurable: false,
  966. isDefault: true,
  967. e: false
  968. },
  969. {
  970. isEditable: true,
  971. isReconfigurable: true,
  972. isDefault: true,
  973. e: true
  974. },
  975. {
  976. isEditable: false,
  977. isReconfigurable: true,
  978. isDefault: false,
  979. e: false
  980. },
  981. {
  982. isEditable: true,
  983. isReconfigurable: false,
  984. isDefault: false,
  985. e: false
  986. }
  987. ]).forEach(function (test) {
  988. it('service installed, isEditable = ' + test.isEditable.toString() + ', isReconfigurable = ' + test.isReconfigurable.toString(), function () {
  989. var config = Em.Object.create({
  990. isReconfigurable: test.isReconfigurable,
  991. isEditable: test.isEditable
  992. });
  993. installerStep7Controller.reopen({
  994. installedServiceNames: Em.A(['a']),
  995. selectedService: Em.Object.create({serviceName: 'a'}),
  996. selectedConfigGroup: Em.Object.create({isDefault: test.isDefault})
  997. });
  998. var updateConfig = installerStep7Controller._setEditableValue(config);
  999. expect(updateConfig.get('isEditable')).to.equal(test.e);
  1000. });
  1001. });
  1002. });
  1003. describe('#_setOverrides', function () {
  1004. it('shouldn\'t update config if no selectedConfigGroup', function () {
  1005. installerStep7Controller.reopen({
  1006. selectedConfigGroup: null
  1007. });
  1008. var config = Em.Object.create({overrides: null});
  1009. var updatedConfig = installerStep7Controller._setOverrides(config, []);
  1010. expect(updatedConfig.get('overrides')).to.be.null;
  1011. });
  1012. it('no overrideToAdd', function () {
  1013. var isDefault = true,
  1014. name = 'n1',
  1015. config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
  1016. overrides = Em.A([
  1017. Em.Object.create({name: name, value: 'v1'}),
  1018. Em.Object.create({name: name, value: 'v2'}),
  1019. Em.Object.create({name: 'n2', value: 'v3'})
  1020. ]);
  1021. installerStep7Controller.reopen({
  1022. overrideToAdd: null,
  1023. selectedConfigGroup: Em.Object.create({
  1024. isDefault: isDefault
  1025. })
  1026. });
  1027. var updatedConfig = installerStep7Controller._setOverrides(config, overrides);
  1028. expect(updatedConfig.get('overrides.length')).to.equal(2);
  1029. expect(updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
  1030. expect(updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
  1031. });
  1032. it('overrideToAdd exists', function () {
  1033. var isDefault = true,
  1034. name = 'n1',
  1035. config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
  1036. overrides = Em.A([
  1037. Em.Object.create({name: name, value: 'v1'}),
  1038. Em.Object.create({name: name, value: 'v2'}),
  1039. Em.Object.create({name: 'n2', value: 'v3'})
  1040. ]);
  1041. installerStep7Controller.reopen({
  1042. overrideToAdd: Em.Object.create({name: name}),
  1043. selectedService: {configGroups: [Em.Object.create({name: 'n', properties: []})]},
  1044. selectedConfigGroup: Em.Object.create({
  1045. isDefault: isDefault,
  1046. name: 'n'
  1047. })
  1048. });
  1049. var updatedConfig = installerStep7Controller._setOverrides(config, overrides);
  1050. expect(updatedConfig.get('overrides.length')).to.equal(3);
  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. });
  1055. describe('#switchConfigGroupConfigs', function () {
  1056. it('if selectedConfigGroup is null, serviceConfigs shouldn\'t be changed', function () {
  1057. installerStep7Controller.reopen({
  1058. selectedConfigGroup: null,
  1059. content: {services: []},
  1060. serviceConfigs: {configs: [
  1061. {overrides: []},
  1062. {overrides: []}
  1063. ]}
  1064. });
  1065. installerStep7Controller.switchConfigGroupConfigs();
  1066. expect(installerStep7Controller.get('serviceConfigs.configs').everyProperty('overrides.length', 0)).to.equal(true);
  1067. });
  1068. it('should set configs for serviceConfigs', function () {
  1069. var configGroups = [
  1070. Em.Object.create({
  1071. properties: [
  1072. {name: 'g1', value: 'v1'},
  1073. {name: 'g2', value: 'v2'}
  1074. ]
  1075. })
  1076. ];
  1077. sinon.stub(installerStep7Controller, '_getDisplayedConfigGroups', function () {
  1078. return configGroups;
  1079. });
  1080. sinon.stub(installerStep7Controller, '_setEditableValue', function (config) {
  1081. config.set('isEditable', true);
  1082. return config;
  1083. });
  1084. installerStep7Controller.reopen({
  1085. selectedConfigGroup: Em.Object.create({isDefault: true, name: 'g1'}),
  1086. content: {services: []},
  1087. selectedService: {configs: Em.A([Em.Object.create({name: 'g1', overrides: [], properties: []}), Em.Object.create({name: 'g2', overrides: []})])},
  1088. serviceConfigs: {configs: [Em.Object.create({name: 'g1'})]}
  1089. });
  1090. installerStep7Controller.switchConfigGroupConfigs();
  1091. var configs = installerStep7Controller.get('selectedService.configs');
  1092. expect(configs.findProperty('name', 'g1').get('overrides').length).to.equal(1);
  1093. expect(configs.findProperty('name', 'g2').get('overrides').length).to.equal(1);
  1094. expect(configs.everyProperty('isEditable', true)).to.equal(true);
  1095. installerStep7Controller._getDisplayedConfigGroups.restore();
  1096. installerStep7Controller._setEditableValue.restore();
  1097. });
  1098. });
  1099. describe('#selectProperService', function () {
  1100. Em.A([
  1101. {
  1102. name: 'addServiceController',
  1103. stepConfigs: [
  1104. {selected: false, name: 'n1'},
  1105. {selected: true, name: 'n2'},
  1106. {selected: true, name: 'n3'}
  1107. ],
  1108. e: 'n2'
  1109. },
  1110. {
  1111. name: 'installerController',
  1112. stepConfigs: [
  1113. {showConfig: false, name: 'n1'},
  1114. {showConfig: false, name: 'n2'},
  1115. {showConfig: true, name: 'n3'}
  1116. ],
  1117. e: 'n3'
  1118. }
  1119. ]).forEach(function (test) {
  1120. it(test.name, function () {
  1121. sinon.stub(installerStep7Controller, 'selectedServiceObserver', Em.K);
  1122. installerStep7Controller.reopen({
  1123. wizardController: Em.Object.create({
  1124. name: test.name
  1125. }),
  1126. stepConfigs: test.stepConfigs
  1127. });
  1128. installerStep7Controller.selectProperService();
  1129. expect(installerStep7Controller.get('selectedService.name')).to.equal(test.e);
  1130. installerStep7Controller.selectedServiceObserver.restore();
  1131. });
  1132. });
  1133. });
  1134. describe('#setStepConfigs', function () {
  1135. beforeEach(function () {
  1136. installerStep7Controller.reopen({
  1137. content: {services: []},
  1138. wizardController: Em.Object.create({
  1139. getDBProperty: function (key) {
  1140. return this.get(key);
  1141. }
  1142. })
  1143. });
  1144. });
  1145. afterEach(function () {
  1146. App.config.renderConfigs.restore();
  1147. });
  1148. it('if wizard isn\'t addService, should set output of App.config.renderConfigs', function () {
  1149. var serviceConfigs = Em.A([
  1150. {serviceName:'HDFS', configs: []},
  1151. {}
  1152. ]);
  1153. sinon.stub(App.config, 'renderConfigs', function () {
  1154. return serviceConfigs;
  1155. });
  1156. installerStep7Controller.set('wizardController.name', 'installerController');
  1157. installerStep7Controller.setStepConfigs([], []);
  1158. expect(installerStep7Controller.get('stepConfigs')).to.eql(serviceConfigs);
  1159. });
  1160. it('addServiceWizard used', function () {
  1161. var serviceConfigs = Em.A([Em.Object.create({serviceName: 'HDFS', configs: []}), Em.Object.create({serviceName: 's2'})]);
  1162. installerStep7Controller.set('wizardController.name', 'addServiceController');
  1163. installerStep7Controller.reopen({selectedServiceNames: ['s2']});
  1164. sinon.stub(App.config, 'renderConfigs', function () {
  1165. return serviceConfigs;
  1166. });
  1167. installerStep7Controller.setStepConfigs([], []);
  1168. expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
  1169. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 's2').get('selected')).to.equal(true);
  1170. });
  1171. it('addServiceWizard used, HA enabled', function () {
  1172. sinon.stub(App, 'get', function (k) {
  1173. if (k === 'isHaEnabled') {
  1174. return true;
  1175. }
  1176. return Em.get(App, k);
  1177. });
  1178. var serviceConfigs = Em.A([
  1179. Em.Object.create({
  1180. serviceName: 'HDFS',
  1181. configs: [
  1182. Em.Object.create({category: 'SECONDARY_NAMENODE'}),
  1183. Em.Object.create({category: 'SECONDARY_NAMENODE'}),
  1184. Em.Object.create({category: 'NameNode'}),
  1185. Em.Object.create({category: 'NameNode'}),
  1186. Em.Object.create({category: 'SECONDARY_NAMENODE'})
  1187. ]
  1188. }),
  1189. Em.Object.create({serviceName: 's2'})]
  1190. );
  1191. installerStep7Controller.set('wizardController.name', 'addServiceController');
  1192. installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
  1193. sinon.stub(App.config, 'renderConfigs', function () {
  1194. return serviceConfigs;
  1195. });
  1196. installerStep7Controller.setStepConfigs([], []);
  1197. expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
  1198. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('selected')).to.equal(true);
  1199. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(5);
  1200. App.get.restore();
  1201. });
  1202. it('not windows stack', function () {
  1203. var s = sinon.stub(App, 'get');
  1204. s.withArgs('isHadoopWindowsStack').returns(false);
  1205. s.withArgs('isHaEnabled').returns(false);
  1206. var serviceConfigs = Em.A([
  1207. Em.Object.create({
  1208. serviceName: 'HDFS',
  1209. configs: [
  1210. {category: 'NameNode'},
  1211. {category: 'NameNode'}
  1212. ]
  1213. }),
  1214. Em.Object.create({serviceName: 's2'})]
  1215. );
  1216. installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
  1217. sinon.stub(App.config, 'renderConfigs', function () {
  1218. return serviceConfigs;
  1219. });
  1220. installerStep7Controller.setStepConfigs([], []);
  1221. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
  1222. s.restore();
  1223. });
  1224. it('windows stack', function () {
  1225. var s = sinon.stub(App, 'get');
  1226. s.withArgs('isHadoopWindowsStack').returns(true);
  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. installerStep7Controller.set('installedServiceNames',['HDFS', 's2', 's3']);
  1240. sinon.stub(App.config, 'renderConfigs', function () {
  1241. return serviceConfigs;
  1242. });
  1243. installerStep7Controller.setStepConfigs([], []);
  1244. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
  1245. s.restore();
  1246. });
  1247. });
  1248. describe('#checkHostOverrideInstaller', function () {
  1249. beforeEach(function () {
  1250. sinon.stub(installerStep7Controller, 'loadConfigGroups', Em.K);
  1251. sinon.stub(installerStep7Controller, 'loadInstalledServicesConfigGroups', Em.K);
  1252. });
  1253. afterEach(function () {
  1254. installerStep7Controller.loadConfigGroups.restore();
  1255. installerStep7Controller.loadInstalledServicesConfigGroups.restore();
  1256. App.get.restore();
  1257. });
  1258. Em.A([
  1259. {
  1260. installedServiceNames: [],
  1261. m: 'installedServiceNames is empty',
  1262. e: {
  1263. loadConfigGroups: true,
  1264. loadInstalledServicesConfigGroups: false
  1265. }
  1266. },
  1267. {
  1268. installedServiceNames: ['s1', 's2', 's3'],
  1269. areInstalledConfigGroupsLoaded: false,
  1270. m: 'installedServiceNames isn\'t empty, config groups not yet loaded',
  1271. e: {
  1272. loadConfigGroups: true,
  1273. loadInstalledServicesConfigGroups: true
  1274. }
  1275. },
  1276. {
  1277. installedServiceNames: ['s1', 's2', 's3'],
  1278. areInstalledConfigGroupsLoaded: true,
  1279. m: 'installedServiceNames isn\'t empty, config groups already loaded',
  1280. e: {
  1281. loadConfigGroups: true,
  1282. loadInstalledServicesConfigGroups: false
  1283. }
  1284. }
  1285. ]).forEach(function (test) {
  1286. it(test.m, function () {
  1287. sinon.stub(App, 'get', function (k) {
  1288. if (k === 'supports.hostOverridesInstaller') return test.hostOverridesInstaller;
  1289. return Em.get(App, k);
  1290. });
  1291. installerStep7Controller.reopen({
  1292. installedServiceNames: test.installedServiceNames,
  1293. wizardController: {
  1294. areInstalledConfigGroupsLoaded: test.areInstalledConfigGroupsLoaded
  1295. }
  1296. });
  1297. installerStep7Controller.checkHostOverrideInstaller();
  1298. if (test.e.loadConfigGroups) {
  1299. expect(installerStep7Controller.loadConfigGroups.calledOnce).to.equal(true);
  1300. }
  1301. else {
  1302. expect(installerStep7Controller.loadConfigGroups.called).to.equal(false);
  1303. }
  1304. if (test.e.loadInstalledServicesConfigGroups) {
  1305. expect(installerStep7Controller.loadInstalledServicesConfigGroups.calledOnce).to.equal(true);
  1306. }
  1307. else {
  1308. expect(installerStep7Controller.loadInstalledServicesConfigGroups.called).to.equal(false);
  1309. }
  1310. });
  1311. });
  1312. });
  1313. describe('#loadStep', function () {
  1314. beforeEach(function () {
  1315. installerStep7Controller.reopen({
  1316. content: {services: []},
  1317. wizardController: Em.Object.create({
  1318. getDBProperty: function (k) {
  1319. return this.get(k);
  1320. },
  1321. stackConfigsLoaded: true
  1322. })
  1323. });
  1324. sinon.stub(App.config, 'mergePreDefinedWithStored', Em.K);
  1325. sinon.stub(App.config, 'fileConfigsIntoTextarea', Em.K);
  1326. sinon.stub(installerStep7Controller, 'clearStep', Em.K);
  1327. sinon.stub(installerStep7Controller, 'getConfigTags', Em.K);
  1328. sinon.stub(installerStep7Controller, 'setInstalledServiceConfigs', Em.K);
  1329. sinon.stub(installerStep7Controller, 'resolveServiceDependencyConfigs', Em.K);
  1330. sinon.stub(installerStep7Controller, 'setStepConfigs', Em.K);
  1331. sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
  1332. sinon.stub(installerStep7Controller, 'activateSpecialConfigs', Em.K);
  1333. sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
  1334. sinon.stub(installerStep7Controller, 'applyServicesConfigs', Em.K);
  1335. sinon.stub(App.router, 'send', Em.K);
  1336. });
  1337. afterEach(function () {
  1338. App.config.mergePreDefinedWithStored.restore();
  1339. App.config.fileConfigsIntoTextarea.restore();
  1340. installerStep7Controller.clearStep.restore();
  1341. installerStep7Controller.getConfigTags.restore();
  1342. installerStep7Controller.setInstalledServiceConfigs.restore();
  1343. installerStep7Controller.resolveServiceDependencyConfigs.restore();
  1344. installerStep7Controller.setStepConfigs.restore();
  1345. installerStep7Controller.checkHostOverrideInstaller.restore();
  1346. installerStep7Controller.activateSpecialConfigs.restore();
  1347. installerStep7Controller.selectProperService.restore();
  1348. installerStep7Controller.applyServicesConfigs.restore();
  1349. App.router.send.restore();
  1350. });
  1351. it('should call clearStep', function () {
  1352. installerStep7Controller.loadStep();
  1353. expect(installerStep7Controller.clearStep.calledOnce).to.equal(true);
  1354. });
  1355. it('shouldn\'t do nothing if isAdvancedConfigLoaded is false', function () {
  1356. installerStep7Controller.set('wizardController.stackConfigsLoaded', false);
  1357. installerStep7Controller.loadStep();
  1358. expect(installerStep7Controller.clearStep.called).to.equal(false);
  1359. });
  1360. it('should use App.config to map configs', function () {
  1361. installerStep7Controller.loadStep();
  1362. expect(App.config.mergePreDefinedWithStored.calledOnce).to.equal(true);
  1363. });
  1364. it('should call setInstalledServiceConfigs for addServiceController', function () {
  1365. installerStep7Controller.set('wizardController.name', 'addServiceController');
  1366. installerStep7Controller.loadStep();
  1367. expect(installerStep7Controller.setInstalledServiceConfigs.calledOnce).to.equal(true);
  1368. });
  1369. });
  1370. describe('#applyServicesConfigs', function() {
  1371. beforeEach(function() {
  1372. installerStep7Controller.reopen({
  1373. allSelectedServiceNames: []
  1374. });
  1375. sinon.stub(App.config, 'fileConfigsIntoTextarea', function(configs) {
  1376. return configs;
  1377. });
  1378. sinon.stub(installerStep7Controller, 'resolveServiceDependencyConfigs', Em.K);
  1379. sinon.stub(installerStep7Controller, 'loadServerSideConfigsRecommendations', function() {
  1380. return $.Deferred().resolve();
  1381. });
  1382. sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
  1383. sinon.stub(installerStep7Controller, 'activateSpecialConfigs', Em.K);
  1384. sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
  1385. sinon.stub(installerStep7Controller, 'setStepConfigs', Em.K);
  1386. sinon.stub(App.router, 'send', Em.K);
  1387. sinon.stub(App.StackService, 'find', function () {
  1388. return {
  1389. findProperty: function () {
  1390. return Em.Object.create({
  1391. isInstalled: true,
  1392. isSelected: false
  1393. });
  1394. },
  1395. filterProperty: function () {
  1396. return [];
  1397. }
  1398. }
  1399. });
  1400. });
  1401. afterEach(function () {
  1402. App.config.fileConfigsIntoTextarea.restore();
  1403. installerStep7Controller.resolveServiceDependencyConfigs.restore();
  1404. installerStep7Controller.loadServerSideConfigsRecommendations.restore();
  1405. installerStep7Controller.checkHostOverrideInstaller.restore();
  1406. installerStep7Controller.activateSpecialConfigs.restore();
  1407. installerStep7Controller.selectProperService.restore();
  1408. installerStep7Controller.setStepConfigs.restore();
  1409. App.router.send.restore();
  1410. App.StackService.find.restore();
  1411. });
  1412. it('should run some methods' , function () {
  1413. installerStep7Controller.applyServicesConfigs({name: 'configs'}, {name: 'storedConfigs'});
  1414. expect(installerStep7Controller.loadServerSideConfigsRecommendations.calledOnce).to.equal(true);
  1415. expect(installerStep7Controller.get('isRecommendedLoaded')).to.equal(true);
  1416. expect(installerStep7Controller.setStepConfigs.calledWith({name: 'configs'}, {name: 'storedConfigs'})).to.equal(true);
  1417. expect(installerStep7Controller.checkHostOverrideInstaller.calledOnce).to.equal(true);
  1418. expect(installerStep7Controller.activateSpecialConfigs.calledOnce).to.equal(true);
  1419. expect(installerStep7Controller.selectProperService.calledOnce).to.equal(true);
  1420. });
  1421. Em.A([
  1422. {
  1423. allSelectedServiceNames: ['YARN'],
  1424. fileConfigsIntoTextarea: true,
  1425. m: 'should run fileConfigsIntoTextarea and resolveServiceDependencyConfigs',
  1426. resolveServiceDependencyConfigs: true
  1427. },
  1428. {
  1429. allSelectedServiceNames: ['STORM'],
  1430. resolveServiceDependencyConfigs: true,
  1431. m: 'should run resolveServiceDependencyConfigs'
  1432. }
  1433. ]).forEach(function(t) {
  1434. it(t.m, function () {
  1435. installerStep7Controller.reopen({
  1436. allSelectedServiceNames: t.allSelectedServiceNames
  1437. });
  1438. installerStep7Controller.applyServicesConfigs({name: 'configs'}, {name: 'storedConfigs'});
  1439. if (t.fileConfigsIntoTextarea) {
  1440. expect(App.config.fileConfigsIntoTextarea.calledWith({name: 'configs'}, 'capacity-scheduler.xml')).to.equal(true);
  1441. } else {
  1442. expect(App.config.fileConfigsIntoTextarea.calledOnce).to.equal(false);
  1443. }
  1444. if (t.resolveServiceDependencyConfigs) {
  1445. expect(installerStep7Controller.resolveServiceDependencyConfigs.calledWith(t.allSelectedServiceNames[0], {name: 'configs'})).to.equal(true);
  1446. } else {
  1447. expect(installerStep7Controller.resolveServiceDependencyConfigs.calledOnce).to.equal(false);
  1448. }
  1449. });
  1450. });
  1451. });
  1452. describe('#_updateIsEditableFlagForConfig', function () {
  1453. beforeEach(function(){
  1454. this.mock = sinon.stub(App, 'isAccessible');
  1455. });
  1456. afterEach(function () {
  1457. this.mock.restore();
  1458. });
  1459. Em.A([
  1460. {
  1461. isAdmin: false,
  1462. isReconfigurable: false,
  1463. isHostsConfigsPage: true,
  1464. defaultGroupSelected: false,
  1465. m: 'false for non-admin users',
  1466. e: false
  1467. },
  1468. {
  1469. isAdmin: true,
  1470. isReconfigurable: false,
  1471. isHostsConfigsPage: true,
  1472. defaultGroupSelected: false,
  1473. m: 'false if defaultGroupSelected is false and isHostsConfigsPage is true',
  1474. e: false
  1475. },
  1476. {
  1477. isAdmin: true,
  1478. isReconfigurable: false,
  1479. isHostsConfigsPage: true,
  1480. defaultGroupSelected: true,
  1481. m: 'false if defaultGroupSelected is true and isHostsConfigsPage is true',
  1482. e: false
  1483. },
  1484. {
  1485. isAdmin: true,
  1486. isReconfigurable: false,
  1487. isHostsConfigsPage: false,
  1488. defaultGroupSelected: false,
  1489. m: 'false if defaultGroupSelected is false and isHostsConfigsPage is false',
  1490. e: false
  1491. },
  1492. {
  1493. isAdmin: true,
  1494. isReconfigurable: true,
  1495. isHostsConfigsPage: false,
  1496. defaultGroupSelected: true,
  1497. m: 'equal to isReconfigurable if defaultGroupSelected is true and isHostsConfigsPage is false',
  1498. e: true
  1499. }
  1500. ]).forEach(function (test) {
  1501. it(test.m, function () {
  1502. this.mock.returns(test.isAdmin);
  1503. installerStep7Controller.reopen({isHostsConfigsPage: test.isHostsConfigsPage});
  1504. var serviceConfigProperty = Em.Object.create({
  1505. isReconfigurable: test.isReconfigurable
  1506. });
  1507. installerStep7Controller._updateIsEditableFlagForConfig(serviceConfigProperty, test.defaultGroupSelected);
  1508. expect(serviceConfigProperty.get('isEditable')).to.equal(test.e);
  1509. });
  1510. });
  1511. });
  1512. describe('#_updateOverridesForConfig', function () {
  1513. it('should set empty array', function () {
  1514. var serviceConfigProperty = Em.Object.create({
  1515. overrides: null
  1516. }), component = Em.Object.create();
  1517. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1518. expect(serviceConfigProperty.get('overrides')).to.eql(Em.A([]));
  1519. });
  1520. it('host overrides not supported', function () {
  1521. var serviceConfigProperty = Em.Object.create({
  1522. overrides: [
  1523. {value: 'new value'}
  1524. ]
  1525. }), component = Em.Object.create({selectedConfigGroup: {isDefault: false}});
  1526. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1527. expect(serviceConfigProperty.get('overrides').length).to.equal(1);
  1528. expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
  1529. expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
  1530. expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
  1531. });
  1532. it('host overrides supported', function () {
  1533. sinon.stub(App, 'get', function (k) {
  1534. if (k === 'supports.hostOverrides') return true;
  1535. return Em.get(App, k);
  1536. });
  1537. var serviceConfigProperty = Em.Object.create({
  1538. overrides: [
  1539. {value: 'new value', group: Em.Object.create({name: 'n1'})}
  1540. ]
  1541. }),
  1542. component = Em.Object.create({
  1543. selectedConfigGroup: {isDefault: true},
  1544. configGroups: Em.A([
  1545. Em.Object.create({name: 'n1', properties: []})
  1546. ])
  1547. });
  1548. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1549. App.get.restore();
  1550. expect(serviceConfigProperty.get('overrides').length).to.equal(1);
  1551. expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
  1552. expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
  1553. expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
  1554. expect(component.get('configGroups.firstObject.properties').length).to.equal(1);
  1555. expect(component.get('configGroups.firstObject.properties.firstObject.isEditable')).to.equal(false);
  1556. expect(component.get('configGroups.firstObject.properties.firstObject.group')).to.be.object;
  1557. });
  1558. });
  1559. describe('#setInstalledServiceConfigs', function () {
  1560. var controller = App.WizardStep7Controller.create({
  1561. installedServiceNames: ['HBASE', 'AMBARI_METRICS']
  1562. }),
  1563. serviceConfigTags = [
  1564. {
  1565. siteName: 'hbase-site',
  1566. tagName: 'version1'
  1567. },
  1568. {
  1569. siteName: 'ams-hbase-site',
  1570. tagName: 'version1'
  1571. },
  1572. {
  1573. siteName: 'site-without-properties',
  1574. tagName: 'version1'
  1575. }
  1576. ],
  1577. configs = [
  1578. {
  1579. name: 'hbase.client.scanner.caching',
  1580. value: '1000',
  1581. serviceName: 'HBASE',
  1582. filename: 'hbase-site.xml'
  1583. },
  1584. {
  1585. name: 'hbase.client.scanner.caching',
  1586. value: '2000',
  1587. serviceName: 'AMBARI_METRICS',
  1588. filename: 'ams-hbase-site.xml'
  1589. }
  1590. ],
  1591. configsByTags = [
  1592. {
  1593. type: 'hbase-site',
  1594. tag: 'version2',
  1595. properties: {
  1596. 'hbase.client.scanner.caching': '1500'
  1597. }
  1598. },
  1599. {
  1600. type: 'ams-hbase-site',
  1601. tag: 'version2',
  1602. properties: {
  1603. 'hbase.client.scanner.caching': '2500'
  1604. }
  1605. },
  1606. {
  1607. type: 'site-without-properties',
  1608. tag: 'version1'
  1609. }
  1610. ],
  1611. installedServiceNames = ['HBASE', 'AMBARI_METRICS'];
  1612. it('should handle properties with the same name', function () {
  1613. controller.setInstalledServiceConfigs(serviceConfigTags, configs, configsByTags, installedServiceNames);
  1614. var properties = configs.filterProperty('name', 'hbase.client.scanner.caching');
  1615. expect(properties).to.have.length(2);
  1616. expect(properties.findProperty('filename', 'hbase-site.xml').value).to.equal('1500');
  1617. expect(properties.findProperty('filename', 'hbase-site.xml').savedValue).to.equal('1500');
  1618. expect(properties.findProperty('filename', 'ams-hbase-site.xml').value).to.equal('2500');
  1619. expect(properties.findProperty('filename', 'ams-hbase-site.xml').savedValue).to.equal('2500');
  1620. });
  1621. });
  1622. describe('#setServiceDatabaseConfigs', function () {
  1623. var controller = App.WizardStep7Controller.create({
  1624. installedServiceNames: ['OOZIE', 'HIVE']
  1625. });
  1626. var configs = [
  1627. {
  1628. name: 'hive_database',
  1629. value: 'MySQL',
  1630. serviceName: 'HIVE',
  1631. filename: 'hbase-site.xml'
  1632. },
  1633. {
  1634. name: 'oozie_database',
  1635. value: 'MySQL',
  1636. serviceName: 'OOZIE',
  1637. filename: 'ams-hbase-site.xml'
  1638. }
  1639. ];
  1640. it('should handle properties with the same name', function () {
  1641. var services = Em.A([
  1642. Em.Object.create({
  1643. isInstalled: true,
  1644. serviceName: 'SQOOP'
  1645. }),
  1646. Em.Object.create({
  1647. isInstalled: true,
  1648. serviceName: 'HDFS'
  1649. })
  1650. ]);
  1651. controller.setServiceDatabaseConfigs(configs);
  1652. var properties = configs.filterProperty('name', 'hive_database');
  1653. expect(properties).to.have.length(1);
  1654. });
  1655. });
  1656. describe('#getAmbariDatabaseSuccess', function () {
  1657. var controller = App.WizardStep7Controller.create({
  1658. stepConfigs: [
  1659. {
  1660. serviceName: 'HIVE',
  1661. configs: [
  1662. {
  1663. name: 'hive_ambari_host',
  1664. value: 'h0'
  1665. }
  1666. ]
  1667. }
  1668. ]
  1669. }),
  1670. cases = [
  1671. {
  1672. data: {
  1673. hostComponents: []
  1674. },
  1675. mySQLServerConflict: false,
  1676. title: 'no Ambari Server host components'
  1677. },
  1678. {
  1679. data: {
  1680. hostComponents: [
  1681. {
  1682. RootServiceHostComponents: {
  1683. properties: {
  1684. 'server.jdbc.url': 'jdbc:mysql://h0/db0?createDatabaseIfNotExist=true'
  1685. }
  1686. }
  1687. }
  1688. ]
  1689. },
  1690. mySQLServerConflict: true,
  1691. title: 'Ambari MySQL Server and Hive Server are on the same host'
  1692. },
  1693. {
  1694. data: {
  1695. hostComponents: [
  1696. {
  1697. RootServiceHostComponents: {
  1698. properties: {
  1699. 'server.jdbc.url': 'jdbc:mysql://h1/db1?createDatabaseIfNotExist=true'
  1700. }
  1701. }
  1702. }
  1703. ]
  1704. },
  1705. mySQLServerConflict: false,
  1706. title: 'Ambari MySQL Server and Hive Server are on different hosts'
  1707. }
  1708. ];
  1709. cases.forEach(function (item) {
  1710. it(item.title, function () {
  1711. controller.getAmbariDatabaseSuccess(item.data);
  1712. expect(controller.get('mySQLServerConflict')).to.equal(item.mySQLServerConflict);
  1713. });
  1714. });
  1715. });
  1716. describe('#showDatabaseConnectionWarningPopup', function () {
  1717. var cases = [
  1718. {
  1719. method: 'onSecondary',
  1720. submitButtonClicked: false,
  1721. isRejected: true,
  1722. title: 'Cancel button clicked'
  1723. },
  1724. {
  1725. method: 'onPrimary',
  1726. submitButtonClicked: true,
  1727. isResolved: true,
  1728. title: 'Proceed Anyway button clicked'
  1729. }
  1730. ],
  1731. dfd,
  1732. testObject,
  1733. serviceNames = ['HIVE', 'OOZIE'],
  1734. bodyMessage = 'HIVE, OOZIE';
  1735. beforeEach(function () {
  1736. installerStep7Controller.set('submitButtonClicked', true);
  1737. dfd = $.Deferred(function (d) {
  1738. d.done(function () {
  1739. testObject.isResolved = true;
  1740. });
  1741. d.fail(function () {
  1742. testObject.isRejected = true;
  1743. })
  1744. });
  1745. testObject = {};
  1746. });
  1747. cases.forEach(function (item) {
  1748. it(item.title, function () {
  1749. var popup = installerStep7Controller.showDatabaseConnectionWarningPopup(serviceNames, dfd);
  1750. expect(popup.get('body')).to.equal(Em.I18n.t('installer.step7.popup.database.connection.body').format(bodyMessage));
  1751. popup[item.method]();
  1752. expect(testObject.isResolved).to.equal(item.isResolved);
  1753. expect(testObject.isRejected).to.equal(item.isRejected);
  1754. expect(installerStep7Controller.get('submitButtonClicked')).to.equal(item.submitButtonClicked);
  1755. });
  1756. });
  1757. });
  1758. describe('#issuesFilterText', function () {
  1759. issuesFilterCases.forEach(function (item) {
  1760. it(item.title, function () {
  1761. issuesFilterTestSetup(installerStep7Controller, item);
  1762. expect(installerStep7Controller.get('issuesFilterText')).to.equal(item.issuesFilterText);
  1763. })
  1764. });
  1765. });
  1766. describe('#loadServiceTagsSuccess', function () {
  1767. it('should create ClusterSiteToTagMap', function () {
  1768. var params = Em.Object.create({
  1769. serviceName: "OOZIE",
  1770. serviceConfigsDef: Em.Object.create({
  1771. configTypes: Em.Object.create({
  1772. site3: true,
  1773. site2: true,
  1774. site1: true
  1775. })
  1776. })
  1777. });
  1778. var wizardController = Em.Object.create({
  1779. allHosts: [
  1780. {hostName: 'h1'},
  1781. {hostName: 'h2'},
  1782. {hostName: 'h3'}
  1783. ]
  1784. });
  1785. installerStep7Controller.set('wizardController', wizardController);
  1786. installerStep7Controller.set('stepConfigs', Em.A([Em.Object.create({serviceName: 'OOZIE', configs: Em.A([]) })]));
  1787. var desired_configs = {
  1788. site1: {
  1789. tag: "tag1"
  1790. },
  1791. site2: {
  1792. tag: "tag2"
  1793. },
  1794. site3: {
  1795. tag: "tag3"
  1796. }
  1797. };
  1798. var data = {
  1799. config_groups: Em.A([Em.Object.create({
  1800. ConfigGroup: Em.Object.create({
  1801. tag: 'OOZIE',
  1802. hosts: Em.A([Em.Object.create({host_name: 'h1'})]),
  1803. id: 1,
  1804. group_name: "",
  1805. description: "",
  1806. desired_configs: Em.A([Em.Object.create({
  1807. type: '1',
  1808. tag: 'h1'
  1809. })])
  1810. })
  1811. })]),
  1812. Clusters: {
  1813. desired_configs: desired_configs
  1814. }
  1815. };
  1816. installerStep7Controller.loadServiceTagsSuccess(data, {}, params);
  1817. var result = installerStep7Controller.get("loadedClusterSiteToTagMap");
  1818. expect(JSON.parse(JSON.stringify(result))).to.eql(JSON.parse(JSON.stringify({"site1":"tag1","site2":"tag2","site3":"tag3"})));
  1819. })
  1820. });
  1821. describe('#issuesFilterLinkText', function () {
  1822. issuesFilterCases.forEach(function (item) {
  1823. it(item.title, function () {
  1824. issuesFilterTestSetup(installerStep7Controller, item);
  1825. expect(installerStep7Controller.get('issuesFilterLinkText')).to.equal(item.issuesFilterLinkText);
  1826. })
  1827. });
  1828. });
  1829. describe('#toggleIssuesFilter', function () {
  1830. it('should toggle issues filter', function () {
  1831. var issuesFilter = installerStep7Controller.get('filterColumns').findProperty('attributeName', 'hasIssues');
  1832. issuesFilter.set('selected', false);
  1833. installerStep7Controller.toggleIssuesFilter();
  1834. expect(issuesFilter.get('selected')).to.be.true;
  1835. installerStep7Controller.toggleIssuesFilter();
  1836. expect(issuesFilter.get('selected')).to.be.false;
  1837. });
  1838. });
  1839. describe('#addKerberosDescriptorConfigs', function() {
  1840. var configs = [
  1841. { name: 'prop1', displayName: 'Prop1' },
  1842. { name: 'prop2', displayName: 'Prop2' },
  1843. { name: 'prop3', displayName: 'Prop3' }
  1844. ];
  1845. var descriptor = [
  1846. Em.Object.create({ name: 'prop4', filename: 'file-1'}),
  1847. Em.Object.create({ name: 'prop1', filename: 'file-1'})
  1848. ];
  1849. var propertiesAttrTests = [
  1850. {
  1851. attr: 'isUserProperty', val: false,
  1852. m: 'descriptor properties should not be marked as custom'
  1853. },
  1854. {
  1855. attr: 'category', val: 'Advanced file-1',
  1856. m: 'descriptor properties should be added to Advanced category'
  1857. },
  1858. {
  1859. attr: 'isOverridable', val: false,
  1860. m: 'descriptor properties should not be overriden'
  1861. }
  1862. ];
  1863. propertiesAttrTests.forEach(function(test) {
  1864. it(test.m, function() {
  1865. installerStep7Controller.addKerberosDescriptorConfigs(configs, descriptor);
  1866. expect(configs.findProperty('name', 'prop1')[test.attr]).to.be.eql(test.val);
  1867. });
  1868. });
  1869. });
  1870. describe('#errorsCount', function () {
  1871. it('should ignore configs with widgets (enhanced configs)', function () {
  1872. installerStep7Controller.reopen({selectedService: {
  1873. configs: [
  1874. Em.Object.create({isVisible: true, widget: Em.View, isValid: false}),
  1875. Em.Object.create({isVisible: true, widget: Em.View, isValid: true}),
  1876. Em.Object.create({isVisible: true, isValid: true}),
  1877. Em.Object.create({isVisible: true, isValid: false})
  1878. ]
  1879. }});
  1880. expect(installerStep7Controller.get('errorsCount')).to.equal(1);
  1881. });
  1882. it('should ignore configs with widgets (enhanced configs) and hidden configs', function () {
  1883. installerStep7Controller.reopen({selectedService: {
  1884. configs: [
  1885. Em.Object.create({isVisible: true, widget: Em.View, isValid: false}),
  1886. Em.Object.create({isVisible: true, widget: Em.View, isValid: true}),
  1887. Em.Object.create({isVisible: false, isValid: false}),
  1888. Em.Object.create({isVisible: true, isValid: true}),
  1889. Em.Object.create({isVisible: true, isValid: false})
  1890. ]
  1891. }});
  1892. expect(installerStep7Controller.get('errorsCount')).to.equal(1);
  1893. });
  1894. });
  1895. describe('#restoreRecommendedConfigs', function () {
  1896. var recommendationsConfigs = {
  1897. site: {
  1898. properties: {
  1899. a: 'recommendedA',
  1900. b: 'recommendedB'
  1901. }
  1902. }
  1903. };
  1904. var stepConfigs = [
  1905. Em.Object.create({
  1906. serviceName: 'srv',
  1907. configs: [
  1908. {name: 'a', value: '--', filename: 'site'},
  1909. {name: 'b', value: '--', filename: 'Custom site'}
  1910. ]
  1911. })
  1912. ];
  1913. var serviceConfigProperties = [
  1914. {name: 'a', value: 'valueA', filename: 'site'},
  1915. {name: 'b', value: 'valueB', filename: 'Custom site'}
  1916. ];
  1917. beforeEach(function() {
  1918. installerStep7Controller.reopen({
  1919. content: {
  1920. serviceConfigProperties: serviceConfigProperties
  1921. },
  1922. recommendationsConfigs: recommendationsConfigs,
  1923. stepConfigs: stepConfigs
  1924. });
  1925. });
  1926. it('should restore provided by user values', function () {
  1927. installerStep7Controller.restoreRecommendedConfigs();
  1928. var configs = installerStep7Controller.get('stepConfigs')[0].configs;
  1929. expect(Em.get(configs.findProperty('name', 'a'), 'value')).to.equal('valueA');
  1930. expect(Em.get(configs.findProperty('name', 'b'), 'value')).to.equal('valueB');
  1931. });
  1932. });
  1933. describe('#_reconfigureServicesOnNnHa', function () {
  1934. var dfsNameservices = 'some_cluster';
  1935. Em.A([
  1936. {
  1937. serviceName: 'HBASE',
  1938. configToUpdate: 'hbase.rootdir',
  1939. oldValue: 'hdfs://nameserv:8020/apps/hbase/data',
  1940. expectedNewValue: 'hdfs://' + dfsNameservices + '/apps/hbase/data'
  1941. },
  1942. {
  1943. serviceName: 'ACCUMULO',
  1944. configToUpdate: 'instance.volumes',
  1945. oldValue: 'hdfs://localhost:8020/apps/accumulo/data',
  1946. expectedNewValue: 'hdfs://' + dfsNameservices + '/apps/accumulo/data'
  1947. }
  1948. ]).forEach(function (test) {
  1949. it(test.serviceName + ' ' + test.configToUpdate, function () {
  1950. var serviceConfigs = [App.ServiceConfig.create({
  1951. serviceName: test.serviceName,
  1952. configs: [
  1953. Em.Object.create({
  1954. name: test.configToUpdate,
  1955. value: test.oldValue
  1956. })
  1957. ]
  1958. }),
  1959. App.ServiceConfig.create({
  1960. serviceName: 'HDFS',
  1961. configs: [
  1962. Em.Object.create({
  1963. name: 'dfs.nameservices',
  1964. value: dfsNameservices
  1965. })
  1966. ]
  1967. })];
  1968. installerStep7Controller.reopen({
  1969. selectedServiceNames: [test.serviceName, 'HDFS']
  1970. });
  1971. serviceConfigs = installerStep7Controller._reconfigureServicesOnNnHa(serviceConfigs);
  1972. expect(serviceConfigs.findProperty('serviceName', test.serviceName).configs.findProperty('name', test.configToUpdate).get('value')).to.equal(test.expectedNewValue);
  1973. });
  1974. });
  1975. });
  1976. });