step7_test.js 72 KB

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