step8_test.js 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153
  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. it('shouldn\'t add request to queue if not installerController used', function() {
  1007. installerStep8Controller.reopen({content: {controllerName: 'addServiceController'}});
  1008. installerStep8Controller.createCluster();
  1009. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1010. });
  1011. it('App.currentStackVersion should be changed if localRepo selected', function() {
  1012. App.set('currentStackVersion', 'HDP-1.1.1');
  1013. installerStep8Controller.reopen({content: {controllerName: 'installerController', installOptions: {localRepo: true}}});
  1014. var data = {
  1015. data: JSON.stringify({ "Clusters": {"version": 'HDPLocal-1.1.1' }})
  1016. };
  1017. installerStep8Controller.createCluster();
  1018. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(data.data);
  1019. });
  1020. it('App.currentStackVersion shouldn\'t be changed if localRepo ins\'t selected', function() {
  1021. App.set('currentStackVersion', 'HDP-1.1.1');
  1022. installerStep8Controller.reopen({content: {controllerName: 'installerController', installOptions: {localRepo: false}}});
  1023. var data = {
  1024. data: JSON.stringify({ "Clusters": {"version": 'HDP-1.1.1' }})
  1025. };
  1026. installerStep8Controller.createCluster();
  1027. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.eql(data.data);
  1028. });
  1029. });
  1030. describe('#createSelectedServices', function() {
  1031. var data;
  1032. beforeEach(function () {
  1033. sinon.stub(installerStep8Controller, 'createSelectedServicesData', function () {
  1034. return data;
  1035. });
  1036. });
  1037. afterEach(function () {
  1038. installerStep8Controller.createSelectedServicesData.restore();
  1039. });
  1040. it('shouldn\'t do nothing if no data', function() {
  1041. data = [];
  1042. installerStep8Controller.createSelectedServices();
  1043. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1044. });
  1045. it('should call addRequestToAjaxQueue with computed data', function() {
  1046. data = [
  1047. {"ServiceInfo": { "service_name": 's1' }},
  1048. {"ServiceInfo": { "service_name": 's2' }},
  1049. {"ServiceInfo": { "service_name": 's3' }}
  1050. ];
  1051. installerStep8Controller.createSelectedServices();
  1052. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data));
  1053. });
  1054. });
  1055. describe('#registerHostsToCluster', function() {
  1056. var data;
  1057. beforeEach(function () {
  1058. sinon.stub(installerStep8Controller, 'createRegisterHostData', function () {
  1059. return data;
  1060. });
  1061. });
  1062. afterEach(function () {
  1063. installerStep8Controller.createRegisterHostData.restore();
  1064. });
  1065. it('shouldn\'t do nothing if no data', function() {
  1066. data = [];
  1067. installerStep8Controller.registerHostsToCluster();
  1068. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1069. });
  1070. it('should call addRequestToAjaxQueue with computed data', function() {
  1071. data = [
  1072. {"Hosts": { "host_name": 'h1'}},
  1073. {"Hosts": { "host_name": 'h3'}}
  1074. ];
  1075. installerStep8Controller.registerHostsToCluster();
  1076. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data));
  1077. });
  1078. });
  1079. describe('#registerHostsToComponent', function() {
  1080. it('shouldn\'t do request if no hosts provided', function() {
  1081. installerStep8Controller.registerHostsToComponent([]);
  1082. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1083. });
  1084. it('should do request if hostNames are provided', function() {
  1085. var hostNames = ['h1', 'h2'],
  1086. componentName = 'c1';
  1087. installerStep8Controller.registerHostsToComponent(hostNames, componentName);
  1088. var data = JSON.parse(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data);
  1089. expect(data.RequestInfo.query).to.equal('Hosts/host_name=h1|Hosts/host_name=h2');
  1090. expect(data.Body.host_components[0].HostRoles.component_name).to.equal('c1');
  1091. });
  1092. });
  1093. describe('#applyConfigurationsToCluster', function() {
  1094. it('should call addRequestToAjaxQueue', function() {
  1095. var serviceConfigTags = [
  1096. {
  1097. type: 'hdfs',
  1098. tag: 'tag1',
  1099. properties: {
  1100. 'prop1': 'value1'
  1101. }
  1102. }
  1103. ],
  1104. data = '['+JSON.stringify({
  1105. Clusters: {
  1106. desired_config: [serviceConfigTags[0]]
  1107. }
  1108. })+']';
  1109. installerStep8Controller.reopen({
  1110. installedServices: [
  1111. Em.Object.create({
  1112. isSelected: true,
  1113. isInstalled: false,
  1114. configTypesRendered: {hdfs:'tag1'}
  1115. })
  1116. ], selectedServices: []
  1117. });
  1118. installerStep8Controller.applyConfigurationsToCluster(serviceConfigTags);
  1119. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(data);
  1120. });
  1121. });
  1122. describe('#newServiceComponentErrorCallback', function() {
  1123. it('should add request for new component', function() {
  1124. var serviceName = 's1',
  1125. componentName = 'c1';
  1126. installerStep8Controller.newServiceComponentErrorCallback({}, {}, '', {}, {serviceName: serviceName, componentName: componentName});
  1127. var data = JSON.parse(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data);
  1128. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.serviceName).to.equal(serviceName);
  1129. expect(data.components[0].ServiceComponentInfo.component_name).to.equal(componentName);
  1130. });
  1131. });
  1132. describe('#createAdditionalHostComponents', function() {
  1133. beforeEach(function() {
  1134. sinon.stub(installerStep8Controller, 'registerHostsToComponent', Em.K);
  1135. });
  1136. afterEach(function() {
  1137. installerStep8Controller.registerHostsToComponent.restore();
  1138. });
  1139. describe('should add components with isRequiredOnAllHosts == true (1)', function() {
  1140. beforeEach(function () {
  1141. installerStep8Controller.reopen({
  1142. getRegisteredHosts: function() {
  1143. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1144. },
  1145. content: {
  1146. services: [
  1147. Em.Object.create({
  1148. serviceName: 'GANGLIA', isSelected: true, isInstalled: false, serviceComponents: [
  1149. Em.Object.create({
  1150. componentName: 'GANGLIA_MONITOR',
  1151. isRequiredOnAllHosts: true
  1152. }),
  1153. Em.Object.create({
  1154. componentName: 'GANGLIA_SERVER',
  1155. isRequiredOnAllHosts: false
  1156. })
  1157. ]
  1158. })
  1159. ]
  1160. }
  1161. });
  1162. installerStep8Controller.createAdditionalHostComponents();
  1163. });
  1164. it('registerHostsToComponent is called once', function () {
  1165. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  1166. });
  1167. it('hosts are ["h1", "h2"]', function () {
  1168. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
  1169. });
  1170. it('component is GANGLIA_MONITOR', function () {
  1171. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
  1172. });
  1173. });
  1174. describe('should add components with isRequiredOnAllHosts == true (2)', function() {
  1175. beforeEach(function () {
  1176. installerStep8Controller.reopen({
  1177. getRegisteredHosts: function() {
  1178. return [{hostName: 'h1', isInstalled: true}, {hostName: 'h2', isInstalled: false}];
  1179. },
  1180. content: {
  1181. services: [
  1182. Em.Object.create({
  1183. serviceName: 'GANGLIA', isSelected: true, isInstalled: true, serviceComponents: [
  1184. Em.Object.create({
  1185. componentName: 'GANGLIA_MONITOR',
  1186. isRequiredOnAllHosts: true
  1187. }),
  1188. Em.Object.create({
  1189. componentName: 'GANGLIA_SERVER',
  1190. isRequiredOnAllHosts: false
  1191. })
  1192. ]
  1193. })
  1194. ]
  1195. }
  1196. });
  1197. installerStep8Controller.createAdditionalHostComponents();
  1198. });
  1199. it('registerHostsToComponent is called once', function () {
  1200. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  1201. });
  1202. it('hosts are ["h2"]', function () {
  1203. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h2']);
  1204. });
  1205. it('component is GANGLIA_MONITOR', function () {
  1206. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
  1207. });
  1208. });
  1209. var newDatabases = [
  1210. {
  1211. name: 'New MySQL Database',
  1212. component: 'MYSQL_SERVER',
  1213. expectedHosts: ['h1']
  1214. },
  1215. {
  1216. name: 'New PostgreSQL Database',
  1217. component: 'POSTGRESQL_SERVER',
  1218. expectedHosts: ['h2']
  1219. }
  1220. ];
  1221. newDatabases.forEach(function (db) {
  1222. describe('should add {0}'.format(db.component), function() {
  1223. beforeEach(function () {
  1224. installerStep8Controller.reopen({
  1225. getRegisteredHosts: function() {
  1226. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1227. },
  1228. content: {
  1229. masterComponentHosts: [
  1230. {component: 'HIVE_METASTORE', hostName: 'h1'},
  1231. {component: 'HIVE_SERVER', hostName: 'h2'}
  1232. ],
  1233. services: [
  1234. Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false, serviceComponents: []})
  1235. ],
  1236. serviceConfigProperties: [
  1237. {name: 'hive_database', value: db.name}
  1238. ]
  1239. }
  1240. });
  1241. installerStep8Controller.createAdditionalHostComponents();
  1242. });
  1243. it('registerHostsToComponent is called once', function () {
  1244. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  1245. });
  1246. it('hosts are ' + db.expectedHosts, function () {
  1247. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(db.expectedHosts);
  1248. });
  1249. it('component is ' + db.component, function () {
  1250. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal(db.component);
  1251. });
  1252. });
  1253. });
  1254. });
  1255. describe('#createAdditionalHostComponentsOnAllHosts', function () {
  1256. beforeEach(function() {
  1257. sinon.stub(installerStep8Controller, 'registerHostsToComponent', Em.K);
  1258. });
  1259. afterEach(function() {
  1260. installerStep8Controller.registerHostsToComponent.restore();
  1261. });
  1262. describe('should add components with isRequiredOnAllHosts == true (1)', function() {
  1263. beforeEach(function () {
  1264. installerStep8Controller.reopen({
  1265. getRegisteredHosts: function() {
  1266. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1267. },
  1268. content: {
  1269. services: Em.A([
  1270. Em.Object.create({
  1271. serviceName: 'ANYSERVICE', isSelected: true, isInstalled: false, serviceComponents: [
  1272. // set isRequiredOnAllHosts = true for slave and client
  1273. Em.Object.create({
  1274. componentName: 'ANYSERVICE_MASTER',
  1275. isMaster: true,
  1276. isRequiredOnAllHosts: false
  1277. }),
  1278. Em.Object.create({
  1279. componentName: 'ANYSERVICE_SLAVE',
  1280. isSlave: true,
  1281. isRequiredOnAllHosts: true
  1282. }),
  1283. Em.Object.create({
  1284. componentName: 'ANYSERVICE_SLAVE2',
  1285. isSlave: true,
  1286. isRequiredOnAllHosts: true
  1287. }),
  1288. Em.Object.create({
  1289. componentName: 'ANYSERVICE_CLIENT',
  1290. isClient: true,
  1291. isRequiredOnAllHosts: true
  1292. })
  1293. ]
  1294. })
  1295. ]),
  1296. masterComponentHosts: Em.A([
  1297. Em.Object.create({
  1298. componentName: 'ANYSERVICE_MASTER',
  1299. component: 'ANYSERVICE_MASTER',
  1300. hosts: Em.A([
  1301. Em.Object.create({hostName: 'h1', isInstalled: true})
  1302. ])
  1303. })
  1304. ]),
  1305. slaveComponentHosts: Em.A([
  1306. Em.Object.create({
  1307. componentName: 'ANYSERVICE_SLAVE',
  1308. hosts: Em.A([
  1309. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1310. Em.Object.create({hostName: 'h2', isInstalled: false})
  1311. ])
  1312. }),
  1313. Em.Object.create({
  1314. componentName: 'ANYSERVICE_SLAVE2',
  1315. hosts: Em.A([
  1316. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1317. Em.Object.create({hostName: 'h2', isInstalled: false})
  1318. ])
  1319. }),
  1320. Em.Object.create({
  1321. componentName: 'CLIENT',
  1322. hosts: Em.A([
  1323. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1324. Em.Object.create({hostName: 'h2', isInstalled: false})
  1325. ])
  1326. })
  1327. ]),
  1328. clients: Em.A([
  1329. Em.Object.create({
  1330. component_name: 'ANYSERVICE_CLIENT',
  1331. isInstalled: false,
  1332. hosts: Em.A([
  1333. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1334. Em.Object.create({hostName: 'h2', isInstalled: false})
  1335. ])
  1336. })
  1337. ])
  1338. }
  1339. });
  1340. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  1341. installerStep8Controller.get('ajaxRequestsQueue').clear();
  1342. installerStep8Controller.createAdditionalHostComponents();
  1343. });
  1344. // Any component with isRequiredOnAllHosts = true implies that
  1345. // registerHostsToComponent would be done via
  1346. // createAdditionalHostComponents() BUT NOT
  1347. // createMasterHostComponents() or createSlaveAndClientsHostComponents()
  1348. // or createAdditionalClientComponents()
  1349. it('registerHostsToComponent 1st call', function () {
  1350. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
  1351. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('ANYSERVICE_SLAVE');
  1352. });
  1353. it('registerHostsToComponent 2nd call', function () {
  1354. expect(installerStep8Controller.registerHostsToComponent.args[1][0]).to.eql(['h1', 'h2']);
  1355. expect(installerStep8Controller.registerHostsToComponent.args[1][1]).to.equal('ANYSERVICE_SLAVE2');
  1356. });
  1357. it('registerHostsToComponent 3rd call', function () {
  1358. expect(installerStep8Controller.registerHostsToComponent.args[2][0]).to.eql(['h1', 'h2']);
  1359. expect(installerStep8Controller.registerHostsToComponent.args[2][1]).to.equal('ANYSERVICE_CLIENT');
  1360. });
  1361. });
  1362. describe('should not add components with isRequiredOnAllHosts == false (2)', function() {
  1363. beforeEach(function () {
  1364. installerStep8Controller.reopen({
  1365. getRegisteredHosts: function() {
  1366. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1367. },
  1368. content: {
  1369. services: Em.A([
  1370. Em.Object.create({
  1371. serviceName: 'ANYSERVICE', isSelected: true, isInstalled: false, serviceComponents: [
  1372. // set isRequiredOnAllHosts = false for all components
  1373. Em.Object.create({
  1374. componentName: 'ANYSERVICE_MASTER',
  1375. isMaster: true,
  1376. isRequiredOnAllHosts: false
  1377. }),
  1378. Em.Object.create({
  1379. componentName: 'ANYSERVICE_SLAVE',
  1380. isSlave: true,
  1381. isRequiredOnAllHosts: false
  1382. }),
  1383. Em.Object.create({
  1384. componentName: 'ANYSERVICE_SLAVE2',
  1385. isSlave: true,
  1386. isRequiredOnAllHosts: false
  1387. }),
  1388. Em.Object.create({
  1389. componentName: 'ANYSERVICE_CLIENT',
  1390. isClient: true,
  1391. isRequiredOnAllHosts: false
  1392. })
  1393. ]
  1394. })
  1395. ]),
  1396. masterComponentHosts: Em.A([
  1397. Em.Object.create({
  1398. componentName: 'ANYSERVICE_MASTER',
  1399. component: 'ANYSERVICE_MASTER',
  1400. hosts: Em.A([
  1401. Em.Object.create({hostName: 'h1', isInstalled: true})
  1402. ])
  1403. })
  1404. ]),
  1405. slaveComponentHosts: Em.A([
  1406. Em.Object.create({
  1407. componentName: 'ANYSERVICE_SLAVE',
  1408. hosts: Em.A([
  1409. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1410. Em.Object.create({hostName: 'h2', isInstalled: false})
  1411. ])
  1412. }),
  1413. Em.Object.create({
  1414. componentName: 'ANYSERVICE_SLAVE2',
  1415. hosts: Em.A([
  1416. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1417. Em.Object.create({hostName: 'h2', isInstalled: false})
  1418. ])
  1419. }),
  1420. Em.Object.create({
  1421. componentName: 'CLIENT',
  1422. hosts: Em.A([
  1423. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1424. Em.Object.create({hostName: 'h2', isInstalled: false})
  1425. ])
  1426. })
  1427. ]),
  1428. clients: Em.A([
  1429. Em.Object.create({
  1430. component_name: 'ANYSERVICE_CLIENT',
  1431. isInstalled: false,
  1432. hosts: Em.A([
  1433. Em.Object.create({hostName: 'h1', isInstalled: false}),
  1434. Em.Object.create({hostName: 'h2', isInstalled: false})
  1435. ])
  1436. })
  1437. ])
  1438. }
  1439. });
  1440. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  1441. installerStep8Controller.get('ajaxRequestsQueue').clear();
  1442. installerStep8Controller.createAdditionalHostComponents();
  1443. });
  1444. it('registerHostsToComponent is not called', function () {
  1445. // isRequiredOnAllHosts = false for all components, implies that
  1446. // registerHostsToComponent would be done via
  1447. // createMasterHostComponents() or createSlaveAndClientsHostComponents()
  1448. // or createAdditionalClientComponents()
  1449. // BUT NOT createAdditionalHostComponents()
  1450. expect(installerStep8Controller.registerHostsToComponent.callCount).to.equal(0);
  1451. });
  1452. });
  1453. });
  1454. describe('#createNotification', function () {
  1455. beforeEach(function () {
  1456. installerStep8Controller.clearStep();
  1457. installerStep8Controller.set('content', {controllerName: 'installerController'});
  1458. installerStep8Controller.set('configs', [
  1459. {name: 'create_notification', value: 'yes', serviceName: 'MISC', filename: 'alert_notification'},
  1460. {name: 'ambari.dispatch.recipients', value: 'to@f.c', serviceName: 'MISC', filename: 'alert_notification'},
  1461. {name: 'mail.smtp.host', value: 'h', serviceName: 'MISC', filename: 'alert_notification'},
  1462. {name: 'mail.smtp.port', value: '25', serviceName: 'MISC', filename: 'alert_notification'},
  1463. {name: 'mail.smtp.from', value: 'from@f.c', serviceName: 'MISC', filename: 'alert_notification'},
  1464. {name: 'mail.smtp.starttls.enable', value: true, serviceName: 'MISC', filename: 'alert_notification'},
  1465. {name: 'mail.smtp.startssl.enable', value: false, serviceName: 'MISC', filename: 'alert_notification'},
  1466. {name: 'smtp_use_auth', value: 'true', serviceName: 'MISC', filename: 'alert_notification'},
  1467. {name: 'ambari.dispatch.credential.username', value: 'usr', serviceName: 'MISC', filename: 'alert_notification'},
  1468. {name: 'ambari.dispatch.credential.password', value: 'pwd', serviceName: 'MISC', filename: 'alert_notification'},
  1469. {name: 'some_p', value: 'some_v', serviceName: 'MISC', filename: 'alert_notification'}
  1470. ]);
  1471. installerStep8Controller.get('ajaxRequestsQueue').clear();
  1472. });
  1473. it('should add request to queue', function () {
  1474. installerStep8Controller.createNotification();
  1475. expect(installerStep8Controller.get('ajaxRequestsQueue.queue.length')).to.equal(1);
  1476. installerStep8Controller.get('ajaxRequestsQueue').runNextRequest();
  1477. var args = testHelpers.findAjaxRequest('name', 'alerts.create_alert_notification');
  1478. expect(args).exists;
  1479. });
  1480. describe('sent data should be valid', function () {
  1481. var data;
  1482. beforeEach(function () {
  1483. installerStep8Controller.createNotification();
  1484. data = installerStep8Controller.get('ajaxRequestsQueue.queue')[0].data.data.AlertTarget;
  1485. });
  1486. it('global is true', function () {
  1487. expect(data.global).to.be.true;
  1488. });
  1489. it('notification_type is EMAIL', function () {
  1490. expect(data.notification_type).to.equal('EMAIL');
  1491. });
  1492. it('alert_states are valid', function () {
  1493. expect(data.alert_states).to.eql(['OK', 'WARNING', 'CRITICAL', 'UNKNOWN']);
  1494. });
  1495. it('ambari.dispatch.recipients is valid', function () {
  1496. expect(data.properties['ambari.dispatch.recipients']).to.eql(['to@f.c']);
  1497. });
  1498. it('mail.smtp.host is valid', function () {
  1499. expect(data.properties['mail.smtp.host']).to.equal('h');
  1500. });
  1501. it('mail.smtp.port is valid', function () {
  1502. expect(data.properties['mail.smtp.port']).to.equal('25');
  1503. });
  1504. it('mail.smtp.from is valid', function () {
  1505. expect(data.properties['mail.smtp.from']).to.equal('from@f.c');
  1506. });
  1507. it('mail.smtp.starttls.enable is true', function () {
  1508. expect(data.properties['mail.smtp.starttls.enable']).to.equal(true);
  1509. });
  1510. it('mail.smtp.startssl.enable is false', function () {
  1511. expect(data.properties['mail.smtp.startssl.enable']).to.equal(false);
  1512. });
  1513. it('ambari.dispatch.credential.username is valid', function () {
  1514. expect(data.properties['ambari.dispatch.credential.username']).to.equal('usr');
  1515. });
  1516. it('ambari.dispatch.credential.password is valid', function () {
  1517. expect(data.properties['ambari.dispatch.credential.password']).to.equal('pwd');
  1518. });
  1519. it('custom property is valid', function () {
  1520. expect(data.properties.some_p).to.equal('some_v');
  1521. });
  1522. });
  1523. });
  1524. });
  1525. App.TestAliases.testAsComputedEqualProperties(getController(), 'isAllClusterDeleteRequestsCompleted', 'clusterDeleteRequestsCompleted', 'clusterNames.length');
  1526. describe('#deleteClusterSuccessCallback', function () {
  1527. beforeEach(function () {
  1528. sinon.stub(installerStep8Controller, 'showDeleteClustersErrorPopup', Em.K);
  1529. sinon.stub(installerStep8Controller, 'startDeploy', Em.K);
  1530. installerStep8Controller.setProperties({
  1531. clusterDeleteRequestsCompleted: 0,
  1532. clusterNames: ['c0', 'c1'],
  1533. clusterDeleteErrorViews: []
  1534. });
  1535. installerStep8Controller.deleteClusterSuccessCallback();
  1536. });
  1537. afterEach(function () {
  1538. installerStep8Controller.showDeleteClustersErrorPopup.restore();
  1539. installerStep8Controller.startDeploy.restore();
  1540. });
  1541. describe('no failed requests', function () {
  1542. it('before Delete Cluster request', function () {
  1543. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1);
  1544. expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
  1545. expect(installerStep8Controller.startDeploy.called).to.be.false;
  1546. });
  1547. it('after Delete Cluster request', function () {
  1548. installerStep8Controller.deleteClusterSuccessCallback();
  1549. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
  1550. expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
  1551. expect(installerStep8Controller.startDeploy.calledOnce).to.be.true;
  1552. });
  1553. });
  1554. it('one request failed', function () {
  1555. installerStep8Controller.deleteClusterErrorCallback({}, null, null, {});
  1556. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
  1557. expect(installerStep8Controller.showDeleteClustersErrorPopup.calledOnce).to.be.true;
  1558. expect(installerStep8Controller.startDeploy.called).to.be.false;
  1559. });
  1560. });
  1561. describe('#deleteClusterErrorCallback', function () {
  1562. var request = {
  1563. status: 500,
  1564. responseText: '{"message":"Internal Server Error"}'
  1565. },
  1566. ajaxOptions = 'error',
  1567. error = 'Internal Server Error',
  1568. opt = {
  1569. url: 'api/v1/clusters/c0',
  1570. type: 'DELETE'
  1571. };
  1572. beforeEach(function () {
  1573. installerStep8Controller.setProperties({
  1574. clusterDeleteRequestsCompleted: 0,
  1575. clusterNames: ['c0', 'c1'],
  1576. clusterDeleteErrorViews: []
  1577. });
  1578. sinon.stub(installerStep8Controller, 'showDeleteClustersErrorPopup', Em.K);
  1579. installerStep8Controller.deleteClusterErrorCallback(request, ajaxOptions, error, opt);
  1580. });
  1581. afterEach(function () {
  1582. installerStep8Controller.showDeleteClustersErrorPopup.restore();
  1583. });
  1584. describe('should show error popup only if all requests are completed', function () {
  1585. it('Before Delete Cluster request fail', function () {
  1586. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1);
  1587. expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
  1588. });
  1589. it('After Delete Cluster request is failed', function () {
  1590. installerStep8Controller.deleteClusterErrorCallback(request, ajaxOptions, error, opt);
  1591. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
  1592. expect(installerStep8Controller.showDeleteClustersErrorPopup.calledOnce).to.be.true;
  1593. });
  1594. });
  1595. describe('should create error popup body view', function () {
  1596. it('One failed request', function () {
  1597. expect(installerStep8Controller.get('clusterDeleteErrorViews')).to.have.length(1);
  1598. });
  1599. it('failed request url is valid', function () {
  1600. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.url')).to.equal('api/v1/clusters/c0');
  1601. });
  1602. it('failed request type is valid', function () {
  1603. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.type')).to.equal('DELETE');
  1604. });
  1605. it('failed request status is valid', function () {
  1606. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.status')).to.equal(500);
  1607. });
  1608. it('failed request message is valid', function () {
  1609. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.message')).to.equal('Internal Server Error');
  1610. });
  1611. });
  1612. });
  1613. describe('#showDeleteClustersErrorPopup', function () {
  1614. beforeEach(function () {
  1615. installerStep8Controller.setProperties({
  1616. isSubmitDisabled: true,
  1617. isBackBtnDisabled: true
  1618. });
  1619. sinon.stub(App.ModalPopup, 'show', Em.K);
  1620. installerStep8Controller.showDeleteClustersErrorPopup();
  1621. });
  1622. afterEach(function () {
  1623. App.ModalPopup.show.restore();
  1624. });
  1625. it('should show error popup and unlock navigation', function () {
  1626. expect(installerStep8Controller.get('isSubmitDisabled')).to.be.false;
  1627. expect(installerStep8Controller.get('isBackBtnDisabled')).to.be.false;
  1628. expect(App.ModalPopup.show.calledOnce).to.be.true;
  1629. });
  1630. });
  1631. describe('#startDeploy', function () {
  1632. var stubbedNames = ['createCluster', 'createSelectedServices', 'createConfigurations',
  1633. 'applyConfigurationsToCluster', 'createComponents', 'registerHostsToCluster', 'createConfigurationGroups',
  1634. 'createMasterHostComponents', 'createSlaveAndClientsHostComponents', 'createAdditionalClientComponents',
  1635. 'createAdditionalHostComponents'],
  1636. cases = [
  1637. {
  1638. controllerName: 'installerController',
  1639. notExecuted: ['createAdditionalClientComponents'],
  1640. fileNamesToUpdate: [],
  1641. title: 'Installer, no configs to update'
  1642. },
  1643. {
  1644. controllerName: 'addHostController',
  1645. notExecuted: ['createConfigurations', 'applyConfigurationsToCluster', 'createAdditionalClientComponents'],
  1646. title: 'Add Host Wizard'
  1647. },
  1648. {
  1649. controllerName: 'addServiceController',
  1650. notExecuted: ['updateConfigurations'],
  1651. fileNamesToUpdate: [],
  1652. title: 'Add Service Wizard, no configs to update'
  1653. },
  1654. {
  1655. controllerName: 'addServiceController',
  1656. notExecuted: [],
  1657. fileNamesToUpdate: [''],
  1658. title: 'Add Service Wizard, some configs to be updated'
  1659. }
  1660. ];
  1661. beforeEach(function () {
  1662. sinon.stub(App, 'get').withArgs('isKerberosEnabled').returns(false);
  1663. stubbedNames.forEach(function (name) {
  1664. sinon.stub(installerStep8Controller, name, Em.K);
  1665. });
  1666. installerStep8Controller.setProperties({
  1667. serviceConfigTags: [],
  1668. content: {
  1669. controllerName: null
  1670. }
  1671. });
  1672. });
  1673. afterEach(function () {
  1674. App.get.restore();
  1675. stubbedNames.forEach(function (name) {
  1676. installerStep8Controller[name].restore();
  1677. });
  1678. installerStep8Controller.get.restore();
  1679. });
  1680. cases.forEach(function (item) {
  1681. describe(item.title, function () {
  1682. beforeEach(function () {
  1683. sinon.stub(installerStep8Controller, 'get')
  1684. .withArgs('ajaxRequestsQueue').returns({
  1685. start: Em.K
  1686. })
  1687. .withArgs('ajaxRequestsQueue.queue.length').returns(1)
  1688. .withArgs('wizardController').returns({
  1689. getDBProperty: function () {
  1690. return item.fileNamesToUpdate;
  1691. }
  1692. })
  1693. .withArgs('content.controllerName').returns(item.controllerName);
  1694. installerStep8Controller.startDeploy();
  1695. });
  1696. stubbedNames.forEach(function (name) {
  1697. it(name, function () {
  1698. expect(installerStep8Controller[name].called).to.equal(!item.notExecuted.contains(name));
  1699. });
  1700. });
  1701. });
  1702. });
  1703. });
  1704. describe('#getClientsMap', function () {
  1705. var cases = [
  1706. {
  1707. flag: 'isMaster',
  1708. result: {
  1709. c8: ['c1', 'c2'],
  1710. c9: ['c1', 'c2']
  1711. },
  1712. title: 'dependencies for masters'
  1713. },
  1714. {
  1715. flag: 'isSlave',
  1716. result: {
  1717. c8: ['c5', 'c6'],
  1718. c9: ['c5', 'c6']
  1719. },
  1720. title: 'dependencies for slaves'
  1721. },
  1722. {
  1723. flag: 'isClient',
  1724. result: {
  1725. c8: ['c9', 'c10'],
  1726. c9: ['c9', 'c10']
  1727. },
  1728. title: 'dependencies for clients'
  1729. },
  1730. {
  1731. flag: null,
  1732. result: {
  1733. c8: ['c1', 'c2', 'c5', 'c6', 'c9', 'c10'],
  1734. c9: ['c1', 'c2', 'c5', 'c6', 'c9', 'c10']
  1735. },
  1736. title: 'dependencies for all components'
  1737. }
  1738. ];
  1739. before(function () {
  1740. sinon.stub(App.StackServiceComponent, 'find').returns([
  1741. Em.Object.create({
  1742. componentName: 'c0',
  1743. isMaster: true,
  1744. dependencies: [
  1745. {
  1746. componentName: 'c1'
  1747. },
  1748. {
  1749. componentName: 'c2'
  1750. },
  1751. {
  1752. componentName: 'c4'
  1753. },
  1754. {
  1755. componentName: 'c5'
  1756. }
  1757. ]
  1758. }),
  1759. Em.Object.create({
  1760. componentName: 'c1',
  1761. isMaster: true,
  1762. dependencies: [
  1763. {
  1764. componentName: 'c4'
  1765. },
  1766. {
  1767. componentName: 'c5'
  1768. },
  1769. {
  1770. componentName: 'c8'
  1771. },
  1772. {
  1773. componentName: 'c9'
  1774. }
  1775. ]
  1776. }),
  1777. Em.Object.create({
  1778. componentName: 'c2',
  1779. isMaster: true,
  1780. dependencies: [
  1781. {
  1782. componentName: 'c1'
  1783. },
  1784. {
  1785. componentName: 'c2'
  1786. },
  1787. {
  1788. componentName: 'c8'
  1789. },
  1790. {
  1791. componentName: 'c9'
  1792. }
  1793. ]
  1794. }),
  1795. Em.Object.create({
  1796. componentName: 'c3',
  1797. isMaster: true,
  1798. dependencies: []
  1799. }),
  1800. Em.Object.create({
  1801. componentName: 'c4',
  1802. isSlave: true,
  1803. dependencies: [
  1804. {
  1805. componentName: 'c1'
  1806. },
  1807. {
  1808. componentName: 'c2'
  1809. },
  1810. {
  1811. componentName: 'c4'
  1812. },
  1813. {
  1814. componentName: 'c5'
  1815. }
  1816. ]
  1817. }),
  1818. Em.Object.create({
  1819. componentName: 'c5',
  1820. isSlave: true,
  1821. dependencies: [
  1822. {
  1823. componentName: 'c4'
  1824. },
  1825. {
  1826. componentName: 'c5'
  1827. },
  1828. {
  1829. componentName: 'c8'
  1830. },
  1831. {
  1832. componentName: 'c9'
  1833. }
  1834. ]
  1835. }),
  1836. Em.Object.create({
  1837. componentName: 'c6',
  1838. isSlave: true,
  1839. dependencies: [
  1840. {
  1841. componentName: 'c1'
  1842. },
  1843. {
  1844. componentName: 'c2'
  1845. },
  1846. {
  1847. componentName: 'c8'
  1848. },
  1849. {
  1850. componentName: 'c9'
  1851. }
  1852. ]
  1853. }),
  1854. Em.Object.create({
  1855. componentName: 'c7',
  1856. isSlave: true,
  1857. dependencies: []
  1858. }),
  1859. Em.Object.create({
  1860. componentName: 'c8',
  1861. isClient: true,
  1862. dependencies: [
  1863. {
  1864. componentName: 'c1'
  1865. },
  1866. {
  1867. componentName: 'c2'
  1868. },
  1869. {
  1870. componentName: 'c4'
  1871. },
  1872. {
  1873. componentName: 'c5'
  1874. }
  1875. ]
  1876. }),
  1877. Em.Object.create({
  1878. componentName: 'c9',
  1879. isClient: true,
  1880. dependencies: [
  1881. {
  1882. componentName: 'c4'
  1883. },
  1884. {
  1885. componentName: 'c5'
  1886. },
  1887. {
  1888. componentName: 'c8'
  1889. },
  1890. {
  1891. componentName: 'c9'
  1892. }
  1893. ]
  1894. }),
  1895. Em.Object.create({
  1896. componentName: 'c10',
  1897. isClient: true,
  1898. dependencies: [
  1899. {
  1900. componentName: 'c1'
  1901. },
  1902. {
  1903. componentName: 'c2'
  1904. },
  1905. {
  1906. componentName: 'c8'
  1907. },
  1908. {
  1909. componentName: 'c9'
  1910. }
  1911. ]
  1912. }),
  1913. Em.Object.create({
  1914. componentName: 'c11',
  1915. isClient: true,
  1916. dependencies: []
  1917. })
  1918. ]);
  1919. });
  1920. after(function () {
  1921. App.StackServiceComponent.find.restore();
  1922. });
  1923. cases.forEach(function (item) {
  1924. it(item.title, function () {
  1925. expect(installerStep8Controller.getClientsMap(item.flag)).to.eql(item.result);
  1926. });
  1927. });
  1928. });
  1929. describe('#showLoadingIndicator', function() {
  1930. beforeEach(function () {
  1931. sinon.spy(App.ModalPopup, 'show');
  1932. });
  1933. afterEach(function () {
  1934. App.ModalPopup.show.restore();
  1935. });
  1936. it('if popup doesn\'t exist should create another', function() {
  1937. installerStep8Controller.set('isSubmitDisabled', true);
  1938. installerStep8Controller.showLoadingIndicator();
  1939. expect(App.ModalPopup.show.calledOnce).to.equal(true);
  1940. });
  1941. });
  1942. describe('#updateKerberosDescriptor', function () {
  1943. var requestData = {artifactName: 'kerberos_descriptor',
  1944. data: {
  1945. artifact_data: 1234
  1946. }
  1947. };
  1948. beforeEach(function () {
  1949. sinon.stub(App.db, 'get').withArgs('KerberosWizard', 'kerberosDescriptorConfigs').returns(1234);
  1950. sinon.stub(installerStep8Controller, 'addRequestToAjaxQueue', Em.K);
  1951. sinon.stub(installerStep8Controller, 'get').withArgs('wizardController').returns(Em.Object.create({
  1952. getDBProperty: function() { return true; }
  1953. }));
  1954. });
  1955. afterEach(function () {
  1956. App.db.get.restore();
  1957. installerStep8Controller.addRequestToAjaxQueue.restore();
  1958. installerStep8Controller.get.restore();
  1959. });
  1960. it('should send request instantly', function () {
  1961. installerStep8Controller.updateKerberosDescriptor(true);
  1962. var args = testHelpers.findAjaxRequest('name', 'admin.kerberos.cluster.artifact.update');
  1963. expect(args[0]).exists;
  1964. expect(args[0].data).to.be.eql(requestData);
  1965. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.be.false;
  1966. });
  1967. it('should add request to the queue', function () {
  1968. installerStep8Controller.updateKerberosDescriptor(false);
  1969. var args = testHelpers.findAjaxRequest('name', 'admin.kerberos.cluster.artifact.update');
  1970. expect(args).not.exists;
  1971. expect(installerStep8Controller.addRequestToAjaxQueue.calledOnce).to.be.true;
  1972. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data).to.be.eql(requestData);
  1973. });
  1974. });
  1975. });