step8_test.js 85 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. require('utils/ajax/ajax_queue');
  20. require('controllers/main/service/info/configs');
  21. require('controllers/wizard/step8_controller');
  22. var installerStep8Controller, configurationController;
  23. var testHelpers = require('test/helpers');
  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. hosts: Em.A([
  475. Em.Object.create({hostName: 'h1', isInstalled: true}),
  476. Em.Object.create({hostName: 'h2', isInstalled: false})
  477. ])
  478. });
  479. installerStep8Controller.set('content', content);
  480. installerStep8Controller.set('services', Em.A([]));
  481. installerStep8Controller.reopen({selectedServices: selectedServices});
  482. installerStep8Controller.loadServices();
  483. });
  484. it('should load services', function () {
  485. var expected = [
  486. {
  487. "service_name": "s1",
  488. "display_name": "s01",
  489. "service_components": []
  490. },
  491. {
  492. "service_name": "s2",
  493. "display_name": "s02",
  494. "service_components": []
  495. },
  496. {
  497. "service_name": "s3",
  498. "display_name": "s03",
  499. "service_components": []
  500. },
  501. {
  502. "service_name": "s4",
  503. "display_name": "s03",
  504. "service_components": [
  505. {
  506. "component_name": "CLIENT",
  507. "display_name": "Clients",
  508. "component_value": "2 hosts"
  509. }
  510. ]
  511. }
  512. ];
  513. var result = JSON.parse(JSON.stringify(installerStep8Controller.get('services')));
  514. expect(result).to.be.eql(expected);
  515. });
  516. });
  517. describe('#removeClientsFromList', function () {
  518. beforeEach(function () {
  519. installerStep8Controller.set('content', Em.Object.create({
  520. hosts: Em.Object.create({
  521. h1: Em.Object.create({
  522. hostName: 'h1',
  523. isInstalled: true,
  524. hostComponents: Em.A([Em.Object.create({HostRoles: Em.Object.create({component_name: "h1"})})])
  525. }),
  526. h2: Em.Object.create({
  527. hostName: 'h2',
  528. isInstalled: true,
  529. hostComponents: Em.A([Em.Object.create({HostRoles: Em.Object.create({component_name: "h2"})})])
  530. })
  531. })
  532. }));
  533. });
  534. it('should remove h1', function () {
  535. var hostList = Em.A(['h1','h2']);
  536. installerStep8Controller.removeClientsFromList('h1', hostList);
  537. expect(JSON.parse(JSON.stringify(hostList))).to.eql(["h2"]);
  538. });
  539. });
  540. describe('#createSlaveAndClientsHostComponents', function () {
  541. beforeEach(function () {
  542. installerStep8Controller.set('content', Em.Object.create({
  543. masterComponentHosts: Em.A([
  544. Em.Object.create({
  545. componentName: 'CLIENT',
  546. component: 'HBASE_MASTER',
  547. hostName: 'h1'
  548. })
  549. ]),
  550. slaveComponentHosts: Em.A([
  551. Em.Object.create({
  552. componentName: 'CLIENT',
  553. hostName: 'h1',
  554. hosts: Em.A([
  555. Em.Object.create({hostName: 'h1', isInstalled: true}),
  556. Em.Object.create({hostName: 'h2', isInstalled: false})
  557. ])
  558. }),
  559. Em.Object.create({
  560. componentName: 'CLIENT1',
  561. hostName: 'h1',
  562. hosts: Em.A([
  563. Em.Object.create({hostName: 'h1', isInstalled: true}),
  564. Em.Object.create({hostName: 'h2', isInstalled: false})
  565. ])
  566. })
  567. ]),
  568. clients: Em.A([
  569. Em.Object.create({
  570. isInstalled: false
  571. })
  572. ]),
  573. services: Em.A([
  574. Em.Object.create({
  575. isInstalled: true,
  576. serviceName: "name",
  577. isClient: true
  578. })
  579. ]),
  580. hosts: Em.Object.create({
  581. h1: Em.Object.create({
  582. hostName: 'h1',
  583. isInstalled: true,
  584. hostComponents: Em.A([Em.Object.create({})])
  585. }),
  586. h2: Em.Object.create({
  587. hostName: 'h2',
  588. isInstalled: false,
  589. hostComponents: Em.A([Em.Object.create({})])
  590. })
  591. }),
  592. additionalClients: Em.A([{hostNames: "name", componentName: "client"}])
  593. }));
  594. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  595. installerStep8Controller.get('ajaxRequestsQueue').clear();
  596. });
  597. it('should return non install object', function () {
  598. installerStep8Controller.createSlaveAndClientsHostComponents();
  599. expect(installerStep8Controller.get('content.clients')[0].isInstalled).to.be.false;
  600. });
  601. });
  602. describe('#createAdditionalClientComponents', function () {
  603. beforeEach(function () {
  604. installerStep8Controller.set('content', Em.Object.create({
  605. masterComponentHosts: Em.A([
  606. Em.Object.create({
  607. componentName: 'CLIENT',
  608. component: 'HBASE_MASTER',
  609. hostName: 'h1'
  610. })
  611. ]),
  612. slaveComponentHosts: Em.A([
  613. Em.Object.create({
  614. componentName: 'CLIENT',
  615. hostName: 'h1',
  616. hosts: Em.A([
  617. Em.Object.create({hostName: 'h1', isInstalled: true}),
  618. Em.Object.create({hostName: 'h2', isInstalled: false})
  619. ])
  620. })
  621. ]),
  622. clients: Em.A([
  623. Em.Object.create({
  624. isInstalled: false
  625. })
  626. ]),
  627. services: Em.A([
  628. Em.Object.create({
  629. isInstalled: true,
  630. serviceName: "name",
  631. isClient: true
  632. })
  633. ]),
  634. hosts: Em.Object.create({
  635. h1: Em.Object.create({
  636. hostName: 'h1',
  637. isInstalled: true,
  638. hostComponents: Em.A([Em.Object.create({})])
  639. }),
  640. h2: Em.Object.create({
  641. hostName: 'h2',
  642. isInstalled: false,
  643. hostComponents: Em.A([Em.Object.create({})])
  644. })
  645. }),
  646. additionalClients: Em.A([{hostNames: "name", componentName: "client"}])
  647. }));
  648. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  649. installerStep8Controller.get('ajaxRequestsQueue').clear();
  650. installerStep8Controller.createAdditionalClientComponents();
  651. });
  652. it('should bes equal to content.cluster.name', function () {
  653. var result = [
  654. {
  655. "hostNames": "name",
  656. "componentName": "client"
  657. }
  658. ];
  659. var expected = installerStep8Controller.get('content.additionalClients');
  660. expect(JSON.parse(JSON.stringify(expected))).to.eql(result);
  661. });
  662. });
  663. describe('#assignComponentHosts', function () {
  664. it('should return host name', function () {
  665. var component = Em.Object.create({
  666. isMaster: true,
  667. componentName: 'HBASE_MASTER',
  668. hostName: 'h1'
  669. });
  670. installerStep8Controller.set('content', Em.Object.create({
  671. masterComponentHosts:Em.A([
  672. Em.Object.create({component: 'HBASE_MASTER', hostName: 'h1'})
  673. ])}));
  674. var res = installerStep8Controller.assignComponentHosts(component);
  675. expect(res).to.equal("h1");
  676. });
  677. it('should return number of hosts', function () {
  678. var component = Em.Object.create({
  679. componentName: 'HBASE_MASTER',
  680. isClient: false,
  681. hostName: 'h1'
  682. });
  683. installerStep8Controller.set('content', Em.Object.create({
  684. slaveComponentHosts:Em.A([
  685. Em.Object.create({
  686. componentName: 'HBASE_MASTER',
  687. hostName: 'h1',
  688. hosts: [
  689. {hostName: 'h1'},
  690. {hostName: 'h2'}
  691. ]
  692. })
  693. ])}));
  694. var res = installerStep8Controller.assignComponentHosts(component);
  695. expect(res).to.equal("2 hosts");
  696. });
  697. });
  698. describe('#loadClusterInfo', function () {
  699. beforeEach(function () {
  700. sinon.stub(App.Stack, 'find', function(){
  701. return Em.A([
  702. Em.Object.create({isSelected: false, hostName: 'h1'}),
  703. Em.Object.create({
  704. isSelected: true,
  705. hostName: 'h2',
  706. operatingSystems: Em.A([Em.Object.create({
  707. name:'windows',
  708. isSelected: true,
  709. repositories: Em.A([Em.Object.create({
  710. baseUrl: "url",
  711. osType: "2",
  712. repoId: "3"
  713. })])
  714. })])
  715. }),
  716. Em.Object.create({isSelected: false, hostName: 'h3'})
  717. ]);
  718. });
  719. });
  720. afterEach(function () {
  721. App.Stack.find.restore();
  722. });
  723. it('should return config with display_name', function () {
  724. installerStep8Controller.set('clusterInfo', Em.A([]));
  725. installerStep8Controller.loadClusterInfo();
  726. var res = [{
  727. "config_name":"cluster",
  728. "display_name":"Cluster Name"
  729. },{
  730. "config_name":"hosts",
  731. "display_name":"Total Hosts",
  732. "config_value":"0 (0 new)"
  733. }];
  734. var calcRes = JSON.parse(JSON.stringify(installerStep8Controller.get('clusterInfo')));
  735. expect(calcRes).to.eql(res);
  736. });
  737. });
  738. describe('#loadStep', function () {
  739. beforeEach(function () {
  740. sinon.stub(installerStep8Controller, 'clearStep', Em.K);
  741. sinon.stub(installerStep8Controller, 'formatProperties', Em.K);
  742. sinon.stub(installerStep8Controller, 'loadConfigs', Em.K);
  743. sinon.stub(installerStep8Controller, 'loadClusterInfo', Em.K);
  744. sinon.stub(installerStep8Controller, 'loadServices', Em.K);
  745. installerStep8Controller.set('content', {controllerName: 'installerController'});
  746. });
  747. afterEach(function () {
  748. installerStep8Controller.clearStep.restore();
  749. installerStep8Controller.formatProperties.restore();
  750. installerStep8Controller.loadConfigs.restore();
  751. installerStep8Controller.loadClusterInfo.restore();
  752. installerStep8Controller.loadServices.restore();
  753. });
  754. it('should call clearStep', function () {
  755. installerStep8Controller.loadStep();
  756. expect(installerStep8Controller.clearStep.calledOnce).to.equal(true);
  757. });
  758. it('should call loadClusterInfo', function () {
  759. installerStep8Controller.loadStep();
  760. expect(installerStep8Controller.loadClusterInfo.calledOnce).to.equal(true);
  761. });
  762. it('should call loadServices', function () {
  763. installerStep8Controller.loadStep();
  764. expect(installerStep8Controller.loadServices.calledOnce).to.equal(true);
  765. });
  766. it('should call formatProperties if content.serviceConfigProperties is true', function () {
  767. installerStep8Controller.set('content.serviceConfigProperties', true);
  768. installerStep8Controller.loadStep();
  769. expect(installerStep8Controller.loadServices.calledOnce).to.equal(true);
  770. });
  771. it('should call loadConfigs if content.serviceConfigProperties is true', function () {
  772. installerStep8Controller.set('content.serviceConfigProperties', true);
  773. installerStep8Controller.loadStep();
  774. expect(installerStep8Controller.loadConfigs.calledOnce).to.equal(true);
  775. });
  776. it('should set isSubmitDisabled to false', function () {
  777. installerStep8Controller.loadStep();
  778. expect(installerStep8Controller.get('isSubmitDisabled')).to.equal(false);
  779. });
  780. it('should set isBackBtnDisabled to false', function () {
  781. installerStep8Controller.loadStep();
  782. expect(installerStep8Controller.get('isBackBtnDisabled')).to.equal(false);
  783. });
  784. });
  785. describe('#getRegisteredHosts', function() {
  786. Em.A([
  787. {
  788. hosts: {},
  789. m: 'no content.hosts',
  790. e: []
  791. },
  792. {
  793. hosts: {
  794. h1:{bootStatus: ''},
  795. h2:{bootStatus: ''}
  796. },
  797. m: 'no registered hosts',
  798. e: []
  799. },
  800. {
  801. hosts: {
  802. h1:{bootStatus: 'REGISTERED', hostName: '', name: 'n1'},
  803. h2:{bootStatus: 'REGISTERED', hostName: '', name: 'n2'}
  804. },
  805. m: 'registered hosts available',
  806. e: ['n1', 'n2']
  807. }
  808. ]).forEach(function(test) {
  809. it(test.m, function() {
  810. installerStep8Controller.set('content', {hosts: test.hosts});
  811. var hosts = installerStep8Controller.getRegisteredHosts();
  812. expect(hosts.mapProperty('hostName')).to.eql(test.e);
  813. });
  814. });
  815. });
  816. describe('#loadRepoInfo', function() {
  817. beforeEach(function () {
  818. sinon.stub(App, 'get').withArgs('currentStackName').returns('HDP');
  819. sinon.stub(App.StackVersion, 'find', function() {
  820. return [
  821. Em.Object.create({state: 'CURRENT', repositoryVersion: {repositoryVersion: '2.3.0.0-2208'}})
  822. ];
  823. });
  824. });
  825. afterEach(function () {
  826. App.get.restore();
  827. App.StackVersion.find.restore();
  828. });
  829. it('should use current StackVersion', function() {
  830. installerStep8Controller.loadRepoInfo();
  831. var args = testHelpers.findAjaxRequest('name', 'cluster.load_repo_version');
  832. expect(args[0].data).to.eql({stackName: 'HDP', repositoryVersion: '2.3.0.0-2208'});
  833. });
  834. });
  835. describe('#loadRepoInfoSuccessCallback', function () {
  836. beforeEach(function () {
  837. installerStep8Controller.set('clusterInfo', Em.Object.create({}));
  838. });
  839. it('should assert error if no data returned from server', function () {
  840. expect(function () {
  841. installerStep8Controller.loadRepoInfoSuccessCallback({items: []});
  842. }).to.throw(Error);
  843. });
  844. Em.A([
  845. {
  846. m: 'Normal JSON',
  847. e: {
  848. base_url: ['baseurl1', 'baseurl2'],
  849. os_type: ['redhat6', 'suse11'],
  850. repo_id: ['HDP-2.3', 'HDP-UTILS-1.1.0.20']
  851. },
  852. items: [
  853. {
  854. repository_versions: [
  855. {
  856. operating_systems: [
  857. {
  858. repositories: [
  859. {
  860. Repositories: {
  861. base_url: 'baseurl1',
  862. os_type: 'redhat6',
  863. repo_id: 'HDP-2.3'
  864. }
  865. }
  866. ]
  867. },
  868. {
  869. repositories: [
  870. {
  871. Repositories: {
  872. base_url: 'baseurl2',
  873. os_type: 'suse11',
  874. repo_id: 'HDP-UTILS-1.1.0.20'
  875. }
  876. }
  877. ]
  878. }
  879. ]
  880. }
  881. ]
  882. }
  883. ]
  884. }
  885. ]).forEach(function (test) {
  886. it(test.m, function () {
  887. installerStep8Controller.loadRepoInfoSuccessCallback({items: test.items});
  888. expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('base_url')).to.eql(test.e.base_url);
  889. expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('os_type')).to.eql(test.e.os_type);
  890. expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('repo_id')).to.eql(test.e.repo_id);
  891. });
  892. });
  893. /*Em.A([
  894. {
  895. items: [
  896. {
  897. repositories: [
  898. {
  899. Repositories: {
  900. os_type: 'redhat5',
  901. base_url: 'url1'
  902. }
  903. }
  904. ],
  905. OperatingSystems: {
  906. is_type: ''
  907. }
  908. }
  909. ],
  910. m: 'only redhat5',
  911. e: {
  912. base_url: ['url1'],
  913. os_type: ['redhat5']
  914. }
  915. },
  916. {
  917. items: [
  918. {
  919. repositories: [
  920. {
  921. Repositories: {
  922. os_type: 'redhat5',
  923. base_url: 'url1'
  924. }
  925. }
  926. ],
  927. OperatingSystems: {
  928. is_type: ''
  929. }
  930. },
  931. {
  932. repositories: [
  933. {
  934. Repositories: {
  935. os_type: 'redhat6',
  936. base_url: 'url2'
  937. }
  938. }
  939. ],
  940. OperatingSystems: {
  941. is_type: ''
  942. }
  943. }
  944. ],
  945. m: 'redhat5, redhat6',
  946. e: {
  947. base_url: ['url1', 'url2'],
  948. os_type: ['redhat5', 'redhat6']
  949. }
  950. },
  951. {
  952. items: [
  953. {
  954. repositories: [
  955. {
  956. Repositories: {
  957. os_type: 'redhat5',
  958. base_url: 'url1'
  959. }
  960. }
  961. ],
  962. OperatingSystems: {
  963. is_type: ''
  964. }
  965. },
  966. {
  967. repositories: [
  968. {
  969. Repositories: {
  970. os_type: 'redhat6',
  971. base_url: 'url2'
  972. }
  973. }
  974. ],
  975. OperatingSystems: {
  976. is_type: ''
  977. }
  978. },
  979. {
  980. repositories: [
  981. {
  982. Repositories: {
  983. os_type: 'sles11',
  984. base_url: 'url3'
  985. }
  986. }
  987. ],
  988. OperatingSystems: {
  989. is_type: ''
  990. }
  991. }
  992. ],
  993. m: 'redhat5, redhat6, sles11',
  994. e: {
  995. base_url: ['url1', 'url2', 'url3'],
  996. os_type: ['redhat5', 'redhat6', 'sles11']
  997. }
  998. }
  999. ]).forEach(function (test) {
  1000. it(test.m, function () {
  1001. installerStep8Controller.loadRepoInfoSuccessCallback({items: test.items});
  1002. expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('base_url')).to.eql(test.e.base_url);
  1003. expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('os_type')).to.eql(test.e.os_type);
  1004. });
  1005. });*/
  1006. });
  1007. describe('#loadRepoInfoErrorCallback', function() {
  1008. it('should set [] to repoInfo', function() {
  1009. installerStep8Controller.set('clusterInfo', Em.Object.create({repoInfo: [{}, {}]}));
  1010. installerStep8Controller.loadRepoInfoErrorCallback({});
  1011. expect(installerStep8Controller.get('clusterInfo.repoInfo.length')).to.be.equal(0);
  1012. });
  1013. });
  1014. describe('#loadHbaseMasterValue', function () {
  1015. Em.A([
  1016. {
  1017. masterComponentHosts: [{component: 'HBASE_MASTER', hostName: 'h1'}],
  1018. component: Em.Object.create({component_name: 'HBASE_MASTER'}),
  1019. m: 'one host',
  1020. e: 'h1'
  1021. },
  1022. {
  1023. masterComponentHosts: [{component: 'HBASE_MASTER', hostName: 'h1'}, {component: 'HBASE_MASTER', hostName: 'h2'}, {component: 'HBASE_MASTER', hostName: 'h3'}],
  1024. component: Em.Object.create({component_name: 'HBASE_MASTER'}),
  1025. m: 'many hosts',
  1026. e: 'h1 ' + Em.I18n.t('installer.step8.other').format(2)
  1027. }
  1028. ]).forEach(function (test) {
  1029. it(test.m, function() {
  1030. installerStep8Controller.set('content', {masterComponentHosts: test.masterComponentHosts});
  1031. installerStep8Controller.loadHbaseMasterValue(test.component);
  1032. expect(test.component.component_value).to.equal(test.e);
  1033. });
  1034. });
  1035. });
  1036. describe('#loadZkServerValue', function() {
  1037. Em.A([
  1038. {
  1039. masterComponentHosts: [{component: 'ZOOKEEPER_SERVER'}],
  1040. component: Em.Object.create({component_name: 'ZOOKEEPER_SERVER'}),
  1041. m: '1 host',
  1042. e: '1 host'
  1043. },
  1044. {
  1045. masterComponentHosts: [{component: 'ZOOKEEPER_SERVER'},{component: 'ZOOKEEPER_SERVER'},{component: 'ZOOKEEPER_SERVER'}],
  1046. component: Em.Object.create({component_name: 'ZOOKEEPER_SERVER'}),
  1047. m: 'many hosts',
  1048. e: '3 hosts'
  1049. }
  1050. ]).forEach(function (test) {
  1051. it(test.m, function () {
  1052. installerStep8Controller.set('content', {masterComponentHosts: test.masterComponentHosts});
  1053. installerStep8Controller.loadZkServerValue(test.component);
  1054. expect(test.component.component_value).to.equal(test.e);
  1055. });
  1056. });
  1057. });
  1058. describe('#submit', function() {
  1059. beforeEach(function() {
  1060. sinon.stub(installerStep8Controller, 'submitProceed', Em.K);
  1061. sinon.stub(installerStep8Controller, 'showRestartWarnings').returns($.Deferred().resolve().promise());
  1062. sinon.stub(App.get('router.mainAdminKerberosController'), 'getKDCSessionState', Em.K);
  1063. });
  1064. afterEach(function() {
  1065. installerStep8Controller.submitProceed.restore();
  1066. installerStep8Controller.showRestartWarnings.restore();
  1067. App.set('isKerberosEnabled', false);
  1068. App.get('router.mainAdminKerberosController').getKDCSessionState.restore();
  1069. });
  1070. it('AddServiceController Kerberos enabled', function () {
  1071. installerStep8Controller.reopen({
  1072. isSubmitDisabled: false,
  1073. content: {controllerName: 'addServiceController'}
  1074. });
  1075. installerStep8Controller.submit();
  1076. expect(App.get('router.mainAdminKerberosController').getKDCSessionState.called).to.equal(true);
  1077. });
  1078. it('shouldn\'t do nothing if isSubmitDisabled is true', function() {
  1079. installerStep8Controller.reopen({isSubmitDisabled: true});
  1080. installerStep8Controller.submit();
  1081. expect(App.get('router.mainAdminKerberosController').getKDCSessionState.called).to.equal(false);
  1082. expect(installerStep8Controller.submitProceed.called).to.equal(false);
  1083. });
  1084. });
  1085. describe('#getExistingClusterNamesSuccessCallBack', function() {
  1086. it('should set clusterNames received from server', function() {
  1087. var data = {
  1088. items:[
  1089. {Clusters: {cluster_name: 'c1'}},
  1090. {Clusters: {cluster_name: 'c2'}},
  1091. {Clusters: {cluster_name: 'c3'}}
  1092. ]
  1093. },
  1094. clasterNames = ['c1','c2','c3'];
  1095. installerStep8Controller.getExistingClusterNamesSuccessCallBack(data);
  1096. expect(installerStep8Controller.get('clusterNames')).to.eql(clasterNames);
  1097. });
  1098. });
  1099. describe('#getExistingClusterNamesErrorCallback', function() {
  1100. it('should set [] to clusterNames', function() {
  1101. installerStep8Controller.set('clusterNames', ['c1', 'c2']);
  1102. installerStep8Controller.getExistingClusterNamesErrorCallback();
  1103. expect(installerStep8Controller.get('clusterNames')).to.eql([]);
  1104. });
  1105. });
  1106. describe('#deleteClusters', function() {
  1107. it('should call App.ajax.send for each provided clusterName', function() {
  1108. var clusterNames = ['h1', 'h2', 'h3'];
  1109. installerStep8Controller.deleteClusters(clusterNames);
  1110. var args = testHelpers.filterAjaxRequests('name', 'common.delete.cluster');
  1111. expect(args).to.have.property('length').equal(clusterNames.length);
  1112. clusterNames.forEach(function(n, i) {
  1113. expect(args[i][0].data).to.eql({name: n, isLast: i === clusterNames.length - 1});
  1114. });
  1115. });
  1116. it('should clear cluster delete error popup body views', function () {
  1117. installerStep8Controller.deleteClusters([]);
  1118. expect(installerStep8Controller.get('clusterDeleteErrorViews')).to.eql([]);
  1119. });
  1120. });
  1121. describe('#createStormSiteObj', function() {
  1122. it('should replace quote \'"\' to "\'" for some properties', function() {
  1123. var _configs = [
  1124. {filename: 'storm-site.xml', value: ["a", "b"], name: 'storm.zookeeper.servers'}
  1125. ],
  1126. expected = {
  1127. type: 'storm-site',
  1128. tag: 'version1',
  1129. properties: {
  1130. 'storm.zookeeper.servers': '[\'a\',\'b\']'
  1131. }
  1132. };
  1133. installerStep8Controller.reopen({configs: _configs});
  1134. expect(installerStep8Controller.createStormSiteObj('version1')).to.eql(expected);
  1135. });
  1136. it('should not escape special characters', function() {
  1137. var _configs = [
  1138. {filename: 'storm-site.xml', value: "abc\n\t", name: 'nimbus.childopts'},
  1139. {filename: 'storm-site.xml', value: "a\nb", name: 'supervisor.childopts'},
  1140. {filename: 'storm-site.xml', value: "a\t\tb", name: 'worker.childopts'}
  1141. ],
  1142. expected = {
  1143. type: 'storm-site',
  1144. tag: 'version1',
  1145. properties: {
  1146. 'nimbus.childopts': 'abc\n\t',
  1147. 'supervisor.childopts': 'a\nb',
  1148. 'worker.childopts': 'a\t\tb'
  1149. }
  1150. };
  1151. installerStep8Controller.reopen({configs: _configs});
  1152. expect(installerStep8Controller.createStormSiteObj('version1')).to.eql(expected);
  1153. });
  1154. });
  1155. describe('#ajaxQueueFinished', function() {
  1156. beforeEach(function () {
  1157. sinon.stub(App.router, 'send', Em.K);
  1158. });
  1159. afterEach(function () {
  1160. App.router.send.restore();
  1161. });
  1162. it('should call App.router.next', function() {
  1163. installerStep8Controller.ajaxQueueFinished();
  1164. expect(App.router.send.calledWith('next')).to.equal(true);
  1165. });
  1166. });
  1167. describe('#addRequestToAjaxQueue', function() {
  1168. describe('testMode = false', function() {
  1169. it('should add request', function() {
  1170. var clusterName = 'c1';
  1171. installerStep8Controller.reopen({clusterName: clusterName});
  1172. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  1173. installerStep8Controller.get('ajaxRequestsQueue').clear();
  1174. installerStep8Controller.addRequestToAjaxQueue({name:'name', data:{}});
  1175. var request = installerStep8Controller.get('ajaxRequestsQueue.queue.firstObject');
  1176. expect(request.error).to.equal('ajaxQueueRequestErrorCallback');
  1177. expect(request.data.cluster).to.equal(clusterName);
  1178. });
  1179. });
  1180. });
  1181. describe('#ajaxQueueRequestErrorCallback', function() {
  1182. var obj = Em.Object.create({
  1183. registerErrPopup: Em.K,
  1184. setStepsEnable: Em.K
  1185. });
  1186. beforeEach(function() {
  1187. sinon.stub(App.router, 'get', function() {
  1188. return obj;
  1189. });
  1190. sinon.spy(obj, 'registerErrPopup');
  1191. sinon.spy(obj, 'setStepsEnable');
  1192. });
  1193. afterEach(function() {
  1194. App.router.get.restore();
  1195. obj.registerErrPopup.restore();
  1196. obj.setStepsEnable.restore();
  1197. });
  1198. it('should set hasErrorOccurred true', function () {
  1199. installerStep8Controller.set('hasErrorOccurred', false);
  1200. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1201. expect(installerStep8Controller.get('hasErrorOccurred')).to.equal(true);
  1202. });
  1203. it('should set isSubmitDisabled false', function () {
  1204. installerStep8Controller.set('isSubmitDisabled', true);
  1205. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1206. expect(installerStep8Controller.get('isSubmitDisabled')).to.equal(false);
  1207. });
  1208. it('should set isBackBtnDisabled false', function () {
  1209. installerStep8Controller.set('isBackBtnDisabled', true);
  1210. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1211. expect(installerStep8Controller.get('isBackBtnDisabled')).to.equal(false);
  1212. });
  1213. it('should call setStepsEnable', function () {
  1214. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1215. expect(obj.setStepsEnable.calledOnce).to.equal(true);
  1216. });
  1217. it('should call registerErrPopup', function () {
  1218. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1219. expect(obj.registerErrPopup.calledOnce).to.equal(true);
  1220. });
  1221. });
  1222. describe('#removeInstalledServicesConfigurationGroups', function() {
  1223. beforeEach(function() {
  1224. sinon.stub(installerStep8Controller, 'deleteConfigurationGroup', Em.K);
  1225. });
  1226. afterEach(function() {
  1227. installerStep8Controller.deleteConfigurationGroup.restore();
  1228. });
  1229. it('should call App.config.deleteConfigGroup for each received group', function() {
  1230. var groups = [{}, {}, {}];
  1231. installerStep8Controller.removeInstalledServicesConfigurationGroups(groups);
  1232. expect(installerStep8Controller.deleteConfigurationGroup.callCount).to.equal(groups.length);
  1233. });
  1234. });
  1235. describe('#applyInstalledServicesConfigurationGroup', function() {
  1236. beforeEach(function() {
  1237. sinon.stub(App.router, 'get', function() {
  1238. return configurationController;
  1239. });
  1240. });
  1241. afterEach(function() {
  1242. App.router.get.restore();
  1243. });
  1244. it('should do ajax request for each config group', function() {
  1245. var configGroups = [{ConfigGroup: {id:''}}, {ConfigGroup: {id:''}}];
  1246. installerStep8Controller.applyInstalledServicesConfigurationGroup(configGroups);
  1247. var args = testHelpers.filterAjaxRequests('name', 'config_groups.update_config_group');
  1248. expect(args).to.have.property('length').equal(configGroups.length);
  1249. });
  1250. });
  1251. describe('#getExistingClusterNames', function() {
  1252. it('should do ajax request', function() {
  1253. installerStep8Controller.getExistingClusterNames();
  1254. var args = testHelpers.findAjaxRequest('name', 'wizard.step8.existing_cluster_names');
  1255. expect(args).exists;
  1256. });
  1257. });
  1258. describe('Queued requests', function() {
  1259. beforeEach(function() {
  1260. installerStep8Controller.clearStep();
  1261. sinon.spy(installerStep8Controller, 'addRequestToAjaxQueue');
  1262. });
  1263. afterEach(function() {
  1264. installerStep8Controller.addRequestToAjaxQueue.restore();
  1265. });
  1266. describe('#createCluster', function() {
  1267. it('shouldn\'t add request to queue if not installerController used', function() {
  1268. installerStep8Controller.reopen({content: {controllerName: 'addServiceController'}});
  1269. installerStep8Controller.createCluster();
  1270. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1271. });
  1272. it('App.currentStackVersion should be changed if localRepo selected', function() {
  1273. App.set('currentStackVersion', 'HDP-1.1.1');
  1274. installerStep8Controller.reopen({content: {controllerName: 'installerController', installOptions: {localRepo: true}}});
  1275. var data = {
  1276. data: JSON.stringify({ "Clusters": {"version": 'HDPLocal-1.1.1' }})
  1277. };
  1278. installerStep8Controller.createCluster();
  1279. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(data.data);
  1280. });
  1281. it('App.currentStackVersion shouldn\'t be changed if localRepo ins\'t selected', function() {
  1282. App.set('currentStackVersion', 'HDP-1.1.1');
  1283. installerStep8Controller.reopen({content: {controllerName: 'installerController', installOptions: {localRepo: false}}});
  1284. var data = {
  1285. data: JSON.stringify({ "Clusters": {"version": 'HDP-1.1.1' }})
  1286. };
  1287. installerStep8Controller.createCluster();
  1288. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.eql(data.data);
  1289. });
  1290. });
  1291. describe('#createSelectedServices', function() {
  1292. var data;
  1293. beforeEach(function () {
  1294. sinon.stub(installerStep8Controller, 'createSelectedServicesData', function () {
  1295. return data;
  1296. });
  1297. });
  1298. afterEach(function () {
  1299. installerStep8Controller.createSelectedServicesData.restore();
  1300. });
  1301. it('shouldn\'t do nothing if no data', function() {
  1302. data = [];
  1303. installerStep8Controller.createSelectedServices();
  1304. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1305. });
  1306. it('should call addRequestToAjaxQueue with computed data', function() {
  1307. data = [
  1308. {"ServiceInfo": { "service_name": 's1' }},
  1309. {"ServiceInfo": { "service_name": 's2' }},
  1310. {"ServiceInfo": { "service_name": 's3' }}
  1311. ];
  1312. installerStep8Controller.createSelectedServices();
  1313. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data));
  1314. });
  1315. });
  1316. describe('#registerHostsToCluster', function() {
  1317. var data;
  1318. beforeEach(function () {
  1319. sinon.stub(installerStep8Controller, 'createRegisterHostData', function () {
  1320. return data;
  1321. });
  1322. });
  1323. afterEach(function () {
  1324. installerStep8Controller.createRegisterHostData.restore();
  1325. });
  1326. it('shouldn\'t do nothing if no data', function() {
  1327. data = [];
  1328. installerStep8Controller.registerHostsToCluster();
  1329. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1330. });
  1331. it('should call addRequestToAjaxQueue with computed data', function() {
  1332. data = [
  1333. {"Hosts": { "host_name": 'h1'}},
  1334. {"Hosts": { "host_name": 'h3'}}
  1335. ];
  1336. installerStep8Controller.registerHostsToCluster();
  1337. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data));
  1338. });
  1339. });
  1340. describe('#registerHostsToComponent', function() {
  1341. it('shouldn\'t do request if no hosts provided', function() {
  1342. installerStep8Controller.registerHostsToComponent([]);
  1343. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1344. });
  1345. it('should do request if hostNames are provided', function() {
  1346. var hostNames = ['h1', 'h2'],
  1347. componentName = 'c1';
  1348. installerStep8Controller.registerHostsToComponent(hostNames, componentName);
  1349. var data = JSON.parse(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data);
  1350. expect(data.RequestInfo.query).to.equal('Hosts/host_name=h1|Hosts/host_name=h2');
  1351. expect(data.Body.host_components[0].HostRoles.component_name).to.equal('c1');
  1352. });
  1353. });
  1354. describe('#applyConfigurationsToCluster', function() {
  1355. it('should call addRequestToAjaxQueue', function() {
  1356. var serviceConfigTags = [
  1357. {
  1358. type: 'hdfs',
  1359. tag: 'tag1',
  1360. properties: {
  1361. 'prop1': 'value1'
  1362. }
  1363. }
  1364. ],
  1365. data = '['+JSON.stringify({
  1366. Clusters: {
  1367. desired_config: [serviceConfigTags[0]]
  1368. }
  1369. })+']';
  1370. installerStep8Controller.reopen({
  1371. installedServices: [
  1372. Em.Object.create({
  1373. isSelected: true,
  1374. isInstalled: false,
  1375. configTypesRendered: {hdfs:'tag1'}
  1376. })
  1377. ], selectedServices: []
  1378. });
  1379. installerStep8Controller.applyConfigurationsToCluster(serviceConfigTags);
  1380. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(data);
  1381. });
  1382. });
  1383. describe('#applyConfigurationGroups', function() {
  1384. it('should call addRequestToAjaxQueue', function() {
  1385. var data = [{}, {}];
  1386. installerStep8Controller.applyConfigurationGroups(data);
  1387. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data));
  1388. });
  1389. });
  1390. describe('#newServiceComponentErrorCallback', function() {
  1391. it('should add request for new component', function() {
  1392. var serviceName = 's1',
  1393. componentName = 'c1';
  1394. installerStep8Controller.newServiceComponentErrorCallback({}, {}, '', {}, {serviceName: serviceName, componentName: componentName});
  1395. var data = JSON.parse(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data);
  1396. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.serviceName).to.equal(serviceName);
  1397. expect(data.components[0].ServiceComponentInfo.component_name).to.equal(componentName);
  1398. });
  1399. });
  1400. describe('#createAdditionalHostComponents', function() {
  1401. beforeEach(function() {
  1402. sinon.stub(installerStep8Controller, 'registerHostsToComponent', Em.K);
  1403. });
  1404. afterEach(function() {
  1405. installerStep8Controller.registerHostsToComponent.restore();
  1406. });
  1407. describe('should add components with isRequiredOnAllHosts == true (1)', function() {
  1408. beforeEach(function () {
  1409. installerStep8Controller.reopen({
  1410. getRegisteredHosts: function() {
  1411. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1412. },
  1413. content: {
  1414. services: [
  1415. Em.Object.create({
  1416. serviceName: 'GANGLIA', isSelected: true, isInstalled: false, serviceComponents: [
  1417. Em.Object.create({
  1418. componentName: 'GANGLIA_MONITOR',
  1419. isRequiredOnAllHosts: true
  1420. }),
  1421. Em.Object.create({
  1422. componentName: 'GANGLIA_SERVER',
  1423. isRequiredOnAllHosts: false
  1424. })
  1425. ]
  1426. })
  1427. ]
  1428. }
  1429. });
  1430. installerStep8Controller.createAdditionalHostComponents();
  1431. });
  1432. it('registerHostsToComponent is called once', function () {
  1433. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  1434. });
  1435. it('hosts are ["h1", "h2"]', function () {
  1436. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
  1437. });
  1438. it('component is GANGLIA_MONITOR', function () {
  1439. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
  1440. });
  1441. });
  1442. describe('should add components with isRequiredOnAllHosts == true (2)', function() {
  1443. beforeEach(function () {
  1444. installerStep8Controller.reopen({
  1445. getRegisteredHosts: function() {
  1446. return [{hostName: 'h1', isInstalled: true}, {hostName: 'h2', isInstalled: false}];
  1447. },
  1448. content: {
  1449. services: [
  1450. Em.Object.create({
  1451. serviceName: 'GANGLIA', isSelected: true, isInstalled: true, serviceComponents: [
  1452. Em.Object.create({
  1453. componentName: 'GANGLIA_MONITOR',
  1454. isRequiredOnAllHosts: true
  1455. }),
  1456. Em.Object.create({
  1457. componentName: 'GANGLIA_SERVER',
  1458. isRequiredOnAllHosts: false
  1459. })
  1460. ]
  1461. })
  1462. ]
  1463. }
  1464. });
  1465. installerStep8Controller.createAdditionalHostComponents();
  1466. });
  1467. it('registerHostsToComponent is called once', function () {
  1468. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  1469. });
  1470. it('hosts are ["h2"]', function () {
  1471. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h2']);
  1472. });
  1473. it('component is GANGLIA_MONITOR', function () {
  1474. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
  1475. });
  1476. });
  1477. var newDatabases = [
  1478. {name: 'New MySQL Database',
  1479. component: 'MYSQL_SERVER'
  1480. },
  1481. {name: 'New PostgreSQL Database',
  1482. component: 'POSTGRESQL_SERVER'
  1483. }
  1484. ];
  1485. newDatabases.forEach(function (db) {
  1486. describe('should add {0}'.format(db.component), function() {
  1487. beforeEach(function () {
  1488. installerStep8Controller.reopen({
  1489. getRegisteredHosts: function() {
  1490. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1491. },
  1492. content: {
  1493. masterComponentHosts: [
  1494. {component: 'HIVE_SERVER', hostName: 'h1'},
  1495. {component: 'HIVE_SERVER', hostName: 'h2'}
  1496. ],
  1497. services: [
  1498. Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false, serviceComponents: []})
  1499. ],
  1500. serviceConfigProperties: [
  1501. {name: 'hive_database', value: db.name}
  1502. ]
  1503. }
  1504. });
  1505. installerStep8Controller.createAdditionalHostComponents();
  1506. });
  1507. it('registerHostsToComponent is called once', function () {
  1508. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  1509. });
  1510. it('hosts are ["h1", "h2"]', function () {
  1511. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
  1512. });
  1513. it('component is ' + db.component, function () {
  1514. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal(db.component);
  1515. });
  1516. });
  1517. });
  1518. });
  1519. describe('#createAdditionalHostComponentsOnAllHosts', function () {
  1520. beforeEach(function() {
  1521. sinon.stub(installerStep8Controller, 'registerHostsToComponent', Em.K);
  1522. });
  1523. afterEach(function() {
  1524. installerStep8Controller.registerHostsToComponent.restore();
  1525. });
  1526. describe('should add components with isRequiredOnAllHosts == true (1)', function() {
  1527. beforeEach(function () {
  1528. installerStep8Controller.reopen({
  1529. getRegisteredHosts: function() {
  1530. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1531. },
  1532. content: {
  1533. services: Em.A([
  1534. Em.Object.create({
  1535. serviceName: 'ANYSERVICE', isSelected: true, isInstalled: false, serviceComponents: [
  1536. // set isRequiredOnAllHosts = true for slave and client
  1537. Em.Object.create({
  1538. componentName: 'ANYSERVICE_MASTER',
  1539. isMaster: true,
  1540. isRequiredOnAllHosts: false
  1541. }),
  1542. Em.Object.create({
  1543. componentName: 'ANYSERVICE_SLAVE',
  1544. isSlave: true,
  1545. isRequiredOnAllHosts: true
  1546. }),
  1547. Em.Object.create({
  1548. componentName: 'ANYSERVICE_SLAVE2',
  1549. isSlave: true,
  1550. isRequiredOnAllHosts: true
  1551. }),
  1552. Em.Object.create({
  1553. componentName: 'ANYSERVICE_CLIENT',
  1554. isClient: true,
  1555. isRequiredOnAllHosts: true
  1556. })
  1557. ]
  1558. })
  1559. ]),
  1560. masterComponentHosts: Em.A([
  1561. Em.Object.create({
  1562. componentName: 'ANYSERVICE_MASTER',
  1563. component: 'ANYSERVICE_MASTER',
  1564. hosts: Em.A([
  1565. Em.Object.create({hostName: 'h1', isInstalled: true})
  1566. ])
  1567. })
  1568. ]),
  1569. slaveComponentHosts: Em.A([
  1570. Em.Object.create({
  1571. componentName: 'ANYSERVICE_SLAVE',
  1572. hosts: Em.A([
  1573. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1574. Em.Object.create({hostName: 'h2', isInstalled: false})
  1575. ])
  1576. }),
  1577. Em.Object.create({
  1578. componentName: 'ANYSERVICE_SLAVE2',
  1579. hosts: Em.A([
  1580. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1581. Em.Object.create({hostName: 'h2', isInstalled: false})
  1582. ])
  1583. }),
  1584. Em.Object.create({
  1585. componentName: 'CLIENT',
  1586. hosts: Em.A([
  1587. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1588. Em.Object.create({hostName: 'h2', isInstalled: false})
  1589. ])
  1590. })
  1591. ]),
  1592. clients: Em.A([
  1593. Em.Object.create({
  1594. component_name: 'ANYSERVICE_CLIENT',
  1595. isInstalled: false,
  1596. hosts: Em.A([
  1597. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1598. Em.Object.create({hostName: 'h2', isInstalled: false})
  1599. ])
  1600. })
  1601. ])
  1602. }
  1603. });
  1604. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  1605. installerStep8Controller.get('ajaxRequestsQueue').clear();
  1606. installerStep8Controller.createAdditionalHostComponents();
  1607. });
  1608. // Any component with isRequiredOnAllHosts = true implies that
  1609. // registerHostsToComponent would be done via
  1610. // createAdditionalHostComponents() BUT NOT
  1611. // createMasterHostComponents() or createSlaveAndClientsHostComponents()
  1612. // or createAdditionalClientComponents()
  1613. it('registerHostsToComponent 1st call', function () {
  1614. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
  1615. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('ANYSERVICE_SLAVE');
  1616. });
  1617. it('registerHostsToComponent 2nd call', function () {
  1618. expect(installerStep8Controller.registerHostsToComponent.args[1][0]).to.eql(['h1', 'h2']);
  1619. expect(installerStep8Controller.registerHostsToComponent.args[1][1]).to.equal('ANYSERVICE_SLAVE2');
  1620. });
  1621. it('registerHostsToComponent 3rd call', function () {
  1622. expect(installerStep8Controller.registerHostsToComponent.args[2][0]).to.eql(['h1', 'h2']);
  1623. expect(installerStep8Controller.registerHostsToComponent.args[2][1]).to.equal('ANYSERVICE_CLIENT');
  1624. });
  1625. });
  1626. describe('should not add components with isRequiredOnAllHosts == false (2)', function() {
  1627. beforeEach(function () {
  1628. installerStep8Controller.reopen({
  1629. getRegisteredHosts: function() {
  1630. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1631. },
  1632. content: {
  1633. services: Em.A([
  1634. Em.Object.create({
  1635. serviceName: 'ANYSERVICE', isSelected: true, isInstalled: false, serviceComponents: [
  1636. // set isRequiredOnAllHosts = false for all components
  1637. Em.Object.create({
  1638. componentName: 'ANYSERVICE_MASTER',
  1639. isMaster: true,
  1640. isRequiredOnAllHosts: false
  1641. }),
  1642. Em.Object.create({
  1643. componentName: 'ANYSERVICE_SLAVE',
  1644. isSlave: true,
  1645. isRequiredOnAllHosts: false
  1646. }),
  1647. Em.Object.create({
  1648. componentName: 'ANYSERVICE_SLAVE2',
  1649. isSlave: true,
  1650. isRequiredOnAllHosts: false
  1651. }),
  1652. Em.Object.create({
  1653. componentName: 'ANYSERVICE_CLIENT',
  1654. isClient: true,
  1655. isRequiredOnAllHosts: false
  1656. })
  1657. ]
  1658. })
  1659. ]),
  1660. masterComponentHosts: Em.A([
  1661. Em.Object.create({
  1662. componentName: 'ANYSERVICE_MASTER',
  1663. component: 'ANYSERVICE_MASTER',
  1664. hosts: Em.A([
  1665. Em.Object.create({hostName: 'h1', isInstalled: true})
  1666. ])
  1667. })
  1668. ]),
  1669. slaveComponentHosts: Em.A([
  1670. Em.Object.create({
  1671. componentName: 'ANYSERVICE_SLAVE',
  1672. hosts: Em.A([
  1673. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1674. Em.Object.create({hostName: 'h2', isInstalled: false})
  1675. ])
  1676. }),
  1677. Em.Object.create({
  1678. componentName: 'ANYSERVICE_SLAVE2',
  1679. hosts: Em.A([
  1680. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1681. Em.Object.create({hostName: 'h2', isInstalled: false})
  1682. ])
  1683. }),
  1684. Em.Object.create({
  1685. componentName: 'CLIENT',
  1686. hosts: Em.A([
  1687. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1688. Em.Object.create({hostName: 'h2', isInstalled: false})
  1689. ])
  1690. })
  1691. ]),
  1692. clients: Em.A([
  1693. Em.Object.create({
  1694. component_name: 'ANYSERVICE_CLIENT',
  1695. isInstalled: false,
  1696. hosts: Em.A([
  1697. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1698. Em.Object.create({hostName: 'h2', isInstalled: false})
  1699. ])
  1700. })
  1701. ])
  1702. }
  1703. });
  1704. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  1705. installerStep8Controller.get('ajaxRequestsQueue').clear();
  1706. installerStep8Controller.createAdditionalHostComponents();
  1707. });
  1708. it('registerHostsToComponent is not called', function () {
  1709. // isRequiredOnAllHosts = false for all components, implies that
  1710. // registerHostsToComponent would be done via
  1711. // createMasterHostComponents() or createSlaveAndClientsHostComponents()
  1712. // or createAdditionalClientComponents()
  1713. // BUT NOT createAdditionalHostComponents()
  1714. expect(installerStep8Controller.registerHostsToComponent.callCount).to.equal(0);
  1715. });
  1716. });
  1717. });
  1718. describe('#createNotification', function () {
  1719. beforeEach(function () {
  1720. installerStep8Controller.clearStep();
  1721. installerStep8Controller.set('content', {controllerName: 'installerController'});
  1722. installerStep8Controller.set('configs', [
  1723. {name: 'create_notification', value: 'yes', serviceName: 'MISC', filename: 'alert_notification'},
  1724. {name: 'ambari.dispatch.recipients', value: 'to@f.c', serviceName: 'MISC', filename: 'alert_notification'},
  1725. {name: 'mail.smtp.host', value: 'h', serviceName: 'MISC', filename: 'alert_notification'},
  1726. {name: 'mail.smtp.port', value: '25', serviceName: 'MISC', filename: 'alert_notification'},
  1727. {name: 'mail.smtp.from', value: 'from@f.c', serviceName: 'MISC', filename: 'alert_notification'},
  1728. {name: 'mail.smtp.starttls.enable', value: true, serviceName: 'MISC', filename: 'alert_notification'},
  1729. {name: 'mail.smtp.startssl.enable', value: false, serviceName: 'MISC', filename: 'alert_notification'},
  1730. {name: 'smtp_use_auth', value: 'true', serviceName: 'MISC', filename: 'alert_notification'},
  1731. {name: 'ambari.dispatch.credential.username', value: 'usr', serviceName: 'MISC', filename: 'alert_notification'},
  1732. {name: 'ambari.dispatch.credential.password', value: 'pwd', serviceName: 'MISC', filename: 'alert_notification'},
  1733. {name: 'some_p', value: 'some_v', serviceName: 'MISC', filename: 'alert_notification'}
  1734. ]);
  1735. installerStep8Controller.get('ajaxRequestsQueue').clear();
  1736. });
  1737. it('should add request to queue', function () {
  1738. installerStep8Controller.createNotification();
  1739. expect(installerStep8Controller.get('ajaxRequestsQueue.queue.length')).to.equal(1);
  1740. installerStep8Controller.get('ajaxRequestsQueue').runNextRequest();
  1741. var args = testHelpers.findAjaxRequest('name', 'alerts.create_alert_notification');
  1742. expect(args).exists;
  1743. });
  1744. describe('sent data should be valid', function () {
  1745. var data;
  1746. beforeEach(function () {
  1747. installerStep8Controller.createNotification();
  1748. data = installerStep8Controller.get('ajaxRequestsQueue.queue')[0].data.data.AlertTarget;
  1749. });
  1750. it('global is true', function () {
  1751. expect(data.global).to.be.true;
  1752. });
  1753. it('notification_type is EMAIL', function () {
  1754. expect(data.notification_type).to.equal('EMAIL');
  1755. });
  1756. it('alert_states are valid', function () {
  1757. expect(data.alert_states).to.eql(['OK', 'WARNING', 'CRITICAL', 'UNKNOWN']);
  1758. });
  1759. it('ambari.dispatch.recipients is valid', function () {
  1760. expect(data.properties['ambari.dispatch.recipients']).to.eql(['to@f.c']);
  1761. });
  1762. it('mail.smtp.host is valid', function () {
  1763. expect(data.properties['mail.smtp.host']).to.equal('h');
  1764. });
  1765. it('mail.smtp.port is valid', function () {
  1766. expect(data.properties['mail.smtp.port']).to.equal('25');
  1767. });
  1768. it('mail.smtp.from is valid', function () {
  1769. expect(data.properties['mail.smtp.from']).to.equal('from@f.c');
  1770. });
  1771. it('mail.smtp.starttls.enable is true', function () {
  1772. expect(data.properties['mail.smtp.starttls.enable']).to.equal(true);
  1773. });
  1774. it('mail.smtp.startssl.enable is false', function () {
  1775. expect(data.properties['mail.smtp.startssl.enable']).to.equal(false);
  1776. });
  1777. it('ambari.dispatch.credential.username is valid', function () {
  1778. expect(data.properties['ambari.dispatch.credential.username']).to.equal('usr');
  1779. });
  1780. it('ambari.dispatch.credential.password is valid', function () {
  1781. expect(data.properties['ambari.dispatch.credential.password']).to.equal('pwd');
  1782. });
  1783. it('custom property is valid', function () {
  1784. expect(data.properties.some_p).to.equal('some_v');
  1785. });
  1786. });
  1787. });
  1788. });
  1789. App.TestAliases.testAsComputedEqualProperties(getController(), 'isAllClusterDeleteRequestsCompleted', 'clusterDeleteRequestsCompleted', 'clusterNames.length');
  1790. describe('#deleteClusterSuccessCallback', function () {
  1791. beforeEach(function () {
  1792. sinon.stub(installerStep8Controller, 'showDeleteClustersErrorPopup', Em.K);
  1793. sinon.stub(installerStep8Controller, 'startDeploy', Em.K);
  1794. installerStep8Controller.setProperties({
  1795. clusterDeleteRequestsCompleted: 0,
  1796. clusterNames: ['c0', 'c1'],
  1797. clusterDeleteErrorViews: []
  1798. });
  1799. installerStep8Controller.deleteClusterSuccessCallback();
  1800. });
  1801. afterEach(function () {
  1802. installerStep8Controller.showDeleteClustersErrorPopup.restore();
  1803. installerStep8Controller.startDeploy.restore();
  1804. });
  1805. describe('no failed requests', function () {
  1806. it('before Delete Cluster request', function () {
  1807. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1);
  1808. expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
  1809. expect(installerStep8Controller.startDeploy.called).to.be.false;
  1810. });
  1811. it('after Delete Cluster request', function () {
  1812. installerStep8Controller.deleteClusterSuccessCallback();
  1813. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
  1814. expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
  1815. expect(installerStep8Controller.startDeploy.calledOnce).to.be.true;
  1816. });
  1817. });
  1818. it('one request failed', function () {
  1819. installerStep8Controller.deleteClusterErrorCallback({}, null, null, {});
  1820. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
  1821. expect(installerStep8Controller.showDeleteClustersErrorPopup.calledOnce).to.be.true;
  1822. expect(installerStep8Controller.startDeploy.called).to.be.false;
  1823. });
  1824. });
  1825. describe('#deleteClusterErrorCallback', function () {
  1826. var request = {
  1827. status: 500,
  1828. responseText: '{"message":"Internal Server Error"}'
  1829. },
  1830. ajaxOptions = 'error',
  1831. error = 'Internal Server Error',
  1832. opt = {
  1833. url: 'api/v1/clusters/c0',
  1834. type: 'DELETE'
  1835. };
  1836. beforeEach(function () {
  1837. installerStep8Controller.setProperties({
  1838. clusterDeleteRequestsCompleted: 0,
  1839. clusterNames: ['c0', 'c1'],
  1840. clusterDeleteErrorViews: []
  1841. });
  1842. sinon.stub(installerStep8Controller, 'showDeleteClustersErrorPopup', Em.K);
  1843. installerStep8Controller.deleteClusterErrorCallback(request, ajaxOptions, error, opt);
  1844. });
  1845. afterEach(function () {
  1846. installerStep8Controller.showDeleteClustersErrorPopup.restore();
  1847. });
  1848. describe('should show error popup only if all requests are completed', function () {
  1849. it('Before Delete Cluster request fail', function () {
  1850. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1);
  1851. expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
  1852. });
  1853. it('After Delete Cluster request is failed', function () {
  1854. installerStep8Controller.deleteClusterErrorCallback(request, ajaxOptions, error, opt);
  1855. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
  1856. expect(installerStep8Controller.showDeleteClustersErrorPopup.calledOnce).to.be.true;
  1857. });
  1858. });
  1859. describe('should create error popup body view', function () {
  1860. it('One failed request', function () {
  1861. expect(installerStep8Controller.get('clusterDeleteErrorViews')).to.have.length(1);
  1862. });
  1863. it('failed request url is valid', function () {
  1864. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.url')).to.equal('api/v1/clusters/c0');
  1865. });
  1866. it('failed request type is valid', function () {
  1867. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.type')).to.equal('DELETE');
  1868. });
  1869. it('failed request status is valid', function () {
  1870. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.status')).to.equal(500);
  1871. });
  1872. it('failed request message is valid', function () {
  1873. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.message')).to.equal('Internal Server Error');
  1874. });
  1875. });
  1876. });
  1877. describe('#showDeleteClustersErrorPopup', function () {
  1878. beforeEach(function () {
  1879. installerStep8Controller.setProperties({
  1880. isSubmitDisabled: true,
  1881. isBackBtnDisabled: true
  1882. });
  1883. sinon.stub(App.ModalPopup, 'show', Em.K);
  1884. installerStep8Controller.showDeleteClustersErrorPopup();
  1885. });
  1886. afterEach(function () {
  1887. App.ModalPopup.show.restore();
  1888. });
  1889. it('should show error popup and unlock navigation', function () {
  1890. expect(installerStep8Controller.get('isSubmitDisabled')).to.be.false;
  1891. expect(installerStep8Controller.get('isBackBtnDisabled')).to.be.false;
  1892. expect(App.ModalPopup.show.calledOnce).to.be.true;
  1893. });
  1894. });
  1895. describe('#startDeploy', function () {
  1896. var stubbedNames = ['createCluster', 'createSelectedServices', 'updateConfigurations', 'createConfigurations',
  1897. 'applyConfigurationsToCluster', 'createComponents', 'registerHostsToCluster', 'createConfigurationGroups',
  1898. 'createMasterHostComponents', 'createSlaveAndClientsHostComponents', 'createAdditionalClientComponents',
  1899. 'createAdditionalHostComponents'],
  1900. cases = [
  1901. {
  1902. controllerName: 'installerController',
  1903. notExecuted: ['createAdditionalClientComponents', 'updateConfigurations'],
  1904. fileNamesToUpdate: [],
  1905. title: 'Installer, no configs to update'
  1906. },
  1907. {
  1908. controllerName: 'addHostController',
  1909. notExecuted: ['updateConfigurations', 'createConfigurations', 'applyConfigurationsToCluster', 'createAdditionalClientComponents'],
  1910. title: 'Add Host Wizard'
  1911. },
  1912. {
  1913. controllerName: 'addServiceController',
  1914. notExecuted: ['updateConfigurations'],
  1915. fileNamesToUpdate: [],
  1916. title: 'Add Service Wizard, no configs to update'
  1917. },
  1918. {
  1919. controllerName: 'addServiceController',
  1920. notExecuted: [],
  1921. fileNamesToUpdate: [''],
  1922. title: 'Add Service Wizard, some configs to be updated'
  1923. }
  1924. ];
  1925. beforeEach(function () {
  1926. sinon.stub(App, 'get').withArgs('isKerberosEnabled').returns(false);
  1927. stubbedNames.forEach(function (name) {
  1928. sinon.stub(installerStep8Controller, name, Em.K);
  1929. });
  1930. installerStep8Controller.setProperties({
  1931. serviceConfigTags: [],
  1932. content: {
  1933. controllerName: null
  1934. }
  1935. });
  1936. });
  1937. afterEach(function () {
  1938. App.get.restore();
  1939. stubbedNames.forEach(function (name) {
  1940. installerStep8Controller[name].restore();
  1941. });
  1942. installerStep8Controller.get.restore();
  1943. });
  1944. cases.forEach(function (item) {
  1945. describe(item.title, function () {
  1946. beforeEach(function () {
  1947. sinon.stub(installerStep8Controller, 'get')
  1948. .withArgs('ajaxRequestsQueue').returns({
  1949. start: Em.K
  1950. })
  1951. .withArgs('ajaxRequestsQueue.queue.length').returns(1)
  1952. .withArgs('wizardController').returns({
  1953. getDBProperty: function () {
  1954. return item.fileNamesToUpdate;
  1955. }
  1956. })
  1957. .withArgs('content.controllerName').returns(item.controllerName);
  1958. installerStep8Controller.startDeploy();
  1959. });
  1960. stubbedNames.forEach(function (name) {
  1961. it(name, function () {
  1962. expect(installerStep8Controller[name].called).to.equal(!item.notExecuted.contains(name));
  1963. });
  1964. });
  1965. });
  1966. });
  1967. });
  1968. describe('#getClientsMap', function () {
  1969. var cases = [
  1970. {
  1971. flag: 'isMaster',
  1972. result: {
  1973. c8: ['c1', 'c2'],
  1974. c9: ['c1', 'c2']
  1975. },
  1976. title: 'dependencies for masters'
  1977. },
  1978. {
  1979. flag: 'isSlave',
  1980. result: {
  1981. c8: ['c5', 'c6'],
  1982. c9: ['c5', 'c6']
  1983. },
  1984. title: 'dependencies for slaves'
  1985. },
  1986. {
  1987. flag: 'isClient',
  1988. result: {
  1989. c8: ['c9', 'c10'],
  1990. c9: ['c9', 'c10']
  1991. },
  1992. title: 'dependencies for clients'
  1993. },
  1994. {
  1995. flag: null,
  1996. result: {
  1997. c8: ['c1', 'c2', 'c5', 'c6', 'c9', 'c10'],
  1998. c9: ['c1', 'c2', 'c5', 'c6', 'c9', 'c10']
  1999. },
  2000. title: 'dependencies for all components'
  2001. }
  2002. ];
  2003. before(function () {
  2004. sinon.stub(App.StackServiceComponent, 'find').returns([
  2005. Em.Object.create({
  2006. componentName: 'c0',
  2007. isMaster: true,
  2008. dependencies: [
  2009. {
  2010. componentName: 'c1'
  2011. },
  2012. {
  2013. componentName: 'c2'
  2014. },
  2015. {
  2016. componentName: 'c4'
  2017. },
  2018. {
  2019. componentName: 'c5'
  2020. }
  2021. ]
  2022. }),
  2023. Em.Object.create({
  2024. componentName: 'c1',
  2025. isMaster: true,
  2026. dependencies: [
  2027. {
  2028. componentName: 'c4'
  2029. },
  2030. {
  2031. componentName: 'c5'
  2032. },
  2033. {
  2034. componentName: 'c8'
  2035. },
  2036. {
  2037. componentName: 'c9'
  2038. }
  2039. ]
  2040. }),
  2041. Em.Object.create({
  2042. componentName: 'c2',
  2043. isMaster: true,
  2044. dependencies: [
  2045. {
  2046. componentName: 'c1'
  2047. },
  2048. {
  2049. componentName: 'c2'
  2050. },
  2051. {
  2052. componentName: 'c8'
  2053. },
  2054. {
  2055. componentName: 'c9'
  2056. }
  2057. ]
  2058. }),
  2059. Em.Object.create({
  2060. componentName: 'c3',
  2061. isMaster: true,
  2062. dependencies: []
  2063. }),
  2064. Em.Object.create({
  2065. componentName: 'c4',
  2066. isSlave: true,
  2067. dependencies: [
  2068. {
  2069. componentName: 'c1'
  2070. },
  2071. {
  2072. componentName: 'c2'
  2073. },
  2074. {
  2075. componentName: 'c4'
  2076. },
  2077. {
  2078. componentName: 'c5'
  2079. }
  2080. ]
  2081. }),
  2082. Em.Object.create({
  2083. componentName: 'c5',
  2084. isSlave: true,
  2085. dependencies: [
  2086. {
  2087. componentName: 'c4'
  2088. },
  2089. {
  2090. componentName: 'c5'
  2091. },
  2092. {
  2093. componentName: 'c8'
  2094. },
  2095. {
  2096. componentName: 'c9'
  2097. }
  2098. ]
  2099. }),
  2100. Em.Object.create({
  2101. componentName: 'c6',
  2102. isSlave: true,
  2103. dependencies: [
  2104. {
  2105. componentName: 'c1'
  2106. },
  2107. {
  2108. componentName: 'c2'
  2109. },
  2110. {
  2111. componentName: 'c8'
  2112. },
  2113. {
  2114. componentName: 'c9'
  2115. }
  2116. ]
  2117. }),
  2118. Em.Object.create({
  2119. componentName: 'c7',
  2120. isSlave: true,
  2121. dependencies: []
  2122. }),
  2123. Em.Object.create({
  2124. componentName: 'c8',
  2125. isClient: true,
  2126. dependencies: [
  2127. {
  2128. componentName: 'c1'
  2129. },
  2130. {
  2131. componentName: 'c2'
  2132. },
  2133. {
  2134. componentName: 'c4'
  2135. },
  2136. {
  2137. componentName: 'c5'
  2138. }
  2139. ]
  2140. }),
  2141. Em.Object.create({
  2142. componentName: 'c9',
  2143. isClient: true,
  2144. dependencies: [
  2145. {
  2146. componentName: 'c4'
  2147. },
  2148. {
  2149. componentName: 'c5'
  2150. },
  2151. {
  2152. componentName: 'c8'
  2153. },
  2154. {
  2155. componentName: 'c9'
  2156. }
  2157. ]
  2158. }),
  2159. Em.Object.create({
  2160. componentName: 'c10',
  2161. isClient: true,
  2162. dependencies: [
  2163. {
  2164. componentName: 'c1'
  2165. },
  2166. {
  2167. componentName: 'c2'
  2168. },
  2169. {
  2170. componentName: 'c8'
  2171. },
  2172. {
  2173. componentName: 'c9'
  2174. }
  2175. ]
  2176. }),
  2177. Em.Object.create({
  2178. componentName: 'c11',
  2179. isClient: true,
  2180. dependencies: []
  2181. })
  2182. ]);
  2183. });
  2184. after(function () {
  2185. App.StackServiceComponent.find.restore();
  2186. });
  2187. cases.forEach(function (item) {
  2188. it(item.title, function () {
  2189. expect(installerStep8Controller.getClientsMap(item.flag)).to.eql(item.result);
  2190. });
  2191. });
  2192. });
  2193. describe('#showLoadingIndicator', function() {
  2194. beforeEach(function () {
  2195. sinon.spy(App.ModalPopup, 'show');
  2196. });
  2197. afterEach(function () {
  2198. App.ModalPopup.show.restore();
  2199. });
  2200. it('if popup doesn\'t exist should create another', function() {
  2201. installerStep8Controller.set('isSubmitDisabled', true);
  2202. installerStep8Controller.showLoadingIndicator();
  2203. expect(App.ModalPopup.show.calledOnce).to.equal(true);
  2204. });
  2205. });
  2206. describe('#updateKerberosDescriptor', function () {
  2207. var requestData = {artifactName: 'kerberos_descriptor',
  2208. data: {
  2209. artifact_data: 1234
  2210. }
  2211. };
  2212. beforeEach(function () {
  2213. sinon.stub(App.db, 'get').withArgs('KerberosWizard', 'kerberosDescriptorConfigs').returns(1234);
  2214. sinon.stub(installerStep8Controller, 'addRequestToAjaxQueue', Em.K);
  2215. sinon.stub(installerStep8Controller, 'get').withArgs('wizardController').returns(Em.Object.create({
  2216. getDBProperty: function() { return true; }
  2217. }));
  2218. });
  2219. afterEach(function () {
  2220. App.db.get.restore();
  2221. installerStep8Controller.addRequestToAjaxQueue.restore();
  2222. installerStep8Controller.get.restore();
  2223. });
  2224. it('should send request instantly', function () {
  2225. installerStep8Controller.updateKerberosDescriptor(true);
  2226. var args = testHelpers.findAjaxRequest('name', 'admin.kerberos.cluster.artifact.update');
  2227. expect(args[0]).exists;
  2228. expect(args[0].data).to.be.eql(requestData);
  2229. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.be.false;
  2230. });
  2231. it('should add request to the queue', function () {
  2232. installerStep8Controller.updateKerberosDescriptor(false);
  2233. var args = testHelpers.findAjaxRequest('name', 'admin.kerberos.cluster.artifact.update');
  2234. expect(args).not.exists;
  2235. expect(installerStep8Controller.addRequestToAjaxQueue.calledOnce).to.be.true;
  2236. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data).to.be.eql(requestData);
  2237. });
  2238. });
  2239. });