step8_test.js 99 KB

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