step7_test.js 75 KB

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