step8_test.js 81 KB

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