step8_test.js 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332
  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('utils/ajax/ajax_queue');
  20. require('controllers/main/admin/security');
  21. require('controllers/main/service/info/configs');
  22. require('controllers/wizard/step8_controller');
  23. var installerStep8Controller, configurationController;
  24. describe('App.WizardStep8Controller', function () {
  25. var configs = Em.A([
  26. Em.Object.create({filename: 'hdfs-site.xml', name: 'p1', value: 'v1'}),
  27. Em.Object.create({filename: 'hdfs-site.xml', name: 'p2', value: 'v2'}),
  28. Em.Object.create({filename: 'hue-site.xml', name: 'p1', value: 'v1'}),
  29. Em.Object.create({filename: 'hue-site.xml', name: 'p2', value: 'v2'}),
  30. Em.Object.create({filename: 'mapred-site.xml', name: 'p1', value: 'v1'}),
  31. Em.Object.create({filename: 'mapred-site.xml', name: 'p2', value: 'v2'}),
  32. Em.Object.create({filename: 'yarn-site.xml', name: 'p1', value: 'v1'}),
  33. Em.Object.create({filename: 'yarn-site.xml', name: 'p2', value: 'v2'}),
  34. Em.Object.create({filename: 'capacity-scheduler.xml', name: 'p1', value: 'v1'}),
  35. Em.Object.create({filename: 'capacity-scheduler.xml', name: 'p2', value: 'v2'}),
  36. Em.Object.create({filename: 'mapred-queue-acls.xml', name: 'p1', value: 'v1'}),
  37. Em.Object.create({filename: 'mapred-queue-acls.xml', name: 'p2', value: 'v2'}),
  38. Em.Object.create({filename: 'hbase-site.xml', name: 'p1', value: 'v1'}),
  39. Em.Object.create({filename: 'hbase-site.xml', name: 'p2', value: 'v2'}),
  40. Em.Object.create({filename: 'oozie-site.xml', name: 'p1', value: 'v1'}),
  41. Em.Object.create({filename: 'oozie-site.xml', name: 'p2', value: 'v2'}),
  42. Em.Object.create({filename: 'hive-site.xml', name: 'p1', value: 'v1'}),
  43. Em.Object.create({filename: 'hive-site.xml', name: 'p2', value: 'v2'}),
  44. Em.Object.create({filename: 'pig-properties.xml', name: 'p1', value: 'v1'}),
  45. Em.Object.create({filename: 'webhcat-site.xml', name: 'p1', value: 'v1'}),
  46. Em.Object.create({filename: 'webhcat-site.xml', name: 'p2', value: 'v2'}),
  47. Em.Object.create({filename: 'tez-site.xml', name: 'p1', value: 'v1'}),
  48. Em.Object.create({filename: 'tez-site.xml', name: 'p2', value: 'v2'}),
  49. Em.Object.create({filename: 'falcon-startup.properties.xml', name: 'p1', value: 'v1'}),
  50. Em.Object.create({filename: 'falcon-startup.properties.xml', name: 'p2', value: 'v2'}),
  51. Em.Object.create({filename: 'falcon-runtime.properties.xml', name: 'p1', value: 'v1'}),
  52. Em.Object.create({filename: 'falcon-runtime.properties.xml', name: 'p2', value: 'v2'})
  53. ]);
  54. beforeEach(function () {
  55. installerStep8Controller = App.WizardStep8Controller.create({
  56. configs: configs
  57. });
  58. configurationController = App.MainServiceInfoConfigsController.create({});
  59. });
  60. var siteObjTests = Em.A([
  61. {name: 'createHdfsSiteObj', e: {type: 'hdfs-site', tag: 'version1', l: 2}},
  62. {name: 'createHueSiteObj', e: {type: 'hue-site', tag: 'version1', l: 2}},
  63. {name: 'createMrSiteObj', e: {type: 'mapred-site', tag: 'version1', l: 2}},
  64. {name: 'createYarnSiteObj', e: {type: 'yarn-site', tag: 'version1', l: 2}},
  65. {name: 'createCapacityScheduler', e: {type: 'capacity-scheduler', tag: 'version1', l: 2}},
  66. {name: 'createMapredQueueAcls', e: {type: 'mapred-queue-acls', tag: 'version1', l: 2}},
  67. {name: 'createHbaseSiteObj', e: {type: 'hbase-site', tag: 'version1', l: 2}},
  68. {name: 'createOozieSiteObj', e: {type: 'oozie-site', tag: 'version1', l: 2}},
  69. {name: 'createHiveSiteObj', e: {type: 'hive-site', tag: 'version1', l: 2}},
  70. {name: 'createWebHCatSiteObj', e: {type: 'webhcat-site', tag: 'version1', l: 2}},
  71. {name: 'createTezSiteObj', e: {type: 'tez-site', tag: 'version1', l: 2}},
  72. {name: 'createPigPropertiesSiteObj', e: {type: 'pig-properties', tag: 'version1', l: 1}},
  73. {name: 'createFalconStartupSiteObj', e: {type: 'falcon-startup.properties', tag: 'version1', l: 2}},
  74. {name: 'createFalconRuntimeSiteObj', e: {type: 'falcon-runtime.properties', tag: 'version1', l: 2}}
  75. ]);
  76. siteObjTests.forEach(function (test) {
  77. describe('#' + test.name, function () {
  78. it(test.name, function () {
  79. var siteObj = installerStep8Controller.createSiteObj(test.e.type);
  80. expect(siteObj.tag).to.equal(test.e.tag);
  81. expect(Em.keys(siteObj.properties).length).to.equal(test.e.l);
  82. });
  83. });
  84. });
  85. describe('#createConfigurations', function () {
  86. it('verify if its installerController', function () {
  87. installerStep8Controller.set('content', {controllerName: 'installerController', services: Em.A([])});
  88. installerStep8Controller.createConfigurations();
  89. expect(installerStep8Controller.get('serviceConfigTags').length).to.equal(4);
  90. installerStep8Controller.clearStep();
  91. });
  92. it('verify if its not installerController', function () {
  93. installerStep8Controller.set('content', {controllerName: 'addServiceController', services: Em.A([])});
  94. installerStep8Controller.createConfigurations();
  95. expect(installerStep8Controller.get('serviceConfigTags').length).to.equal(2);
  96. installerStep8Controller.clearStep();
  97. });
  98. it('verify not App.supports.capacitySchedulerUi', function () {
  99. installerStep8Controller = App.WizardStep8Controller.create({
  100. content: {controllerName: 'addServiceController', services: Em.A([
  101. {isSelected: true, isInstalled: false, serviceName: 'MAPREDUCE'}
  102. ])},
  103. configs: configs
  104. });
  105. App.set('supports.capacitySchedulerUi', false);
  106. installerStep8Controller.createConfigurations();
  107. expect(installerStep8Controller.get('serviceConfigTags').length).to.equal(4);
  108. installerStep8Controller.clearStep();
  109. });
  110. it('verify App.supports.capacitySchedulerUi', function () {
  111. installerStep8Controller = App.WizardStep8Controller.create({
  112. content: {controllerName: 'addServiceController', services: Em.A([
  113. {isSelected: true, isInstalled: false, serviceName: 'MAPREDUCE'}
  114. ])},
  115. configs: configs
  116. });
  117. App.set('supports.capacitySchedulerUi', true);
  118. installerStep8Controller.createConfigurations();
  119. expect(installerStep8Controller.get('serviceConfigTags').length).to.equal(6);
  120. installerStep8Controller.clearStep();
  121. });
  122. // e - without global and core!
  123. var tests = Em.A([
  124. {selectedServices: Em.A(['MAPREDUCE2']), e: 2},
  125. {selectedServices: Em.A(['MAPREDUCE2', 'YARN']), e: 5},
  126. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE']), e: 7},
  127. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE']), e: 9},
  128. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE']), e: 12},
  129. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'WEBHCAT']), e: 13},
  130. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'WEBHCAT', 'HUE']), e: 14},
  131. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'WEBHCAT', 'HUE', 'PIG']), e: 16},
  132. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'WEBHCAT', 'HUE', 'PIG', 'FALCON']), e: 18},
  133. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'WEBHCAT', 'HUE', 'PIG', 'FALCON', 'STORM']), e: 19},
  134. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'WEBHCAT', 'HUE', 'PIG', 'FALCON', 'STORM', 'TEZ']), e: 20},
  135. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'WEBHCAT', 'HUE', 'PIG', 'FALCON', 'STORM', 'TEZ', 'ZOOKEEPER']), e: 22}
  136. ]);
  137. tests.forEach(function (test) {
  138. it(test.selectedServices.join(','), function () {
  139. var services = test.selectedServices.map(function (serviceName) {
  140. return Em.Object.create({isSelected: true, isInstalled: false, serviceName: serviceName});
  141. });
  142. installerStep8Controller = App.WizardStep8Controller.create({
  143. content: {controllerName: 'addServiceController', services: services},
  144. configs: configs
  145. });
  146. installerStep8Controller.createConfigurations();
  147. expect(installerStep8Controller.get('serviceConfigTags').length).to.equal(test.e + 2);
  148. installerStep8Controller.clearStep();
  149. });
  150. });
  151. // Verify xml character escaping is not done for log4j files and falcon startup-properties and runtime-properties files.
  152. it('escape xml character for installer wizard', function () {
  153. var services = Em.A([Em.Object.create({isSelected: true, isInstalled: false, serviceName: 'OOZIE'}),
  154. Em.Object.create({isSelected: true, isInstalled: false, serviceName: 'FALCON'})]);
  155. var nonXmlConfigs = [
  156. {filename: 'oozie-log4j.xml', name: 'p1', value: "'.'v1"},
  157. {filename: 'falcon-startup.properties.xml', name: 'p1', value: "'.'v1"} ,
  158. {filename: 'falcon-startup.properties.xml', name: 'p2', value: 'v2'},
  159. {filename: 'falcon-runtime.properties.xml', name: 'p1', value: "'.'v1"},
  160. {filename: 'falcon-runtime.properties.xml', name: 'p2', value: 'v2'}
  161. ];
  162. installerStep8Controller = App.WizardStep8Controller.create({
  163. content: {controllerName: 'installerController', services: services},
  164. configs: nonXmlConfigs
  165. });
  166. installerStep8Controller.createConfigurations();
  167. var nonXmlConfigTypes = ['oozie-log4j', 'falcon-startup.properties', 'falcon-runtime.properties'];
  168. nonXmlConfigTypes.forEach(function (_nonXmlConfigType) {
  169. var nonXmlConfigTypeObj = installerStep8Controller.get('serviceConfigTags').findProperty('type', _nonXmlConfigType);
  170. var nonXmlSitePropertyVal = nonXmlConfigTypeObj.properties['p1'];
  171. expect(nonXmlSitePropertyVal).to.equal("'.'v1");
  172. });
  173. installerStep8Controller.clearStep();
  174. });
  175. });
  176. describe('#createSelectedServicesData', function () {
  177. var tests = Em.A([
  178. {selectedServices: Em.A(['MAPREDUCE2']), e: 2},
  179. {selectedServices: Em.A(['MAPREDUCE2', 'YARN']), e: 5},
  180. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE']), e: 7},
  181. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE']), e: 9},
  182. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE']), e: 12},
  183. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'WEBHCAT']), e: 13},
  184. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'WEBHCAT', 'HUE']), e: 14},
  185. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'WEBHCAT', 'HUE', 'PIG']), e: 15},
  186. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'WEBHCAT', 'HUE', 'PIG', 'FALCON']), e: 17},
  187. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'WEBHCAT', 'HUE', 'PIG', 'FALCON', 'STORM']), e: 18},
  188. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'WEBHCAT', 'HUE', 'PIG', 'FALCON', 'STORM', 'TEZ']), e: 19},
  189. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'WEBHCAT', 'HUE', 'PIG', 'FALCON', 'STORM', 'TEZ', 'ZOOKEEPER']), e: 21}
  190. ]);
  191. tests.forEach(function (test) {
  192. it(test.selectedServices.join(','), function () {
  193. var services = test.selectedServices.map(function (serviceName) {
  194. return Em.Object.create({isSelected: true, isInstalled: false, serviceName: serviceName});
  195. });
  196. installerStep8Controller = App.WizardStep8Controller.create({
  197. content: {controllerName: 'addServiceController', services: services},
  198. configs: configs
  199. });
  200. var serviceData = installerStep8Controller.createSelectedServicesData();
  201. expect(serviceData.mapProperty('ServiceInfo.service_name')).to.eql(test.selectedServices.toArray());
  202. installerStep8Controller.clearStep();
  203. });
  204. });
  205. });
  206. describe('#getRegisteredHosts', function () {
  207. var tests = Em.A([
  208. {
  209. hosts: {
  210. h1: Em.Object.create({bootStatus: 'REGISTERED', name: 'h1'}),
  211. h2: Em.Object.create({bootStatus: 'OTHER', name: 'h2'})
  212. },
  213. e: ['h1'],
  214. m: 'Two hosts, one registered'
  215. },
  216. {
  217. hosts: {
  218. h1: Em.Object.create({bootStatus: 'OTHER', name: 'h1'}),
  219. h2: Em.Object.create({bootStatus: 'OTHER', name: 'h2'})
  220. },
  221. e: [],
  222. m: 'Two hosts, zero registered'
  223. },
  224. {
  225. hosts: {
  226. h1: Em.Object.create({bootStatus: 'REGISTERED', name: 'h1'}),
  227. h2: Em.Object.create({bootStatus: 'REGISTERED', name: 'h2'})
  228. },
  229. e: ['h1', 'h2'],
  230. m: 'Two hosts, two registered'
  231. }
  232. ]);
  233. tests.forEach(function (test) {
  234. it(test.m, function () {
  235. installerStep8Controller.set('content', Em.Object.create({hosts: test.hosts}));
  236. var registeredHosts = installerStep8Controller.getRegisteredHosts();
  237. expect(registeredHosts.mapProperty('hostName').toArray()).to.eql(test.e);
  238. });
  239. });
  240. });
  241. describe('#createRegisterHostData', function () {
  242. var tests = Em.A([
  243. {
  244. hosts: {
  245. h1: Em.Object.create({bootStatus: 'REGISTERED', name: 'h1', isInstalled: false}),
  246. h2: Em.Object.create({bootStatus: 'REGISTERED', name: 'h2', isInstalled: false})
  247. },
  248. e: ['h1', 'h2'],
  249. m: 'two registered, two isInstalled false'
  250. },
  251. {
  252. hosts: {
  253. h1: Em.Object.create({bootStatus: 'OTHER', name: 'h1', isInstalled: false}),
  254. h2: Em.Object.create({bootStatus: 'REGISTERED', name: 'h2', isInstalled: false})
  255. },
  256. e: ['h2'],
  257. m: 'one registered, two isInstalled false'
  258. },
  259. {
  260. hosts: {
  261. h1: Em.Object.create({bootStatus: 'OTHER', name: 'h1', isInstalled: true}),
  262. h2: Em.Object.create({bootStatus: 'REGISTERED', name: 'h2', isInstalled: false})
  263. },
  264. e: ['h2'],
  265. m: 'one registered, one isInstalled false'
  266. },
  267. {
  268. hosts: {
  269. h1: Em.Object.create({bootStatus: 'REGISTERED', name: 'h1', isInstalled: true}),
  270. h2: Em.Object.create({bootStatus: 'REGISTERED', name: 'h2', isInstalled: false})
  271. },
  272. e: ['h2'],
  273. m: 'two registered, one isInstalled false'
  274. },
  275. {
  276. hosts: {
  277. h1: Em.Object.create({bootStatus: 'OTHER', name: 'h1', isInstalled: false}),
  278. h2: Em.Object.create({bootStatus: 'OTHER', name: 'h2', isInstalled: false})
  279. },
  280. e: [],
  281. m: 'zero registered, two isInstalled false'
  282. },
  283. {
  284. hosts: {
  285. h1: Em.Object.create({bootStatus: 'REGISTERED', name: 'h1', isInstalled: true}),
  286. h2: Em.Object.create({bootStatus: 'REGISTERED', name: 'h2', isInstalled: true})
  287. },
  288. e: [],
  289. m: 'two registered, zeto insInstalled false'
  290. }
  291. ]);
  292. tests.forEach(function (test) {
  293. it(test.m, function () {
  294. installerStep8Controller.set('content', Em.Object.create({hosts: test.hosts}));
  295. var registeredHostData = installerStep8Controller.createRegisterHostData();
  296. expect(registeredHostData.mapProperty('Hosts.host_name').toArray()).to.eql(test.e);
  297. });
  298. });
  299. });
  300. describe('#clusterName', function () {
  301. it('should be equal to content.cluster.name', function () {
  302. installerStep8Controller.set('content', {cluster: {name: 'new_name'}});
  303. expect(installerStep8Controller.get('clusterName')).to.equal('new_name');
  304. });
  305. });
  306. describe('#loadStep', function () {
  307. beforeEach(function () {
  308. sinon.stub(installerStep8Controller, 'clearStep', Em.K);
  309. sinon.stub(installerStep8Controller, 'formatProperties', Em.K);
  310. sinon.stub(installerStep8Controller, 'loadGlobals', Em.K);
  311. sinon.stub(installerStep8Controller, 'loadConfigs', Em.K);
  312. sinon.stub(installerStep8Controller, 'loadClusterInfo', Em.K);
  313. sinon.stub(installerStep8Controller, 'loadServices', Em.K);
  314. installerStep8Controller.set('content', {controllerName: 'installerController'});
  315. });
  316. afterEach(function () {
  317. installerStep8Controller.clearStep.restore();
  318. installerStep8Controller.formatProperties.restore();
  319. installerStep8Controller.loadGlobals.restore();
  320. installerStep8Controller.loadConfigs.restore();
  321. installerStep8Controller.loadClusterInfo.restore();
  322. installerStep8Controller.loadServices.restore();
  323. });
  324. it('should call clearStep', function () {
  325. installerStep8Controller.loadStep();
  326. expect(installerStep8Controller.clearStep.calledOnce).to.equal(true);
  327. });
  328. it('should call loadClusterInfo', function () {
  329. installerStep8Controller.loadStep();
  330. expect(installerStep8Controller.loadClusterInfo.calledOnce).to.equal(true);
  331. });
  332. it('should call loadServices', function () {
  333. installerStep8Controller.loadStep();
  334. expect(installerStep8Controller.loadServices.calledOnce).to.equal(true);
  335. });
  336. it('should call formatProperties if content.serviceConfigProperties is true', function () {
  337. installerStep8Controller.set('content.serviceConfigProperties', true);
  338. installerStep8Controller.loadStep();
  339. expect(installerStep8Controller.loadServices.calledOnce).to.equal(true);
  340. });
  341. it('should call loadGlobals if content.serviceConfigProperties is true', function () {
  342. installerStep8Controller.set('content.serviceConfigProperties', true);
  343. installerStep8Controller.loadStep();
  344. expect(installerStep8Controller.loadGlobals.calledOnce).to.equal(true);
  345. });
  346. it('should call loadConfigs if content.serviceConfigProperties is true', function () {
  347. installerStep8Controller.set('content.serviceConfigProperties', true);
  348. installerStep8Controller.loadStep();
  349. expect(installerStep8Controller.loadConfigs.calledOnce).to.equal(true);
  350. });
  351. it('should set isSubmitDisabled to false', function () {
  352. installerStep8Controller.loadStep();
  353. expect(installerStep8Controller.get('isSubmitDisabled')).to.equal(false);
  354. });
  355. it('should set isBackBtnDisabled to false', function () {
  356. installerStep8Controller.loadStep();
  357. expect(installerStep8Controller.get('isBackBtnDisabled')).to.equal(false);
  358. });
  359. it('should call setSecurityStatus for non-installerController', function () {
  360. var obj = Em.Object.create({
  361. setSecurityStatus: Em.K
  362. });
  363. sinon.stub(App.router, 'get', function () {
  364. return obj;
  365. });
  366. sinon.spy(obj, 'setSecurityStatus');
  367. installerStep8Controller.set('content.controllerName', 'addServiceController');
  368. installerStep8Controller.loadStep();
  369. expect(obj.setSecurityStatus.calledOnce).to.equal(true);
  370. obj.setSecurityStatus.restore();
  371. App.router.get.restore();
  372. });
  373. });
  374. describe('#loadGlobals', function () {
  375. beforeEach(function () {
  376. sinon.stub(installerStep8Controller, 'removeHiveConfigs', function (o) {
  377. return o;
  378. });
  379. sinon.stub(installerStep8Controller, 'removeOozieConfigs', function (o) {
  380. return o;
  381. });
  382. });
  383. afterEach(function () {
  384. installerStep8Controller.removeHiveConfigs.restore();
  385. installerStep8Controller.removeOozieConfigs.restore();
  386. });
  387. Em.A([
  388. {
  389. configs: [],
  390. m: 'empty configs, removeHiveConfigs isn\'t called, removeOozieConfigs ins\'t called',
  391. e: {
  392. globals: [],
  393. removeHiveConfigs: false,
  394. removeOozieConfigs: false
  395. }
  396. },
  397. {
  398. configs: [
  399. Em.Object.create({id: 'puppet var', name: 'n1'})
  400. ],
  401. m: 'not empty configs, removeHiveConfigs isn\'t called, removeOozieConfigs ins\'t called',
  402. e: {
  403. globals: ['n1'],
  404. removeHiveConfigs: false,
  405. removeOozieConfigs: false
  406. }
  407. },
  408. {
  409. configs: [
  410. Em.Object.create({id: 'puppet var', name: 'n1'}),
  411. Em.Object.create({id: 'puppet var', name: 'hive_database'})
  412. ],
  413. m: 'not empty configs, removeHiveConfigs called, removeOozieConfigs ins\'t called',
  414. e: {
  415. globals: ['n1', 'hive_database'],
  416. removeHiveConfigs: true,
  417. removeOozieConfigs: false
  418. }
  419. },
  420. {
  421. configs: [
  422. Em.Object.create({id: 'puppet var', name: 'n1'}),
  423. Em.Object.create({id: 'puppet var', name: 'oozie_database'})
  424. ],
  425. m: 'not empty configs, removeHiveConfigs isn\'t called, removeOozieConfigs called',
  426. e: {
  427. globals: ['n1', 'oozie_database'],
  428. removeHiveConfigs: false,
  429. removeOozieConfigs: true
  430. }
  431. }
  432. ]).forEach(function (test) {
  433. it(test.m, function () {
  434. installerStep8Controller.set('content', {serviceConfigProperties: test.configs});
  435. installerStep8Controller.loadGlobals();
  436. if (test.e.removeHiveConfigs) {
  437. expect(installerStep8Controller.removeHiveConfigs.calledOnce).to.equal(true);
  438. }
  439. else {
  440. expect(installerStep8Controller.removeHiveConfigs.called).to.equal(false);
  441. }
  442. if (test.e.removeOozieConfigs) {
  443. expect(installerStep8Controller.removeOozieConfigs.calledOnce).to.equal(true);
  444. }
  445. else {
  446. expect(installerStep8Controller.removeOozieConfigs.called).to.equal(false);
  447. }
  448. expect(installerStep8Controller.get('globals').mapProperty('name')).to.eql(test.e.globals);
  449. });
  450. });
  451. });
  452. describe('#removeHiveConfigs', function () {
  453. Em.A([
  454. {
  455. globals: [
  456. {name: 'hive_database', value: 'New MySQL Database'},
  457. {name: 'hive_ambari_host', value: 'h1'},
  458. {name: 'hive_hostname', value: 'h2'}
  459. ],
  460. removed: Em.A(['hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_oracle_host',
  461. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']),
  462. hive_database_type: 'mysql',
  463. m: 'hive_database: New MySQL Database',
  464. host: 'h1'
  465. },
  466. {
  467. globals: [
  468. {name: 'hive_database', value: 'Existing MySQL Database'},
  469. {name: 'hive_existing_mysql_host', value: 'h1'},
  470. {name: 'hive_hostname', value: 'h2'}
  471. ],
  472. removed: Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host',
  473. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']),
  474. hive_database_type: 'mysql',
  475. m: 'hive_database: Existing MySQL Database',
  476. host: 'h1'
  477. },
  478. {
  479. globals: [
  480. {name: 'hive_database', value: 'Existing PostgreSQL Database'},
  481. {name: 'hive_existing_postgresql_host', value: 'h1'},
  482. {name: 'hive_hostname', value: 'h2'}
  483. ],
  484. removed: Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host',
  485. 'hive_existing_oracle_database', 'hive_existing_mysql_host', 'hive_existing_mysql_database']),
  486. hive_database_type: 'postgres',
  487. m: 'hive_database: Existing PostgreSQL Database',
  488. host: 'h1'
  489. },
  490. {
  491. globals: [
  492. {name: 'hive_database', value: 'Existing Oracle Database'},
  493. {name: 'hive_existing_oracle_host', value: 'h1'},
  494. {name: 'hive_hostname', value: 'h2'}
  495. ],
  496. removed: Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_mysql_host',
  497. 'hive_existing_mysql_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']),
  498. hive_database_type: 'oracle',
  499. m: 'hive_database: Existing Oracle Database',
  500. host: 'h1'
  501. }
  502. ]).forEach(function (test) {
  503. it(test.m, function () {
  504. test.removed.forEach(function (c) {
  505. test.globals.pushObject({name: c})
  506. });
  507. var configs = installerStep8Controller.removeHiveConfigs(test.globals);
  508. test.removed.forEach(function(name) {
  509. expect(Em.isNone(configs.findProperty('name', name))).to.equal(true);
  510. });
  511. expect(configs.findProperty('name', 'hive_database_type').value).to.equal(test.hive_database_type);
  512. expect(configs.findProperty('name', 'hive_hostname').value).to.equal(test.host);
  513. });
  514. });
  515. });
  516. describe('#removeOozieConfigs', function () {
  517. Em.A([
  518. {
  519. globals: [
  520. {name: 'oozie_database', value: 'New Derby Database'},
  521. {name: 'oozie_ambari_host', value: 'h1'},
  522. {name: 'oozie_hostname', value: 'h2'}
  523. ],
  524. removed: Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_mysql_host',
  525. 'oozie_existing_mysql_database', 'oozie_existing_oracle_host', 'oozie_existing_oracle_database',
  526. 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database']),
  527. oozie_database_type: 'derby',
  528. m: 'oozie_database: New Derby Database',
  529. host: 'h1'
  530. },
  531. {
  532. globals: [
  533. {name: 'oozie_database', value: 'Existing MySQL Database'},
  534. {name: 'oozie_existing_mysql_host', value: 'h1'},
  535. {name: 'oozie_hostname', value: 'h2'}
  536. ],
  537. removed: Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_oracle_host',
  538. 'oozie_existing_oracle_database', 'oozie_derby_database', 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database']),
  539. oozie_database_type: 'mysql',
  540. m: 'oozie_database: Existing MySQL Database',
  541. host: 'h1'
  542. },
  543. {
  544. globals: [
  545. {name: 'oozie_database', value: 'Existing PostgreSQL Database'},
  546. {name: 'oozie_existing_postgresql_host', value: 'h1'},
  547. {name: 'oozie_hostname', value: 'h2'}
  548. ],
  549. removed: Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_oracle_host',
  550. 'oozie_existing_oracle_database', 'oozie_existing_mysql_host', 'oozie_existing_mysql_database']),
  551. oozie_database_type: 'postgresql',
  552. m: 'oozie_database: Existing PostgreSQL Database',
  553. host: 'h1'
  554. },
  555. {
  556. globals: [
  557. {name: 'oozie_database', value: 'Existing Oracle Database'},
  558. {name: 'oozie_existing_oracle_host', value: 'h1'},
  559. {name: 'oozie_hostname', value: 'h2'}
  560. ],
  561. removed: Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_mysql_host',
  562. 'oozie_existing_mysql_database', 'oozie_derby_database', 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database']),
  563. oozie_database_type: 'oracle',
  564. m: 'oozie_database: Existing Oracle Database',
  565. host: 'h1'
  566. }
  567. ]).forEach(function (test) {
  568. it(test.m, function () {
  569. test.removed.forEach(function (c) {
  570. if (!test.globals.findProperty('name', c)) {
  571. test.globals.pushObject({name: c})
  572. }
  573. });
  574. var configs = installerStep8Controller.removeOozieConfigs(test.globals);
  575. test.removed.forEach(function(name) {
  576. expect(Em.isNone(configs.findProperty('name', name))).to.equal(true);
  577. });
  578. expect(configs.findProperty('name', 'oozie_database_type').value).to.equal(test.oozie_database_type);
  579. expect(configs.findProperty('name', 'oozie_hostname').value).to.equal(test.host);
  580. });
  581. });
  582. });
  583. describe('#getRegisteredHosts', function() {
  584. Em.A([
  585. {
  586. hosts: {},
  587. m: 'no content.hosts',
  588. e: []
  589. },
  590. {
  591. hosts: {
  592. h1:{bootStatus: ''},
  593. h2:{bootStatus: ''}
  594. },
  595. m: 'no registered hosts',
  596. e: []
  597. },
  598. {
  599. hosts: {
  600. h1:{bootStatus: 'REGISTERED', hostName: '', name: 'n1'},
  601. h2:{bootStatus: 'REGISTERED', hostName: '', name: 'n2'}
  602. },
  603. m: 'registered hosts available',
  604. e: ['n1', 'n2']
  605. }
  606. ]).forEach(function(test) {
  607. it(test.m, function() {
  608. installerStep8Controller.set('content', {hosts: test.hosts});
  609. var hosts = installerStep8Controller.getRegisteredHosts();
  610. expect(hosts.mapProperty('hostName')).to.eql(test.e);
  611. });
  612. });
  613. });
  614. describe('#loadRepoInfo', function() {
  615. it('should use App.currentStackVersion', function() {
  616. var version = 'HDP-1.1.1';
  617. sinon.stub(App, 'get', function() {return version;});
  618. sinon.stub(App.ajax, 'send', Em.K);
  619. installerStep8Controller.loadRepoInfo();
  620. var data = App.ajax.send.args[0][0].data;
  621. expect(data).to.eql({stackName: 'HDP', stackVersion: '1.1.1'});
  622. App.ajax.send.restore();
  623. App.get.restore();
  624. });
  625. });
  626. describe('#loadRepoInfoSuccessCallback', function () {
  627. beforeEach(function () {
  628. installerStep8Controller.set('clusterInfo', Em.Object.create({}));
  629. });
  630. Em.A([
  631. {
  632. items: [],
  633. m: 'no data',
  634. e: {
  635. base_url: [],
  636. os_type: []
  637. }
  638. },
  639. {
  640. items: [
  641. {
  642. repositories: [
  643. {
  644. Repositories: {
  645. os_type: 'bulgenos',
  646. base_url: 'url1'
  647. }
  648. }
  649. ]
  650. }
  651. ],
  652. m: 'unsupported os',
  653. e: {
  654. base_url: [],
  655. os_type: []
  656. }
  657. },
  658. {
  659. items: [
  660. {
  661. repositories: [
  662. {
  663. Repositories: {
  664. os_type: 'redhat5',
  665. base_url: 'url1'
  666. }
  667. }
  668. ]
  669. }
  670. ],
  671. m: 'only redhat5',
  672. e: {
  673. base_url: ['url1'],
  674. os_type: [Em.I18n.t("installer.step8.repoInfo.osType.redhat5")]
  675. }
  676. },
  677. {
  678. items: [
  679. {
  680. repositories: [
  681. {
  682. Repositories: {
  683. os_type: 'redhat5',
  684. base_url: 'url1'
  685. }
  686. }
  687. ]
  688. },
  689. {
  690. repositories: [
  691. {
  692. Repositories: {
  693. os_type: 'redhat6',
  694. base_url: 'url2'
  695. }
  696. }
  697. ]
  698. }
  699. ],
  700. m: 'redhat5, redhat6',
  701. e: {
  702. base_url: ['url1', 'url2'],
  703. os_type: [Em.I18n.t("installer.step8.repoInfo.osType.redhat5"), Em.I18n.t("installer.step8.repoInfo.osType.redhat6")]
  704. }
  705. },
  706. {
  707. items: [
  708. {
  709. repositories: [
  710. {
  711. Repositories: {
  712. os_type: 'redhat5',
  713. base_url: 'url1'
  714. }
  715. }
  716. ]
  717. },
  718. {
  719. repositories: [
  720. {
  721. Repositories: {
  722. os_type: 'redhat6',
  723. base_url: 'url2'
  724. }
  725. }
  726. ]
  727. },
  728. {
  729. repositories: [
  730. {
  731. Repositories: {
  732. os_type: 'sles11',
  733. base_url: 'url3'
  734. }
  735. }
  736. ]
  737. }
  738. ],
  739. m: 'redhat5, redhat6, sles11',
  740. e: {
  741. base_url: ['url1', 'url2', 'url3'],
  742. os_type: [Em.I18n.t("installer.step8.repoInfo.osType.redhat5"), Em.I18n.t("installer.step8.repoInfo.osType.redhat6"), Em.I18n.t("installer.step8.repoInfo.osType.sles11")]
  743. }
  744. }
  745. ]).forEach(function (test) {
  746. it(test.m, function () {
  747. installerStep8Controller.loadRepoInfoSuccessCallback({items: test.items});
  748. expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('base_url')).to.eql(test.e.base_url);
  749. expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('os_type')).to.eql(test.e.os_type);
  750. });
  751. });
  752. });
  753. describe('#loadRepoInfoErrorCallback', function() {
  754. it('should set [] to repoInfo', function() {
  755. installerStep8Controller.set('clusterInfo', Em.Object.create({repoInfo: [{}, {}]}));
  756. installerStep8Controller.loadRepoInfoErrorCallback({});
  757. expect(installerStep8Controller.get('clusterInfo.repoInfo.length')).to.eql(0);
  758. });
  759. });
  760. describe('#loadHiveDbValue', function() {
  761. beforeEach(function() {
  762. installerStep8Controller.set('wizardController', Em.Object.create({
  763. getDBProperty: Em.K
  764. }));
  765. });
  766. Em.A([
  767. {
  768. serviceConfigProperties: [
  769. {name: 'hive_database', value: 'New MySQL Database'}
  770. ],
  771. m: 'New MySQL Database',
  772. e: 'MySQL (New Database)'
  773. },
  774. {
  775. serviceConfigProperties: [
  776. {name: 'hive_database', value: 'Existing MySQL Database'},
  777. {name: 'hive_existing_mysql_database', value: 'dbname'}
  778. ],
  779. m: 'Existing MySQL Database',
  780. e: 'dbname (Existing MySQL Database)'
  781. },
  782. {
  783. serviceConfigProperties: [
  784. {name: 'hive_database', value: 'Existing PostgreSQL Database'},
  785. {name: 'hive_existing_postgresql_database', value: 'dbname'}
  786. ],
  787. m: 'Existing PostgreSQL Database',
  788. e: 'dbname (Existing PostgreSQL Database)'
  789. },
  790. {
  791. serviceConfigProperties: [
  792. {name: 'hive_database', value: 'Existing Oracle Database'},
  793. {name: 'hive_existing_oracle_database', value: 'dbname'}
  794. ],
  795. m: 'Existing Oracle Database',
  796. e: 'dbname (Existing Oracle Database)'
  797. }
  798. ]).forEach(function(test) {
  799. it(test.m, function() {
  800. sinon.stub(installerStep8Controller.get('wizardController'), 'getDBProperty', function() {
  801. return test.serviceConfigProperties;
  802. });
  803. var dbComponent = Em.Object.create({});
  804. installerStep8Controller.loadHiveDbValue(dbComponent);
  805. expect(dbComponent.get('component_value')).to.equal(test.e);
  806. installerStep8Controller.get('wizardController').getDBProperty.restore();
  807. });
  808. });
  809. });
  810. describe('#loadHbaseMasterValue', function () {
  811. Em.A([
  812. {
  813. masterComponentHosts: [{component: 'HBASE_MASTER', hostName: 'h1'}],
  814. component: Em.Object.create({component_name: 'HBASE_MASTER'}),
  815. m: 'one host',
  816. e: 'h1'
  817. },
  818. {
  819. masterComponentHosts: [{component: 'HBASE_MASTER', hostName: 'h1'}, {component: 'HBASE_MASTER', hostName: 'h2'}, {component: 'HBASE_MASTER', hostName: 'h3'}],
  820. component: Em.Object.create({component_name: 'HBASE_MASTER'}),
  821. m: 'many hosts',
  822. e: 'h1 ' + Em.I18n.t('installer.step8.other').format(2)
  823. }
  824. ]).forEach(function (test) {
  825. it(test.m, function() {
  826. installerStep8Controller.set('content', {masterComponentHosts: test.masterComponentHosts});
  827. installerStep8Controller.loadHbaseMasterValue(test.component);
  828. expect(test.component.component_value).to.equal(test.e);
  829. });
  830. });
  831. });
  832. describe('#loadZkServerValue', function() {
  833. Em.A([
  834. {
  835. masterComponentHosts: [{component: 'ZOOKEEPER_SERVER'}],
  836. component: Em.Object.create({component_name: 'ZOOKEEPER_SERVER'}),
  837. m: '1 host',
  838. e: '1 host'
  839. },
  840. {
  841. masterComponentHosts: [{component: 'ZOOKEEPER_SERVER'},{component: 'ZOOKEEPER_SERVER'},{component: 'ZOOKEEPER_SERVER'}],
  842. component: Em.Object.create({component_name: 'ZOOKEEPER_SERVER'}),
  843. m: 'many hosts',
  844. e: '3 hosts'
  845. }
  846. ]).forEach(function (test) {
  847. it(test.m, function () {
  848. installerStep8Controller.set('content', {masterComponentHosts: test.masterComponentHosts});
  849. installerStep8Controller.loadZkServerValue(test.component);
  850. expect(test.component.component_value).to.equal(test.e);
  851. });
  852. });
  853. });
  854. describe('#loadOozieDbValue', function() {
  855. beforeEach(function() {
  856. installerStep8Controller.set('wizardController', Em.Object.create({
  857. getDBProperty: Em.K
  858. }));
  859. });
  860. Em.A([
  861. {
  862. serviceConfigProperties: [
  863. {name: 'oozie_database', value: 'New Derby Database'},
  864. {name: 'oozie_derby_database', value: 'dbname'}
  865. ],
  866. m: 'New Derby Database',
  867. e: 'dbname (New Derby Database)'
  868. },
  869. {
  870. serviceConfigProperties: [
  871. {name: 'oozie_database', value: 'Existing MySQL Database'},
  872. {name: 'oozie_existing_mysql_database', value: 'dbname'}
  873. ],
  874. m: 'Existing MySQL Database',
  875. e: 'dbname (Existing MySQL Database)'
  876. },
  877. {
  878. serviceConfigProperties: [
  879. {name: 'oozie_database', value: 'Existing PostgreSQL Database'},
  880. {name: 'oozie_existing_postgresql_database', value: 'dbname'}
  881. ],
  882. m: 'Existing PostgreSQL Database',
  883. e: 'dbname (Existing PostgreSQL Database)'
  884. },
  885. {
  886. serviceConfigProperties: [
  887. {name: 'oozie_database', value: 'Existing Oracle Database'},
  888. {name: 'oozie_existing_oracle_database', value: 'dbname'}
  889. ],
  890. m: 'Existing Oracle Database',
  891. e: 'dbname (Existing Oracle Database)'
  892. }
  893. ]).forEach(function(test) {
  894. it(test.m, function() {
  895. sinon.stub(installerStep8Controller.get('wizardController'), 'getDBProperty', function() {
  896. return test.serviceConfigProperties;
  897. });
  898. var dbComponent = Em.Object.create({});
  899. installerStep8Controller.loadOozieDbValue(dbComponent);
  900. expect(dbComponent.get('component_value')).to.equal(test.e);
  901. installerStep8Controller.get('wizardController').getDBProperty.restore();
  902. });
  903. });
  904. });
  905. describe('#loadNagiosAdminValue', function() {
  906. it('should use serviceConfigProperties nagios_web_login and nagios_contact', function() {
  907. installerStep8Controller.set('content', {
  908. serviceConfigProperties: [
  909. {name: 'nagios_web_login', value: 'admin'},
  910. {name: 'nagios_contact', value: 'admin@admin.com'}
  911. ]
  912. });
  913. var nagiosAdmin = Em.Object.create({
  914. component_value: ''
  915. });
  916. installerStep8Controller.loadNagiosAdminValue(nagiosAdmin);
  917. expect(nagiosAdmin.get('component_value')).to.equal('admin / (admin@admin.com)');
  918. });
  919. });
  920. describe('#submit', function() {
  921. beforeEach(function() {
  922. sinon.stub(installerStep8Controller, 'submitProceed', Em.K);
  923. sinon.spy(App, 'showConfirmationPopup');
  924. });
  925. afterEach(function() {
  926. installerStep8Controller.submitProceed.restore();
  927. App.showConfirmationPopup.restore();
  928. });
  929. Em.A([
  930. {
  931. controllerName: 'addHostController',
  932. securityEnabled: true,
  933. e: true
  934. },
  935. {
  936. controllerName: 'addHostController',
  937. securityEnabled: false,
  938. e: false
  939. },
  940. {
  941. controllerName: 'addServiceController',
  942. securityEnabled: true,
  943. e: false
  944. },
  945. {
  946. controllerName: 'addServiceController',
  947. securityEnabled: false,
  948. e: false
  949. }
  950. ]).forEach(function (test) {
  951. it(test.controllerName + ' ' + test.securityEnabled.toString(), function () {
  952. installerStep8Controller.reopen({isSubmitDisabled: false, securityEnabled: test.securityEnabled, content: {controllerName: test.controllerName}});
  953. installerStep8Controller.submit();
  954. if (test.e) {
  955. expect(App.showConfirmationPopup.calledOnce).to.equal(true);
  956. expect(installerStep8Controller.submitProceed.called).to.equal(false);
  957. }
  958. else {
  959. expect(App.showConfirmationPopup.called).to.equal(false);
  960. expect(installerStep8Controller.submitProceed.calledOnce).to.equal(true);
  961. }
  962. });
  963. });
  964. it('should call submitProceed when Ok clicked', function() {
  965. installerStep8Controller.reopen({isSubmitDisabled: false, securityEnabled: true, content: {controllerName: 'addHostController'}});
  966. installerStep8Controller.submit().onPrimary();
  967. expect(installerStep8Controller.submitProceed.calledOnce).to.equal(true);
  968. });
  969. it('shouldn\'t do nothing if isSubmitDisabled is true', function() {
  970. installerStep8Controller.reopen({isSubmitDisabled: true});
  971. installerStep8Controller.submit();
  972. expect(App.showConfirmationPopup.called).to.equal(false);
  973. expect(installerStep8Controller.submitProceed.called).to.equal(false);
  974. });
  975. });
  976. describe('#getExistingClusterNamesSuccessCallBack', function() {
  977. it('should set clusterNames received from server', function() {
  978. var data = {
  979. items:[
  980. {Clusters: {cluster_name: 'c1'}},
  981. {Clusters: {cluster_name: 'c2'}},
  982. {Clusters: {cluster_name: 'c3'}}
  983. ]
  984. },
  985. clasterNames = ['c1','c2','c3'];
  986. installerStep8Controller.getExistingClusterNamesSuccessCallBack(data);
  987. expect(installerStep8Controller.get('clusterNames')).to.eql(clasterNames);
  988. });
  989. });
  990. describe('#getExistingClusterNamesErrorCallback', function() {
  991. it('should set [] to clusterNames', function() {
  992. installerStep8Controller.set('clusterNames', ['c1', 'c2']);
  993. installerStep8Controller.getExistingClusterNamesErrorCallback();
  994. expect(installerStep8Controller.get('clusterNames')).to.eql([]);
  995. });
  996. });
  997. describe('#deleteClusters', function() {
  998. it('should call App.ajax.send for each provided clusterName', function() {
  999. sinon.stub(App.ajax, 'send', Em.K);
  1000. var clusterNames = ['h1', 'h2', 'h3'];
  1001. installerStep8Controller.deleteClusters(clusterNames);
  1002. expect(App.ajax.send.callCount).to.equal(clusterNames.length);
  1003. clusterNames.forEach(function(n, i) {
  1004. expect(App.ajax.send.getCall(i).args[0].data).to.eql({name: n});
  1005. });
  1006. App.ajax.send.restore();
  1007. });
  1008. });
  1009. describe('#createSelectedServicesData', function() {
  1010. it('should reformat provided data', function() {
  1011. var selectedServices = [
  1012. Em.Object.create({serviceName: 's1'}),
  1013. Em.Object.create({serviceName: 's2'}),
  1014. Em.Object.create({serviceName: 's3'})
  1015. ];
  1016. var expected = [
  1017. {"ServiceInfo": { "service_name": 's1' }},
  1018. {"ServiceInfo": { "service_name": 's2' }},
  1019. {"ServiceInfo": { "service_name": 's3' }}
  1020. ];
  1021. installerStep8Controller.reopen({selectedServices: selectedServices});
  1022. var createdData = installerStep8Controller.createSelectedServicesData();
  1023. expect(createdData).to.eql(expected);
  1024. });
  1025. });
  1026. describe('#createRegisterHostData', function() {
  1027. it('should return empty data if no hosts', function() {
  1028. sinon.stub(installerStep8Controller, 'getRegisteredHosts', function() {return [];});
  1029. expect(installerStep8Controller.createRegisterHostData()).to.eql([]);
  1030. installerStep8Controller.getRegisteredHosts.restore();
  1031. });
  1032. it('should return computed data', function() {
  1033. var data = [
  1034. {isInstalled: false, hostName: 'h1'},
  1035. {isInstalled: true, hostName: 'h2'},
  1036. {isInstalled: false, hostName: 'h3'}
  1037. ];
  1038. var expected = [
  1039. {"Hosts": { "host_name": 'h1'}},
  1040. {"Hosts": { "host_name": 'h3'}}
  1041. ];
  1042. sinon.stub(installerStep8Controller, 'getRegisteredHosts', function() {return data;});
  1043. expect(installerStep8Controller.createRegisterHostData()).to.eql(expected);
  1044. installerStep8Controller.getRegisteredHosts.restore();
  1045. });
  1046. });
  1047. describe('#createZooCfgObj', function() {
  1048. it('should affect zoo.cfg properties', function() {
  1049. var configs = [
  1050. {filename: 'zoo.cfg', value: 'a&b', name: 'p1'},
  1051. {filename: 'zoo.cfg', value: 'a<b', name: 'p2'},
  1052. {filename: 'zoo.cfg', value: 'a>b', name: 'p3'},
  1053. {filename: 'zoo.cfg', value: 'a"b', name: 'p4'},
  1054. {filename: 'zoo.cfg', value: 'a'b', name: 'p5'}
  1055. ],
  1056. expected = {
  1057. type: 'zoo.cfg',
  1058. tag: 'version1',
  1059. properties: {
  1060. p1: 'a&b',
  1061. p2: 'a<b',
  1062. p3: 'a>b',
  1063. p4: 'a"b',
  1064. p5: 'a\'b'
  1065. }
  1066. };
  1067. installerStep8Controller.reopen({configs: configs});
  1068. expect(installerStep8Controller.createZooCfgObj()).to.eql(expected);
  1069. });
  1070. });
  1071. describe('#createStormSiteObj', function() {
  1072. it('should remove quotes for some properties', function() {
  1073. var configs = [
  1074. {filename: 'storm-site.xml', value: ["a", "b"], name: 'nimbus.childopts'},
  1075. {filename: 'storm-site.xml', value: ["a", "b"], name: 'supervisor.childopts'},
  1076. {filename: 'storm-site.xml', value: ["a", "b"], name: 'worker.childopts'}
  1077. ],
  1078. expected = {
  1079. type: 'storm-site',
  1080. tag: 'version1',
  1081. properties: {
  1082. 'nimbus.childopts': '[a,b]',
  1083. 'supervisor.childopts': '[a,b]',
  1084. 'worker.childopts': '[a,b]'
  1085. }
  1086. };
  1087. installerStep8Controller.reopen({configs: configs});
  1088. expect(installerStep8Controller.createStormSiteObj()).to.eql(expected);
  1089. });
  1090. it('should replace quote \'"\' to "\'" for some properties', function() {
  1091. var configs = [
  1092. {filename: 'storm-site.xml', value: ["a", "b"], name: 'storm.zookeeper.servers'}
  1093. ],
  1094. expected = {
  1095. type: 'storm-site',
  1096. tag: 'version1',
  1097. properties: {
  1098. 'storm.zookeeper.servers': '[\'a\',\'b\']'
  1099. }
  1100. };
  1101. installerStep8Controller.reopen({configs: configs});
  1102. expect(installerStep8Controller.createStormSiteObj()).to.eql(expected);
  1103. });
  1104. it('should affect storm-site.xml properties', function() {
  1105. var configs = [
  1106. {filename: 'storm-site.xml', value: 'a&amp;b', name: 'p1'},
  1107. {filename: 'storm-site.xml', value: 'a&lt;b', name: 'p2'},
  1108. {filename: 'storm-site.xml', value: 'a&gt;b', name: 'p3'},
  1109. {filename: 'storm-site.xml', value: 'a&quot;b', name: 'p4'},
  1110. {filename: 'storm-site.xml', value: 'a&apos;b', name: 'p5'}
  1111. ],
  1112. expected = {
  1113. type: 'storm-site',
  1114. tag: 'version1',
  1115. properties: {
  1116. p1: 'a&b',
  1117. p2: 'a<b',
  1118. p3: 'a>b',
  1119. p4: 'a"b',
  1120. p5: 'a\'b'
  1121. }
  1122. };
  1123. installerStep8Controller.reopen({configs: configs});
  1124. expect(installerStep8Controller.createStormSiteObj()).to.eql(expected);
  1125. });
  1126. });
  1127. describe('#ajaxQueueFinished', function() {
  1128. it('should call App.router.next', function() {
  1129. sinon.stub(App.router, 'send', Em.K);
  1130. installerStep8Controller.ajaxQueueFinished();
  1131. expect(App.router.send.calledWith('next')).to.equal(true);
  1132. App.router.send.restore();
  1133. });
  1134. });
  1135. describe('#addRequestToAjaxQueue', function() {
  1136. describe('testMode = true', function() {
  1137. before(function() {
  1138. App.set('testMode', true);
  1139. });
  1140. after(function() {
  1141. App.set('testMode', false);
  1142. });
  1143. it('shouldn\'t do nothing', function() {
  1144. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  1145. installerStep8Controller.get('ajaxRequestsQueue').clear();
  1146. installerStep8Controller.addRequestToAjaxQueue({});
  1147. expect(installerStep8Controller.get('ajaxRequestsQueue.queue.length')).to.equal(0);
  1148. });
  1149. });
  1150. describe('testMode = true', function() {
  1151. before(function() {
  1152. App.set('testMode', false);
  1153. });
  1154. it('should add request', function() {
  1155. var clusterName = 'c1';
  1156. installerStep8Controller.reopen({clusterName: clusterName});
  1157. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  1158. installerStep8Controller.get('ajaxRequestsQueue').clear();
  1159. installerStep8Controller.addRequestToAjaxQueue({name:'name', data:{}});
  1160. var request = installerStep8Controller.get('ajaxRequestsQueue.queue.firstObject');
  1161. expect(request.error).to.equal('ajaxQueueRequestErrorCallback');
  1162. expect(request.data.cluster).to.equal(clusterName);
  1163. });
  1164. });
  1165. });
  1166. describe('#ajaxQueueRequestErrorCallback', function() {
  1167. var obj = Em.Object.create({
  1168. registerErrPopup: Em.K,
  1169. setStepsEnable: Em.K
  1170. });
  1171. beforeEach(function() {
  1172. sinon.stub(App.router, 'get', function() {
  1173. return obj;
  1174. });
  1175. sinon.spy(obj, 'registerErrPopup');
  1176. sinon.spy(obj, 'setStepsEnable');
  1177. });
  1178. afterEach(function() {
  1179. App.router.get.restore();
  1180. obj.registerErrPopup.restore();
  1181. obj.setStepsEnable.restore();
  1182. });
  1183. it('should set hasErrorOccurred true', function () {
  1184. installerStep8Controller.set('hasErrorOccurred', false);
  1185. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1186. expect(installerStep8Controller.get('hasErrorOccurred')).to.equal(true);
  1187. });
  1188. it('should set isSubmitDisabled false', function () {
  1189. installerStep8Controller.set('isSubmitDisabled', true);
  1190. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1191. expect(installerStep8Controller.get('isSubmitDisabled')).to.equal(false);
  1192. });
  1193. it('should set isBackBtnDisabled false', function () {
  1194. installerStep8Controller.set('isBackBtnDisabled', true);
  1195. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1196. expect(installerStep8Controller.get('isBackBtnDisabled')).to.equal(false);
  1197. });
  1198. it('should call setStepsEnable', function () {
  1199. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1200. expect(obj.setStepsEnable.calledOnce).to.equal(true);
  1201. });
  1202. it('should call registerErrPopup', function () {
  1203. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1204. expect(obj.registerErrPopup.calledOnce).to.equal(true);
  1205. });
  1206. });
  1207. describe('#removeInstalledServicesConfigurationGroups', function() {
  1208. beforeEach(function() {
  1209. sinon.stub(App.config, 'deleteConfigGroup', Em.K);
  1210. });
  1211. afterEach(function() {
  1212. App.config.deleteConfigGroup.restore();
  1213. });
  1214. it('should call App.config.deleteConfigGroup for each received group', function() {
  1215. var groups = [{}, {}, {}];
  1216. installerStep8Controller.removeInstalledServicesConfigurationGroups(groups);
  1217. expect(App.config.deleteConfigGroup.callCount).to.equal(groups.length);
  1218. });
  1219. });
  1220. describe('#assignComponentHosts', function() {
  1221. it('component with custom handler', function() {
  1222. var castom_value = 'custom',
  1223. component = Em.Object.create({
  1224. customHandler: 'customHandler'
  1225. });
  1226. installerStep8Controller.reopen({
  1227. customHandler: function(o) {o.set('component_value', castom_value)}
  1228. });
  1229. installerStep8Controller.assignComponentHosts(component);
  1230. expect(component.get('component_value')).to.equal(castom_value);
  1231. });
  1232. it('component is master', function() {
  1233. var component = Em.Object.create({
  1234. component_name: 'c1',
  1235. isMaster: true
  1236. }),
  1237. masterComponentHosts = [
  1238. {component: 'c1', hostName: 'h1'}
  1239. ];
  1240. installerStep8Controller.reopen({content: {masterComponentHosts: masterComponentHosts}});
  1241. installerStep8Controller.assignComponentHosts(component);
  1242. expect(component.get('component_value')).to.equal('h1');
  1243. });
  1244. it('component isn\'t master, 1 host', function() {
  1245. var component = Em.Object.create({
  1246. component_name: 'c1',
  1247. isMaster: false
  1248. }),
  1249. slaveComponentHosts = [
  1250. {componentName: 'c1', hosts: [{}]}
  1251. ];
  1252. installerStep8Controller.reopen({content: {slaveComponentHosts: slaveComponentHosts}});
  1253. installerStep8Controller.assignComponentHosts(component);
  1254. expect(component.get('component_value')).to.equal('1 host');
  1255. });
  1256. it('component isn\'t master, 2 hosts', function() {
  1257. var component = Em.Object.create({
  1258. component_name: 'c1',
  1259. isMaster: false
  1260. }),
  1261. slaveComponentHosts = [
  1262. {componentName: 'c1', hosts: [{}, {}]}
  1263. ];
  1264. installerStep8Controller.reopen({content: {slaveComponentHosts: slaveComponentHosts}});
  1265. installerStep8Controller.assignComponentHosts(component);
  1266. expect(component.get('component_value')).to.equal('2 hosts');
  1267. });
  1268. });
  1269. describe('#addDynamicProperties', function() {
  1270. it('shouldn\'t add property', function() {
  1271. var serviceConfigProperties = [
  1272. {name: 'templeton.hive.properties'}
  1273. ],
  1274. configs = [];
  1275. installerStep8Controller.reopen({content: {serviceConfigProperties: serviceConfigProperties}});
  1276. installerStep8Controller.addDynamicProperties(configs);
  1277. expect(configs.length).to.equal(0);
  1278. });
  1279. it('should add property', function() {
  1280. var serviceConfigProperties = [],
  1281. configs = [];
  1282. installerStep8Controller.reopen({content: {serviceConfigProperties: serviceConfigProperties}});
  1283. installerStep8Controller.addDynamicProperties(configs);
  1284. expect(configs.length).to.equal(1);
  1285. });
  1286. });
  1287. describe('#formatProperties', function() {
  1288. });
  1289. describe('#updateConfigurations', function() {
  1290. beforeEach(function() {
  1291. sinon.stub(configurationController, 'doPUTClusterConfigurationSite', Em.K);
  1292. sinon.stub(App.router, 'get', function() {
  1293. return configurationController;
  1294. });
  1295. });
  1296. afterEach(function() {
  1297. configurationController.doPUTClusterConfigurationSite.restore();
  1298. App.router.get.restore();
  1299. });
  1300. it('empty configsToUpdate', function() {
  1301. installerStep8Controller.updateConfigurations([]);
  1302. expect(configurationController.doPUTClusterConfigurationSite.called).to.be.false;
  1303. });
  1304. it('one service, no site properties', function() {
  1305. var configsToUpdate = [
  1306. {serviceName: 's1', id: ''},
  1307. {serviceName: 's1', id: ''}
  1308. ];
  1309. installerStep8Controller.updateConfigurations(configsToUpdate);
  1310. expect(configurationController.doPUTClusterConfigurationSite.called).to.be.false;
  1311. });
  1312. it('one service, site properties, 2 files', function() {
  1313. var configsToUpdate = [
  1314. {serviceName: 's1', id: 'site property', filename: 'f1.xml', name: 'n1', value: 'v1'},
  1315. {serviceName: 's1', id: 'site property', filename: 'f2.xml', name: 'n2', value: 'v2'}
  1316. ];
  1317. installerStep8Controller.updateConfigurations(configsToUpdate);
  1318. expect(configurationController.doPUTClusterConfigurationSite.calledTwice).to.be.true;
  1319. });
  1320. it('two services, site properties, 2 files', function() {
  1321. var configsToUpdate = [
  1322. {serviceName: 's1', id: 'site property', filename: 'f1.xml', name: 'n1', value: 'v1'},
  1323. {serviceName: 's1', id: 'site property', filename: 'f1.xml', name: 'n12', value: 'v12'},
  1324. {serviceName: 's1', id: 'site property', filename: 'f2.xml', name: 'n2', value: 'v2'},
  1325. {serviceName: 's2', id: 'site property', filename: 'f2.xml', name: 'n3', value: 'v3'}
  1326. ];
  1327. installerStep8Controller.updateConfigurations(configsToUpdate);
  1328. expect(configurationController.doPUTClusterConfigurationSite.calledThrice).to.be.true;
  1329. var firstCallArgs = configurationController.doPUTClusterConfigurationSite.args[0][0];
  1330. expect(firstCallArgs.type).to.equal('f1');
  1331. expect(firstCallArgs.properties).to.eql({"n1":"v1","n12":"v12"});
  1332. var secondCallArgs = configurationController.doPUTClusterConfigurationSite.args[1][0];
  1333. expect(secondCallArgs.type).to.equal('f2');
  1334. expect(secondCallArgs.properties).to.eql({"n2":"v2"});
  1335. var thirdCallArgs = configurationController.doPUTClusterConfigurationSite.args[2][0];
  1336. expect(thirdCallArgs.type).to.equal('f2');
  1337. expect(thirdCallArgs.properties).to.eql({"n3":"v3"});
  1338. });
  1339. });
  1340. describe('#loadServices', function() {
  1341. beforeEach(function() {
  1342. sinon.stub(installerStep8Controller, 'assignComponentHosts', function(obj) {
  1343. Em.set(obj, 'component_value', 'component_value');
  1344. });
  1345. installerStep8Controller.set('services', []);
  1346. });
  1347. afterEach(function() {
  1348. installerStep8Controller.assignComponentHosts.restore();
  1349. });
  1350. it('no reviewService', function() {
  1351. installerStep8Controller.set('rawContent', []);
  1352. installerStep8Controller.loadServices();
  1353. expect(installerStep8Controller.get('services')).to.eql([]);
  1354. });
  1355. it('no reviewService 2', function() {
  1356. installerStep8Controller.set('rawContent', [{config_name: 'services'}]);
  1357. installerStep8Controller.loadServices();
  1358. expect(installerStep8Controller.get('services')).to.eql([]);
  1359. });
  1360. it('no selectedServices', function() {
  1361. installerStep8Controller.reopen({
  1362. selectedServices: [],
  1363. rawContent: [{config_name: 'services', config_value: [{}]}]
  1364. });
  1365. installerStep8Controller.loadServices();
  1366. expect(installerStep8Controller.get('services')).to.eql([]);
  1367. });
  1368. it('no intersections selectedServices and reviewService.services', function() {
  1369. installerStep8Controller.reopen({
  1370. selectedServices: [{serviceName: 's1'}],
  1371. rawContent: [{config_name: 'services', config_value: [{service_name: 's2'}]}]
  1372. });
  1373. installerStep8Controller.loadServices();
  1374. expect(installerStep8Controller.get('services')).to.eql([]);
  1375. });
  1376. it('push some services', function() {
  1377. installerStep8Controller.reopen({
  1378. selectedServices: [{serviceName: 's1'}],
  1379. rawContent: [
  1380. {
  1381. config_name: 'services',
  1382. config_value: [Em.Object.create({service_name: 's1', service_components: [{}]})]
  1383. }
  1384. ]
  1385. });
  1386. installerStep8Controller.loadServices();
  1387. expect(installerStep8Controller.get('services.length')).to.eql(1);
  1388. });
  1389. });
  1390. describe('#createCoreSiteObj', function() {
  1391. Em.A([
  1392. {
  1393. configs: [
  1394. {filename: 'core-site.xml', name: 'hadoop.proxyuser.o.hosts'},
  1395. {filename: 'core-site.xml', name: 'hadoop.proxyuser.o.groups'}
  1396. ],
  1397. globals: [
  1398. {name: 'oozie_user', value: 'o'}
  1399. ],
  1400. selectedServices: [
  1401. {serviceName: ''}
  1402. ],
  1403. m: 'no OOZIE',
  1404. e: {
  1405. excludedConfigs: ['hadoop.proxyuser.o.hosts', 'hadoop.proxyuser.o.groups'],
  1406. includedConfigs: []
  1407. }
  1408. },
  1409. {
  1410. configs: [
  1411. {filename: 'core-site.xml', name: 'hadoop.proxyuser.o.hosts'},
  1412. {filename: 'core-site.xml', name: 'hadoop.proxyuser.o.groups'}
  1413. ],
  1414. globals: [
  1415. {name: 'oozie_user', value: 'o'}
  1416. ],
  1417. selectedServices: [
  1418. {serviceName: 'OOZIE'}
  1419. ],
  1420. m: 'OOZIE exists',
  1421. e: {
  1422. excludedConfigs: [],
  1423. includedConfigs: ['hadoop.proxyuser.o.hosts', 'hadoop.proxyuser.o.groups']
  1424. }
  1425. },
  1426. {
  1427. configs: [
  1428. {filename: 'core-site.xml', name: 'hadoop.proxyuser.h.hosts'},
  1429. {filename: 'core-site.xml', name: 'hadoop.proxyuser.h.groups'}
  1430. ],
  1431. globals: [
  1432. {name: 'hive_user', value: 'h'}
  1433. ],
  1434. selectedServices: [
  1435. {serviceName: ''}
  1436. ],
  1437. m: 'no HIVE',
  1438. e: {
  1439. excludedConfigs: ['hadoop.proxyuser.h.hosts', 'hadoop.proxyuser.h.groups'],
  1440. includedConfigs: []
  1441. }
  1442. },
  1443. {
  1444. configs: [
  1445. {filename: 'core-site.xml', name: 'hadoop.proxyuser.h.hosts'},
  1446. {filename: 'core-site.xml', name: 'hadoop.proxyuser.h.groups'}
  1447. ],
  1448. globals: [
  1449. {name: 'hive_user', value: 'h'}
  1450. ],
  1451. selectedServices: [
  1452. {serviceName: 'HIVE'}
  1453. ],
  1454. m: 'HIVE exists',
  1455. e: {
  1456. excludedConfigs: [],
  1457. includedConfigs: ['hadoop.proxyuser.h.hosts', 'hadoop.proxyuser.h.groups']
  1458. }
  1459. },
  1460. {
  1461. configs: [
  1462. {filename: 'core-site.xml', name: 'hadoop.proxyuser.hc.hosts'},
  1463. {filename: 'core-site.xml', name: 'hadoop.proxyuser.hc.groups'}
  1464. ],
  1465. globals: [
  1466. {name: 'hcat_user', value: 'hc'}
  1467. ],
  1468. selectedServices: [
  1469. {serviceName: ''}
  1470. ],
  1471. m: 'no WEBHCAT',
  1472. e: {
  1473. excludedConfigs: ['hadoop.proxyuser.hc.hosts', 'hadoop.proxyuser.hc.groups'],
  1474. includedConfigs: []
  1475. }
  1476. },
  1477. {
  1478. configs: [
  1479. {filename: 'core-site.xml', name: 'hadoop.proxyuser.hc.hosts'},
  1480. {filename: 'core-site.xml', name: 'hadoop.proxyuser.hc.groups'}
  1481. ],
  1482. globals: [
  1483. {name: 'hcat_user', value: 'hc'}
  1484. ],
  1485. selectedServices: [
  1486. {serviceName: 'WEBHCAT'}
  1487. ],
  1488. m: 'WEBHCAT exists',
  1489. e: {
  1490. excludedConfigs: [],
  1491. includedConfigs: ['hadoop.proxyuser.hc.hosts', 'hadoop.proxyuser.hc.groups']
  1492. }
  1493. },
  1494. {
  1495. configs: [
  1496. {filename: 'core-site.xml', name: 'fs.glusterfs.c1'},
  1497. {filename: 'core-site.xml', name: 'fs.glusterfs.c2'}
  1498. ],
  1499. globals: [],
  1500. selectedServices: [
  1501. {serviceName: ''}
  1502. ],
  1503. m: 'no GLUSTERFS',
  1504. e: {
  1505. excludedConfigs: ['fs.glusterfs.c1', 'fs.glusterfs.c2', 'fs.default.name', 'fs.defaultFS'],
  1506. includedConfigs: []
  1507. }
  1508. },
  1509. {
  1510. configs: [
  1511. {filename: 'core-site.xml', name: 'fs.default.name'},
  1512. {filename: 'core-site.xml', name: 'fs.defaultFS'}
  1513. ],
  1514. globals: [
  1515. {name: 'fs_glusterfs_default_name', value: 'v1'},
  1516. {name: 'glusterfs_defaultFS_name', value: 'v2'}
  1517. ],
  1518. selectedServices: [
  1519. {serviceName: 'GLUSTERFS'}
  1520. ],
  1521. m: 'GLUSTERFS exists',
  1522. e: {
  1523. excludedConfigs: [],
  1524. includedConfigs: ['fs.default.name', 'fs.defaultFS']
  1525. }
  1526. },
  1527. {
  1528. configs: [],
  1529. globals: [
  1530. {name: 'fs_glusterfs_default_name', value: 'v1'},
  1531. {name: 'glusterfs_defaultFS_name', value: 'v2'}
  1532. ],
  1533. selectedServices: [
  1534. {serviceName: 'GLUSTERFS'}
  1535. ],
  1536. m: 'GLUSTERFS exists 2',
  1537. e: {
  1538. excludedConfigs: ['fs_glusterfs_default_name', 'glusterfs_defaultFS_name'],
  1539. includedConfigs: []
  1540. }
  1541. }
  1542. ]).forEach(function (test) {
  1543. it(test.m, function () {
  1544. installerStep8Controller.reopen({
  1545. globals: test.globals,
  1546. configs: test.configs,
  1547. selectedServices: test.selectedServices
  1548. });
  1549. var coreSiteObj = installerStep8Controller.createCoreSiteObj();
  1550. expect(coreSiteObj.type).to.equal('core-site');
  1551. expect(coreSiteObj.tag).to.equal('version1');
  1552. var properties = Em.keys(coreSiteObj.properties);
  1553. test.e.excludedConfigs.forEach(function (configName) {
  1554. expect(properties.contains(configName)).to.be.false;
  1555. });
  1556. test.e.includedConfigs.forEach(function (configName) {
  1557. expect(properties.contains(configName)).to.be.true;
  1558. });
  1559. });
  1560. });
  1561. });
  1562. describe('#createGlobalSiteObj', function() {
  1563. it('required by agent configs should be skipped', function() {
  1564. var globals = [{isRequiredByAgent: false, name: ''}, {isRequiredByAgent: false, name: ''}];
  1565. installerStep8Controller.reopen({globals: globals, selectedServices: []});
  1566. var globalSiteObj = installerStep8Controller.createGlobalSiteObj();
  1567. expect(globalSiteObj.type).to.equal('global');
  1568. expect(globalSiteObj.tag).to.equal('version1');
  1569. expect(Em.keys(globalSiteObj.properties)).to.eql(['gmond_user']);
  1570. });
  1571. it('gluster configs should be skipped', function() {
  1572. var globals = [{isRequiredByAgent: true, name: 'fs_glusterfs.c1'}, {isRequiredByAgent: true, name: 'fs_glusterfs.c2'}];
  1573. installerStep8Controller.reopen({globals: globals, selectedServices: [{serviceName: ''}]});
  1574. var globalSiteObj = installerStep8Controller.createGlobalSiteObj();
  1575. expect(globalSiteObj.type).to.equal('global');
  1576. expect(globalSiteObj.tag).to.equal('version1');
  1577. expect(Em.keys(globalSiteObj.properties)).to.eql(['gmond_user']);
  1578. });
  1579. it('_heapsize|_newsize|_maxnewsize should add m to end', function() {
  1580. var globals = [
  1581. {isRequiredByAgent: true, name: 'c1_heapsize', value: '1'},
  1582. {isRequiredByAgent: true, name: 'c1_newsize', value: '2'},
  1583. {isRequiredByAgent: true, name: 'c1_maxnewsize', value: '3'}
  1584. ];
  1585. installerStep8Controller.reopen({globals: globals, selectedServices: [{serviceName: ''}]});
  1586. var globalSiteObj = installerStep8Controller.createGlobalSiteObj();
  1587. expect(globalSiteObj.type).to.equal('global');
  1588. expect(globalSiteObj.tag).to.equal('version1');
  1589. globals.forEach(function(global) {
  1590. expect(globalSiteObj.properties[global.name]).to.equal(global.value + 'm');
  1591. });
  1592. });
  1593. it('for some configs should not add m to end', function() {
  1594. var globals = [
  1595. {isRequiredByAgent: true, name: 'hadoop_heapsize', value: '1'},
  1596. {isRequiredByAgent: true, name: 'yarn_heapsize', value: '2'},
  1597. {isRequiredByAgent: true, name: 'nodemanager_heapsize', value: '3'},
  1598. {isRequiredByAgent: true, name: 'resourcemanager_heapsize', value: '4'},
  1599. {isRequiredByAgent: true, name: 'apptimelineserver_heapsize', value: '5'},
  1600. {isRequiredByAgent: true, name: 'jobhistory_heapsize', value: '6'}
  1601. ];
  1602. installerStep8Controller.reopen({globals: globals, selectedServices: [{serviceName: ''}]});
  1603. var globalSiteObj = installerStep8Controller.createGlobalSiteObj();
  1604. expect(globalSiteObj.type).to.equal('global');
  1605. expect(globalSiteObj.tag).to.equal('version1');
  1606. globals.forEach(function(global) {
  1607. expect(globalSiteObj.properties[global.name]).to.equal(global.value);
  1608. });
  1609. });
  1610. });
  1611. describe('#applyInstalledServicesConfigurationGroup', function() {
  1612. beforeEach(function() {
  1613. sinon.stub($, 'ajax', Em.K);
  1614. sinon.stub(App.router, 'get', function() {
  1615. return configurationController;
  1616. });
  1617. });
  1618. afterEach(function() {
  1619. $.ajax.restore();
  1620. App.router.get.restore();
  1621. });
  1622. it('should do ajax request for each config group', function() {
  1623. var configGroups = [{ConfigGroup: {id:''}}, {ConfigGroup: {id:''}}];
  1624. installerStep8Controller.applyInstalledServicesConfigurationGroup(configGroups);
  1625. expect($.ajax.callCount).to.equal(configGroups.length);
  1626. });
  1627. });
  1628. describe('#getExistingClusterNames', function() {
  1629. beforeEach(function() {
  1630. sinon.stub(App.ajax, 'send', Em.K);
  1631. });
  1632. afterEach(function() {
  1633. App.ajax.send.restore();
  1634. });
  1635. it('should do ajax request', function() {
  1636. installerStep8Controller.getExistingClusterNames();
  1637. expect(App.ajax.send.calledOnce).to.be.true;
  1638. });
  1639. });
  1640. describe('#loadConfigs', function() {
  1641. beforeEach(function() {
  1642. sinon.stub(installerStep8Controller, 'loadUiSideConfigs', function(k) {return k});
  1643. sinon.stub(App.config, 'excludeUnsupportedConfigs', function(k) {return k;});
  1644. });
  1645. afterEach(function() {
  1646. installerStep8Controller.loadUiSideConfigs.restore();
  1647. App.config.excludeUnsupportedConfigs.restore();
  1648. });
  1649. it('should save configs', function() {
  1650. var serviceConfigProperties = [
  1651. {id: 'site property', value: true, isCanBeEmpty: true},
  1652. {id: 'site property', value: 1, isCanBeEmpty: true},
  1653. {id: 'site property', value: '1', isCanBeEmpty: true},
  1654. {id: 'site property', value: null, isCanBeEmpty: false}
  1655. ];
  1656. installerStep8Controller.reopen({content: {services: [], serviceConfigProperties: serviceConfigProperties}, configMapping: []});
  1657. installerStep8Controller.loadConfigs();
  1658. var configs = installerStep8Controller.get('configs');
  1659. expect(configs.mapProperty('value')).to.eql(['true', 1, '1']);
  1660. });
  1661. });
  1662. describe('#loadUiSideConfigs', function() {
  1663. beforeEach(function() {
  1664. sinon.stub(installerStep8Controller, 'addDynamicProperties', Em.K);
  1665. sinon.stub(installerStep8Controller, 'getGlobConfigValueWithOverrides', function(t, v, n) {
  1666. return {
  1667. value: v,
  1668. overrides: []
  1669. }
  1670. });
  1671. sinon.stub(App.config, 'setConfigValue', Em.K);
  1672. });
  1673. afterEach(function() {
  1674. installerStep8Controller.addDynamicProperties.restore();
  1675. installerStep8Controller.getGlobConfigValueWithOverrides.restore();
  1676. App.config.setConfigValue.restore();
  1677. });
  1678. it('all configs witohut foreignKey', function() {
  1679. var configMapping = [
  1680. {foreignKey: null, templateName: 't1', value: 'v1', name: 'c1', filename: 'f1'},
  1681. {foreignKey: null, templateName: 't2', value: 'v2', name: 'c2', filename: 'f2'},
  1682. {foreignKey: null, templateName: 't3', value: 'v3', name: 'c3', filename: 'f2'},
  1683. {foreignKey: null, templateName: 't4', value: 'v4', name: 'c4', filename: 'f1'}
  1684. ];
  1685. var uiConfigs = installerStep8Controller.loadUiSideConfigs(configMapping);
  1686. expect(uiConfigs.length).to.equal(configMapping.length);
  1687. expect(uiConfigs.everyProperty('id', 'site property')).to.be.true;
  1688. uiConfigs.forEach(function(c, index) {
  1689. expect(c.overrides).to.be.an.array;
  1690. expect(c.value).to.equal(configMapping[index].value);
  1691. expect(c.name).to.equal(configMapping[index].name);
  1692. expect(c.filename).to.equal(configMapping[index].filename);
  1693. });
  1694. });
  1695. it('some configs witohut foreignKey', function() {
  1696. var configMapping = [
  1697. {foreignKey: null, templateName: 't1', value: 'v1', name: 'c1', filename: 'f1'},
  1698. {foreignKey: null, templateName: 't2', value: 'v2', name: 'c2', filename: 'f2'},
  1699. {foreignKey: null, templateName: 't3', value: 'v3', name: 'c3', filename: 'f2'},
  1700. {foreignKey: null, templateName: 't4', value: 'v4', name: 'c4', filename: 'f1'},
  1701. {foreignKey: 'fk1', templateName: 't5', value: 'v5', name: 'c5', filename: 'f1'},
  1702. {foreignKey: 'fk2', templateName: 't6', value: 'v6', name: 'c6', filename: 'f1'},
  1703. {foreignKey: 'fk3', templateName: 't7', value: 'v7', name: 'c7', filename: 'f2'},
  1704. {foreignKey: 'fk4', templateName: 't8', value: 'v8', name: 'c8', filename: 'f2'}
  1705. ];
  1706. var uiConfigs = installerStep8Controller.loadUiSideConfigs(configMapping);
  1707. expect(uiConfigs.length).to.equal(configMapping.length);
  1708. expect(uiConfigs.everyProperty('id', 'site property')).to.be.true;
  1709. uiConfigs.forEach(function(c, index) {
  1710. if (Em.isNone(configMapping[index].foreignKey))
  1711. expect(c.overrides).to.be.an.array;
  1712. expect(c.value).to.equal(configMapping[index].value);
  1713. expect(c.name).to.equal(configMapping[index].name);
  1714. expect(c.filename).to.equal(configMapping[index].filename);
  1715. });
  1716. });
  1717. });
  1718. describe('#getGlobConfigValueWithOverrides', function() {
  1719. it('shouldn\t do nothing', function() {
  1720. var r = installerStep8Controller.getGlobConfigValueWithOverrides('', 'without tags', '');
  1721. expect(r).to.eql({value: 'without tags', overrides: []});
  1722. });
  1723. it('should return value with empty overrides', function() {
  1724. installerStep8Controller.set('globals', [
  1725. {name: 'c1', value: 'v1', overrides: []}
  1726. ]);
  1727. var r = installerStep8Controller.getGlobConfigValueWithOverrides(['c1'], '<templateName[0]>', '');
  1728. expect(r).to.eql({value: 'v1', overrides: []});
  1729. });
  1730. it('should return value with not empty overrides', function() {
  1731. installerStep8Controller.set('globals', [
  1732. {name: 'c1', value: 'v1', overrides: [{value: 'v2', hosts: ['h2']}]}
  1733. ]);
  1734. var r = installerStep8Controller.getGlobConfigValueWithOverrides(['c1'], '<templateName[0]>', '');
  1735. expect(r).to.eql({value: 'v1', overrides: [{value: 'v2', hosts: ['h2']}]});
  1736. });
  1737. });
  1738. describe('Queued requests', function() {
  1739. beforeEach(function() {
  1740. sinon.stub(installerStep8Controller, 'addRequestToAjaxQueue', Em.K);
  1741. });
  1742. afterEach(function() {
  1743. installerStep8Controller.addRequestToAjaxQueue.restore();
  1744. });
  1745. describe('#createCluster', function() {
  1746. it('shouldn\'t add request to queue if not installerController used', function() {
  1747. installerStep8Controller.reopen({content: {controllerName: 'addServiceController'}});
  1748. installerStep8Controller.createCluster();
  1749. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1750. });
  1751. it('App.currentStackVersion should be changed if localRepo selected', function() {
  1752. App.set('currentStackVersion', 'HDP-1.1.1');
  1753. installerStep8Controller.reopen({content: {controllerName: 'installerController', installOptions: {localRepo: true}}});
  1754. var data = {
  1755. data: JSON.stringify({ "Clusters": {"version": 'HDPLocal-1.1.1' }})
  1756. };
  1757. installerStep8Controller.createCluster();
  1758. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data).to.eql(data);
  1759. });
  1760. it('App.currentStackVersion shouldn\'t be changed if localRepo ins\'t selected', function() {
  1761. App.set('currentStackVersion', 'HDP-1.1.1');
  1762. installerStep8Controller.reopen({content: {controllerName: 'installerController', installOptions: {localRepo: false}}});
  1763. var data = {
  1764. data: JSON.stringify({ "Clusters": {"version": 'HDP-1.1.1' }})
  1765. };
  1766. installerStep8Controller.createCluster();
  1767. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data).to.eql(data);
  1768. });
  1769. });
  1770. describe('#createSelectedServices', function() {
  1771. it('shouldn\'t do nothing if no data', function() {
  1772. sinon.stub(installerStep8Controller, 'createSelectedServicesData', function() {return [];});
  1773. installerStep8Controller.createSelectedServices();
  1774. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1775. installerStep8Controller.createSelectedServicesData.restore();
  1776. });
  1777. it('should call addRequestToAjaxQueue with computed data', function() {
  1778. var data = [
  1779. {"ServiceInfo": { "service_name": 's1' }},
  1780. {"ServiceInfo": { "service_name": 's2' }},
  1781. {"ServiceInfo": { "service_name": 's3' }}
  1782. ];
  1783. sinon.stub(installerStep8Controller, 'createSelectedServicesData', function() {return data;});
  1784. installerStep8Controller.createSelectedServices();
  1785. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data).to.eql({data: JSON.stringify(data)});
  1786. installerStep8Controller.createSelectedServicesData.restore();
  1787. });
  1788. });
  1789. describe('#registerHostsToCluster', function() {
  1790. it('shouldn\'t do nothing if no data', function() {
  1791. sinon.stub(installerStep8Controller, 'createRegisterHostData', function() {return [];});
  1792. installerStep8Controller.registerHostsToCluster();
  1793. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1794. installerStep8Controller.createRegisterHostData.restore();
  1795. });
  1796. it('should call addRequestToAjaxQueue with computed data', function() {
  1797. var data = [
  1798. {"Hosts": { "host_name": 'h1'}},
  1799. {"Hosts": { "host_name": 'h3'}}
  1800. ];
  1801. sinon.stub(installerStep8Controller, 'createRegisterHostData', function() {return data;});
  1802. installerStep8Controller.registerHostsToCluster();
  1803. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data).to.eql({data: JSON.stringify(data)});
  1804. installerStep8Controller.createRegisterHostData.restore();
  1805. });
  1806. });
  1807. describe('#registerHostsToComponent', function() {
  1808. it('shouldn\'t do request if no hosts provided', function() {
  1809. installerStep8Controller.registerHostsToComponent([]);
  1810. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1811. });
  1812. it('should do request if hostNames are provided', function() {
  1813. var hostNames = ['h1', 'h2'],
  1814. componentName = 'c1';
  1815. installerStep8Controller.registerHostsToComponent(hostNames, componentName);
  1816. var data = JSON.parse(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data);
  1817. expect(data.RequestInfo.query).to.equal('Hosts/host_name=h1|Hosts/host_name=h2');
  1818. expect(data.Body.host_components[0].HostRoles.component_name).to.equal('c1');
  1819. });
  1820. });
  1821. describe('#applyConfigurationsToCluster', function() {
  1822. it('should call addRequestToAjaxQueue', function() {
  1823. var serviceConfigTags = [
  1824. {
  1825. type: 'type1',
  1826. tag: 'tag1',
  1827. properties: [
  1828. {},
  1829. {}
  1830. ]
  1831. }
  1832. ],
  1833. data = '['+JSON.stringify({
  1834. Clusters: {
  1835. desired_config: {
  1836. type: serviceConfigTags[0].type,
  1837. tag: serviceConfigTags[0].tag,
  1838. properties: serviceConfigTags[0].properties
  1839. }
  1840. }
  1841. })+']';
  1842. installerStep8Controller.reopen({serviceConfigTags: serviceConfigTags});
  1843. installerStep8Controller.applyConfigurationsToCluster();
  1844. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data).to.eql({data: data});
  1845. });
  1846. });
  1847. describe('#applyConfigurationGroups', function() {
  1848. it('should call addRequestToAjaxQueue', function() {
  1849. var data = [{}, {}];
  1850. installerStep8Controller.applyConfigurationGroups(data);
  1851. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data).to.eql({data: JSON.stringify(data)});
  1852. });
  1853. });
  1854. describe('#newServiceComponentErrorCallback', function() {
  1855. it('should add request for new component', function() {
  1856. var serviceName = 's1',
  1857. componentName = 'c1';
  1858. installerStep8Controller.newServiceComponentErrorCallback({}, {}, '', {}, {serviceName: serviceName, componentName: componentName});
  1859. var data = JSON.parse(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data);
  1860. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.serviceName).to.equal(serviceName);
  1861. expect(data.components[0].ServiceComponentInfo.component_name).to.equal(componentName);
  1862. });
  1863. });
  1864. describe('#createComponents', function() {
  1865. beforeEach(function() {
  1866. installerStep8Controller.reopen({
  1867. selectedServices: [
  1868. Em.Object.create({serviceName: 's1'}),
  1869. Em.Object.create({serviceName: 's2'})
  1870. ]
  1871. });
  1872. sinon.stub(App.StackServiceComponent, 'find', function() {
  1873. return Em.A([
  1874. Em.Object.create({serviceName: 's1', componentName: 'c1'}),
  1875. Em.Object.create({serviceName: 's1', componentName: 'c2'}),
  1876. Em.Object.create({serviceName: 's2', componentName: 'c3'}),
  1877. Em.Object.create({serviceName: 's2', componentName: 'c4'})
  1878. ]);
  1879. });
  1880. });
  1881. afterEach(function() {
  1882. App.StackServiceComponent.find.restore();
  1883. });
  1884. it('should do two requests', function() {
  1885. installerStep8Controller.createComponents();
  1886. expect(installerStep8Controller.addRequestToAjaxQueue.calledTwice).to.be.true;
  1887. var firstRequestData = JSON.parse(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data);
  1888. expect(firstRequestData.components.mapProperty('ServiceComponentInfo.component_name')).to.eql(['c1', 'c2']);
  1889. var secondRequestData = JSON.parse(installerStep8Controller.addRequestToAjaxQueue.args[1][0].data.data);
  1890. expect(secondRequestData.components.mapProperty('ServiceComponentInfo.component_name')).to.eql(['c3', 'c4']);
  1891. });
  1892. it('should check App_TIMELINE_SERVER', function() {
  1893. sinon.stub(App, 'get', function(k) {
  1894. if ('isHadoop21Stack' === k) return true;
  1895. if ('testMode' === k) return false;
  1896. return Em.get(App, k);
  1897. });
  1898. sinon.stub(App.YARNService, 'find', function() {return [{}]});
  1899. sinon.stub(App.ajax, 'send', Em.K);
  1900. installerStep8Controller.set('content', {controllerName: 'addServiceController'});
  1901. installerStep8Controller.createComponents();
  1902. expect(App.ajax.send.calledOnce).to.equal(true);
  1903. expect(App.ajax.send.args[0][0].data.serviceName).to.equal('YARN');
  1904. expect(App.ajax.send.args[0][0].data.componentName).to.equal('APP_TIMELINE_SERVER');
  1905. App.ajax.send.restore();
  1906. App.get.restore();
  1907. App.YARNService.find.restore();
  1908. });
  1909. });
  1910. describe('#setLocalRepositories', function() {
  1911. it('shouldn\'t do nothing', function () {
  1912. installerStep8Controller.set('content', {controllerName: 'addServiceController'});
  1913. sinon.stub(App, 'get', function (k) {
  1914. if ('supports.localRepositories' === k) return false;
  1915. return Em.get(App, k);
  1916. });
  1917. expect(installerStep8Controller.setLocalRepositories()).to.equal(false);
  1918. App.get.restore();
  1919. });
  1920. it('shouldn\'t do requests', function() {
  1921. installerStep8Controller.set('content', {
  1922. controllerName: 'installerController',
  1923. stacks: [
  1924. {
  1925. isSelected: true,
  1926. operatingSystems: [
  1927. {baseUrl: 'u1', originalBaseUrl: 'u1'},
  1928. {baseUrl: 'u2', originalBaseUrl: 'u2'}
  1929. ]
  1930. }
  1931. ]
  1932. });
  1933. installerStep8Controller.setLocalRepositories();
  1934. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1935. });
  1936. it('should do 2 requests', function() {
  1937. installerStep8Controller.set('content', {
  1938. controllerName: 'installerController',
  1939. stacks: [
  1940. {
  1941. isSelected: true,
  1942. operatingSystems: [
  1943. {baseUrl: 'new_u1', originalBaseUrl: 'u1', osType: 'o1', repoId: 'r1'},
  1944. {baseUrl: 'new_u2', originalBaseUrl: 'u2', osType: 'o2', repoId: 'r2'}
  1945. ]
  1946. }
  1947. ]
  1948. });
  1949. installerStep8Controller.setLocalRepositories();
  1950. expect(installerStep8Controller.addRequestToAjaxQueue.calledTwice).to.equal(true);
  1951. var firstRequestData = installerStep8Controller.addRequestToAjaxQueue.args[0][0].data;
  1952. expect(firstRequestData.osType).to.equal('o1');
  1953. expect(firstRequestData.repoId).to.equal('r1');
  1954. expect(JSON.parse(firstRequestData.data).Repositories.base_url).to.equal('new_u1');
  1955. var secondRequestData = installerStep8Controller.addRequestToAjaxQueue.args[1][0].data;
  1956. expect(secondRequestData.osType).to.equal('o2');
  1957. expect(secondRequestData.repoId).to.equal('r2');
  1958. expect(JSON.parse(secondRequestData.data).Repositories.base_url).to.equal('new_u2');
  1959. });
  1960. });
  1961. describe('#createMasterHostComponents', function() {
  1962. beforeEach(function() {
  1963. sinon.stub(installerStep8Controller, 'registerHostsToComponent', Em.K);
  1964. });
  1965. afterEach(function() {
  1966. installerStep8Controller.registerHostsToComponent.restore();
  1967. });
  1968. it('should create components', function() {
  1969. var masterComponentHosts = [
  1970. {component: 'c1', isInstalled: false, hostName: 'h1'},
  1971. {component: 'c1', isInstalled: true, hostName: 'h2'},
  1972. {component: 'c2', isInstalled: false, hostName: 'h1'},
  1973. {component: 'c2', isInstalled: false, hostName: 'h2'}
  1974. ];
  1975. installerStep8Controller.set('content', {masterComponentHosts: masterComponentHosts});
  1976. installerStep8Controller.createMasterHostComponents();
  1977. expect(installerStep8Controller.registerHostsToComponent.calledTwice).to.equal(true);
  1978. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1']);
  1979. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('c1');
  1980. expect(installerStep8Controller.registerHostsToComponent.args[1][0]).to.eql(['h1', 'h2']);
  1981. expect(installerStep8Controller.registerHostsToComponent.args[1][1]).to.equal('c2');
  1982. });
  1983. });
  1984. describe('#createAdditionalHostComponents', function() {
  1985. beforeEach(function() {
  1986. sinon.stub(installerStep8Controller, 'registerHostsToComponent', Em.K);
  1987. });
  1988. afterEach(function() {
  1989. installerStep8Controller.registerHostsToComponent.restore();
  1990. });
  1991. it('should add GANGLIA MONITOR (1)', function() {
  1992. installerStep8Controller.reopen({
  1993. getRegisteredHosts: function() {
  1994. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1995. },
  1996. content: {
  1997. services: [
  1998. Em.Object.create({serviceName: 'GANGLIA', isSelected: true, isInstalled: false})
  1999. ]
  2000. }
  2001. });
  2002. installerStep8Controller.createAdditionalHostComponents();
  2003. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  2004. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
  2005. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
  2006. });
  2007. it('should add GANGLIA MONITOR (2)', function() {
  2008. installerStep8Controller.reopen({
  2009. getRegisteredHosts: function() {
  2010. return [{hostName: 'h1', isInstalled: true}, {hostName: 'h2', isInstalled: false}];
  2011. },
  2012. content: {
  2013. services: [
  2014. Em.Object.create({serviceName: 'GANGLIA', isSelected: true, isInstalled: true})
  2015. ]
  2016. }
  2017. });
  2018. installerStep8Controller.createAdditionalHostComponents();
  2019. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  2020. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h2']);
  2021. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
  2022. });
  2023. it('should add MYSQL_SERVER', function() {
  2024. installerStep8Controller.reopen({
  2025. getRegisteredHosts: function() {
  2026. return [{hostName: 'h1'}, {hostName: 'h2'}];
  2027. },
  2028. content: {
  2029. masterComponentHosts: [
  2030. {component: 'HIVE_SERVER', hostName: 'h1'},
  2031. {component: 'HIVE_SERVER', hostName: 'h2'}
  2032. ],
  2033. services: [
  2034. Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false})
  2035. ],
  2036. serviceConfigProperties: [
  2037. {name: 'hive_database', value: 'New MySQL Database'}
  2038. ]
  2039. }
  2040. });
  2041. installerStep8Controller.createAdditionalHostComponents();
  2042. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  2043. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
  2044. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('MYSQL_SERVER');
  2045. });
  2046. });
  2047. describe('#createSlaveAndClientsHostComponents', function() {
  2048. beforeEach(function() {
  2049. sinon.stub(installerStep8Controller, 'registerHostsToComponent', Em.K);
  2050. });
  2051. afterEach(function() {
  2052. installerStep8Controller.registerHostsToComponent.restore();
  2053. });
  2054. it('each slave is not CLIENT', function() {
  2055. installerStep8Controller.reopen({
  2056. content: {
  2057. slaveComponentHosts: [
  2058. {componentName: 'c1', hosts: [{isInstalled: true, hostName: 'h1'}, {isInstalled: false, hostName: 'h2'}, {isInstalled: false, hostName: 'h3'}]}
  2059. ]
  2060. }
  2061. });
  2062. installerStep8Controller.createSlaveAndClientsHostComponents();
  2063. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.be.true;
  2064. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h2', 'h3']);
  2065. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('c1');
  2066. });
  2067. var clients = Em.A([
  2068. {
  2069. component_name: 'HDFS_CLIENT',
  2070. masterComponentHosts: [
  2071. {component: 'HBASE_MASTER', isInstalled: false, hostName: 'h1'},
  2072. {component: 'HBASE_MASTER', isInstalled: true, hostName: 'h2'},
  2073. {component: 'HBASE_REGIONSERVER', isInstalled: false, hostName: 'h3'},
  2074. {component: 'WEBHCAT_SERVER', isInstalled: false, hostName: 'h1'},
  2075. {component: 'HISTORYSERVER', isInstalled: false, hostName: 'h3'},
  2076. {component: 'OOZIE_SERVER', isInstalled: true, hostName: 'h4'}
  2077. ],
  2078. e: ['h1', 'h3']
  2079. },
  2080. {
  2081. component_name: 'MAPREDUCE_CLIENT',
  2082. masterComponentHosts: [
  2083. {component: 'HIVE_SERVER', isInstalled: false, hostName: 'h1'},
  2084. {component: 'WEBHCAT_SERVER', isInstalled: false, hostName: 'h1'},
  2085. {component: 'NAGIOS_SERVER', isInstalled: false, hostName: 'h2'},
  2086. {component: 'OOZIE_SERVER', isInstalled: true, hostName: 'h3'}
  2087. ],
  2088. e: ['h1', 'h2']
  2089. },
  2090. {
  2091. component_name: 'OOZIE_CLIENT',
  2092. masterComponentHosts: [
  2093. {component: 'NAGIOS_SERVER', isInstalled: false, hostName: 'h2'}
  2094. ],
  2095. e: ['h2']
  2096. },
  2097. {
  2098. component_name: 'ZOOKEEPER_CLIENT',
  2099. masterComponentHosts: [
  2100. {component: 'WEBHCAT_SERVER', isInstalled: false, hostName: 'h1'}
  2101. ],
  2102. e: ['h1']
  2103. },
  2104. {
  2105. component_name: 'HIVE_CLIENT',
  2106. masterComponentHosts: [
  2107. {component: 'WEBHCAT_SERVER', isInstalled: false, hostName: 'h1'},
  2108. {component: 'HIVE_SERVER', isInstalled: false, hostName: 'h1'}
  2109. ],
  2110. e: ['h1']
  2111. },
  2112. {
  2113. component_name: 'HCAT',
  2114. masterComponentHosts: [
  2115. {component: 'NAGIOS_SERVER', isInstalled: false, hostName: 'h1'}
  2116. ],
  2117. e: ['h1']
  2118. },
  2119. {
  2120. component_name: 'YARN_CLIENT',
  2121. masterComponentHosts: [
  2122. {component: 'NAGIOS_SERVER', isInstalled: false, hostName: 'h1'},
  2123. {component: 'HIVE_SERVER', isInstalled: false, hostName: 'h2'},
  2124. {component: 'OOZIE_SERVER', isInstalled: false, hostName: 'h3'},
  2125. {component: 'WEBHCAT_SERVER', isInstalled: true, hostName: 'h1'}
  2126. ],
  2127. e: ['h1', 'h2', 'h3']
  2128. },
  2129. {
  2130. component_name: 'TEZ_CLIENT',
  2131. masterComponentHosts: [
  2132. {component: 'NAGIOS_SERVER', isInstalled: false, hostName: 'h1'},
  2133. {component: 'HIVE_SERVER', isInstalled: false, hostName: 'h2'}
  2134. ],
  2135. e: ['h1', 'h2']
  2136. }
  2137. ]);
  2138. clients.forEach(function(test) {
  2139. it('slave is CLIENT (isInstalled false) ' + test.component_name, function() {
  2140. installerStep8Controller.reopen({
  2141. content: {
  2142. clients: [
  2143. {isInstalled: false, component_name: test.component_name}
  2144. ],
  2145. slaveComponentHosts: [
  2146. {componentName: 'CLIENT', hosts: []}
  2147. ],
  2148. masterComponentHosts: test.masterComponentHosts
  2149. }
  2150. });
  2151. installerStep8Controller.createSlaveAndClientsHostComponents();
  2152. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.be.true;
  2153. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(test.e);
  2154. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal(test.component_name);
  2155. });
  2156. });
  2157. clients.forEach(function(test) {
  2158. it('slave is CLIENT (isInstalled true, h1 - host to be excluded) ' + test.component_name, function() {
  2159. sinon.stub(App.HostComponent, 'find', function() {
  2160. return [
  2161. {componentName: test.component_name, workStatus: 'INSTALLED', host: {hostName: 'h1'}}
  2162. ];
  2163. });
  2164. installerStep8Controller.reopen({
  2165. content: {
  2166. clients: [
  2167. {isInstalled: true, component_name: test.component_name}
  2168. ],
  2169. slaveComponentHosts: [
  2170. {componentName: 'CLIENT', hosts: []}
  2171. ],
  2172. masterComponentHosts: test.masterComponentHosts
  2173. }
  2174. });
  2175. installerStep8Controller.createSlaveAndClientsHostComponents();
  2176. App.HostComponent.find.restore();
  2177. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.be.true;
  2178. // Don't know why, but
  2179. // expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(test.e.without('h1'));
  2180. // doesn't work
  2181. expect(JSON.stringify(installerStep8Controller.registerHostsToComponent.args[0][0])).to.equal(JSON.stringify(test.e.without('h1')));
  2182. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal(test.component_name);
  2183. });
  2184. });
  2185. });
  2186. });
  2187. });