step8_test.js 76 KB

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