step8_test.js 94 KB

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