step8_test.js 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. var modelSetup = require('test/init_model_test');
  20. require('utils/ajax/ajax_queue');
  21. require('controllers/main/admin/security');
  22. require('controllers/main/service/info/configs');
  23. require('controllers/wizard/step8_controller');
  24. var installerStep8Controller, configurationController;
  25. describe('App.WizardStep8Controller', function () {
  26. var configs = Em.A([
  27. Em.Object.create({filename: 'hdfs-site.xml', name: 'p1', value: 'v1'}),
  28. Em.Object.create({filename: 'hdfs-site.xml', name: 'p2', value: 'v2'}),
  29. Em.Object.create({filename: 'hue-site.xml', name: 'p1', value: 'v1'}),
  30. Em.Object.create({filename: 'hue-site.xml', name: 'p2', value: 'v2'}),
  31. Em.Object.create({filename: 'mapred-site.xml', name: 'p1', value: 'v1'}),
  32. Em.Object.create({filename: 'mapred-site.xml', name: 'p2', value: 'v2'}),
  33. Em.Object.create({filename: 'yarn-site.xml', name: 'p1', value: 'v1'}),
  34. Em.Object.create({filename: 'yarn-site.xml', name: 'p2', value: 'v2'}),
  35. Em.Object.create({filename: 'capacity-scheduler.xml', name: 'p1', value: 'v1'}),
  36. Em.Object.create({filename: 'capacity-scheduler.xml', name: 'p2', value: 'v2'}),
  37. Em.Object.create({filename: 'mapred-queue-acls.xml', name: 'p1', value: 'v1'}),
  38. Em.Object.create({filename: 'mapred-queue-acls.xml', name: 'p2', value: 'v2'}),
  39. Em.Object.create({filename: 'hbase-site.xml', name: 'p1', value: 'v1'}),
  40. Em.Object.create({filename: 'hbase-site.xml', name: 'p2', value: 'v2'}),
  41. Em.Object.create({filename: 'oozie-site.xml', name: 'p1', value: 'v1'}),
  42. Em.Object.create({filename: 'oozie-site.xml', name: 'p2', value: 'v2'}),
  43. Em.Object.create({filename: 'hive-site.xml', name: 'p1', value: 'v1'}),
  44. Em.Object.create({filename: 'hive-site.xml', name: 'p2', value: 'v2'}),
  45. Em.Object.create({filename: 'pig-properties.xml', name: 'p1', value: 'v1'}),
  46. Em.Object.create({filename: 'webhcat-site.xml', name: 'p1', value: 'v1'}),
  47. Em.Object.create({filename: 'webhcat-site.xml', name: 'p2', value: 'v2'}),
  48. Em.Object.create({filename: 'tez-site.xml', name: 'p1', value: 'v1'}),
  49. Em.Object.create({filename: 'tez-site.xml', name: 'p2', value: 'v2'}),
  50. Em.Object.create({filename: 'falcon-startup.properties.xml', name: 'p1', value: 'v1'}),
  51. Em.Object.create({filename: 'falcon-startup.properties.xml', name: 'p2', value: 'v2'}),
  52. Em.Object.create({filename: 'falcon-runtime.properties.xml', name: 'p1', value: 'v1'}),
  53. Em.Object.create({filename: 'falcon-runtime.properties.xml', name: 'p2', value: 'v2'})
  54. ]);
  55. beforeEach(function () {
  56. installerStep8Controller = App.WizardStep8Controller.create({
  57. configs: configs
  58. });
  59. configurationController = App.MainServiceInfoConfigsController.create({});
  60. });
  61. var siteObjTests = Em.A([
  62. {name: 'createHdfsSiteObj', e: {type: 'hdfs-site', tag: 'version1', l: 2}},
  63. {name: 'createHueSiteObj', e: {type: 'hue-site', tag: 'version1', l: 2}},
  64. {name: 'createMrSiteObj', e: {type: 'mapred-site', tag: 'version1', l: 2}},
  65. {name: 'createYarnSiteObj', e: {type: 'yarn-site', tag: 'version1', l: 2}},
  66. {name: 'createCapacityScheduler', e: {type: 'capacity-scheduler', tag: 'version1', l: 2}},
  67. {name: 'createMapredQueueAcls', e: {type: 'mapred-queue-acls', tag: 'version1', l: 2}},
  68. {name: 'createHbaseSiteObj', e: {type: 'hbase-site', tag: 'version1', l: 2}},
  69. {name: 'createOozieSiteObj', e: {type: 'oozie-site', tag: 'version1', l: 2}},
  70. {name: 'createHiveSiteObj', e: {type: 'hive-site', tag: 'version1', l: 2}},
  71. {name: 'createWebHCatSiteObj', e: {type: 'webhcat-site', tag: 'version1', l: 2}},
  72. {name: 'createTezSiteObj', e: {type: 'tez-site', tag: 'version1', l: 2}},
  73. {name: 'createPigPropertiesSiteObj', e: {type: 'pig-properties', tag: 'version1', l: 1}},
  74. {name: 'createFalconStartupSiteObj', e: {type: 'falcon-startup.properties', tag: 'version1', l: 2}},
  75. {name: 'createFalconRuntimeSiteObj', e: {type: 'falcon-runtime.properties', tag: 'version1', l: 2}}
  76. ]);
  77. siteObjTests.forEach(function (test) {
  78. describe('#' + test.name, function () {
  79. it(test.name, function () {
  80. var siteObj = installerStep8Controller.createSiteObj(test.e.type, test.e.tag);
  81. expect(siteObj.tag).to.equal(test.e.tag);
  82. expect(Em.keys(siteObj.properties).length).to.equal(test.e.l);
  83. });
  84. });
  85. });
  86. describe('#createSelectedServicesData', function () {
  87. var tests = Em.A([
  88. {selectedServices: Em.A(['MAPREDUCE2']), e: 2},
  89. {selectedServices: Em.A(['MAPREDUCE2', 'YARN']), e: 5},
  90. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE']), e: 7},
  91. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE']), e: 9},
  92. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE']), e: 12},
  93. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE']), e: 13},
  94. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'HUE']), e: 14},
  95. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'HUE', 'PIG']), e: 15},
  96. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'HUE', 'PIG', 'FALCON']), e: 17},
  97. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'HUE', 'PIG', 'FALCON', 'STORM']), e: 18},
  98. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'HUE', 'PIG', 'FALCON', 'STORM', 'TEZ']), e: 19},
  99. {selectedServices: Em.A(['MAPREDUCE2', 'YARN', 'HBASE', 'OOZIE', 'HIVE', 'HUE', 'PIG', 'FALCON', 'STORM', 'TEZ', 'ZOOKEEPER']), e: 21}
  100. ]);
  101. tests.forEach(function (test) {
  102. it(test.selectedServices.join(','), function () {
  103. var services = test.selectedServices.map(function (serviceName) {
  104. return Em.Object.create({isSelected: true, isInstalled: false, serviceName: serviceName});
  105. });
  106. installerStep8Controller = App.WizardStep8Controller.create({
  107. content: {controllerName: 'addServiceController', services: services},
  108. configs: configs
  109. });
  110. var serviceData = installerStep8Controller.createSelectedServicesData();
  111. expect(serviceData.mapProperty('ServiceInfo.service_name')).to.eql(test.selectedServices.toArray());
  112. installerStep8Controller.clearStep();
  113. });
  114. });
  115. });
  116. describe('#getRegisteredHosts', function () {
  117. var tests = Em.A([
  118. {
  119. hosts: {
  120. h1: Em.Object.create({bootStatus: 'REGISTERED', name: 'h1'}),
  121. h2: Em.Object.create({bootStatus: 'OTHER', name: 'h2'})
  122. },
  123. e: ['h1'],
  124. m: 'Two hosts, one registered'
  125. },
  126. {
  127. hosts: {
  128. h1: Em.Object.create({bootStatus: 'OTHER', name: 'h1'}),
  129. h2: Em.Object.create({bootStatus: 'OTHER', name: 'h2'})
  130. },
  131. e: [],
  132. m: 'Two hosts, zero registered'
  133. },
  134. {
  135. hosts: {
  136. h1: Em.Object.create({bootStatus: 'REGISTERED', name: 'h1'}),
  137. h2: Em.Object.create({bootStatus: 'REGISTERED', name: 'h2'})
  138. },
  139. e: ['h1', 'h2'],
  140. m: 'Two hosts, two registered'
  141. }
  142. ]);
  143. tests.forEach(function (test) {
  144. it(test.m, function () {
  145. installerStep8Controller.set('content', Em.Object.create({hosts: test.hosts}));
  146. var registeredHosts = installerStep8Controller.getRegisteredHosts();
  147. expect(registeredHosts.mapProperty('hostName').toArray()).to.eql(test.e);
  148. });
  149. });
  150. });
  151. describe('#createRegisterHostData', function () {
  152. var tests = Em.A([
  153. {
  154. hosts: {
  155. h1: Em.Object.create({bootStatus: 'REGISTERED', name: 'h1', isInstalled: false}),
  156. h2: Em.Object.create({bootStatus: 'REGISTERED', name: 'h2', isInstalled: false})
  157. },
  158. e: ['h1', 'h2'],
  159. m: 'two registered, two isInstalled false'
  160. },
  161. {
  162. hosts: {
  163. h1: Em.Object.create({bootStatus: 'OTHER', name: 'h1', isInstalled: false}),
  164. h2: Em.Object.create({bootStatus: 'REGISTERED', name: 'h2', isInstalled: false})
  165. },
  166. e: ['h2'],
  167. m: 'one registered, two isInstalled false'
  168. },
  169. {
  170. hosts: {
  171. h1: Em.Object.create({bootStatus: 'OTHER', name: 'h1', isInstalled: true}),
  172. h2: Em.Object.create({bootStatus: 'REGISTERED', name: 'h2', isInstalled: false})
  173. },
  174. e: ['h2'],
  175. m: 'one registered, one isInstalled false'
  176. },
  177. {
  178. hosts: {
  179. h1: Em.Object.create({bootStatus: 'REGISTERED', name: 'h1', isInstalled: true}),
  180. h2: Em.Object.create({bootStatus: 'REGISTERED', name: 'h2', isInstalled: false})
  181. },
  182. e: ['h2'],
  183. m: 'two registered, one isInstalled false'
  184. },
  185. {
  186. hosts: {
  187. h1: Em.Object.create({bootStatus: 'OTHER', name: 'h1', isInstalled: false}),
  188. h2: Em.Object.create({bootStatus: 'OTHER', name: 'h2', isInstalled: false})
  189. },
  190. e: [],
  191. m: 'zero registered, two isInstalled false'
  192. },
  193. {
  194. hosts: {
  195. h1: Em.Object.create({bootStatus: 'REGISTERED', name: 'h1', isInstalled: true}),
  196. h2: Em.Object.create({bootStatus: 'REGISTERED', name: 'h2', isInstalled: true})
  197. },
  198. e: [],
  199. m: 'two registered, zeto insInstalled false'
  200. }
  201. ]);
  202. tests.forEach(function (test) {
  203. it(test.m, function () {
  204. installerStep8Controller.set('content', Em.Object.create({hosts: test.hosts}));
  205. var registeredHostData = installerStep8Controller.createRegisterHostData();
  206. expect(registeredHostData.mapProperty('Hosts.host_name').toArray()).to.eql(test.e);
  207. });
  208. });
  209. });
  210. describe('#clusterName', function () {
  211. it('should be equal to content.cluster.name', function () {
  212. installerStep8Controller.set('content', {cluster: {name: 'new_name'}});
  213. expect(installerStep8Controller.get('clusterName')).to.equal('new_name');
  214. });
  215. });
  216. describe('#loadStep', function () {
  217. beforeEach(function () {
  218. sinon.stub(installerStep8Controller, 'clearStep', Em.K);
  219. sinon.stub(installerStep8Controller, 'formatProperties', Em.K);
  220. sinon.stub(installerStep8Controller, 'loadConfigs', Em.K);
  221. sinon.stub(installerStep8Controller, 'loadClusterInfo', Em.K);
  222. sinon.stub(installerStep8Controller, 'loadServices', Em.K);
  223. installerStep8Controller.set('content', {controllerName: 'installerController'});
  224. });
  225. afterEach(function () {
  226. installerStep8Controller.clearStep.restore();
  227. installerStep8Controller.formatProperties.restore();
  228. installerStep8Controller.loadConfigs.restore();
  229. installerStep8Controller.loadClusterInfo.restore();
  230. installerStep8Controller.loadServices.restore();
  231. });
  232. it('should call clearStep', function () {
  233. installerStep8Controller.loadStep();
  234. expect(installerStep8Controller.clearStep.calledOnce).to.equal(true);
  235. });
  236. it('should call loadClusterInfo', function () {
  237. installerStep8Controller.loadStep();
  238. expect(installerStep8Controller.loadClusterInfo.calledOnce).to.equal(true);
  239. });
  240. it('should call loadServices', function () {
  241. installerStep8Controller.loadStep();
  242. expect(installerStep8Controller.loadServices.calledOnce).to.equal(true);
  243. });
  244. it('should call formatProperties if content.serviceConfigProperties is true', function () {
  245. installerStep8Controller.set('content.serviceConfigProperties', true);
  246. installerStep8Controller.loadStep();
  247. expect(installerStep8Controller.loadServices.calledOnce).to.equal(true);
  248. });
  249. it('should call loadConfigs if content.serviceConfigProperties is true', function () {
  250. installerStep8Controller.set('content.serviceConfigProperties', true);
  251. installerStep8Controller.loadStep();
  252. expect(installerStep8Controller.loadConfigs.calledOnce).to.equal(true);
  253. });
  254. it('should set isSubmitDisabled to false', function () {
  255. installerStep8Controller.loadStep();
  256. expect(installerStep8Controller.get('isSubmitDisabled')).to.equal(false);
  257. });
  258. it('should set isBackBtnDisabled to false', function () {
  259. installerStep8Controller.loadStep();
  260. expect(installerStep8Controller.get('isBackBtnDisabled')).to.equal(false);
  261. });
  262. });
  263. describe('#removeHiveConfigs', function () {
  264. Em.A([
  265. {
  266. globals: [
  267. {name: 'hive_database', value: 'New MySQL Database'},
  268. {name: 'hive_database_type', value: 'mysql'},
  269. {name: 'hive_ambari_host', value: 'h1'},
  270. {name: 'hive_hostname', value: 'h2'}
  271. ],
  272. removed: Em.A(['hive_existing_mysql_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database', 'hive_master_hosts']),
  273. m: 'hive_database: New MySQL Database',
  274. host: 'h1'
  275. },
  276. {
  277. globals: [
  278. {name: 'hive_database', value: 'Existing MySQL Database'},
  279. {name: 'hive_database_type', value: 'mysql'},
  280. {name: 'hive_existing_mysql_host', value: 'h1'},
  281. {name: 'hive_hostname', value: 'h2'}
  282. ],
  283. removed: Em.A(['hive_ambari_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database', 'hive_master_hosts']),
  284. m: 'hive_database: Existing MySQL Database',
  285. host: 'h1'
  286. },
  287. {
  288. globals: [
  289. {name: 'hive_database', value: 'Existing PostgreSQL Database'},
  290. {name: 'hive_database_type', value: 'postgresql'},
  291. {name: 'hive_existing_postgresql_host', value: 'h1'},
  292. {name: 'hive_hostname', value: 'h2'}
  293. ],
  294. removed: Em.A(['hive_ambari_database', 'hive_existing_oracle_database', 'hive_existing_mysql_database', 'hive_master_hosts']),
  295. m: 'hive_database: Existing PostgreSQL Database',
  296. host: 'h1'
  297. },
  298. {
  299. globals: [
  300. {name: 'hive_database', value: 'Existing Oracle Database'},
  301. {name: 'hive_database_type', value: 'oracle'},
  302. {name: 'hive_existing_oracle_host', value: 'h1'},
  303. {name: 'hive_hostname', value: 'h2'}
  304. ],
  305. removed: Em.A(['hive_ambari_database', 'hive_existing_mysql_database', 'hive_existing_postgresql_database', 'hive_master_hosts']),
  306. m: 'hive_database: Existing Oracle Database',
  307. host: 'h1'
  308. }
  309. ]).forEach(function (test) {
  310. it(test.m, function () {
  311. test.removed.forEach(function (c) {
  312. test.globals.pushObject({name: c})
  313. });
  314. var configs = installerStep8Controller.removeHiveConfigs(test.globals);
  315. test.removed.forEach(function(name) {
  316. expect(Em.isNone(configs.findProperty('name', name))).to.equal(true);
  317. });
  318. expect(configs.findProperty('name', 'hive_hostname').value).to.equal(test.host);
  319. });
  320. });
  321. });
  322. describe('#removeOozieConfigs', function () {
  323. Em.A([
  324. {
  325. globals: [
  326. {name: 'oozie_database', value: 'New Derby Database'},
  327. {name: 'oozie_ambari_host', value: 'h1'},
  328. {name: 'oozie_hostname', value: 'h2'}
  329. ],
  330. removed: Em.A(['oozie_ambari_database', 'oozie_existing_mysql_database', 'oozie_existing_oracle_database',
  331. 'oozie_existing_postgresql_database']),
  332. m: 'oozie_database: New Derby Database',
  333. host: 'h1'
  334. },
  335. {
  336. globals: [
  337. {name: 'oozie_database', value: 'Existing MySQL Database'},
  338. {name: 'oozie_existing_mysql_host', value: 'h1'},
  339. {name: 'oozie_hostname', value: 'h2'}
  340. ],
  341. removed: Em.A(['oozie_ambari_database', 'oozie_existing_oracle_database', 'oozie_derby_database',
  342. 'oozie_existing_postgresql_database']),
  343. m: 'oozie_database: Existing MySQL Database',
  344. host: 'h1'
  345. },
  346. {
  347. globals: [
  348. {name: 'oozie_database', value: 'Existing PostgreSQL Database'},
  349. {name: 'oozie_existing_postgresql_host', value: 'h1'},
  350. {name: 'oozie_hostname', value: 'h2'}
  351. ],
  352. removed: Em.A(['oozie_ambari_database', 'oozie_existing_oracle_database', 'oozie_existing_mysql_database']),
  353. m: 'oozie_database: Existing PostgreSQL Database',
  354. host: 'h1'
  355. },
  356. {
  357. globals: [
  358. {name: 'oozie_database', value: 'Existing Oracle Database'},
  359. {name: 'oozie_existing_oracle_host', value: 'h1'},
  360. {name: 'oozie_hostname', value: 'h2'}
  361. ],
  362. removed: Em.A(['oozie_ambari_database', 'oozie_existing_mysql_database', 'oozie_derby_database',
  363. 'oozie_existing_postgresql_database']),
  364. m: 'oozie_database: Existing Oracle Database',
  365. host: 'h1'
  366. }
  367. ]).forEach(function (test) {
  368. it(test.m, function () {
  369. test.removed.forEach(function (c) {
  370. if (!test.globals.findProperty('name', c)) {
  371. test.globals.pushObject({name: c})
  372. }
  373. });
  374. var configs = installerStep8Controller.removeOozieConfigs(test.globals);
  375. test.removed.forEach(function(name) {
  376. expect(Em.isNone(configs.findProperty('name', name))).to.equal(true);
  377. });
  378. expect(configs.findProperty('name', 'oozie_hostname').value).to.equal(test.host);
  379. });
  380. });
  381. });
  382. describe('#getRegisteredHosts', function() {
  383. Em.A([
  384. {
  385. hosts: {},
  386. m: 'no content.hosts',
  387. e: []
  388. },
  389. {
  390. hosts: {
  391. h1:{bootStatus: ''},
  392. h2:{bootStatus: ''}
  393. },
  394. m: 'no registered hosts',
  395. e: []
  396. },
  397. {
  398. hosts: {
  399. h1:{bootStatus: 'REGISTERED', hostName: '', name: 'n1'},
  400. h2:{bootStatus: 'REGISTERED', hostName: '', name: 'n2'}
  401. },
  402. m: 'registered hosts available',
  403. e: ['n1', 'n2']
  404. }
  405. ]).forEach(function(test) {
  406. it(test.m, function() {
  407. installerStep8Controller.set('content', {hosts: test.hosts});
  408. var hosts = installerStep8Controller.getRegisteredHosts();
  409. expect(hosts.mapProperty('hostName')).to.eql(test.e);
  410. });
  411. });
  412. });
  413. describe('#loadRepoInfo', function() {
  414. it('should use App.currentStackVersion', function() {
  415. var version = 'HDP-1.1.1';
  416. sinon.stub(App, 'get', function() {return version;});
  417. sinon.stub(App.ajax, 'send', Em.K);
  418. installerStep8Controller.loadRepoInfo();
  419. var data = App.ajax.send.args[0][0].data;
  420. expect(data).to.eql({stackName: 'HDP', stackVersion: '1.1.1'});
  421. App.ajax.send.restore();
  422. App.get.restore();
  423. });
  424. });
  425. describe('#loadRepoInfoSuccessCallback', function () {
  426. beforeEach(function () {
  427. installerStep8Controller.set('clusterInfo', Em.Object.create({}));
  428. });
  429. Em.A([
  430. {
  431. items: [],
  432. m: 'no data',
  433. e: {
  434. base_url: [],
  435. os_type: []
  436. }
  437. },
  438. {
  439. items: [
  440. {
  441. repositories: [
  442. {
  443. Repositories: {
  444. os_type: 'redhat5',
  445. base_url: 'url1'
  446. }
  447. }
  448. ],
  449. OperatingSystems: {
  450. is_type: ''
  451. }
  452. }
  453. ],
  454. m: 'only redhat5',
  455. e: {
  456. base_url: ['url1'],
  457. os_type: ['redhat5']
  458. }
  459. },
  460. {
  461. items: [
  462. {
  463. repositories: [
  464. {
  465. Repositories: {
  466. os_type: 'redhat5',
  467. base_url: 'url1'
  468. }
  469. }
  470. ],
  471. OperatingSystems: {
  472. is_type: ''
  473. }
  474. },
  475. {
  476. repositories: [
  477. {
  478. Repositories: {
  479. os_type: 'redhat6',
  480. base_url: 'url2'
  481. }
  482. }
  483. ],
  484. OperatingSystems: {
  485. is_type: ''
  486. }
  487. }
  488. ],
  489. m: 'redhat5, redhat6',
  490. e: {
  491. base_url: ['url1', 'url2'],
  492. os_type: ['redhat5', 'redhat6']
  493. }
  494. },
  495. {
  496. items: [
  497. {
  498. repositories: [
  499. {
  500. Repositories: {
  501. os_type: 'redhat5',
  502. base_url: 'url1'
  503. }
  504. }
  505. ],
  506. OperatingSystems: {
  507. is_type: ''
  508. }
  509. },
  510. {
  511. repositories: [
  512. {
  513. Repositories: {
  514. os_type: 'redhat6',
  515. base_url: 'url2'
  516. }
  517. }
  518. ],
  519. OperatingSystems: {
  520. is_type: ''
  521. }
  522. },
  523. {
  524. repositories: [
  525. {
  526. Repositories: {
  527. os_type: 'sles11',
  528. base_url: 'url3'
  529. }
  530. }
  531. ],
  532. OperatingSystems: {
  533. is_type: ''
  534. }
  535. }
  536. ],
  537. m: 'redhat5, redhat6, sles11',
  538. e: {
  539. base_url: ['url1', 'url2', 'url3'],
  540. os_type: ['redhat5', 'redhat6', 'sles11']
  541. }
  542. }
  543. ]).forEach(function (test) {
  544. it(test.m, function () {
  545. installerStep8Controller.loadRepoInfoSuccessCallback({items: test.items});
  546. expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('base_url')).to.eql(test.e.base_url);
  547. expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('os_type')).to.eql(test.e.os_type);
  548. });
  549. });
  550. });
  551. describe('#loadRepoInfoErrorCallback', function() {
  552. it('should set [] to repoInfo', function() {
  553. installerStep8Controller.set('clusterInfo', Em.Object.create({repoInfo: [{}, {}]}));
  554. installerStep8Controller.loadRepoInfoErrorCallback({});
  555. expect(installerStep8Controller.get('clusterInfo.repoInfo.length')).to.eql(0);
  556. });
  557. });
  558. describe('#loadHiveDbValue', function() {
  559. beforeEach(function() {
  560. installerStep8Controller.set('wizardController', Em.Object.create({
  561. getDBProperty: Em.K
  562. }));
  563. });
  564. Em.A([
  565. {
  566. serviceConfigProperties: [
  567. {name: 'hive_database', value: 'New MySQL Database'}
  568. ],
  569. m: 'New MySQL Database',
  570. e: 'MySQL (New Database)'
  571. },
  572. {
  573. serviceConfigProperties: [
  574. {name: 'hive_database', value: 'New PostgreSQL Database'}
  575. ],
  576. m: 'New PostgreSQL Database',
  577. e: 'Postgres (New Database)'
  578. },
  579. {
  580. serviceConfigProperties: [
  581. {name: 'hive_database', value: 'Existing MySQL Database'},
  582. {name: 'hive_existing_mysql_database', value: 'dbname'}
  583. ],
  584. m: 'Existing MySQL Database',
  585. e: 'dbname (Existing MySQL Database)'
  586. },
  587. {
  588. serviceConfigProperties: [
  589. {name: 'hive_database', value: 'Existing PostgreSQL Database'},
  590. {name: 'hive_existing_postgresql_database', value: 'dbname'}
  591. ],
  592. m: 'Existing PostgreSQL Database',
  593. e: 'dbname (Existing PostgreSQL Database)'
  594. },
  595. {
  596. serviceConfigProperties: [
  597. {name: 'hive_database', value: 'Existing Oracle Database'},
  598. {name: 'hive_existing_oracle_database', value: 'dbname'}
  599. ],
  600. m: 'Existing Oracle Database',
  601. e: 'dbname (Existing Oracle Database)'
  602. }
  603. ]).forEach(function(test) {
  604. it(test.m, function() {
  605. sinon.stub(installerStep8Controller.get('wizardController'), 'getDBProperty', function() {
  606. return test.serviceConfigProperties;
  607. });
  608. var dbComponent = installerStep8Controller.loadHiveDbValue();
  609. expect(dbComponent).to.equal(test.e);
  610. installerStep8Controller.get('wizardController').getDBProperty.restore();
  611. });
  612. });
  613. });
  614. describe('#loadHbaseMasterValue', function () {
  615. Em.A([
  616. {
  617. masterComponentHosts: [{component: 'HBASE_MASTER', hostName: 'h1'}],
  618. component: Em.Object.create({component_name: 'HBASE_MASTER'}),
  619. m: 'one host',
  620. e: 'h1'
  621. },
  622. {
  623. masterComponentHosts: [{component: 'HBASE_MASTER', hostName: 'h1'}, {component: 'HBASE_MASTER', hostName: 'h2'}, {component: 'HBASE_MASTER', hostName: 'h3'}],
  624. component: Em.Object.create({component_name: 'HBASE_MASTER'}),
  625. m: 'many hosts',
  626. e: 'h1 ' + Em.I18n.t('installer.step8.other').format(2)
  627. }
  628. ]).forEach(function (test) {
  629. it(test.m, function() {
  630. installerStep8Controller.set('content', {masterComponentHosts: test.masterComponentHosts});
  631. installerStep8Controller.loadHbaseMasterValue(test.component);
  632. expect(test.component.component_value).to.equal(test.e);
  633. });
  634. });
  635. });
  636. describe('#loadZkServerValue', function() {
  637. Em.A([
  638. {
  639. masterComponentHosts: [{component: 'ZOOKEEPER_SERVER'}],
  640. component: Em.Object.create({component_name: 'ZOOKEEPER_SERVER'}),
  641. m: '1 host',
  642. e: '1 host'
  643. },
  644. {
  645. masterComponentHosts: [{component: 'ZOOKEEPER_SERVER'},{component: 'ZOOKEEPER_SERVER'},{component: 'ZOOKEEPER_SERVER'}],
  646. component: Em.Object.create({component_name: 'ZOOKEEPER_SERVER'}),
  647. m: 'many hosts',
  648. e: '3 hosts'
  649. }
  650. ]).forEach(function (test) {
  651. it(test.m, function () {
  652. installerStep8Controller.set('content', {masterComponentHosts: test.masterComponentHosts});
  653. installerStep8Controller.loadZkServerValue(test.component);
  654. expect(test.component.component_value).to.equal(test.e);
  655. });
  656. });
  657. });
  658. describe('#loadOozieDbValue', function() {
  659. beforeEach(function() {
  660. installerStep8Controller.set('wizardController', Em.Object.create({
  661. getDBProperty: Em.K
  662. }));
  663. });
  664. Em.A([
  665. {
  666. serviceConfigProperties: [
  667. {name: 'oozie_database', value: 'New Derby Database'},
  668. {name: 'oozie_derby_database', value: 'dbname'}
  669. ],
  670. m: 'New Derby Database',
  671. e: 'dbname (New Derby Database)'
  672. },
  673. {
  674. serviceConfigProperties: [
  675. {name: 'oozie_database', value: 'Existing MySQL Database'},
  676. {name: 'oozie_existing_mysql_database', value: 'dbname'}
  677. ],
  678. m: 'Existing MySQL Database',
  679. e: 'dbname (Existing MySQL Database)'
  680. },
  681. {
  682. serviceConfigProperties: [
  683. {name: 'oozie_database', value: 'Existing PostgreSQL Database'},
  684. {name: 'oozie_existing_postgresql_database', value: 'dbname'}
  685. ],
  686. m: 'Existing PostgreSQL Database',
  687. e: 'dbname (Existing PostgreSQL Database)'
  688. },
  689. {
  690. serviceConfigProperties: [
  691. {name: 'oozie_database', value: 'Existing Oracle Database'},
  692. {name: 'oozie_existing_oracle_database', value: 'dbname'}
  693. ],
  694. m: 'Existing Oracle Database',
  695. e: 'dbname (Existing Oracle Database)'
  696. }
  697. ]).forEach(function(test) {
  698. it(test.m, function() {
  699. sinon.stub(installerStep8Controller.get('wizardController'), 'getDBProperty', function() {
  700. return test.serviceConfigProperties;
  701. });
  702. var dbComponent = installerStep8Controller.loadOozieDbValue();
  703. expect(dbComponent).to.equal(test.e);
  704. installerStep8Controller.get('wizardController').getDBProperty.restore();
  705. });
  706. });
  707. });
  708. describe('#submit', function() {
  709. beforeEach(function() {
  710. sinon.stub(installerStep8Controller, 'submitProceed', Em.K);
  711. sinon.stub(App.get('router.mainAdminKerberosController'), 'getKDCSessionState', Em.K);
  712. });
  713. afterEach(function() {
  714. installerStep8Controller.submitProceed.restore();
  715. App.get('router.mainAdminKerberosController').getKDCSessionState.restore();
  716. });
  717. Em.A([
  718. {
  719. controllerName: 'addServiceController',
  720. securityEnabled: true
  721. },
  722. {
  723. controllerName: 'addServiceController',
  724. securityEnabled: false
  725. }
  726. ]).forEach(function (test) {
  727. it(test.controllerName + ' ' + test.securityEnabled.toString(), function () {
  728. installerStep8Controller.reopen({isSubmitDisabled: false, securityEnabled: test.securityEnabled, content: {controllerName: test.controllerName}});
  729. installerStep8Controller.submit();
  730. if (test.securityEnabled) {
  731. expect(App.get('router.mainAdminKerberosController').getKDCSessionState.called).to.equal(true);
  732. expect(installerStep8Controller.submitProceed.called).to.equal(false);
  733. } else {
  734. expect(App.get('router.mainAdminKerberosController').getKDCSessionState.called).to.equal(false);
  735. expect(installerStep8Controller.submitProceed.called).to.equal(true);
  736. }
  737. });
  738. });
  739. it('shouldn\'t do nothing if isSubmitDisabled is true', function() {
  740. installerStep8Controller.reopen({isSubmitDisabled: true});
  741. installerStep8Controller.submit();
  742. expect(App.get('router.mainAdminKerberosController').getKDCSessionState.called).to.equal(false);
  743. expect(installerStep8Controller.submitProceed.called).to.equal(false);
  744. });
  745. });
  746. describe('#getExistingClusterNamesSuccessCallBack', function() {
  747. it('should set clusterNames received from server', function() {
  748. var data = {
  749. items:[
  750. {Clusters: {cluster_name: 'c1'}},
  751. {Clusters: {cluster_name: 'c2'}},
  752. {Clusters: {cluster_name: 'c3'}}
  753. ]
  754. },
  755. clasterNames = ['c1','c2','c3'];
  756. installerStep8Controller.getExistingClusterNamesSuccessCallBack(data);
  757. expect(installerStep8Controller.get('clusterNames')).to.eql(clasterNames);
  758. });
  759. });
  760. describe('#getExistingClusterNamesErrorCallback', function() {
  761. it('should set [] to clusterNames', function() {
  762. installerStep8Controller.set('clusterNames', ['c1', 'c2']);
  763. installerStep8Controller.getExistingClusterNamesErrorCallback();
  764. expect(installerStep8Controller.get('clusterNames')).to.eql([]);
  765. });
  766. });
  767. describe('#deleteClusters', function() {
  768. beforeEach(function () {
  769. sinon.stub(App.ajax, 'send', Em.K);
  770. });
  771. afterEach(function () {
  772. App.ajax.send.restore();
  773. });
  774. it('should call App.ajax.send for each provided clusterName', function() {
  775. var clusterNames = ['h1', 'h2', 'h3'];
  776. installerStep8Controller.deleteClusters(clusterNames);
  777. expect(App.ajax.send.callCount).to.equal(clusterNames.length);
  778. clusterNames.forEach(function(n, i) {
  779. expect(App.ajax.send.getCall(i).args[0].data).to.eql({name: n, isLast: i == clusterNames.length - 1});
  780. });
  781. });
  782. it('should clear cluster delete error popup body views', function () {
  783. installerStep8Controller.deleteClusters([]);
  784. expect(installerStep8Controller.get('clusterDeleteErrorViews')).to.eql([]);
  785. });
  786. });
  787. describe('#createSelectedServicesData', function() {
  788. it('should reformat provided data', function() {
  789. var selectedServices = [
  790. Em.Object.create({serviceName: 's1'}),
  791. Em.Object.create({serviceName: 's2'}),
  792. Em.Object.create({serviceName: 's3'})
  793. ];
  794. var expected = [
  795. {"ServiceInfo": { "service_name": 's1' }},
  796. {"ServiceInfo": { "service_name": 's2' }},
  797. {"ServiceInfo": { "service_name": 's3' }}
  798. ];
  799. installerStep8Controller.reopen({selectedServices: selectedServices});
  800. var createdData = installerStep8Controller.createSelectedServicesData();
  801. expect(createdData).to.eql(expected);
  802. });
  803. });
  804. describe('#createRegisterHostData', function() {
  805. it('should return empty data if no hosts', function() {
  806. sinon.stub(installerStep8Controller, 'getRegisteredHosts', function() {return [];});
  807. expect(installerStep8Controller.createRegisterHostData()).to.eql([]);
  808. installerStep8Controller.getRegisteredHosts.restore();
  809. });
  810. it('should return computed data', function() {
  811. var data = [
  812. {isInstalled: false, hostName: 'h1'},
  813. {isInstalled: true, hostName: 'h2'},
  814. {isInstalled: false, hostName: 'h3'}
  815. ];
  816. var expected = [
  817. {"Hosts": { "host_name": 'h1'}},
  818. {"Hosts": { "host_name": 'h3'}}
  819. ];
  820. sinon.stub(installerStep8Controller, 'getRegisteredHosts', function() {return data;});
  821. expect(installerStep8Controller.createRegisterHostData()).to.eql(expected);
  822. installerStep8Controller.getRegisteredHosts.restore();
  823. });
  824. });
  825. describe('#createStormSiteObj', function() {
  826. it('should replace quote \'"\' to "\'" for some properties', function() {
  827. var configs = [
  828. {filename: 'storm-site.xml', value: ["a", "b"], name: 'storm.zookeeper.servers'}
  829. ],
  830. expected = {
  831. type: 'storm-site',
  832. tag: 'version1',
  833. properties: {
  834. 'storm.zookeeper.servers': '[\'a\',\'b\']'
  835. }
  836. };
  837. installerStep8Controller.reopen({configs: configs});
  838. expect(installerStep8Controller.createStormSiteObj('version1')).to.eql(expected);
  839. });
  840. it('should not escape special characters', function() {
  841. var configs = [
  842. {filename: 'storm-site.xml', value: "abc\n\t", name: 'nimbus.childopts'},
  843. {filename: 'storm-site.xml', value: "a\nb", name: 'supervisor.childopts'},
  844. {filename: 'storm-site.xml', value: "a\t\tb", name: 'worker.childopts'}
  845. ],
  846. expected = {
  847. type: 'storm-site',
  848. tag: 'version1',
  849. properties: {
  850. 'nimbus.childopts': 'abc\n\t',
  851. 'supervisor.childopts': 'a\nb',
  852. 'worker.childopts': 'a\t\tb'
  853. }
  854. };
  855. installerStep8Controller.reopen({configs: configs});
  856. expect(installerStep8Controller.createStormSiteObj('version1')).to.eql(expected);
  857. });
  858. });
  859. describe('#ajaxQueueFinished', function() {
  860. it('should call App.router.next', function() {
  861. sinon.stub(App.router, 'send', Em.K);
  862. installerStep8Controller.ajaxQueueFinished();
  863. expect(App.router.send.calledWith('next')).to.equal(true);
  864. App.router.send.restore();
  865. });
  866. });
  867. describe('#addRequestToAjaxQueue', function() {
  868. describe('testMode = true', function() {
  869. before(function() {
  870. App.set('testMode', true);
  871. });
  872. after(function() {
  873. App.set('testMode', false);
  874. });
  875. it('shouldn\'t do nothing', function() {
  876. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  877. installerStep8Controller.get('ajaxRequestsQueue').clear();
  878. installerStep8Controller.addRequestToAjaxQueue({});
  879. expect(installerStep8Controller.get('ajaxRequestsQueue.queue.length')).to.equal(0);
  880. });
  881. });
  882. describe('testMode = true', function() {
  883. before(function() {
  884. App.set('testMode', false);
  885. });
  886. it('should add request', function() {
  887. var clusterName = 'c1';
  888. installerStep8Controller.reopen({clusterName: clusterName});
  889. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  890. installerStep8Controller.get('ajaxRequestsQueue').clear();
  891. installerStep8Controller.addRequestToAjaxQueue({name:'name', data:{}});
  892. var request = installerStep8Controller.get('ajaxRequestsQueue.queue.firstObject');
  893. expect(request.error).to.equal('ajaxQueueRequestErrorCallback');
  894. expect(request.data.cluster).to.equal(clusterName);
  895. });
  896. });
  897. });
  898. describe('#ajaxQueueRequestErrorCallback', function() {
  899. var obj = Em.Object.create({
  900. registerErrPopup: Em.K,
  901. setStepsEnable: Em.K
  902. });
  903. beforeEach(function() {
  904. sinon.stub(App.router, 'get', function() {
  905. return obj;
  906. });
  907. sinon.spy(obj, 'registerErrPopup');
  908. sinon.spy(obj, 'setStepsEnable');
  909. });
  910. afterEach(function() {
  911. App.router.get.restore();
  912. obj.registerErrPopup.restore();
  913. obj.setStepsEnable.restore();
  914. });
  915. it('should set hasErrorOccurred true', function () {
  916. installerStep8Controller.set('hasErrorOccurred', false);
  917. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  918. expect(installerStep8Controller.get('hasErrorOccurred')).to.equal(true);
  919. });
  920. it('should set isSubmitDisabled false', function () {
  921. installerStep8Controller.set('isSubmitDisabled', true);
  922. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  923. expect(installerStep8Controller.get('isSubmitDisabled')).to.equal(false);
  924. });
  925. it('should set isBackBtnDisabled false', function () {
  926. installerStep8Controller.set('isBackBtnDisabled', true);
  927. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  928. expect(installerStep8Controller.get('isBackBtnDisabled')).to.equal(false);
  929. });
  930. it('should call setStepsEnable', function () {
  931. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  932. expect(obj.setStepsEnable.calledOnce).to.equal(true);
  933. });
  934. it('should call registerErrPopup', function () {
  935. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  936. expect(obj.registerErrPopup.calledOnce).to.equal(true);
  937. });
  938. });
  939. describe('#removeInstalledServicesConfigurationGroups', function() {
  940. beforeEach(function() {
  941. sinon.stub(App.config, 'deleteConfigGroup', Em.K);
  942. });
  943. afterEach(function() {
  944. App.config.deleteConfigGroup.restore();
  945. });
  946. it('should call App.config.deleteConfigGroup for each received group', function() {
  947. var groups = [{}, {}, {}];
  948. installerStep8Controller.removeInstalledServicesConfigurationGroups(groups);
  949. expect(App.config.deleteConfigGroup.callCount).to.equal(groups.length);
  950. });
  951. });
  952. describe('#addDynamicProperties', function() {
  953. it('shouldn\'t add property', function() {
  954. var serviceConfigProperties = [
  955. {name: 'templeton.hive.properties'}
  956. ],
  957. configs = [];
  958. installerStep8Controller.reopen({content: {serviceConfigProperties: serviceConfigProperties}});
  959. installerStep8Controller.addDynamicProperties(configs);
  960. expect(configs.length).to.equal(0);
  961. });
  962. it('should add property', function() {
  963. var serviceConfigProperties = [],
  964. configs = [];
  965. installerStep8Controller.reopen({content: {serviceConfigProperties: serviceConfigProperties}});
  966. installerStep8Controller.addDynamicProperties(configs);
  967. expect(configs.length).to.equal(1);
  968. });
  969. });
  970. describe('#applyInstalledServicesConfigurationGroup', function() {
  971. beforeEach(function() {
  972. sinon.stub($, 'ajax', Em.K);
  973. sinon.stub(App.router, 'get', function() {
  974. return configurationController;
  975. });
  976. });
  977. afterEach(function() {
  978. $.ajax.restore();
  979. App.router.get.restore();
  980. });
  981. it('should do ajax request for each config group', function() {
  982. var configGroups = [{ConfigGroup: {id:''}}, {ConfigGroup: {id:''}}];
  983. installerStep8Controller.applyInstalledServicesConfigurationGroup(configGroups);
  984. expect($.ajax.callCount).to.equal(configGroups.length);
  985. });
  986. });
  987. describe('#getExistingClusterNames', function() {
  988. beforeEach(function() {
  989. sinon.stub(App.ajax, 'send', Em.K);
  990. });
  991. afterEach(function() {
  992. App.ajax.send.restore();
  993. });
  994. it('should do ajax request', function() {
  995. installerStep8Controller.getExistingClusterNames();
  996. expect(App.ajax.send.calledOnce).to.be.true;
  997. });
  998. });
  999. describe('#loadUiSideConfigs', function() {
  1000. beforeEach(function() {
  1001. sinon.stub(installerStep8Controller, 'addDynamicProperties', Em.K);
  1002. sinon.stub(installerStep8Controller, 'getGlobConfigValueWithOverrides', function(t, v, n) {
  1003. return {
  1004. value: v,
  1005. overrides: []
  1006. }
  1007. });
  1008. sinon.stub(App.config, 'setConfigValue', Em.K);
  1009. });
  1010. afterEach(function() {
  1011. installerStep8Controller.addDynamicProperties.restore();
  1012. installerStep8Controller.getGlobConfigValueWithOverrides.restore();
  1013. App.config.setConfigValue.restore();
  1014. });
  1015. it('all configs witohut foreignKey', function() {
  1016. var configMapping = [
  1017. {foreignKey: null, templateName: 't1', value: 'v1', name: 'c1', filename: 'f1'},
  1018. {foreignKey: null, templateName: 't2', value: 'v2', name: 'c2', filename: 'f2'},
  1019. {foreignKey: null, templateName: 't3', value: 'v3', name: 'c3', filename: 'f2'},
  1020. {foreignKey: null, templateName: 't4', value: 'v4', name: 'c4', filename: 'f1'}
  1021. ];
  1022. var uiConfigs = installerStep8Controller.loadUiSideConfigs(configMapping);
  1023. expect(uiConfigs.length).to.equal(configMapping.length);
  1024. expect(uiConfigs.everyProperty('id', 'site property')).to.be.true;
  1025. uiConfigs.forEach(function(c, index) {
  1026. expect(c.overrides).to.be.an.array;
  1027. expect(c.value).to.equal(configMapping[index].value);
  1028. expect(c.name).to.equal(configMapping[index].name);
  1029. expect(c.filename).to.equal(configMapping[index].filename);
  1030. });
  1031. });
  1032. it('some configs witohut foreignKey', function() {
  1033. var configMapping = [
  1034. {foreignKey: null, templateName: 't1', value: 'v1', name: 'c1', filename: 'f1'},
  1035. {foreignKey: null, templateName: 't2', value: 'v2', name: 'c2', filename: 'f2'},
  1036. {foreignKey: null, templateName: 't3', value: 'v3', name: 'c3', filename: 'f2'},
  1037. {foreignKey: null, templateName: 't4', value: 'v4', name: 'c4', filename: 'f1'},
  1038. {foreignKey: 'fk1', templateName: 't5', value: 'v5', name: 'c5', filename: 'f1'},
  1039. {foreignKey: 'fk2', templateName: 't6', value: 'v6', name: 'c6', filename: 'f1'},
  1040. {foreignKey: 'fk3', templateName: 't7', value: 'v7', name: 'c7', filename: 'f2'},
  1041. {foreignKey: 'fk4', templateName: 't8', value: 'v8', name: 'c8', filename: 'f2'}
  1042. ];
  1043. var uiConfigs = installerStep8Controller.loadUiSideConfigs(configMapping);
  1044. expect(uiConfigs.length).to.equal(configMapping.length);
  1045. expect(uiConfigs.everyProperty('id', 'site property')).to.be.true;
  1046. uiConfigs.forEach(function(c, index) {
  1047. if (Em.isNone(configMapping[index].foreignKey))
  1048. expect(c.overrides).to.be.an.array;
  1049. expect(c.value).to.equal(configMapping[index].value);
  1050. expect(c.name).to.equal(configMapping[index].name);
  1051. expect(c.filename).to.equal(configMapping[index].filename);
  1052. });
  1053. });
  1054. });
  1055. describe('Queued requests', function() {
  1056. beforeEach(function() {
  1057. installerStep8Controller.clearStep();
  1058. sinon.spy(installerStep8Controller, 'addRequestToAjaxQueue');
  1059. });
  1060. afterEach(function() {
  1061. installerStep8Controller.addRequestToAjaxQueue.restore();
  1062. });
  1063. describe('#createCluster', function() {
  1064. it('shouldn\'t add request to queue if not installerController used', function() {
  1065. installerStep8Controller.reopen({content: {controllerName: 'addServiceController'}});
  1066. installerStep8Controller.createCluster();
  1067. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1068. });
  1069. it('App.currentStackVersion should be changed if localRepo selected', function() {
  1070. App.set('currentStackVersion', 'HDP-1.1.1');
  1071. installerStep8Controller.reopen({content: {controllerName: 'installerController', installOptions: {localRepo: true}}});
  1072. var data = {
  1073. data: JSON.stringify({ "Clusters": {"version": 'HDPLocal-1.1.1' }})
  1074. };
  1075. installerStep8Controller.createCluster();
  1076. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(data.data);
  1077. });
  1078. it('App.currentStackVersion shouldn\'t be changed if localRepo ins\'t selected', function() {
  1079. App.set('currentStackVersion', 'HDP-1.1.1');
  1080. installerStep8Controller.reopen({content: {controllerName: 'installerController', installOptions: {localRepo: false}}});
  1081. var data = {
  1082. data: JSON.stringify({ "Clusters": {"version": 'HDP-1.1.1' }})
  1083. };
  1084. installerStep8Controller.createCluster();
  1085. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.eql(data.data);
  1086. });
  1087. });
  1088. describe('#createSelectedServices', function() {
  1089. it('shouldn\'t do nothing if no data', function() {
  1090. sinon.stub(installerStep8Controller, 'createSelectedServicesData', function() {return [];});
  1091. installerStep8Controller.createSelectedServices();
  1092. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1093. installerStep8Controller.createSelectedServicesData.restore();
  1094. });
  1095. it('should call addRequestToAjaxQueue with computed data', function() {
  1096. var data = [
  1097. {"ServiceInfo": { "service_name": 's1' }},
  1098. {"ServiceInfo": { "service_name": 's2' }},
  1099. {"ServiceInfo": { "service_name": 's3' }}
  1100. ];
  1101. sinon.stub(installerStep8Controller, 'createSelectedServicesData', function() {return data;});
  1102. installerStep8Controller.createSelectedServices();
  1103. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data));
  1104. installerStep8Controller.createSelectedServicesData.restore();
  1105. });
  1106. });
  1107. describe('#registerHostsToCluster', function() {
  1108. it('shouldn\'t do nothing if no data', function() {
  1109. sinon.stub(installerStep8Controller, 'createRegisterHostData', function() {return [];});
  1110. installerStep8Controller.registerHostsToCluster();
  1111. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1112. installerStep8Controller.createRegisterHostData.restore();
  1113. });
  1114. it('should call addRequestToAjaxQueue with computed data', function() {
  1115. var data = [
  1116. {"Hosts": { "host_name": 'h1'}},
  1117. {"Hosts": { "host_name": 'h3'}}
  1118. ];
  1119. sinon.stub(installerStep8Controller, 'createRegisterHostData', function() {return data;});
  1120. installerStep8Controller.registerHostsToCluster();
  1121. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data));
  1122. installerStep8Controller.createRegisterHostData.restore();
  1123. });
  1124. });
  1125. describe('#registerHostsToComponent', function() {
  1126. it('shouldn\'t do request if no hosts provided', function() {
  1127. installerStep8Controller.registerHostsToComponent([]);
  1128. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1129. });
  1130. it('should do request if hostNames are provided', function() {
  1131. var hostNames = ['h1', 'h2'],
  1132. componentName = 'c1';
  1133. installerStep8Controller.registerHostsToComponent(hostNames, componentName);
  1134. var data = JSON.parse(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data);
  1135. expect(data.RequestInfo.query).to.equal('Hosts/host_name=h1|Hosts/host_name=h2');
  1136. expect(data.Body.host_components[0].HostRoles.component_name).to.equal('c1');
  1137. });
  1138. });
  1139. describe('#applyConfigurationsToCluster', function() {
  1140. it('should call addRequestToAjaxQueue', function() {
  1141. var serviceConfigTags = [
  1142. {
  1143. type: 'hdfs',
  1144. tag: 'tag1',
  1145. properties: [
  1146. {},
  1147. {}
  1148. ]
  1149. }
  1150. ],
  1151. data = '['+JSON.stringify({
  1152. Clusters: {
  1153. desired_config: [serviceConfigTags[0]]
  1154. }
  1155. })+']';
  1156. installerStep8Controller.reopen({
  1157. installedServices: [
  1158. Em.Object.create({
  1159. isSelected: true,
  1160. isInstalled: false,
  1161. configTypesRendered: {hdfs:'tag1'}
  1162. })
  1163. ], selectedServices: []
  1164. });
  1165. installerStep8Controller.applyConfigurationsToCluster(serviceConfigTags);
  1166. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(data);
  1167. });
  1168. });
  1169. describe('#applyConfigurationGroups', function() {
  1170. it('should call addRequestToAjaxQueue', function() {
  1171. var data = [{}, {}];
  1172. installerStep8Controller.applyConfigurationGroups(data);
  1173. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data));
  1174. });
  1175. });
  1176. describe('#newServiceComponentErrorCallback', function() {
  1177. it('should add request for new component', function() {
  1178. var serviceName = 's1',
  1179. componentName = 'c1';
  1180. installerStep8Controller.newServiceComponentErrorCallback({}, {}, '', {}, {serviceName: serviceName, componentName: componentName});
  1181. var data = JSON.parse(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data);
  1182. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.serviceName).to.equal(serviceName);
  1183. expect(data.components[0].ServiceComponentInfo.component_name).to.equal(componentName);
  1184. });
  1185. });
  1186. describe('#createAdditionalHostComponents', function() {
  1187. beforeEach(function() {
  1188. sinon.stub(installerStep8Controller, 'registerHostsToComponent', Em.K);
  1189. });
  1190. afterEach(function() {
  1191. installerStep8Controller.registerHostsToComponent.restore();
  1192. });
  1193. it('should add components with isRequiredOnAllHosts == true (1)', function() {
  1194. installerStep8Controller.reopen({
  1195. getRegisteredHosts: function() {
  1196. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1197. },
  1198. content: {
  1199. services: [
  1200. Em.Object.create({
  1201. serviceName: 'GANGLIA', isSelected: true, isInstalled: false, serviceComponents: [
  1202. Em.Object.create({
  1203. componentName: 'GANGLIA_MONITOR',
  1204. isRequiredOnAllHosts: true
  1205. }),
  1206. Em.Object.create({
  1207. componentName: 'GANGLIA_SERVER',
  1208. isRequiredOnAllHosts: false
  1209. })
  1210. ]
  1211. })
  1212. ]
  1213. }
  1214. });
  1215. installerStep8Controller.createAdditionalHostComponents();
  1216. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  1217. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
  1218. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
  1219. });
  1220. it('should add components with isRequiredOnAllHosts == true (2)', function() {
  1221. installerStep8Controller.reopen({
  1222. getRegisteredHosts: function() {
  1223. return [{hostName: 'h1', isInstalled: true}, {hostName: 'h2', isInstalled: false}];
  1224. },
  1225. content: {
  1226. services: [
  1227. Em.Object.create({
  1228. serviceName: 'GANGLIA', isSelected: true, isInstalled: true, serviceComponents: [
  1229. Em.Object.create({
  1230. componentName: 'GANGLIA_MONITOR',
  1231. isRequiredOnAllHosts: true
  1232. }),
  1233. Em.Object.create({
  1234. componentName: 'GANGLIA_SERVER',
  1235. isRequiredOnAllHosts: false
  1236. })
  1237. ]
  1238. })
  1239. ]
  1240. }
  1241. });
  1242. installerStep8Controller.createAdditionalHostComponents();
  1243. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  1244. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h2']);
  1245. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
  1246. });
  1247. var newDatabases = [
  1248. {name: 'New MySQL Database',
  1249. component: 'MYSQL_SERVER'
  1250. },
  1251. {name: 'New PostgreSQL Database',
  1252. component: 'POSTGRESQL_SERVER'
  1253. }
  1254. ];
  1255. newDatabases.forEach(function (db) {
  1256. it('should add {0}'.format(db.component), function() {
  1257. installerStep8Controller.reopen({
  1258. getRegisteredHosts: function() {
  1259. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1260. },
  1261. content: {
  1262. masterComponentHosts: [
  1263. {component: 'HIVE_SERVER', hostName: 'h1'},
  1264. {component: 'HIVE_SERVER', hostName: 'h2'}
  1265. ],
  1266. services: [
  1267. Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false, serviceComponents: []})
  1268. ],
  1269. serviceConfigProperties: [
  1270. {name: 'hive_database', value: db.name}
  1271. ]
  1272. }
  1273. });
  1274. installerStep8Controller.createAdditionalHostComponents();
  1275. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  1276. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
  1277. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal(db.component);
  1278. });
  1279. });
  1280. });
  1281. describe('#createNotification', function () {
  1282. beforeEach(function () {
  1283. var stub = sinon.stub(App, 'get');
  1284. stub.withArgs('testMode').returns(false);
  1285. installerStep8Controller.clearStep();
  1286. installerStep8Controller.set('content', {controllerName: 'installerController'});
  1287. installerStep8Controller.set('configs', [
  1288. {name: 'create_notification', value: 'yes', serviceName: 'MISC', filename: 'alert_notification'},
  1289. {name: 'ambari.dispatch.recipients', value: 'to@f.c', serviceName: 'MISC', filename: 'alert_notification'},
  1290. {name: 'mail.smtp.host', value: 'h', serviceName: 'MISC', filename: 'alert_notification'},
  1291. {name: 'mail.smtp.port', value: '25', serviceName: 'MISC', filename: 'alert_notification'},
  1292. {name: 'mail.smtp.from', value: 'from@f.c', serviceName: 'MISC', filename: 'alert_notification'},
  1293. {name: 'mail.smtp.starttls.enable', value: true, serviceName: 'MISC', filename: 'alert_notification'},
  1294. {name: 'mail.smtp.startssl.enable', value: false, serviceName: 'MISC', filename: 'alert_notification'},
  1295. {name: 'smtp_use_auth', value: 'true', serviceName: 'MISC', filename: 'alert_notification'},
  1296. {name: 'ambari.dispatch.credential.username', value: 'usr', serviceName: 'MISC', filename: 'alert_notification'},
  1297. {name: 'ambari.dispatch.credential.password', value: 'pwd', serviceName: 'MISC', filename: 'alert_notification'},
  1298. {name: 'some_p', value: 'some_v', serviceName: 'MISC', filename: 'alert_notification'}
  1299. ]);
  1300. installerStep8Controller.get('ajaxRequestsQueue').clear();
  1301. sinon.stub($, 'ajax', function () {return {complete: Em.K}});
  1302. });
  1303. afterEach(function () {
  1304. App.get.restore();
  1305. $.ajax.restore();
  1306. });
  1307. it('should add request to queue', function () {
  1308. installerStep8Controller.createNotification();
  1309. expect(installerStep8Controller.get('ajaxRequestsQueue.queue.length')).to.equal(1);
  1310. installerStep8Controller.get('ajaxRequestsQueue').runNextRequest();
  1311. expect($.ajax.calledOnce).to.be.true;
  1312. expect($.ajax.args[0][0].url.contains('overwrite_existing=true')).to.be.true;
  1313. });
  1314. it('sent data should be valid', function () {
  1315. installerStep8Controller.createNotification();
  1316. var data = installerStep8Controller.get('ajaxRequestsQueue.queue')[0].data.data.AlertTarget;
  1317. expect(data.global).to.be.true;
  1318. expect(data.notification_type).to.equal('EMAIL');
  1319. expect(data.alert_states).to.eql(['OK', 'WARNING', 'CRITICAL', 'UNKNOWN']);
  1320. expect(data.properties['ambari.dispatch.recipients']).to.eql(['to@f.c']);
  1321. expect(data.properties['mail.smtp.host']).to.equal('h');
  1322. expect(data.properties['mail.smtp.port']).to.equal('25');
  1323. expect(data.properties['mail.smtp.from']).to.equal('from@f.c');
  1324. expect(data.properties['mail.smtp.starttls.enable']).to.equal(true);
  1325. expect(data.properties['mail.smtp.startssl.enable']).to.equal(false);
  1326. expect(data.properties['ambari.dispatch.credential.username']).to.equal('usr');
  1327. expect(data.properties['ambari.dispatch.credential.password']).to.equal('pwd');
  1328. expect(data.properties['some_p']).to.equal('some_v');
  1329. });
  1330. });
  1331. });
  1332. describe("#resolveProxyuserDependecies()", function() {
  1333. it("No core-site configs", function() {
  1334. expect(installerStep8Controller.resolveProxyuserDependecies([], [])).to.be.empty;
  1335. });
  1336. it("Only proxyuser group config", function() {
  1337. var configs = [{
  1338. name: 'proxyuser_group'
  1339. }];
  1340. installerStep8Controller.set('configs', [{
  1341. name: 'proxyuser_group',
  1342. value: 'val1'
  1343. }]);
  1344. expect(installerStep8Controller.resolveProxyuserDependecies(configs, [])).to.be.empty;
  1345. });
  1346. it("Property should be added", function() {
  1347. var configs = [
  1348. {
  1349. name: 'proxyuser_group'
  1350. },
  1351. {
  1352. name: 'hadoop.proxyuser.user.hosts',
  1353. value: 'val2'
  1354. }
  1355. ];
  1356. installerStep8Controller.set('configs', [{
  1357. name: 'proxyuser_group',
  1358. value: 'val1'
  1359. }]);
  1360. expect(installerStep8Controller.resolveProxyuserDependecies(configs, [])).to.be.eql({
  1361. 'hadoop.proxyuser.user.hosts': 'val2',
  1362. 'proxyuser_group': 'val1'
  1363. });
  1364. });
  1365. it("Property should be skipped", function() {
  1366. var configs = [
  1367. {
  1368. name: 'proxyuser_group'
  1369. },
  1370. {
  1371. name: 'hadoop.proxyuser.user.hosts',
  1372. value: 'val2'
  1373. }
  1374. ];
  1375. installerStep8Controller.set('configs', [
  1376. {
  1377. name: 'proxyuser_group',
  1378. value: 'val1'
  1379. },
  1380. {
  1381. name: 'user1',
  1382. value: 'user'
  1383. }
  1384. ]);
  1385. installerStep8Controller.set('optionalCoreSiteConfigs', [
  1386. {
  1387. serviceName: 'S1',
  1388. user: 'user1'
  1389. }
  1390. ]);
  1391. expect(installerStep8Controller.resolveProxyuserDependecies(configs, [])).to.be.empty;
  1392. });
  1393. });
  1394. describe("#addDynamicProperties", function() {
  1395. var tests = [
  1396. {
  1397. content: Em.Object.create({
  1398. serviceConfigProperties: [
  1399. Em.Object.create({
  1400. configs: []
  1401. })
  1402. ]
  1403. }),
  1404. m: 'add dynamic property',
  1405. addDynamic: true
  1406. },
  1407. {
  1408. content: Em.Object.create({
  1409. serviceConfigProperties: [
  1410. Em.Object.create({
  1411. name: 'templeton.hive.properties'
  1412. })
  1413. ]
  1414. }),
  1415. m: 'don\'t add dynamic property (already included)',
  1416. addDynamic: false
  1417. }
  1418. ],
  1419. dynamicProperty = {
  1420. name: 'templeton.hive.properties',
  1421. templateName: ['hive.metastore.uris'],
  1422. foreignKey: null,
  1423. value: 'hive.metastore.local=false,hive.metastore.uris=<templateName[0]>,hive.metastore.sasl.enabled=yes,hive.metastore.execute.setugi=true,hive.metastore.warehouse.dir=/apps/hive/warehouse',
  1424. filename: 'webhcat-site.xml'
  1425. };
  1426. tests.forEach(function(t) {
  1427. it(t.m, function() {
  1428. installerStep8Controller.set('content', t.content);
  1429. var configs = [];
  1430. installerStep8Controller.addDynamicProperties(configs);
  1431. if (t.addDynamic){
  1432. expect(configs.findProperty('name', 'templeton.hive.properties')).to.deep.eql(dynamicProperty);
  1433. }
  1434. });
  1435. });
  1436. });
  1437. describe('#isAllClusterDeleteRequestsCompleted', function () {
  1438. it('should depend on completed cluster delete requests number', function () {
  1439. installerStep8Controller.setProperties({
  1440. clusterDeleteRequestsCompleted: 0,
  1441. clusterNames: ['c0']
  1442. });
  1443. expect(installerStep8Controller.get('isAllClusterDeleteRequestsCompleted')).to.be.false;
  1444. installerStep8Controller.incrementProperty('clusterDeleteRequestsCompleted');
  1445. expect(installerStep8Controller.get('isAllClusterDeleteRequestsCompleted')).to.be.true;
  1446. });
  1447. });
  1448. describe('#deleteClusterSuccessCallback', function () {
  1449. beforeEach(function () {
  1450. sinon.stub(installerStep8Controller, 'showDeleteClustersErrorPopup', Em.K);
  1451. sinon.stub(installerStep8Controller, 'startDeploy', Em.K);
  1452. installerStep8Controller.setProperties({
  1453. clusterDeleteRequestsCompleted: 0,
  1454. clusterNames: ['c0', 'c1'],
  1455. clusterDeleteErrorViews: []
  1456. });
  1457. installerStep8Controller.deleteClusterSuccessCallback();
  1458. });
  1459. afterEach(function () {
  1460. installerStep8Controller.showDeleteClustersErrorPopup.restore();
  1461. installerStep8Controller.startDeploy.restore();
  1462. });
  1463. it('no failed requests', function () {
  1464. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1);
  1465. expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
  1466. expect(installerStep8Controller.startDeploy.called).to.be.false;
  1467. installerStep8Controller.deleteClusterSuccessCallback();
  1468. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
  1469. expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
  1470. expect(installerStep8Controller.startDeploy.calledOnce).to.be.true;
  1471. });
  1472. it('one request failed', function () {
  1473. installerStep8Controller.deleteClusterErrorCallback({}, null, null, {});
  1474. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
  1475. expect(installerStep8Controller.showDeleteClustersErrorPopup.calledOnce).to.be.true;
  1476. expect(installerStep8Controller.startDeploy.called).to.be.false;
  1477. });
  1478. });
  1479. describe('#deleteClusterErrorCallback', function () {
  1480. var request = {
  1481. status: 500,
  1482. responseText: '{"message":"Internal Server Error"}'
  1483. },
  1484. ajaxOptions = 'error',
  1485. error = 'Internal Server Error',
  1486. opt = {
  1487. url: 'api/v1/clusters/c0',
  1488. type: 'DELETE'
  1489. };
  1490. beforeEach(function () {
  1491. installerStep8Controller.setProperties({
  1492. clusterDeleteRequestsCompleted: 0,
  1493. clusterNames: ['c0', 'c1'],
  1494. clusterDeleteErrorViews: []
  1495. });
  1496. sinon.stub(installerStep8Controller, 'showDeleteClustersErrorPopup', Em.K);
  1497. installerStep8Controller.deleteClusterErrorCallback(request, ajaxOptions, error, opt);
  1498. });
  1499. afterEach(function () {
  1500. installerStep8Controller.showDeleteClustersErrorPopup.restore();
  1501. });
  1502. it('should show error popup only if all requests are completed', function () {
  1503. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1);
  1504. expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
  1505. installerStep8Controller.deleteClusterErrorCallback(request, ajaxOptions, error, opt);
  1506. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
  1507. expect(installerStep8Controller.showDeleteClustersErrorPopup.calledOnce).to.be.true;
  1508. });
  1509. it('should create error popup body view', function () {
  1510. expect(installerStep8Controller.get('clusterDeleteErrorViews')).to.have.length(1);
  1511. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.url')).to.equal('api/v1/clusters/c0');
  1512. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.type')).to.equal('DELETE');
  1513. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.status')).to.equal(500);
  1514. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.message')).to.equal('Internal Server Error');
  1515. });
  1516. });
  1517. describe('#showDeleteClustersErrorPopup', function () {
  1518. beforeEach(function () {
  1519. installerStep8Controller.setProperties({
  1520. isSubmitDisabled: true,
  1521. isBackBtnDisabled: true
  1522. });
  1523. sinon.stub(App.ModalPopup, 'show', Em.K);
  1524. installerStep8Controller.showDeleteClustersErrorPopup();
  1525. });
  1526. afterEach(function () {
  1527. App.ModalPopup.show.restore();
  1528. });
  1529. it('should show error popup and unlock navigation', function () {
  1530. expect(installerStep8Controller.get('isSubmitDisabled')).to.be.false;
  1531. expect(installerStep8Controller.get('isBackBtnDisabled')).to.be.false;
  1532. expect(App.ModalPopup.show.calledOnce).to.be.true;
  1533. });
  1534. });
  1535. describe('#startDeploy', function () {
  1536. var stubbedNames = ['createCluster', 'createSelectedServices', 'updateConfigurations', 'createConfigurations',
  1537. 'applyConfigurationsToCluster', 'createComponents', 'registerHostsToCluster', 'createConfigurationGroups',
  1538. 'createMasterHostComponents', 'createSlaveAndClientsHostComponents', 'createAdditionalClientComponents',
  1539. 'createAdditionalHostComponents'],
  1540. cases = [
  1541. {
  1542. controllerName: 'installerController',
  1543. notExecuted: ['createAdditionalClientComponents', 'updateConfigurations'],
  1544. fileNamesToUpdate: [],
  1545. title: 'Installer, no configs to update'
  1546. },
  1547. {
  1548. controllerName: 'installerController',
  1549. notExecuted: ['createAdditionalClientComponents'],
  1550. fileNamesToUpdate: [''],
  1551. title: 'Installer, some configs to be updated'
  1552. },
  1553. {
  1554. controllerName: 'addHostController',
  1555. notExecuted: ['updateConfigurations', 'createConfigurations', 'applyConfigurationsToCluster', 'createAdditionalClientComponents'],
  1556. title: 'Add Host Wizard'
  1557. },
  1558. {
  1559. controllerName: 'addServiceController',
  1560. notExecuted: ['updateConfigurations'],
  1561. fileNamesToUpdate: [],
  1562. title: 'Add Service Wizard, no configs to update'
  1563. },
  1564. {
  1565. controllerName: 'addServiceController',
  1566. notExecuted: [],
  1567. fileNamesToUpdate: [''],
  1568. title: 'Add Service Wizard, some configs to be updated'
  1569. }
  1570. ];
  1571. beforeEach(function () {
  1572. stubbedNames.forEach(function (name) {
  1573. sinon.stub(installerStep8Controller, name, Em.K);
  1574. });
  1575. installerStep8Controller.setProperties({
  1576. serviceConfigTags: [],
  1577. content: {
  1578. controllerName: null
  1579. }
  1580. });
  1581. });
  1582. afterEach(function () {
  1583. stubbedNames.forEach(function (name) {
  1584. installerStep8Controller[name].restore();
  1585. });
  1586. installerStep8Controller.get.restore();
  1587. });
  1588. cases.forEach(function (item) {
  1589. it(item.title, function () {
  1590. sinon.stub(installerStep8Controller, 'get')
  1591. .withArgs('ajaxRequestsQueue').returns({
  1592. start: Em.K
  1593. })
  1594. .withArgs('ajaxRequestsQueue.queue.length').returns(1)
  1595. .withArgs('wizardController').returns({
  1596. getDBProperty: function () {
  1597. return item.fileNamesToUpdate;
  1598. }
  1599. })
  1600. .withArgs('content.controllerName').returns(item.controllerName);
  1601. installerStep8Controller.startDeploy();
  1602. stubbedNames.forEach(function (name) {
  1603. expect(installerStep8Controller[name].called).to.equal(!item.notExecuted.contains(name));
  1604. });
  1605. });
  1606. });
  1607. });
  1608. });