step8_test.js 95 KB

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