step7_test.js 85 KB

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