step8_test.js 85 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440
  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. describe('should call App.ajax.send for each provided clusterName', function() {
  1108. var clusterNames = ['h1', 'h2', 'h3'];
  1109. var args;
  1110. beforeEach(function () {
  1111. installerStep8Controller.deleteClusters(clusterNames);
  1112. args = testHelpers.filterAjaxRequests('name', 'common.delete.cluster');
  1113. });
  1114. it('args', function () {
  1115. expect(args).to.have.property('length').equal(clusterNames.length);
  1116. });
  1117. clusterNames.forEach(function(n, i) {
  1118. it(n, function () {
  1119. expect(args[i][0].data).to.eql({name: n, isLast: i === clusterNames.length - 1});
  1120. });
  1121. });
  1122. });
  1123. it('should clear cluster delete error popup body views', function () {
  1124. installerStep8Controller.deleteClusters([]);
  1125. expect(installerStep8Controller.get('clusterDeleteErrorViews')).to.eql([]);
  1126. });
  1127. });
  1128. describe('#createStormSiteObj', function() {
  1129. it('should replace quote \'"\' to "\'" for some properties', function() {
  1130. var _configs = [
  1131. {filename: 'storm-site.xml', value: ["a", "b"], name: 'storm.zookeeper.servers'}
  1132. ],
  1133. expected = {
  1134. type: 'storm-site',
  1135. tag: 'version1',
  1136. properties: {
  1137. 'storm.zookeeper.servers': '[\'a\',\'b\']'
  1138. }
  1139. };
  1140. installerStep8Controller.reopen({configs: _configs});
  1141. expect(installerStep8Controller.createStormSiteObj('version1')).to.eql(expected);
  1142. });
  1143. it('should not escape special characters', function() {
  1144. var _configs = [
  1145. {filename: 'storm-site.xml', value: "abc\n\t", name: 'nimbus.childopts'},
  1146. {filename: 'storm-site.xml', value: "a\nb", name: 'supervisor.childopts'},
  1147. {filename: 'storm-site.xml', value: "a\t\tb", name: 'worker.childopts'}
  1148. ],
  1149. expected = {
  1150. type: 'storm-site',
  1151. tag: 'version1',
  1152. properties: {
  1153. 'nimbus.childopts': 'abc\n\t',
  1154. 'supervisor.childopts': 'a\nb',
  1155. 'worker.childopts': 'a\t\tb'
  1156. }
  1157. };
  1158. installerStep8Controller.reopen({configs: _configs});
  1159. expect(installerStep8Controller.createStormSiteObj('version1')).to.eql(expected);
  1160. });
  1161. });
  1162. describe('#ajaxQueueFinished', function() {
  1163. beforeEach(function () {
  1164. sinon.stub(App.router, 'send', Em.K);
  1165. });
  1166. afterEach(function () {
  1167. App.router.send.restore();
  1168. });
  1169. it('should call App.router.next', function() {
  1170. installerStep8Controller.ajaxQueueFinished();
  1171. expect(App.router.send.calledWith('next')).to.equal(true);
  1172. });
  1173. });
  1174. describe('#addRequestToAjaxQueue', function() {
  1175. describe('testMode = false', function() {
  1176. it('should add request', function() {
  1177. var clusterName = 'c1';
  1178. installerStep8Controller.reopen({clusterName: clusterName});
  1179. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  1180. installerStep8Controller.get('ajaxRequestsQueue').clear();
  1181. installerStep8Controller.addRequestToAjaxQueue({name:'name', data:{}});
  1182. var request = installerStep8Controller.get('ajaxRequestsQueue.queue.firstObject');
  1183. expect(request.error).to.equal('ajaxQueueRequestErrorCallback');
  1184. expect(request.data.cluster).to.equal(clusterName);
  1185. });
  1186. });
  1187. });
  1188. describe('#ajaxQueueRequestErrorCallback', function() {
  1189. var obj = Em.Object.create({
  1190. registerErrPopup: Em.K,
  1191. setStepsEnable: Em.K
  1192. });
  1193. beforeEach(function() {
  1194. sinon.stub(App.router, 'get', function() {
  1195. return obj;
  1196. });
  1197. sinon.spy(obj, 'registerErrPopup');
  1198. sinon.spy(obj, 'setStepsEnable');
  1199. });
  1200. afterEach(function() {
  1201. App.router.get.restore();
  1202. obj.registerErrPopup.restore();
  1203. obj.setStepsEnable.restore();
  1204. });
  1205. it('should set hasErrorOccurred true', function () {
  1206. installerStep8Controller.set('hasErrorOccurred', false);
  1207. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1208. expect(installerStep8Controller.get('hasErrorOccurred')).to.equal(true);
  1209. });
  1210. it('should set isSubmitDisabled false', function () {
  1211. installerStep8Controller.set('isSubmitDisabled', true);
  1212. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1213. expect(installerStep8Controller.get('isSubmitDisabled')).to.equal(false);
  1214. });
  1215. it('should set isBackBtnDisabled false', function () {
  1216. installerStep8Controller.set('isBackBtnDisabled', true);
  1217. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1218. expect(installerStep8Controller.get('isBackBtnDisabled')).to.equal(false);
  1219. });
  1220. it('should call setStepsEnable', function () {
  1221. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1222. expect(obj.setStepsEnable.calledOnce).to.equal(true);
  1223. });
  1224. it('should call registerErrPopup', function () {
  1225. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1226. expect(obj.registerErrPopup.calledOnce).to.equal(true);
  1227. });
  1228. });
  1229. describe('#removeInstalledServicesConfigurationGroups', function() {
  1230. beforeEach(function() {
  1231. sinon.stub(installerStep8Controller, 'deleteConfigurationGroup', Em.K);
  1232. });
  1233. afterEach(function() {
  1234. installerStep8Controller.deleteConfigurationGroup.restore();
  1235. });
  1236. it('should call App.config.deleteConfigGroup for each received group', function() {
  1237. var groups = [{}, {}, {}];
  1238. installerStep8Controller.removeInstalledServicesConfigurationGroups(groups);
  1239. expect(installerStep8Controller.deleteConfigurationGroup.callCount).to.equal(groups.length);
  1240. });
  1241. });
  1242. describe('#applyInstalledServicesConfigurationGroup', function() {
  1243. beforeEach(function() {
  1244. sinon.stub(App.router, 'get', function() {
  1245. return configurationController;
  1246. });
  1247. });
  1248. afterEach(function() {
  1249. App.router.get.restore();
  1250. });
  1251. it('should do ajax request for each config group', function() {
  1252. var configGroups = [{ConfigGroup: {id:''}}, {ConfigGroup: {id:''}}];
  1253. installerStep8Controller.applyInstalledServicesConfigurationGroup(configGroups);
  1254. var args = testHelpers.filterAjaxRequests('name', 'config_groups.update_config_group');
  1255. expect(args).to.have.property('length').equal(configGroups.length);
  1256. });
  1257. });
  1258. describe('#getExistingClusterNames', function() {
  1259. it('should do ajax request', function() {
  1260. installerStep8Controller.getExistingClusterNames();
  1261. var args = testHelpers.findAjaxRequest('name', 'wizard.step8.existing_cluster_names');
  1262. expect(args).exists;
  1263. });
  1264. });
  1265. describe('Queued requests', function() {
  1266. beforeEach(function() {
  1267. installerStep8Controller.clearStep();
  1268. sinon.spy(installerStep8Controller, 'addRequestToAjaxQueue');
  1269. });
  1270. afterEach(function() {
  1271. installerStep8Controller.addRequestToAjaxQueue.restore();
  1272. });
  1273. describe('#createCluster', function() {
  1274. it('shouldn\'t add request to queue if not installerController used', function() {
  1275. installerStep8Controller.reopen({content: {controllerName: 'addServiceController'}});
  1276. installerStep8Controller.createCluster();
  1277. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1278. });
  1279. it('App.currentStackVersion should be changed if localRepo selected', function() {
  1280. App.set('currentStackVersion', 'HDP-1.1.1');
  1281. installerStep8Controller.reopen({content: {controllerName: 'installerController', installOptions: {localRepo: true}}});
  1282. var data = {
  1283. data: JSON.stringify({ "Clusters": {"version": 'HDPLocal-1.1.1' }})
  1284. };
  1285. installerStep8Controller.createCluster();
  1286. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(data.data);
  1287. });
  1288. it('App.currentStackVersion shouldn\'t be changed if localRepo ins\'t selected', function() {
  1289. App.set('currentStackVersion', 'HDP-1.1.1');
  1290. installerStep8Controller.reopen({content: {controllerName: 'installerController', installOptions: {localRepo: false}}});
  1291. var data = {
  1292. data: JSON.stringify({ "Clusters": {"version": 'HDP-1.1.1' }})
  1293. };
  1294. installerStep8Controller.createCluster();
  1295. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.eql(data.data);
  1296. });
  1297. });
  1298. describe('#createSelectedServices', function() {
  1299. var data;
  1300. beforeEach(function () {
  1301. sinon.stub(installerStep8Controller, 'createSelectedServicesData', function () {
  1302. return data;
  1303. });
  1304. });
  1305. afterEach(function () {
  1306. installerStep8Controller.createSelectedServicesData.restore();
  1307. });
  1308. it('shouldn\'t do nothing if no data', function() {
  1309. data = [];
  1310. installerStep8Controller.createSelectedServices();
  1311. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1312. });
  1313. it('should call addRequestToAjaxQueue with computed data', function() {
  1314. data = [
  1315. {"ServiceInfo": { "service_name": 's1' }},
  1316. {"ServiceInfo": { "service_name": 's2' }},
  1317. {"ServiceInfo": { "service_name": 's3' }}
  1318. ];
  1319. installerStep8Controller.createSelectedServices();
  1320. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data));
  1321. });
  1322. });
  1323. describe('#registerHostsToCluster', function() {
  1324. var data;
  1325. beforeEach(function () {
  1326. sinon.stub(installerStep8Controller, 'createRegisterHostData', function () {
  1327. return data;
  1328. });
  1329. });
  1330. afterEach(function () {
  1331. installerStep8Controller.createRegisterHostData.restore();
  1332. });
  1333. it('shouldn\'t do nothing if no data', function() {
  1334. data = [];
  1335. installerStep8Controller.registerHostsToCluster();
  1336. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1337. });
  1338. it('should call addRequestToAjaxQueue with computed data', function() {
  1339. data = [
  1340. {"Hosts": { "host_name": 'h1'}},
  1341. {"Hosts": { "host_name": 'h3'}}
  1342. ];
  1343. installerStep8Controller.registerHostsToCluster();
  1344. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data));
  1345. });
  1346. });
  1347. describe('#registerHostsToComponent', function() {
  1348. it('shouldn\'t do request if no hosts provided', function() {
  1349. installerStep8Controller.registerHostsToComponent([]);
  1350. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1351. });
  1352. it('should do request if hostNames are provided', function() {
  1353. var hostNames = ['h1', 'h2'],
  1354. componentName = 'c1';
  1355. installerStep8Controller.registerHostsToComponent(hostNames, componentName);
  1356. var data = JSON.parse(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data);
  1357. expect(data.RequestInfo.query).to.equal('Hosts/host_name=h1|Hosts/host_name=h2');
  1358. expect(data.Body.host_components[0].HostRoles.component_name).to.equal('c1');
  1359. });
  1360. });
  1361. describe('#applyConfigurationsToCluster', function() {
  1362. it('should call addRequestToAjaxQueue', function() {
  1363. var serviceConfigTags = [
  1364. {
  1365. type: 'hdfs',
  1366. tag: 'tag1',
  1367. properties: {
  1368. 'prop1': 'value1'
  1369. }
  1370. }
  1371. ],
  1372. data = '['+JSON.stringify({
  1373. Clusters: {
  1374. desired_config: [serviceConfigTags[0]]
  1375. }
  1376. })+']';
  1377. installerStep8Controller.reopen({
  1378. installedServices: [
  1379. Em.Object.create({
  1380. isSelected: true,
  1381. isInstalled: false,
  1382. configTypesRendered: {hdfs:'tag1'}
  1383. })
  1384. ], selectedServices: []
  1385. });
  1386. installerStep8Controller.applyConfigurationsToCluster(serviceConfigTags);
  1387. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(data);
  1388. });
  1389. });
  1390. describe('#applyConfigurationGroups', function() {
  1391. it('should call addRequestToAjaxQueue', function() {
  1392. var data = [{}, {}];
  1393. installerStep8Controller.applyConfigurationGroups(data);
  1394. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data));
  1395. });
  1396. });
  1397. describe('#newServiceComponentErrorCallback', function() {
  1398. it('should add request for new component', function() {
  1399. var serviceName = 's1',
  1400. componentName = 'c1';
  1401. installerStep8Controller.newServiceComponentErrorCallback({}, {}, '', {}, {serviceName: serviceName, componentName: componentName});
  1402. var data = JSON.parse(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data);
  1403. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.serviceName).to.equal(serviceName);
  1404. expect(data.components[0].ServiceComponentInfo.component_name).to.equal(componentName);
  1405. });
  1406. });
  1407. describe('#createAdditionalHostComponents', function() {
  1408. beforeEach(function() {
  1409. sinon.stub(installerStep8Controller, 'registerHostsToComponent', Em.K);
  1410. });
  1411. afterEach(function() {
  1412. installerStep8Controller.registerHostsToComponent.restore();
  1413. });
  1414. describe('should add components with isRequiredOnAllHosts == true (1)', function() {
  1415. beforeEach(function () {
  1416. installerStep8Controller.reopen({
  1417. getRegisteredHosts: function() {
  1418. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1419. },
  1420. content: {
  1421. services: [
  1422. Em.Object.create({
  1423. serviceName: 'GANGLIA', isSelected: true, isInstalled: false, serviceComponents: [
  1424. Em.Object.create({
  1425. componentName: 'GANGLIA_MONITOR',
  1426. isRequiredOnAllHosts: true
  1427. }),
  1428. Em.Object.create({
  1429. componentName: 'GANGLIA_SERVER',
  1430. isRequiredOnAllHosts: false
  1431. })
  1432. ]
  1433. })
  1434. ]
  1435. }
  1436. });
  1437. installerStep8Controller.createAdditionalHostComponents();
  1438. });
  1439. it('registerHostsToComponent is called once', function () {
  1440. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  1441. });
  1442. it('hosts are ["h1", "h2"]', function () {
  1443. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
  1444. });
  1445. it('component is GANGLIA_MONITOR', function () {
  1446. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
  1447. });
  1448. });
  1449. describe('should add components with isRequiredOnAllHosts == true (2)', function() {
  1450. beforeEach(function () {
  1451. installerStep8Controller.reopen({
  1452. getRegisteredHosts: function() {
  1453. return [{hostName: 'h1', isInstalled: true}, {hostName: 'h2', isInstalled: false}];
  1454. },
  1455. content: {
  1456. services: [
  1457. Em.Object.create({
  1458. serviceName: 'GANGLIA', isSelected: true, isInstalled: true, serviceComponents: [
  1459. Em.Object.create({
  1460. componentName: 'GANGLIA_MONITOR',
  1461. isRequiredOnAllHosts: true
  1462. }),
  1463. Em.Object.create({
  1464. componentName: 'GANGLIA_SERVER',
  1465. isRequiredOnAllHosts: false
  1466. })
  1467. ]
  1468. })
  1469. ]
  1470. }
  1471. });
  1472. installerStep8Controller.createAdditionalHostComponents();
  1473. });
  1474. it('registerHostsToComponent is called once', function () {
  1475. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  1476. });
  1477. it('hosts are ["h2"]', function () {
  1478. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h2']);
  1479. });
  1480. it('component is GANGLIA_MONITOR', function () {
  1481. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
  1482. });
  1483. });
  1484. var newDatabases = [
  1485. {name: 'New MySQL Database',
  1486. component: 'MYSQL_SERVER'
  1487. },
  1488. {name: 'New PostgreSQL Database',
  1489. component: 'POSTGRESQL_SERVER'
  1490. }
  1491. ];
  1492. newDatabases.forEach(function (db) {
  1493. describe('should add {0}'.format(db.component), function() {
  1494. beforeEach(function () {
  1495. installerStep8Controller.reopen({
  1496. getRegisteredHosts: function() {
  1497. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1498. },
  1499. content: {
  1500. masterComponentHosts: [
  1501. {component: 'HIVE_SERVER', hostName: 'h1'},
  1502. {component: 'HIVE_SERVER', hostName: 'h2'}
  1503. ],
  1504. services: [
  1505. Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false, serviceComponents: []})
  1506. ],
  1507. serviceConfigProperties: [
  1508. {name: 'hive_database', value: db.name}
  1509. ]
  1510. }
  1511. });
  1512. installerStep8Controller.createAdditionalHostComponents();
  1513. });
  1514. it('registerHostsToComponent is called once', function () {
  1515. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  1516. });
  1517. it('hosts are ["h1", "h2"]', function () {
  1518. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
  1519. });
  1520. it('component is ' + db.component, function () {
  1521. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal(db.component);
  1522. });
  1523. });
  1524. });
  1525. });
  1526. describe('#createAdditionalHostComponentsOnAllHosts', function () {
  1527. beforeEach(function() {
  1528. sinon.stub(installerStep8Controller, 'registerHostsToComponent', Em.K);
  1529. });
  1530. afterEach(function() {
  1531. installerStep8Controller.registerHostsToComponent.restore();
  1532. });
  1533. describe('should add components with isRequiredOnAllHosts == true (1)', function() {
  1534. beforeEach(function () {
  1535. installerStep8Controller.reopen({
  1536. getRegisteredHosts: function() {
  1537. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1538. },
  1539. content: {
  1540. services: Em.A([
  1541. Em.Object.create({
  1542. serviceName: 'ANYSERVICE', isSelected: true, isInstalled: false, serviceComponents: [
  1543. // set isRequiredOnAllHosts = true for slave and client
  1544. Em.Object.create({
  1545. componentName: 'ANYSERVICE_MASTER',
  1546. isMaster: true,
  1547. isRequiredOnAllHosts: false
  1548. }),
  1549. Em.Object.create({
  1550. componentName: 'ANYSERVICE_SLAVE',
  1551. isSlave: true,
  1552. isRequiredOnAllHosts: true
  1553. }),
  1554. Em.Object.create({
  1555. componentName: 'ANYSERVICE_SLAVE2',
  1556. isSlave: true,
  1557. isRequiredOnAllHosts: true
  1558. }),
  1559. Em.Object.create({
  1560. componentName: 'ANYSERVICE_CLIENT',
  1561. isClient: true,
  1562. isRequiredOnAllHosts: true
  1563. })
  1564. ]
  1565. })
  1566. ]),
  1567. masterComponentHosts: Em.A([
  1568. Em.Object.create({
  1569. componentName: 'ANYSERVICE_MASTER',
  1570. component: 'ANYSERVICE_MASTER',
  1571. hosts: Em.A([
  1572. Em.Object.create({hostName: 'h1', isInstalled: true})
  1573. ])
  1574. })
  1575. ]),
  1576. slaveComponentHosts: Em.A([
  1577. Em.Object.create({
  1578. componentName: 'ANYSERVICE_SLAVE',
  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: 'ANYSERVICE_SLAVE2',
  1586. hosts: Em.A([
  1587. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1588. Em.Object.create({hostName: 'h2', isInstalled: false})
  1589. ])
  1590. }),
  1591. Em.Object.create({
  1592. componentName: 'CLIENT',
  1593. hosts: Em.A([
  1594. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1595. Em.Object.create({hostName: 'h2', isInstalled: false})
  1596. ])
  1597. })
  1598. ]),
  1599. clients: Em.A([
  1600. Em.Object.create({
  1601. component_name: 'ANYSERVICE_CLIENT',
  1602. isInstalled: false,
  1603. hosts: Em.A([
  1604. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1605. Em.Object.create({hostName: 'h2', isInstalled: false})
  1606. ])
  1607. })
  1608. ])
  1609. }
  1610. });
  1611. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  1612. installerStep8Controller.get('ajaxRequestsQueue').clear();
  1613. installerStep8Controller.createAdditionalHostComponents();
  1614. });
  1615. // Any component with isRequiredOnAllHosts = true implies that
  1616. // registerHostsToComponent would be done via
  1617. // createAdditionalHostComponents() BUT NOT
  1618. // createMasterHostComponents() or createSlaveAndClientsHostComponents()
  1619. // or createAdditionalClientComponents()
  1620. it('registerHostsToComponent 1st call', function () {
  1621. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
  1622. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('ANYSERVICE_SLAVE');
  1623. });
  1624. it('registerHostsToComponent 2nd call', function () {
  1625. expect(installerStep8Controller.registerHostsToComponent.args[1][0]).to.eql(['h1', 'h2']);
  1626. expect(installerStep8Controller.registerHostsToComponent.args[1][1]).to.equal('ANYSERVICE_SLAVE2');
  1627. });
  1628. it('registerHostsToComponent 3rd call', function () {
  1629. expect(installerStep8Controller.registerHostsToComponent.args[2][0]).to.eql(['h1', 'h2']);
  1630. expect(installerStep8Controller.registerHostsToComponent.args[2][1]).to.equal('ANYSERVICE_CLIENT');
  1631. });
  1632. });
  1633. describe('should not add components with isRequiredOnAllHosts == false (2)', function() {
  1634. beforeEach(function () {
  1635. installerStep8Controller.reopen({
  1636. getRegisteredHosts: function() {
  1637. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1638. },
  1639. content: {
  1640. services: Em.A([
  1641. Em.Object.create({
  1642. serviceName: 'ANYSERVICE', isSelected: true, isInstalled: false, serviceComponents: [
  1643. // set isRequiredOnAllHosts = false for all components
  1644. Em.Object.create({
  1645. componentName: 'ANYSERVICE_MASTER',
  1646. isMaster: true,
  1647. isRequiredOnAllHosts: false
  1648. }),
  1649. Em.Object.create({
  1650. componentName: 'ANYSERVICE_SLAVE',
  1651. isSlave: true,
  1652. isRequiredOnAllHosts: false
  1653. }),
  1654. Em.Object.create({
  1655. componentName: 'ANYSERVICE_SLAVE2',
  1656. isSlave: true,
  1657. isRequiredOnAllHosts: false
  1658. }),
  1659. Em.Object.create({
  1660. componentName: 'ANYSERVICE_CLIENT',
  1661. isClient: true,
  1662. isRequiredOnAllHosts: false
  1663. })
  1664. ]
  1665. })
  1666. ]),
  1667. masterComponentHosts: Em.A([
  1668. Em.Object.create({
  1669. componentName: 'ANYSERVICE_MASTER',
  1670. component: 'ANYSERVICE_MASTER',
  1671. hosts: Em.A([
  1672. Em.Object.create({hostName: 'h1', isInstalled: true})
  1673. ])
  1674. })
  1675. ]),
  1676. slaveComponentHosts: Em.A([
  1677. Em.Object.create({
  1678. componentName: 'ANYSERVICE_SLAVE',
  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: 'ANYSERVICE_SLAVE2',
  1686. hosts: Em.A([
  1687. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1688. Em.Object.create({hostName: 'h2', isInstalled: false})
  1689. ])
  1690. }),
  1691. Em.Object.create({
  1692. componentName: 'CLIENT',
  1693. hosts: Em.A([
  1694. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1695. Em.Object.create({hostName: 'h2', isInstalled: false})
  1696. ])
  1697. })
  1698. ]),
  1699. clients: Em.A([
  1700. Em.Object.create({
  1701. component_name: 'ANYSERVICE_CLIENT',
  1702. isInstalled: false,
  1703. hosts: Em.A([
  1704. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1705. Em.Object.create({hostName: 'h2', isInstalled: false})
  1706. ])
  1707. })
  1708. ])
  1709. }
  1710. });
  1711. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  1712. installerStep8Controller.get('ajaxRequestsQueue').clear();
  1713. installerStep8Controller.createAdditionalHostComponents();
  1714. });
  1715. it('registerHostsToComponent is not called', function () {
  1716. // isRequiredOnAllHosts = false for all components, implies that
  1717. // registerHostsToComponent would be done via
  1718. // createMasterHostComponents() or createSlaveAndClientsHostComponents()
  1719. // or createAdditionalClientComponents()
  1720. // BUT NOT createAdditionalHostComponents()
  1721. expect(installerStep8Controller.registerHostsToComponent.callCount).to.equal(0);
  1722. });
  1723. });
  1724. });
  1725. describe('#createNotification', function () {
  1726. beforeEach(function () {
  1727. installerStep8Controller.clearStep();
  1728. installerStep8Controller.set('content', {controllerName: 'installerController'});
  1729. installerStep8Controller.set('configs', [
  1730. {name: 'create_notification', value: 'yes', serviceName: 'MISC', filename: 'alert_notification'},
  1731. {name: 'ambari.dispatch.recipients', value: 'to@f.c', serviceName: 'MISC', filename: 'alert_notification'},
  1732. {name: 'mail.smtp.host', value: 'h', serviceName: 'MISC', filename: 'alert_notification'},
  1733. {name: 'mail.smtp.port', value: '25', serviceName: 'MISC', filename: 'alert_notification'},
  1734. {name: 'mail.smtp.from', value: 'from@f.c', serviceName: 'MISC', filename: 'alert_notification'},
  1735. {name: 'mail.smtp.starttls.enable', value: true, serviceName: 'MISC', filename: 'alert_notification'},
  1736. {name: 'mail.smtp.startssl.enable', value: false, serviceName: 'MISC', filename: 'alert_notification'},
  1737. {name: 'smtp_use_auth', value: 'true', serviceName: 'MISC', filename: 'alert_notification'},
  1738. {name: 'ambari.dispatch.credential.username', value: 'usr', serviceName: 'MISC', filename: 'alert_notification'},
  1739. {name: 'ambari.dispatch.credential.password', value: 'pwd', serviceName: 'MISC', filename: 'alert_notification'},
  1740. {name: 'some_p', value: 'some_v', serviceName: 'MISC', filename: 'alert_notification'}
  1741. ]);
  1742. installerStep8Controller.get('ajaxRequestsQueue').clear();
  1743. });
  1744. it('should add request to queue', function () {
  1745. installerStep8Controller.createNotification();
  1746. expect(installerStep8Controller.get('ajaxRequestsQueue.queue.length')).to.equal(1);
  1747. installerStep8Controller.get('ajaxRequestsQueue').runNextRequest();
  1748. var args = testHelpers.findAjaxRequest('name', 'alerts.create_alert_notification');
  1749. expect(args).exists;
  1750. });
  1751. describe('sent data should be valid', function () {
  1752. var data;
  1753. beforeEach(function () {
  1754. installerStep8Controller.createNotification();
  1755. data = installerStep8Controller.get('ajaxRequestsQueue.queue')[0].data.data.AlertTarget;
  1756. });
  1757. it('global is true', function () {
  1758. expect(data.global).to.be.true;
  1759. });
  1760. it('notification_type is EMAIL', function () {
  1761. expect(data.notification_type).to.equal('EMAIL');
  1762. });
  1763. it('alert_states are valid', function () {
  1764. expect(data.alert_states).to.eql(['OK', 'WARNING', 'CRITICAL', 'UNKNOWN']);
  1765. });
  1766. it('ambari.dispatch.recipients is valid', function () {
  1767. expect(data.properties['ambari.dispatch.recipients']).to.eql(['to@f.c']);
  1768. });
  1769. it('mail.smtp.host is valid', function () {
  1770. expect(data.properties['mail.smtp.host']).to.equal('h');
  1771. });
  1772. it('mail.smtp.port is valid', function () {
  1773. expect(data.properties['mail.smtp.port']).to.equal('25');
  1774. });
  1775. it('mail.smtp.from is valid', function () {
  1776. expect(data.properties['mail.smtp.from']).to.equal('from@f.c');
  1777. });
  1778. it('mail.smtp.starttls.enable is true', function () {
  1779. expect(data.properties['mail.smtp.starttls.enable']).to.equal(true);
  1780. });
  1781. it('mail.smtp.startssl.enable is false', function () {
  1782. expect(data.properties['mail.smtp.startssl.enable']).to.equal(false);
  1783. });
  1784. it('ambari.dispatch.credential.username is valid', function () {
  1785. expect(data.properties['ambari.dispatch.credential.username']).to.equal('usr');
  1786. });
  1787. it('ambari.dispatch.credential.password is valid', function () {
  1788. expect(data.properties['ambari.dispatch.credential.password']).to.equal('pwd');
  1789. });
  1790. it('custom property is valid', function () {
  1791. expect(data.properties.some_p).to.equal('some_v');
  1792. });
  1793. });
  1794. });
  1795. });
  1796. App.TestAliases.testAsComputedEqualProperties(getController(), 'isAllClusterDeleteRequestsCompleted', 'clusterDeleteRequestsCompleted', 'clusterNames.length');
  1797. describe('#deleteClusterSuccessCallback', function () {
  1798. beforeEach(function () {
  1799. sinon.stub(installerStep8Controller, 'showDeleteClustersErrorPopup', Em.K);
  1800. sinon.stub(installerStep8Controller, 'startDeploy', Em.K);
  1801. installerStep8Controller.setProperties({
  1802. clusterDeleteRequestsCompleted: 0,
  1803. clusterNames: ['c0', 'c1'],
  1804. clusterDeleteErrorViews: []
  1805. });
  1806. installerStep8Controller.deleteClusterSuccessCallback();
  1807. });
  1808. afterEach(function () {
  1809. installerStep8Controller.showDeleteClustersErrorPopup.restore();
  1810. installerStep8Controller.startDeploy.restore();
  1811. });
  1812. describe('no failed requests', function () {
  1813. it('before Delete Cluster request', function () {
  1814. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1);
  1815. expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
  1816. expect(installerStep8Controller.startDeploy.called).to.be.false;
  1817. });
  1818. it('after Delete Cluster request', function () {
  1819. installerStep8Controller.deleteClusterSuccessCallback();
  1820. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
  1821. expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
  1822. expect(installerStep8Controller.startDeploy.calledOnce).to.be.true;
  1823. });
  1824. });
  1825. it('one request failed', function () {
  1826. installerStep8Controller.deleteClusterErrorCallback({}, null, null, {});
  1827. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
  1828. expect(installerStep8Controller.showDeleteClustersErrorPopup.calledOnce).to.be.true;
  1829. expect(installerStep8Controller.startDeploy.called).to.be.false;
  1830. });
  1831. });
  1832. describe('#deleteClusterErrorCallback', function () {
  1833. var request = {
  1834. status: 500,
  1835. responseText: '{"message":"Internal Server Error"}'
  1836. },
  1837. ajaxOptions = 'error',
  1838. error = 'Internal Server Error',
  1839. opt = {
  1840. url: 'api/v1/clusters/c0',
  1841. type: 'DELETE'
  1842. };
  1843. beforeEach(function () {
  1844. installerStep8Controller.setProperties({
  1845. clusterDeleteRequestsCompleted: 0,
  1846. clusterNames: ['c0', 'c1'],
  1847. clusterDeleteErrorViews: []
  1848. });
  1849. sinon.stub(installerStep8Controller, 'showDeleteClustersErrorPopup', Em.K);
  1850. installerStep8Controller.deleteClusterErrorCallback(request, ajaxOptions, error, opt);
  1851. });
  1852. afterEach(function () {
  1853. installerStep8Controller.showDeleteClustersErrorPopup.restore();
  1854. });
  1855. describe('should show error popup only if all requests are completed', function () {
  1856. it('Before Delete Cluster request fail', function () {
  1857. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1);
  1858. expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
  1859. });
  1860. it('After Delete Cluster request is failed', function () {
  1861. installerStep8Controller.deleteClusterErrorCallback(request, ajaxOptions, error, opt);
  1862. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
  1863. expect(installerStep8Controller.showDeleteClustersErrorPopup.calledOnce).to.be.true;
  1864. });
  1865. });
  1866. describe('should create error popup body view', function () {
  1867. it('One failed request', function () {
  1868. expect(installerStep8Controller.get('clusterDeleteErrorViews')).to.have.length(1);
  1869. });
  1870. it('failed request url is valid', function () {
  1871. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.url')).to.equal('api/v1/clusters/c0');
  1872. });
  1873. it('failed request type is valid', function () {
  1874. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.type')).to.equal('DELETE');
  1875. });
  1876. it('failed request status is valid', function () {
  1877. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.status')).to.equal(500);
  1878. });
  1879. it('failed request message is valid', function () {
  1880. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.message')).to.equal('Internal Server Error');
  1881. });
  1882. });
  1883. });
  1884. describe('#showDeleteClustersErrorPopup', function () {
  1885. beforeEach(function () {
  1886. installerStep8Controller.setProperties({
  1887. isSubmitDisabled: true,
  1888. isBackBtnDisabled: true
  1889. });
  1890. sinon.stub(App.ModalPopup, 'show', Em.K);
  1891. installerStep8Controller.showDeleteClustersErrorPopup();
  1892. });
  1893. afterEach(function () {
  1894. App.ModalPopup.show.restore();
  1895. });
  1896. it('should show error popup and unlock navigation', function () {
  1897. expect(installerStep8Controller.get('isSubmitDisabled')).to.be.false;
  1898. expect(installerStep8Controller.get('isBackBtnDisabled')).to.be.false;
  1899. expect(App.ModalPopup.show.calledOnce).to.be.true;
  1900. });
  1901. });
  1902. describe('#startDeploy', function () {
  1903. var stubbedNames = ['createCluster', 'createSelectedServices', 'updateConfigurations', 'createConfigurations',
  1904. 'applyConfigurationsToCluster', 'createComponents', 'registerHostsToCluster', 'createConfigurationGroups',
  1905. 'createMasterHostComponents', 'createSlaveAndClientsHostComponents', 'createAdditionalClientComponents',
  1906. 'createAdditionalHostComponents'],
  1907. cases = [
  1908. {
  1909. controllerName: 'installerController',
  1910. notExecuted: ['createAdditionalClientComponents', 'updateConfigurations'],
  1911. fileNamesToUpdate: [],
  1912. title: 'Installer, no configs to update'
  1913. },
  1914. {
  1915. controllerName: 'addHostController',
  1916. notExecuted: ['updateConfigurations', 'createConfigurations', 'applyConfigurationsToCluster', 'createAdditionalClientComponents'],
  1917. title: 'Add Host Wizard'
  1918. },
  1919. {
  1920. controllerName: 'addServiceController',
  1921. notExecuted: ['updateConfigurations'],
  1922. fileNamesToUpdate: [],
  1923. title: 'Add Service Wizard, no configs to update'
  1924. },
  1925. {
  1926. controllerName: 'addServiceController',
  1927. notExecuted: [],
  1928. fileNamesToUpdate: [''],
  1929. title: 'Add Service Wizard, some configs to be updated'
  1930. }
  1931. ];
  1932. beforeEach(function () {
  1933. sinon.stub(App, 'get').withArgs('isKerberosEnabled').returns(false);
  1934. stubbedNames.forEach(function (name) {
  1935. sinon.stub(installerStep8Controller, name, Em.K);
  1936. });
  1937. installerStep8Controller.setProperties({
  1938. serviceConfigTags: [],
  1939. content: {
  1940. controllerName: null
  1941. }
  1942. });
  1943. });
  1944. afterEach(function () {
  1945. App.get.restore();
  1946. stubbedNames.forEach(function (name) {
  1947. installerStep8Controller[name].restore();
  1948. });
  1949. installerStep8Controller.get.restore();
  1950. });
  1951. cases.forEach(function (item) {
  1952. describe(item.title, function () {
  1953. beforeEach(function () {
  1954. sinon.stub(installerStep8Controller, 'get')
  1955. .withArgs('ajaxRequestsQueue').returns({
  1956. start: Em.K
  1957. })
  1958. .withArgs('ajaxRequestsQueue.queue.length').returns(1)
  1959. .withArgs('wizardController').returns({
  1960. getDBProperty: function () {
  1961. return item.fileNamesToUpdate;
  1962. }
  1963. })
  1964. .withArgs('content.controllerName').returns(item.controllerName);
  1965. installerStep8Controller.startDeploy();
  1966. });
  1967. stubbedNames.forEach(function (name) {
  1968. it(name, function () {
  1969. expect(installerStep8Controller[name].called).to.equal(!item.notExecuted.contains(name));
  1970. });
  1971. });
  1972. });
  1973. });
  1974. });
  1975. describe('#getClientsMap', function () {
  1976. var cases = [
  1977. {
  1978. flag: 'isMaster',
  1979. result: {
  1980. c8: ['c1', 'c2'],
  1981. c9: ['c1', 'c2']
  1982. },
  1983. title: 'dependencies for masters'
  1984. },
  1985. {
  1986. flag: 'isSlave',
  1987. result: {
  1988. c8: ['c5', 'c6'],
  1989. c9: ['c5', 'c6']
  1990. },
  1991. title: 'dependencies for slaves'
  1992. },
  1993. {
  1994. flag: 'isClient',
  1995. result: {
  1996. c8: ['c9', 'c10'],
  1997. c9: ['c9', 'c10']
  1998. },
  1999. title: 'dependencies for clients'
  2000. },
  2001. {
  2002. flag: null,
  2003. result: {
  2004. c8: ['c1', 'c2', 'c5', 'c6', 'c9', 'c10'],
  2005. c9: ['c1', 'c2', 'c5', 'c6', 'c9', 'c10']
  2006. },
  2007. title: 'dependencies for all components'
  2008. }
  2009. ];
  2010. before(function () {
  2011. sinon.stub(App.StackServiceComponent, 'find').returns([
  2012. Em.Object.create({
  2013. componentName: 'c0',
  2014. isMaster: true,
  2015. dependencies: [
  2016. {
  2017. componentName: 'c1'
  2018. },
  2019. {
  2020. componentName: 'c2'
  2021. },
  2022. {
  2023. componentName: 'c4'
  2024. },
  2025. {
  2026. componentName: 'c5'
  2027. }
  2028. ]
  2029. }),
  2030. Em.Object.create({
  2031. componentName: 'c1',
  2032. isMaster: true,
  2033. dependencies: [
  2034. {
  2035. componentName: 'c4'
  2036. },
  2037. {
  2038. componentName: 'c5'
  2039. },
  2040. {
  2041. componentName: 'c8'
  2042. },
  2043. {
  2044. componentName: 'c9'
  2045. }
  2046. ]
  2047. }),
  2048. Em.Object.create({
  2049. componentName: 'c2',
  2050. isMaster: true,
  2051. dependencies: [
  2052. {
  2053. componentName: 'c1'
  2054. },
  2055. {
  2056. componentName: 'c2'
  2057. },
  2058. {
  2059. componentName: 'c8'
  2060. },
  2061. {
  2062. componentName: 'c9'
  2063. }
  2064. ]
  2065. }),
  2066. Em.Object.create({
  2067. componentName: 'c3',
  2068. isMaster: true,
  2069. dependencies: []
  2070. }),
  2071. Em.Object.create({
  2072. componentName: 'c4',
  2073. isSlave: true,
  2074. dependencies: [
  2075. {
  2076. componentName: 'c1'
  2077. },
  2078. {
  2079. componentName: 'c2'
  2080. },
  2081. {
  2082. componentName: 'c4'
  2083. },
  2084. {
  2085. componentName: 'c5'
  2086. }
  2087. ]
  2088. }),
  2089. Em.Object.create({
  2090. componentName: 'c5',
  2091. isSlave: true,
  2092. dependencies: [
  2093. {
  2094. componentName: 'c4'
  2095. },
  2096. {
  2097. componentName: 'c5'
  2098. },
  2099. {
  2100. componentName: 'c8'
  2101. },
  2102. {
  2103. componentName: 'c9'
  2104. }
  2105. ]
  2106. }),
  2107. Em.Object.create({
  2108. componentName: 'c6',
  2109. isSlave: true,
  2110. dependencies: [
  2111. {
  2112. componentName: 'c1'
  2113. },
  2114. {
  2115. componentName: 'c2'
  2116. },
  2117. {
  2118. componentName: 'c8'
  2119. },
  2120. {
  2121. componentName: 'c9'
  2122. }
  2123. ]
  2124. }),
  2125. Em.Object.create({
  2126. componentName: 'c7',
  2127. isSlave: true,
  2128. dependencies: []
  2129. }),
  2130. Em.Object.create({
  2131. componentName: 'c8',
  2132. isClient: true,
  2133. dependencies: [
  2134. {
  2135. componentName: 'c1'
  2136. },
  2137. {
  2138. componentName: 'c2'
  2139. },
  2140. {
  2141. componentName: 'c4'
  2142. },
  2143. {
  2144. componentName: 'c5'
  2145. }
  2146. ]
  2147. }),
  2148. Em.Object.create({
  2149. componentName: 'c9',
  2150. isClient: true,
  2151. dependencies: [
  2152. {
  2153. componentName: 'c4'
  2154. },
  2155. {
  2156. componentName: 'c5'
  2157. },
  2158. {
  2159. componentName: 'c8'
  2160. },
  2161. {
  2162. componentName: 'c9'
  2163. }
  2164. ]
  2165. }),
  2166. Em.Object.create({
  2167. componentName: 'c10',
  2168. isClient: true,
  2169. dependencies: [
  2170. {
  2171. componentName: 'c1'
  2172. },
  2173. {
  2174. componentName: 'c2'
  2175. },
  2176. {
  2177. componentName: 'c8'
  2178. },
  2179. {
  2180. componentName: 'c9'
  2181. }
  2182. ]
  2183. }),
  2184. Em.Object.create({
  2185. componentName: 'c11',
  2186. isClient: true,
  2187. dependencies: []
  2188. })
  2189. ]);
  2190. });
  2191. after(function () {
  2192. App.StackServiceComponent.find.restore();
  2193. });
  2194. cases.forEach(function (item) {
  2195. it(item.title, function () {
  2196. expect(installerStep8Controller.getClientsMap(item.flag)).to.eql(item.result);
  2197. });
  2198. });
  2199. });
  2200. describe('#showLoadingIndicator', function() {
  2201. beforeEach(function () {
  2202. sinon.spy(App.ModalPopup, 'show');
  2203. });
  2204. afterEach(function () {
  2205. App.ModalPopup.show.restore();
  2206. });
  2207. it('if popup doesn\'t exist should create another', function() {
  2208. installerStep8Controller.set('isSubmitDisabled', true);
  2209. installerStep8Controller.showLoadingIndicator();
  2210. expect(App.ModalPopup.show.calledOnce).to.equal(true);
  2211. });
  2212. });
  2213. describe('#updateKerberosDescriptor', function () {
  2214. var requestData = {artifactName: 'kerberos_descriptor',
  2215. data: {
  2216. artifact_data: 1234
  2217. }
  2218. };
  2219. beforeEach(function () {
  2220. sinon.stub(App.db, 'get').withArgs('KerberosWizard', 'kerberosDescriptorConfigs').returns(1234);
  2221. sinon.stub(installerStep8Controller, 'addRequestToAjaxQueue', Em.K);
  2222. sinon.stub(installerStep8Controller, 'get').withArgs('wizardController').returns(Em.Object.create({
  2223. getDBProperty: function() { return true; }
  2224. }));
  2225. });
  2226. afterEach(function () {
  2227. App.db.get.restore();
  2228. installerStep8Controller.addRequestToAjaxQueue.restore();
  2229. installerStep8Controller.get.restore();
  2230. });
  2231. it('should send request instantly', function () {
  2232. installerStep8Controller.updateKerberosDescriptor(true);
  2233. var args = testHelpers.findAjaxRequest('name', 'admin.kerberos.cluster.artifact.update');
  2234. expect(args[0]).exists;
  2235. expect(args[0].data).to.be.eql(requestData);
  2236. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.be.false;
  2237. });
  2238. it('should add request to the queue', function () {
  2239. installerStep8Controller.updateKerberosDescriptor(false);
  2240. var args = testHelpers.findAjaxRequest('name', 'admin.kerberos.cluster.artifact.update');
  2241. expect(args).not.exists;
  2242. expect(installerStep8Controller.addRequestToAjaxQueue.calledOnce).to.be.true;
  2243. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data).to.be.eql(requestData);
  2244. });
  2245. });
  2246. });