step8_test.js 85 KB

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