step7_test.js 70 KB

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