step7_test.js 85 KB

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