step7_test.js 79 KB

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