step8_test.js 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732
  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. sinon.stub(App, 'get', function (k) {
  1284. if ('testMode' === k) return false;
  1285. return Em.get(App, k);
  1286. });
  1287. installerStep8Controller.clearStep();
  1288. installerStep8Controller.set('content', {controllerName: 'installerController'});
  1289. installerStep8Controller.set('configs', [
  1290. {name: 'create_notification', value: 'yes', serviceName: 'MISC', filename: 'alert_notification'},
  1291. {name: 'ambari.dispatch.recipients', value: 'to@f.c', serviceName: 'MISC', filename: 'alert_notification'},
  1292. {name: 'mail.smtp.host', value: 'h', serviceName: 'MISC', filename: 'alert_notification'},
  1293. {name: 'mail.smtp.port', value: '25', serviceName: 'MISC', filename: 'alert_notification'},
  1294. {name: 'mail.smtp.from', value: 'from@f.c', serviceName: 'MISC', filename: 'alert_notification'},
  1295. {name: 'mail.smtp.starttls.enable', value: true, serviceName: 'MISC', filename: 'alert_notification'},
  1296. {name: 'mail.smtp.startssl.enable', value: false, serviceName: 'MISC', filename: 'alert_notification'},
  1297. {name: 'smtp_use_auth', value: 'true', serviceName: 'MISC', filename: 'alert_notification'},
  1298. {name: 'ambari.dispatch.credential.username', value: 'usr', serviceName: 'MISC', filename: 'alert_notification'},
  1299. {name: 'ambari.dispatch.credential.password', value: 'pwd', serviceName: 'MISC', filename: 'alert_notification'},
  1300. {name: 'some_p', value: 'some_v', serviceName: 'MISC', filename: 'alert_notification'}
  1301. ]);
  1302. installerStep8Controller.get('ajaxRequestsQueue').clear();
  1303. });
  1304. afterEach(function () {
  1305. App.get.restore();
  1306. });
  1307. it('should add request to queue', function () {
  1308. installerStep8Controller.createNotification();
  1309. expect(installerStep8Controller.get('ajaxRequestsQueue.queue.length')).to.equal(1);
  1310. });
  1311. it('sent data should be valid', function () {
  1312. installerStep8Controller.createNotification();
  1313. var data = installerStep8Controller.get('ajaxRequestsQueue.queue')[0].data.data.AlertTarget;
  1314. expect(data.global).to.be.true;
  1315. expect(data.notification_type).to.equal('EMAIL');
  1316. expect(data.alert_states).to.eql(['OK', 'WARNING', 'CRITICAL', 'UNKNOWN']);
  1317. expect(data.properties['ambari.dispatch.recipients']).to.eql(['to@f.c']);
  1318. expect(data.properties['mail.smtp.host']).to.equal('h');
  1319. expect(data.properties['mail.smtp.port']).to.equal('25');
  1320. expect(data.properties['mail.smtp.from']).to.equal('from@f.c');
  1321. expect(data.properties['mail.smtp.starttls.enable']).to.equal(true);
  1322. expect(data.properties['mail.smtp.startssl.enable']).to.equal(false);
  1323. expect(data.properties['ambari.dispatch.credential.username']).to.equal('usr');
  1324. expect(data.properties['ambari.dispatch.credential.password']).to.equal('pwd');
  1325. expect(data.properties['some_p']).to.equal('some_v');
  1326. });
  1327. });
  1328. });
  1329. describe("#resolveProxyuserDependecies()", function() {
  1330. it("No core-site configs", function() {
  1331. expect(installerStep8Controller.resolveProxyuserDependecies([], [])).to.be.empty;
  1332. });
  1333. it("Only proxyuser group config", function() {
  1334. var configs = [{
  1335. name: 'proxyuser_group'
  1336. }];
  1337. installerStep8Controller.set('configs', [{
  1338. name: 'proxyuser_group',
  1339. value: 'val1'
  1340. }]);
  1341. expect(installerStep8Controller.resolveProxyuserDependecies(configs, [])).to.be.empty;
  1342. });
  1343. it("Property should be added", function() {
  1344. var configs = [
  1345. {
  1346. name: 'proxyuser_group'
  1347. },
  1348. {
  1349. name: 'hadoop.proxyuser.user.hosts',
  1350. value: 'val2'
  1351. }
  1352. ];
  1353. installerStep8Controller.set('configs', [{
  1354. name: 'proxyuser_group',
  1355. value: 'val1'
  1356. }]);
  1357. expect(installerStep8Controller.resolveProxyuserDependecies(configs, [])).to.be.eql({
  1358. 'hadoop.proxyuser.user.hosts': 'val2',
  1359. 'proxyuser_group': 'val1'
  1360. });
  1361. });
  1362. it("Property should be skipped", function() {
  1363. var configs = [
  1364. {
  1365. name: 'proxyuser_group'
  1366. },
  1367. {
  1368. name: 'hadoop.proxyuser.user.hosts',
  1369. value: 'val2'
  1370. }
  1371. ];
  1372. installerStep8Controller.set('configs', [
  1373. {
  1374. name: 'proxyuser_group',
  1375. value: 'val1'
  1376. },
  1377. {
  1378. name: 'user1',
  1379. value: 'user'
  1380. }
  1381. ]);
  1382. installerStep8Controller.set('optionalCoreSiteConfigs', [
  1383. {
  1384. serviceName: 'S1',
  1385. user: 'user1'
  1386. }
  1387. ]);
  1388. expect(installerStep8Controller.resolveProxyuserDependecies(configs, [])).to.be.empty;
  1389. });
  1390. });
  1391. describe("#addDynamicProperties", function() {
  1392. var tests = [
  1393. {
  1394. content: Em.Object.create({
  1395. serviceConfigProperties: [
  1396. Em.Object.create({
  1397. configs: []
  1398. })
  1399. ]
  1400. }),
  1401. m: 'add dynamic property',
  1402. addDynamic: true
  1403. },
  1404. {
  1405. content: Em.Object.create({
  1406. serviceConfigProperties: [
  1407. Em.Object.create({
  1408. name: 'templeton.hive.properties'
  1409. })
  1410. ]
  1411. }),
  1412. m: 'don\'t add dynamic property (already included)',
  1413. addDynamic: false
  1414. }
  1415. ],
  1416. dynamicProperty = {
  1417. name: 'templeton.hive.properties',
  1418. templateName: ['hive.metastore.uris'],
  1419. foreignKey: null,
  1420. 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',
  1421. filename: 'webhcat-site.xml'
  1422. };
  1423. tests.forEach(function(t) {
  1424. it(t.m, function() {
  1425. installerStep8Controller.set('content', t.content);
  1426. var configs = [];
  1427. installerStep8Controller.addDynamicProperties(configs);
  1428. if (t.addDynamic){
  1429. expect(configs.findProperty('name', 'templeton.hive.properties')).to.deep.eql(dynamicProperty);
  1430. }
  1431. });
  1432. });
  1433. });
  1434. describe('#isAllClusterDeleteRequestsCompleted', function () {
  1435. it('should depend on completed cluster delete requests number', function () {
  1436. installerStep8Controller.setProperties({
  1437. clusterDeleteRequestsCompleted: 0,
  1438. clusterNames: ['c0']
  1439. });
  1440. expect(installerStep8Controller.get('isAllClusterDeleteRequestsCompleted')).to.be.false;
  1441. installerStep8Controller.incrementProperty('clusterDeleteRequestsCompleted');
  1442. expect(installerStep8Controller.get('isAllClusterDeleteRequestsCompleted')).to.be.true;
  1443. });
  1444. });
  1445. describe('#deleteClusterSuccessCallback', function () {
  1446. beforeEach(function () {
  1447. sinon.stub(installerStep8Controller, 'showDeleteClustersErrorPopup', Em.K);
  1448. sinon.stub(installerStep8Controller, 'startDeploy', Em.K);
  1449. installerStep8Controller.setProperties({
  1450. clusterDeleteRequestsCompleted: 0,
  1451. clusterNames: ['c0', 'c1'],
  1452. clusterDeleteErrorViews: []
  1453. });
  1454. installerStep8Controller.deleteClusterSuccessCallback();
  1455. });
  1456. afterEach(function () {
  1457. installerStep8Controller.showDeleteClustersErrorPopup.restore();
  1458. installerStep8Controller.startDeploy.restore();
  1459. });
  1460. it('no failed requests', function () {
  1461. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1);
  1462. expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
  1463. expect(installerStep8Controller.startDeploy.called).to.be.false;
  1464. installerStep8Controller.deleteClusterSuccessCallback();
  1465. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
  1466. expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
  1467. expect(installerStep8Controller.startDeploy.calledOnce).to.be.true;
  1468. });
  1469. it('one request failed', function () {
  1470. installerStep8Controller.deleteClusterErrorCallback({}, null, null, {});
  1471. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
  1472. expect(installerStep8Controller.showDeleteClustersErrorPopup.calledOnce).to.be.true;
  1473. expect(installerStep8Controller.startDeploy.called).to.be.false;
  1474. });
  1475. });
  1476. describe('#deleteClusterErrorCallback', function () {
  1477. var request = {
  1478. status: 500,
  1479. responseText: '{"message":"Internal Server Error"}'
  1480. },
  1481. ajaxOptions = 'error',
  1482. error = 'Internal Server Error',
  1483. opt = {
  1484. url: 'api/v1/clusters/c0',
  1485. type: 'DELETE'
  1486. };
  1487. beforeEach(function () {
  1488. installerStep8Controller.setProperties({
  1489. clusterDeleteRequestsCompleted: 0,
  1490. clusterNames: ['c0', 'c1'],
  1491. clusterDeleteErrorViews: []
  1492. });
  1493. sinon.stub(installerStep8Controller, 'showDeleteClustersErrorPopup', Em.K);
  1494. installerStep8Controller.deleteClusterErrorCallback(request, ajaxOptions, error, opt);
  1495. });
  1496. afterEach(function () {
  1497. installerStep8Controller.showDeleteClustersErrorPopup.restore();
  1498. });
  1499. it('should show error popup only if all requests are completed', function () {
  1500. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1);
  1501. expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
  1502. installerStep8Controller.deleteClusterErrorCallback(request, ajaxOptions, error, opt);
  1503. expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
  1504. expect(installerStep8Controller.showDeleteClustersErrorPopup.calledOnce).to.be.true;
  1505. });
  1506. it('should create error popup body view', function () {
  1507. expect(installerStep8Controller.get('clusterDeleteErrorViews')).to.have.length(1);
  1508. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.url')).to.equal('api/v1/clusters/c0');
  1509. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.type')).to.equal('DELETE');
  1510. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.status')).to.equal(500);
  1511. expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.message')).to.equal('Internal Server Error');
  1512. });
  1513. });
  1514. describe('#showDeleteClustersErrorPopup', function () {
  1515. beforeEach(function () {
  1516. installerStep8Controller.setProperties({
  1517. isSubmitDisabled: true,
  1518. isBackBtnDisabled: true
  1519. });
  1520. sinon.stub(App.ModalPopup, 'show', Em.K);
  1521. installerStep8Controller.showDeleteClustersErrorPopup();
  1522. });
  1523. afterEach(function () {
  1524. App.ModalPopup.show.restore();
  1525. });
  1526. it('should show error popup and unlock navigation', function () {
  1527. expect(installerStep8Controller.get('isSubmitDisabled')).to.be.false;
  1528. expect(installerStep8Controller.get('isBackBtnDisabled')).to.be.false;
  1529. expect(App.ModalPopup.show.calledOnce).to.be.true;
  1530. });
  1531. });
  1532. describe('#startDeploy', function () {
  1533. var stubbedNames = ['createCluster', 'createSelectedServices', 'updateConfigurations', 'createConfigurations',
  1534. 'applyConfigurationsToCluster', 'createComponents', 'registerHostsToCluster', 'createConfigurationGroups',
  1535. 'createMasterHostComponents', 'createSlaveAndClientsHostComponents', 'createAdditionalClientComponents',
  1536. 'createAdditionalHostComponents'],
  1537. cases = [
  1538. {
  1539. controllerName: 'installerController',
  1540. notExecuted: ['createAdditionalClientComponents', 'updateConfigurations'],
  1541. fileNamesToUpdate: [],
  1542. title: 'Installer, no configs to update'
  1543. },
  1544. {
  1545. controllerName: 'installerController',
  1546. notExecuted: ['createAdditionalClientComponents'],
  1547. fileNamesToUpdate: [''],
  1548. title: 'Installer, some configs to be updated'
  1549. },
  1550. {
  1551. controllerName: 'addHostController',
  1552. notExecuted: ['updateConfigurations', 'createConfigurations', 'applyConfigurationsToCluster', 'createAdditionalClientComponents'],
  1553. title: 'Add Host Wizard'
  1554. },
  1555. {
  1556. controllerName: 'addServiceController',
  1557. notExecuted: ['updateConfigurations'],
  1558. fileNamesToUpdate: [],
  1559. title: 'Add Service Wizard, no configs to update'
  1560. },
  1561. {
  1562. controllerName: 'addServiceController',
  1563. notExecuted: [],
  1564. fileNamesToUpdate: [''],
  1565. title: 'Add Service Wizard, some configs to be updated'
  1566. }
  1567. ];
  1568. beforeEach(function () {
  1569. stubbedNames.forEach(function (name) {
  1570. sinon.stub(installerStep8Controller, name, Em.K);
  1571. });
  1572. installerStep8Controller.setProperties({
  1573. serviceConfigTags: [],
  1574. content: {
  1575. controllerName: null
  1576. }
  1577. });
  1578. });
  1579. afterEach(function () {
  1580. stubbedNames.forEach(function (name) {
  1581. installerStep8Controller[name].restore();
  1582. });
  1583. installerStep8Controller.get.restore();
  1584. });
  1585. cases.forEach(function (item) {
  1586. it(item.title, function () {
  1587. sinon.stub(installerStep8Controller, 'get')
  1588. .withArgs('ajaxRequestsQueue').returns({
  1589. start: Em.K
  1590. })
  1591. .withArgs('ajaxRequestsQueue.queue.length').returns(1)
  1592. .withArgs('wizardController').returns({
  1593. getDBProperty: function () {
  1594. return item.fileNamesToUpdate;
  1595. }
  1596. })
  1597. .withArgs('content.controllerName').returns(item.controllerName);
  1598. installerStep8Controller.startDeploy();
  1599. stubbedNames.forEach(function (name) {
  1600. expect(installerStep8Controller[name].called).to.equal(!item.notExecuted.contains(name));
  1601. });
  1602. });
  1603. });
  1604. });
  1605. });