step7_test.js 77 KB

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