step7_test.js 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142
  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. getDBProperties: function (keys) {
  665. return this.getProperties(keys);
  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. getDBProperties: function (keys) {
  740. return this.getProperties(keys);
  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. stackConfigsLoaded: true
  1322. })
  1323. });
  1324. sinon.stub(App.config, 'mergePreDefinedWithStack', 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.mergePreDefinedWithStack.restore();
  1339. App.config.fileConfigsIntoTextarea.restore();
  1340. installerStep7Controller.clearStep.restore();
  1341. installerStep7Controller.getConfigTags.restore();
  1342. installerStep7Controller.setInstalledServiceConfigs.restore();
  1343. installerStep7Controller.resolveServiceDependencyConfigs.restore();
  1344. installerStep7Controller.setStepConfigs.restore();
  1345. installerStep7Controller.checkHostOverrideInstaller.restore();
  1346. installerStep7Controller.activateSpecialConfigs.restore();
  1347. installerStep7Controller.selectProperService.restore();
  1348. installerStep7Controller.applyServicesConfigs.restore();
  1349. App.router.send.restore();
  1350. });
  1351. it('should call clearStep', function () {
  1352. installerStep7Controller.loadStep();
  1353. expect(installerStep7Controller.clearStep.calledOnce).to.equal(true);
  1354. });
  1355. it('shouldn\'t do nothing if isAdvancedConfigLoaded is false', function () {
  1356. installerStep7Controller.set('wizardController.stackConfigsLoaded', false);
  1357. installerStep7Controller.loadStep();
  1358. expect(installerStep7Controller.clearStep.called).to.equal(false);
  1359. });
  1360. it('should use App.config to map configs', function () {
  1361. installerStep7Controller.loadStep();
  1362. expect(App.config.mergePreDefinedWithStack.calledOnce).to.equal(true);
  1363. });
  1364. it('should call setInstalledServiceConfigs for addServiceController', function () {
  1365. installerStep7Controller.set('wizardController.name', 'addServiceController');
  1366. installerStep7Controller.loadStep();
  1367. expect(installerStep7Controller.setInstalledServiceConfigs.calledOnce).to.equal(true);
  1368. });
  1369. });
  1370. describe('#applyServicesConfigs', function() {
  1371. beforeEach(function() {
  1372. installerStep7Controller.reopen({
  1373. allSelectedServiceNames: []
  1374. });
  1375. sinon.stub(App.config, 'fileConfigsIntoTextarea', function(configs) {
  1376. return configs;
  1377. });
  1378. sinon.stub(installerStep7Controller, 'resolveServiceDependencyConfigs', Em.K);
  1379. sinon.stub(installerStep7Controller, 'loadServerSideConfigsRecommendations', function() {
  1380. return $.Deferred().resolve();
  1381. });
  1382. sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
  1383. sinon.stub(installerStep7Controller, 'activateSpecialConfigs', Em.K);
  1384. sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
  1385. sinon.stub(installerStep7Controller, 'setStepConfigs', Em.K);
  1386. sinon.stub(App.router, 'send', Em.K);
  1387. sinon.stub(App.StackService, 'find', function () {
  1388. return {
  1389. findProperty: function () {
  1390. return Em.Object.create({
  1391. isInstalled: true,
  1392. isSelected: false
  1393. });
  1394. },
  1395. filterProperty: function () {
  1396. return [];
  1397. }
  1398. }
  1399. });
  1400. });
  1401. afterEach(function () {
  1402. App.config.fileConfigsIntoTextarea.restore();
  1403. installerStep7Controller.resolveServiceDependencyConfigs.restore();
  1404. installerStep7Controller.loadServerSideConfigsRecommendations.restore();
  1405. installerStep7Controller.checkHostOverrideInstaller.restore();
  1406. installerStep7Controller.activateSpecialConfigs.restore();
  1407. installerStep7Controller.selectProperService.restore();
  1408. installerStep7Controller.setStepConfigs.restore();
  1409. App.router.send.restore();
  1410. App.StackService.find.restore();
  1411. });
  1412. it('should run some methods' , function () {
  1413. installerStep7Controller.applyServicesConfigs({name: 'configs'}, {name: 'storedConfigs'});
  1414. expect(installerStep7Controller.loadServerSideConfigsRecommendations.calledOnce).to.equal(true);
  1415. expect(installerStep7Controller.get('isRecommendedLoaded')).to.equal(true);
  1416. expect(installerStep7Controller.setStepConfigs.calledWith({name: 'configs'}, {name: 'storedConfigs'})).to.equal(true);
  1417. expect(installerStep7Controller.checkHostOverrideInstaller.calledOnce).to.equal(true);
  1418. expect(installerStep7Controller.activateSpecialConfigs.calledOnce).to.equal(true);
  1419. expect(installerStep7Controller.selectProperService.calledOnce).to.equal(true);
  1420. });
  1421. Em.A([
  1422. {
  1423. allSelectedServiceNames: ['YARN'],
  1424. fileConfigsIntoTextarea: true,
  1425. m: 'should run fileConfigsIntoTextarea and resolveServiceDependencyConfigs',
  1426. resolveServiceDependencyConfigs: true
  1427. },
  1428. {
  1429. allSelectedServiceNames: ['STORM'],
  1430. resolveServiceDependencyConfigs: true,
  1431. m: 'should run resolveServiceDependencyConfigs'
  1432. }
  1433. ]).forEach(function(t) {
  1434. it(t.m, function () {
  1435. installerStep7Controller.reopen({
  1436. allSelectedServiceNames: t.allSelectedServiceNames
  1437. });
  1438. installerStep7Controller.applyServicesConfigs({name: 'configs'}, {name: 'storedConfigs'});
  1439. if (t.fileConfigsIntoTextarea) {
  1440. expect(App.config.fileConfigsIntoTextarea.calledWith({name: 'configs'}, 'capacity-scheduler.xml')).to.equal(true);
  1441. } else {
  1442. expect(App.config.fileConfigsIntoTextarea.calledOnce).to.equal(false);
  1443. }
  1444. if (t.resolveServiceDependencyConfigs) {
  1445. expect(installerStep7Controller.resolveServiceDependencyConfigs.calledWith(t.allSelectedServiceNames[0], {name: 'configs'})).to.equal(true);
  1446. } else {
  1447. expect(installerStep7Controller.resolveServiceDependencyConfigs.calledOnce).to.equal(false);
  1448. }
  1449. });
  1450. });
  1451. });
  1452. describe('#_updateIsEditableFlagForConfig', function () {
  1453. beforeEach(function(){
  1454. this.mock = sinon.stub(App, 'isAccessible');
  1455. });
  1456. afterEach(function () {
  1457. this.mock.restore();
  1458. });
  1459. Em.A([
  1460. {
  1461. isAdmin: false,
  1462. isReconfigurable: false,
  1463. isHostsConfigsPage: true,
  1464. defaultGroupSelected: false,
  1465. m: 'false for non-admin users',
  1466. e: false
  1467. },
  1468. {
  1469. isAdmin: true,
  1470. isReconfigurable: false,
  1471. isHostsConfigsPage: true,
  1472. defaultGroupSelected: false,
  1473. m: 'false if defaultGroupSelected is false and isHostsConfigsPage is true',
  1474. e: false
  1475. },
  1476. {
  1477. isAdmin: true,
  1478. isReconfigurable: false,
  1479. isHostsConfigsPage: true,
  1480. defaultGroupSelected: true,
  1481. m: 'false if defaultGroupSelected is true and isHostsConfigsPage is true',
  1482. e: false
  1483. },
  1484. {
  1485. isAdmin: true,
  1486. isReconfigurable: false,
  1487. isHostsConfigsPage: false,
  1488. defaultGroupSelected: false,
  1489. m: 'false if defaultGroupSelected is false and isHostsConfigsPage is false',
  1490. e: false
  1491. },
  1492. {
  1493. isAdmin: true,
  1494. isReconfigurable: true,
  1495. isHostsConfigsPage: false,
  1496. defaultGroupSelected: true,
  1497. m: 'equal to isReconfigurable if defaultGroupSelected is true and isHostsConfigsPage is false',
  1498. e: true
  1499. }
  1500. ]).forEach(function (test) {
  1501. it(test.m, function () {
  1502. this.mock.returns(test.isAdmin);
  1503. installerStep7Controller.reopen({isHostsConfigsPage: test.isHostsConfigsPage});
  1504. var serviceConfigProperty = Em.Object.create({
  1505. isReconfigurable: test.isReconfigurable
  1506. });
  1507. installerStep7Controller._updateIsEditableFlagForConfig(serviceConfigProperty, test.defaultGroupSelected);
  1508. expect(serviceConfigProperty.get('isEditable')).to.equal(test.e);
  1509. });
  1510. });
  1511. });
  1512. describe('#_updateOverridesForConfig', function () {
  1513. it('should set empty array', function () {
  1514. var serviceConfigProperty = Em.Object.create({
  1515. overrides: null
  1516. }), component = Em.Object.create();
  1517. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1518. expect(serviceConfigProperty.get('overrides')).to.eql(Em.A([]));
  1519. });
  1520. it('host overrides not supported', function () {
  1521. var serviceConfigProperty = Em.Object.create({
  1522. overrides: [
  1523. {value: 'new value'}
  1524. ]
  1525. }), component = Em.Object.create({selectedConfigGroup: {isDefault: false}});
  1526. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1527. expect(serviceConfigProperty.get('overrides').length).to.equal(1);
  1528. expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
  1529. expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
  1530. expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
  1531. });
  1532. it('host overrides supported', function () {
  1533. sinon.stub(App, 'get', function (k) {
  1534. if (k === 'supports.hostOverrides') return true;
  1535. return Em.get(App, k);
  1536. });
  1537. var serviceConfigProperty = Em.Object.create({
  1538. overrides: [
  1539. {value: 'new value', group: Em.Object.create({name: 'n1'})}
  1540. ]
  1541. }),
  1542. component = Em.Object.create({
  1543. selectedConfigGroup: {isDefault: true},
  1544. configGroups: Em.A([
  1545. Em.Object.create({name: 'n1', properties: []})
  1546. ])
  1547. });
  1548. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1549. App.get.restore();
  1550. expect(serviceConfigProperty.get('overrides').length).to.equal(1);
  1551. expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
  1552. expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
  1553. expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
  1554. expect(component.get('configGroups.firstObject.properties').length).to.equal(1);
  1555. expect(component.get('configGroups.firstObject.properties.firstObject.isEditable')).to.equal(false);
  1556. expect(component.get('configGroups.firstObject.properties.firstObject.group')).to.be.object;
  1557. });
  1558. });
  1559. describe('#setInstalledServiceConfigs', function () {
  1560. var controller = App.WizardStep7Controller.create({
  1561. installedServiceNames: ['HBASE', 'AMBARI_METRICS']
  1562. }),
  1563. serviceConfigTags = [
  1564. {
  1565. siteName: 'hbase-site',
  1566. tagName: 'version1'
  1567. },
  1568. {
  1569. siteName: 'ams-hbase-site',
  1570. tagName: 'version1'
  1571. },
  1572. {
  1573. siteName: 'site-without-properties',
  1574. tagName: 'version1'
  1575. }
  1576. ],
  1577. configs = [
  1578. {
  1579. name: 'hbase.client.scanner.caching',
  1580. value: '1000',
  1581. serviceName: 'HBASE',
  1582. filename: 'hbase-site.xml'
  1583. },
  1584. {
  1585. name: 'hbase.client.scanner.caching',
  1586. value: '2000',
  1587. serviceName: 'AMBARI_METRICS',
  1588. filename: 'ams-hbase-site.xml'
  1589. }
  1590. ],
  1591. configsByTags = [
  1592. {
  1593. type: 'hbase-site',
  1594. tag: 'version2',
  1595. properties: {
  1596. 'hbase.client.scanner.caching': '1500'
  1597. }
  1598. },
  1599. {
  1600. type: 'ams-hbase-site',
  1601. tag: 'version2',
  1602. properties: {
  1603. 'hbase.client.scanner.caching': '2500'
  1604. }
  1605. },
  1606. {
  1607. type: 'site-without-properties',
  1608. tag: 'version1'
  1609. }
  1610. ],
  1611. installedServiceNames = ['HBASE', 'AMBARI_METRICS'];
  1612. it('should handle properties with the same name', function () {
  1613. controller.setInstalledServiceConfigs(serviceConfigTags, configs, configsByTags, installedServiceNames);
  1614. var properties = configs.filterProperty('name', 'hbase.client.scanner.caching');
  1615. expect(properties).to.have.length(2);
  1616. expect(properties.findProperty('filename', 'hbase-site.xml').value).to.equal('1500');
  1617. expect(properties.findProperty('filename', 'hbase-site.xml').savedValue).to.equal('1500');
  1618. expect(properties.findProperty('filename', 'ams-hbase-site.xml').value).to.equal('2500');
  1619. expect(properties.findProperty('filename', 'ams-hbase-site.xml').savedValue).to.equal('2500');
  1620. });
  1621. });
  1622. describe('#setServiceDatabaseConfigs', function () {
  1623. var controller = App.WizardStep7Controller.create({
  1624. installedServiceNames: ['OOZIE', 'HIVE']
  1625. });
  1626. var configs = [
  1627. {
  1628. name: 'hive_database',
  1629. value: 'MySQL',
  1630. serviceName: 'HIVE',
  1631. filename: 'hbase-site.xml'
  1632. },
  1633. {
  1634. name: 'oozie_database',
  1635. value: 'MySQL',
  1636. serviceName: 'OOZIE',
  1637. filename: 'ams-hbase-site.xml'
  1638. }
  1639. ];
  1640. it('should handle properties with the same name', function () {
  1641. var services = Em.A([
  1642. Em.Object.create({
  1643. isInstalled: true,
  1644. serviceName: 'SQOOP'
  1645. }),
  1646. Em.Object.create({
  1647. isInstalled: true,
  1648. serviceName: 'HDFS'
  1649. })
  1650. ]);
  1651. controller.setServiceDatabaseConfigs(configs);
  1652. var properties = configs.filterProperty('name', 'hive_database');
  1653. expect(properties).to.have.length(1);
  1654. });
  1655. });
  1656. describe('#getAmbariDatabaseSuccess', function () {
  1657. var controller = App.WizardStep7Controller.create({
  1658. stepConfigs: [
  1659. {
  1660. serviceName: 'HIVE',
  1661. configs: [
  1662. {
  1663. name: 'hive_ambari_host',
  1664. value: 'h0'
  1665. }
  1666. ]
  1667. }
  1668. ]
  1669. }),
  1670. cases = [
  1671. {
  1672. data: {
  1673. hostComponents: []
  1674. },
  1675. mySQLServerConflict: false,
  1676. title: 'no Ambari Server host components'
  1677. },
  1678. {
  1679. data: {
  1680. hostComponents: [
  1681. {
  1682. RootServiceHostComponents: {
  1683. properties: {
  1684. 'server.jdbc.url': 'jdbc:mysql://h0/db0?createDatabaseIfNotExist=true'
  1685. }
  1686. }
  1687. }
  1688. ]
  1689. },
  1690. mySQLServerConflict: true,
  1691. title: 'Ambari MySQL Server and Hive Server are on the same host'
  1692. },
  1693. {
  1694. data: {
  1695. hostComponents: [
  1696. {
  1697. RootServiceHostComponents: {
  1698. properties: {
  1699. 'server.jdbc.url': 'jdbc:mysql://h1/db1?createDatabaseIfNotExist=true'
  1700. }
  1701. }
  1702. }
  1703. ]
  1704. },
  1705. mySQLServerConflict: false,
  1706. title: 'Ambari MySQL Server and Hive Server are on different hosts'
  1707. }
  1708. ];
  1709. cases.forEach(function (item) {
  1710. it(item.title, function () {
  1711. controller.getAmbariDatabaseSuccess(item.data);
  1712. expect(controller.get('mySQLServerConflict')).to.equal(item.mySQLServerConflict);
  1713. });
  1714. });
  1715. });
  1716. describe('#showDatabaseConnectionWarningPopup', function () {
  1717. var cases = [
  1718. {
  1719. method: 'onSecondary',
  1720. submitButtonClicked: false,
  1721. isRejected: true,
  1722. title: 'Cancel button clicked'
  1723. },
  1724. {
  1725. method: 'onPrimary',
  1726. submitButtonClicked: true,
  1727. isResolved: true,
  1728. title: 'Proceed Anyway button clicked'
  1729. }
  1730. ],
  1731. dfd,
  1732. testObject,
  1733. serviceNames = ['HIVE', 'OOZIE'],
  1734. bodyMessage = 'HIVE, OOZIE';
  1735. beforeEach(function () {
  1736. installerStep7Controller.set('submitButtonClicked', true);
  1737. dfd = $.Deferred(function (d) {
  1738. d.done(function () {
  1739. testObject.isResolved = true;
  1740. });
  1741. d.fail(function () {
  1742. testObject.isRejected = true;
  1743. })
  1744. });
  1745. testObject = {};
  1746. });
  1747. cases.forEach(function (item) {
  1748. it(item.title, function () {
  1749. var popup = installerStep7Controller.showDatabaseConnectionWarningPopup(serviceNames, dfd);
  1750. expect(popup.get('body')).to.equal(Em.I18n.t('installer.step7.popup.database.connection.body').format(bodyMessage));
  1751. popup[item.method]();
  1752. expect(testObject.isResolved).to.equal(item.isResolved);
  1753. expect(testObject.isRejected).to.equal(item.isRejected);
  1754. expect(installerStep7Controller.get('submitButtonClicked')).to.equal(item.submitButtonClicked);
  1755. });
  1756. });
  1757. });
  1758. describe('#issuesFilterText', function () {
  1759. issuesFilterCases.forEach(function (item) {
  1760. it(item.title, function () {
  1761. issuesFilterTestSetup(installerStep7Controller, item);
  1762. expect(installerStep7Controller.get('issuesFilterText')).to.equal(item.issuesFilterText);
  1763. })
  1764. });
  1765. });
  1766. describe('#loadServiceTagsSuccess', function () {
  1767. it('should create ClusterSiteToTagMap', function () {
  1768. var params = Em.Object.create({
  1769. serviceName: "OOZIE",
  1770. serviceConfigsDef: Em.Object.create({
  1771. configTypes: Em.Object.create({
  1772. site3: true,
  1773. site2: true,
  1774. site1: true
  1775. })
  1776. })
  1777. });
  1778. var wizardController = Em.Object.create({
  1779. allHosts: [
  1780. {hostName: 'h1'},
  1781. {hostName: 'h2'},
  1782. {hostName: 'h3'}
  1783. ]
  1784. });
  1785. installerStep7Controller.set('wizardController', wizardController);
  1786. installerStep7Controller.set('stepConfigs', Em.A([Em.Object.create({serviceName: 'OOZIE', configs: Em.A([]) })]));
  1787. var desired_configs = {
  1788. site1: {
  1789. tag: "tag1"
  1790. },
  1791. site2: {
  1792. tag: "tag2"
  1793. },
  1794. site3: {
  1795. tag: "tag3"
  1796. }
  1797. };
  1798. var data = {
  1799. config_groups: Em.A([Em.Object.create({
  1800. ConfigGroup: Em.Object.create({
  1801. tag: 'OOZIE',
  1802. hosts: Em.A([Em.Object.create({host_name: 'h1'})]),
  1803. id: 1,
  1804. group_name: "",
  1805. description: "",
  1806. desired_configs: Em.A([Em.Object.create({
  1807. type: '1',
  1808. tag: 'h1'
  1809. })])
  1810. })
  1811. })]),
  1812. Clusters: {
  1813. desired_configs: desired_configs
  1814. }
  1815. };
  1816. installerStep7Controller.loadServiceTagsSuccess(data, {}, params);
  1817. var result = installerStep7Controller.get("loadedClusterSiteToTagMap");
  1818. expect(JSON.parse(JSON.stringify(result))).to.eql(JSON.parse(JSON.stringify({"site1":"tag1","site2":"tag2","site3":"tag3"})));
  1819. })
  1820. });
  1821. describe('#issuesFilterLinkText', function () {
  1822. issuesFilterCases.forEach(function (item) {
  1823. it(item.title, function () {
  1824. issuesFilterTestSetup(installerStep7Controller, item);
  1825. expect(installerStep7Controller.get('issuesFilterLinkText')).to.equal(item.issuesFilterLinkText);
  1826. })
  1827. });
  1828. });
  1829. describe('#toggleIssuesFilter', function () {
  1830. it('should toggle issues filter', function () {
  1831. var issuesFilter = installerStep7Controller.get('filterColumns').findProperty('attributeName', 'hasIssues');
  1832. issuesFilter.set('selected', false);
  1833. installerStep7Controller.toggleIssuesFilter();
  1834. expect(issuesFilter.get('selected')).to.be.true;
  1835. installerStep7Controller.toggleIssuesFilter();
  1836. expect(issuesFilter.get('selected')).to.be.false;
  1837. });
  1838. });
  1839. describe('#addKerberosDescriptorConfigs', function() {
  1840. var configs = [
  1841. { name: 'prop1', displayName: 'Prop1' },
  1842. { name: 'prop2', displayName: 'Prop2' },
  1843. { name: 'prop3', displayName: 'Prop3' }
  1844. ];
  1845. var descriptor = [
  1846. Em.Object.create({ name: 'prop4', filename: 'file-1'}),
  1847. Em.Object.create({ name: 'prop1', filename: 'file-1'})
  1848. ];
  1849. var propertiesAttrTests = [
  1850. {
  1851. attr: 'isUserProperty', val: false,
  1852. m: 'descriptor properties should not be marked as custom'
  1853. },
  1854. {
  1855. attr: 'category', val: 'Advanced file-1',
  1856. m: 'descriptor properties should be added to Advanced category'
  1857. },
  1858. {
  1859. attr: 'isOverridable', val: false,
  1860. m: 'descriptor properties should not be overriden'
  1861. }
  1862. ];
  1863. propertiesAttrTests.forEach(function(test) {
  1864. it(test.m, function() {
  1865. installerStep7Controller.addKerberosDescriptorConfigs(configs, descriptor);
  1866. expect(configs.findProperty('name', 'prop1')[test.attr]).to.be.eql(test.val);
  1867. });
  1868. });
  1869. });
  1870. describe('#errorsCount', function () {
  1871. it('should ignore configs with widgets (enhanced configs)', function () {
  1872. installerStep7Controller.reopen({selectedService: {
  1873. configs: [
  1874. Em.Object.create({isVisible: true, widget: Em.View, isValid: false}),
  1875. Em.Object.create({isVisible: true, widget: Em.View, isValid: true}),
  1876. Em.Object.create({isVisible: true, isValid: true}),
  1877. Em.Object.create({isVisible: true, isValid: false})
  1878. ]
  1879. }});
  1880. expect(installerStep7Controller.get('errorsCount')).to.equal(1);
  1881. });
  1882. it('should ignore configs with widgets (enhanced configs) and hidden configs', function () {
  1883. installerStep7Controller.reopen({selectedService: {
  1884. configs: [
  1885. Em.Object.create({isVisible: true, widget: Em.View, isValid: false}),
  1886. Em.Object.create({isVisible: true, widget: Em.View, isValid: true}),
  1887. Em.Object.create({isVisible: false, isValid: false}),
  1888. Em.Object.create({isVisible: true, isValid: true}),
  1889. Em.Object.create({isVisible: true, isValid: false})
  1890. ]
  1891. }});
  1892. expect(installerStep7Controller.get('errorsCount')).to.equal(1);
  1893. });
  1894. });
  1895. describe('#restoreRecommendedConfigs', function () {
  1896. var recommendationsConfigs = {
  1897. site: {
  1898. properties: {
  1899. a: 'recommendedA',
  1900. b: 'recommendedB'
  1901. }
  1902. }
  1903. };
  1904. var stepConfigs = [
  1905. Em.Object.create({
  1906. serviceName: 'srv',
  1907. configs: [
  1908. {name: 'a', value: '--', filename: 'site'},
  1909. {name: 'b', value: '--', filename: 'Custom site'}
  1910. ]
  1911. })
  1912. ];
  1913. var serviceConfigProperties = [
  1914. {name: 'a', value: 'valueA', filename: 'site'},
  1915. {name: 'b', value: 'valueB', filename: 'Custom site'}
  1916. ];
  1917. beforeEach(function() {
  1918. installerStep7Controller.reopen({
  1919. content: {
  1920. serviceConfigProperties: serviceConfigProperties
  1921. },
  1922. recommendationsConfigs: recommendationsConfigs,
  1923. stepConfigs: stepConfigs
  1924. });
  1925. });
  1926. it('should restore provided by user values', function () {
  1927. installerStep7Controller.restoreRecommendedConfigs();
  1928. var configs = installerStep7Controller.get('stepConfigs')[0].configs;
  1929. expect(Em.get(configs.findProperty('name', 'a'), 'value')).to.equal('valueA');
  1930. expect(Em.get(configs.findProperty('name', 'b'), 'value')).to.equal('valueB');
  1931. });
  1932. });
  1933. describe('#_reconfigureServicesOnNnHa', function () {
  1934. var dfsNameservices = 'some_cluster';
  1935. Em.A([
  1936. {
  1937. serviceName: 'HBASE',
  1938. configToUpdate: 'hbase.rootdir',
  1939. oldValue: 'hdfs://nameserv:8020/apps/hbase/data',
  1940. expectedNewValue: 'hdfs://' + dfsNameservices + '/apps/hbase/data'
  1941. },
  1942. {
  1943. serviceName: 'ACCUMULO',
  1944. configToUpdate: 'instance.volumes',
  1945. oldValue: 'hdfs://localhost:8020/apps/accumulo/data',
  1946. expectedNewValue: 'hdfs://' + dfsNameservices + '/apps/accumulo/data'
  1947. }
  1948. ]).forEach(function (test) {
  1949. it(test.serviceName + ' ' + test.configToUpdate, function () {
  1950. var serviceConfigs = [App.ServiceConfig.create({
  1951. serviceName: test.serviceName,
  1952. configs: [
  1953. Em.Object.create({
  1954. name: test.configToUpdate,
  1955. value: test.oldValue
  1956. })
  1957. ]
  1958. }),
  1959. App.ServiceConfig.create({
  1960. serviceName: 'HDFS',
  1961. configs: [
  1962. Em.Object.create({
  1963. name: 'dfs.nameservices',
  1964. value: dfsNameservices
  1965. })
  1966. ]
  1967. })];
  1968. installerStep7Controller.reopen({
  1969. selectedServiceNames: [test.serviceName, 'HDFS']
  1970. });
  1971. serviceConfigs = installerStep7Controller._reconfigureServicesOnNnHa(serviceConfigs);
  1972. expect(serviceConfigs.findProperty('serviceName', test.serviceName).configs.findProperty('name', test.configToUpdate).get('value')).to.equal(test.expectedNewValue);
  1973. });
  1974. });
  1975. });
  1976. describe('#showOozieDerbyWarning', function() {
  1977. var controller;
  1978. beforeEach(function() {
  1979. controller = App.WizardStep7Controller.create({});
  1980. sinon.stub(App.ModalPopup, 'show', Em.K);
  1981. });
  1982. afterEach(function() {
  1983. App.ModalPopup.show.restore();
  1984. });
  1985. Em.A([
  1986. {
  1987. selectedServiceNames: ['HDFS', 'OOZIE'],
  1988. databaseType: Em.I18n.t('installer.step7.oozie.database.new'),
  1989. e: true,
  1990. m: 'Oozie selected with derby database, warning popup should be shown'
  1991. },
  1992. {
  1993. selectedServiceNames: ['HDFS'],
  1994. databaseType: Em.I18n.t('installer.step7.oozie.database.new'),
  1995. e: false,
  1996. m: 'Oozie not selected warning popup should be skipped'
  1997. },
  1998. {
  1999. selectedServiceNames: ['HDFS', 'OOZIE'],
  2000. databaseType: 'New Mysql Database',
  2001. e: false,
  2002. m: 'Oozie selected, mysql database used, warning popup should be sk'
  2003. }
  2004. ]).forEach(function(test) {
  2005. it(test.m, function() {
  2006. var callback = sinon.spy();
  2007. sinon.stub(controller, 'findConfigProperty').returns(Em.Object.create({ value: test.databaseType}));
  2008. controller.reopen({
  2009. selectedServiceNames: test.selectedServiceNames
  2010. });
  2011. controller.showOozieDerbyWarningPopup(callback);
  2012. controller.findConfigProperty.restore();
  2013. expect(App.ModalPopup.show.calledOnce).to.equal(test.e);
  2014. });
  2015. });
  2016. });
  2017. });