step8_test.js 89 KB

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