step7_test.js 73 KB

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