step7_test.js 72 KB

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