step8_test.js 91 KB

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