step7_test.js 76 KB

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