step8_test.js 83 KB

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