step8_test.js 86 KB

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