step8_test.js 94 KB

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