step7_test.js 72 KB

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