step8_test.js 82 KB

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