step8_test.js 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465
  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_host', 'hive_existing_mysql_database', 'hive_existing_oracle_host',
  273. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']),
  274. hive_database_type: 'mysql',
  275. m: 'hive_database: New MySQL Database',
  276. host: 'h1'
  277. },
  278. {
  279. globals: [
  280. {name: 'hive_database', value: 'Existing MySQL Database'},
  281. {name: 'hive_database_type', value: 'mysql'},
  282. {name: 'hive_existing_mysql_host', value: 'h1'},
  283. {name: 'hive_hostname', value: 'h2'}
  284. ],
  285. removed: Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host',
  286. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']),
  287. hive_database_type: 'mysql',
  288. m: 'hive_database: Existing MySQL Database',
  289. host: 'h1'
  290. },
  291. {
  292. globals: [
  293. {name: 'hive_database', value: 'Existing PostgreSQL Database'},
  294. {name: 'hive_database_type', value: 'postgresql'},
  295. {name: 'hive_existing_postgresql_host', value: 'h1'},
  296. {name: 'hive_hostname', value: 'h2'}
  297. ],
  298. removed: Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host',
  299. 'hive_existing_oracle_database', 'hive_existing_mysql_host', 'hive_existing_mysql_database']),
  300. hive_database_type: 'postgres',
  301. m: 'hive_database: Existing PostgreSQL Database',
  302. host: 'h1'
  303. },
  304. {
  305. globals: [
  306. {name: 'hive_database', value: 'Existing Oracle Database'},
  307. {name: 'hive_database_type', value: 'oracle'},
  308. {name: 'hive_existing_oracle_host', value: 'h1'},
  309. {name: 'hive_hostname', value: 'h2'}
  310. ],
  311. removed: Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_mysql_host',
  312. 'hive_existing_mysql_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']),
  313. hive_database_type: 'oracle',
  314. m: 'hive_database: Existing Oracle Database',
  315. host: 'h1'
  316. }
  317. ]).forEach(function (test) {
  318. it(test.m, function () {
  319. test.removed.forEach(function (c) {
  320. test.globals.pushObject({name: c})
  321. });
  322. var configs = installerStep8Controller.removeHiveConfigs(test.globals);
  323. test.removed.forEach(function(name) {
  324. expect(Em.isNone(configs.findProperty('name', name))).to.equal(true);
  325. });
  326. expect(configs.findProperty('name', 'hive_database_type').value).to.equal(test.hive_database_type);
  327. expect(configs.findProperty('name', 'hive_hostname').value).to.equal(test.host);
  328. });
  329. });
  330. });
  331. describe('#removeOozieConfigs', function () {
  332. Em.A([
  333. {
  334. globals: [
  335. {name: 'oozie_database', value: 'New Derby Database'},
  336. {name: 'oozie_database_type', value: 'derby'},
  337. {name: 'oozie_ambari_host', value: 'h1'},
  338. {name: 'oozie_hostname', value: 'h2'}
  339. ],
  340. removed: Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_mysql_host',
  341. 'oozie_existing_mysql_database', 'oozie_existing_oracle_host', 'oozie_existing_oracle_database',
  342. 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database']),
  343. oozie_database_type: 'derby',
  344. m: 'oozie_database: New Derby Database',
  345. host: 'h1'
  346. },
  347. {
  348. globals: [
  349. {name: 'oozie_database', value: 'Existing MySQL Database'},
  350. {name: 'oozie_database_type', value: 'mysql'},
  351. {name: 'oozie_existing_mysql_host', value: 'h1'},
  352. {name: 'oozie_hostname', value: 'h2'}
  353. ],
  354. removed: Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_oracle_host',
  355. 'oozie_existing_oracle_database', 'oozie_derby_database', 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database']),
  356. oozie_database_type: 'mysql',
  357. m: 'oozie_database: Existing MySQL Database',
  358. host: 'h1'
  359. },
  360. {
  361. globals: [
  362. {name: 'oozie_database', value: 'Existing PostgreSQL Database'},
  363. {name: 'oozie_database_type', value: 'postgresql'},
  364. {name: 'oozie_existing_postgresql_host', value: 'h1'},
  365. {name: 'oozie_hostname', value: 'h2'}
  366. ],
  367. removed: Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_oracle_host',
  368. 'oozie_existing_oracle_database', 'oozie_existing_mysql_host', 'oozie_existing_mysql_database']),
  369. oozie_database_type: 'postgresql',
  370. m: 'oozie_database: Existing PostgreSQL Database',
  371. host: 'h1'
  372. },
  373. {
  374. globals: [
  375. {name: 'oozie_database', value: 'Existing Oracle Database'},
  376. {name: 'oozie_database_type', value: 'oracle'},
  377. {name: 'oozie_existing_oracle_host', value: 'h1'},
  378. {name: 'oozie_hostname', value: 'h2'}
  379. ],
  380. removed: Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_mysql_host',
  381. 'oozie_existing_mysql_database', 'oozie_derby_database', 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database']),
  382. oozie_database_type: 'oracle',
  383. m: 'oozie_database: Existing Oracle Database',
  384. host: 'h1'
  385. }
  386. ]).forEach(function (test) {
  387. it(test.m, function () {
  388. test.removed.forEach(function (c) {
  389. if (!test.globals.findProperty('name', c)) {
  390. test.globals.pushObject({name: c})
  391. }
  392. });
  393. var configs = installerStep8Controller.removeOozieConfigs(test.globals);
  394. test.removed.forEach(function(name) {
  395. expect(Em.isNone(configs.findProperty('name', name))).to.equal(true);
  396. });
  397. expect(configs.findProperty('name', 'oozie_database_type').value).to.equal(test.oozie_database_type);
  398. expect(configs.findProperty('name', 'oozie_hostname').value).to.equal(test.host);
  399. });
  400. });
  401. });
  402. describe('#getRegisteredHosts', function() {
  403. Em.A([
  404. {
  405. hosts: {},
  406. m: 'no content.hosts',
  407. e: []
  408. },
  409. {
  410. hosts: {
  411. h1:{bootStatus: ''},
  412. h2:{bootStatus: ''}
  413. },
  414. m: 'no registered hosts',
  415. e: []
  416. },
  417. {
  418. hosts: {
  419. h1:{bootStatus: 'REGISTERED', hostName: '', name: 'n1'},
  420. h2:{bootStatus: 'REGISTERED', hostName: '', name: 'n2'}
  421. },
  422. m: 'registered hosts available',
  423. e: ['n1', 'n2']
  424. }
  425. ]).forEach(function(test) {
  426. it(test.m, function() {
  427. installerStep8Controller.set('content', {hosts: test.hosts});
  428. var hosts = installerStep8Controller.getRegisteredHosts();
  429. expect(hosts.mapProperty('hostName')).to.eql(test.e);
  430. });
  431. });
  432. });
  433. describe('#loadRepoInfo', function() {
  434. it('should use App.currentStackVersion', function() {
  435. var version = 'HDP-1.1.1';
  436. sinon.stub(App, 'get', function() {return version;});
  437. sinon.stub(App.ajax, 'send', Em.K);
  438. installerStep8Controller.loadRepoInfo();
  439. var data = App.ajax.send.args[0][0].data;
  440. expect(data).to.eql({stackName: 'HDP', stackVersion: '1.1.1'});
  441. App.ajax.send.restore();
  442. App.get.restore();
  443. });
  444. });
  445. describe('#loadRepoInfoSuccessCallback', function () {
  446. beforeEach(function () {
  447. installerStep8Controller.set('clusterInfo', Em.Object.create({}));
  448. });
  449. Em.A([
  450. {
  451. items: [],
  452. m: 'no data',
  453. e: {
  454. base_url: [],
  455. os_type: []
  456. }
  457. },
  458. {
  459. items: [
  460. {
  461. repositories: [
  462. {
  463. Repositories: {
  464. os_type: 'redhat5',
  465. base_url: 'url1'
  466. }
  467. }
  468. ],
  469. OperatingSystems: {
  470. is_type: ''
  471. }
  472. }
  473. ],
  474. m: 'only redhat5',
  475. e: {
  476. base_url: ['url1'],
  477. os_type: ['redhat5']
  478. }
  479. },
  480. {
  481. items: [
  482. {
  483. repositories: [
  484. {
  485. Repositories: {
  486. os_type: 'redhat5',
  487. base_url: 'url1'
  488. }
  489. }
  490. ],
  491. OperatingSystems: {
  492. is_type: ''
  493. }
  494. },
  495. {
  496. repositories: [
  497. {
  498. Repositories: {
  499. os_type: 'redhat6',
  500. base_url: 'url2'
  501. }
  502. }
  503. ],
  504. OperatingSystems: {
  505. is_type: ''
  506. }
  507. }
  508. ],
  509. m: 'redhat5, redhat6',
  510. e: {
  511. base_url: ['url1', 'url2'],
  512. os_type: ['redhat5', 'redhat6']
  513. }
  514. },
  515. {
  516. items: [
  517. {
  518. repositories: [
  519. {
  520. Repositories: {
  521. os_type: 'redhat5',
  522. base_url: 'url1'
  523. }
  524. }
  525. ],
  526. OperatingSystems: {
  527. is_type: ''
  528. }
  529. },
  530. {
  531. repositories: [
  532. {
  533. Repositories: {
  534. os_type: 'redhat6',
  535. base_url: 'url2'
  536. }
  537. }
  538. ],
  539. OperatingSystems: {
  540. is_type: ''
  541. }
  542. },
  543. {
  544. repositories: [
  545. {
  546. Repositories: {
  547. os_type: 'sles11',
  548. base_url: 'url3'
  549. }
  550. }
  551. ],
  552. OperatingSystems: {
  553. is_type: ''
  554. }
  555. }
  556. ],
  557. m: 'redhat5, redhat6, sles11',
  558. e: {
  559. base_url: ['url1', 'url2', 'url3'],
  560. os_type: ['redhat5', 'redhat6', 'sles11']
  561. }
  562. }
  563. ]).forEach(function (test) {
  564. it(test.m, function () {
  565. installerStep8Controller.loadRepoInfoSuccessCallback({items: test.items});
  566. expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('base_url')).to.eql(test.e.base_url);
  567. expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('os_type')).to.eql(test.e.os_type);
  568. });
  569. });
  570. });
  571. describe('#loadRepoInfoErrorCallback', function() {
  572. it('should set [] to repoInfo', function() {
  573. installerStep8Controller.set('clusterInfo', Em.Object.create({repoInfo: [{}, {}]}));
  574. installerStep8Controller.loadRepoInfoErrorCallback({});
  575. expect(installerStep8Controller.get('clusterInfo.repoInfo.length')).to.eql(0);
  576. });
  577. });
  578. describe('#loadHiveDbValue', function() {
  579. beforeEach(function() {
  580. installerStep8Controller.set('wizardController', Em.Object.create({
  581. getDBProperty: Em.K
  582. }));
  583. });
  584. Em.A([
  585. {
  586. serviceConfigProperties: [
  587. {name: 'hive_database', value: 'New MySQL Database'}
  588. ],
  589. m: 'New MySQL Database',
  590. e: 'MySQL (New Database)'
  591. },
  592. {
  593. serviceConfigProperties: [
  594. {name: 'hive_database', value: 'New PostgreSQL Database'}
  595. ],
  596. m: 'New PostgreSQL Database',
  597. e: 'Postgres (New Database)'
  598. },
  599. {
  600. serviceConfigProperties: [
  601. {name: 'hive_database', value: 'Existing MySQL Database'},
  602. {name: 'hive_existing_mysql_database', value: 'dbname'}
  603. ],
  604. m: 'Existing MySQL Database',
  605. e: 'dbname (Existing MySQL Database)'
  606. },
  607. {
  608. serviceConfigProperties: [
  609. {name: 'hive_database', value: 'Existing PostgreSQL Database'},
  610. {name: 'hive_existing_postgresql_database', value: 'dbname'}
  611. ],
  612. m: 'Existing PostgreSQL Database',
  613. e: 'dbname (Existing PostgreSQL Database)'
  614. },
  615. {
  616. serviceConfigProperties: [
  617. {name: 'hive_database', value: 'Existing Oracle Database'},
  618. {name: 'hive_existing_oracle_database', value: 'dbname'}
  619. ],
  620. m: 'Existing Oracle Database',
  621. e: 'dbname (Existing Oracle Database)'
  622. }
  623. ]).forEach(function(test) {
  624. it(test.m, function() {
  625. sinon.stub(installerStep8Controller.get('wizardController'), 'getDBProperty', function() {
  626. return test.serviceConfigProperties;
  627. });
  628. var dbComponent = installerStep8Controller.loadHiveDbValue();
  629. expect(dbComponent).to.equal(test.e);
  630. installerStep8Controller.get('wizardController').getDBProperty.restore();
  631. });
  632. });
  633. });
  634. describe('#loadHbaseMasterValue', function () {
  635. Em.A([
  636. {
  637. masterComponentHosts: [{component: 'HBASE_MASTER', hostName: 'h1'}],
  638. component: Em.Object.create({component_name: 'HBASE_MASTER'}),
  639. m: 'one host',
  640. e: 'h1'
  641. },
  642. {
  643. masterComponentHosts: [{component: 'HBASE_MASTER', hostName: 'h1'}, {component: 'HBASE_MASTER', hostName: 'h2'}, {component: 'HBASE_MASTER', hostName: 'h3'}],
  644. component: Em.Object.create({component_name: 'HBASE_MASTER'}),
  645. m: 'many hosts',
  646. e: 'h1 ' + Em.I18n.t('installer.step8.other').format(2)
  647. }
  648. ]).forEach(function (test) {
  649. it(test.m, function() {
  650. installerStep8Controller.set('content', {masterComponentHosts: test.masterComponentHosts});
  651. installerStep8Controller.loadHbaseMasterValue(test.component);
  652. expect(test.component.component_value).to.equal(test.e);
  653. });
  654. });
  655. });
  656. describe('#loadZkServerValue', function() {
  657. Em.A([
  658. {
  659. masterComponentHosts: [{component: 'ZOOKEEPER_SERVER'}],
  660. component: Em.Object.create({component_name: 'ZOOKEEPER_SERVER'}),
  661. m: '1 host',
  662. e: '1 host'
  663. },
  664. {
  665. masterComponentHosts: [{component: 'ZOOKEEPER_SERVER'},{component: 'ZOOKEEPER_SERVER'},{component: 'ZOOKEEPER_SERVER'}],
  666. component: Em.Object.create({component_name: 'ZOOKEEPER_SERVER'}),
  667. m: 'many hosts',
  668. e: '3 hosts'
  669. }
  670. ]).forEach(function (test) {
  671. it(test.m, function () {
  672. installerStep8Controller.set('content', {masterComponentHosts: test.masterComponentHosts});
  673. installerStep8Controller.loadZkServerValue(test.component);
  674. expect(test.component.component_value).to.equal(test.e);
  675. });
  676. });
  677. });
  678. describe('#loadOozieDbValue', function() {
  679. beforeEach(function() {
  680. installerStep8Controller.set('wizardController', Em.Object.create({
  681. getDBProperty: Em.K
  682. }));
  683. });
  684. Em.A([
  685. {
  686. serviceConfigProperties: [
  687. {name: 'oozie_database', value: 'New Derby Database'},
  688. {name: 'oozie_derby_database', value: 'dbname'}
  689. ],
  690. m: 'New Derby Database',
  691. e: 'dbname (New Derby Database)'
  692. },
  693. {
  694. serviceConfigProperties: [
  695. {name: 'oozie_database', value: 'Existing MySQL Database'},
  696. {name: 'oozie_existing_mysql_database', value: 'dbname'}
  697. ],
  698. m: 'Existing MySQL Database',
  699. e: 'dbname (Existing MySQL Database)'
  700. },
  701. {
  702. serviceConfigProperties: [
  703. {name: 'oozie_database', value: 'Existing PostgreSQL Database'},
  704. {name: 'oozie_existing_postgresql_database', value: 'dbname'}
  705. ],
  706. m: 'Existing PostgreSQL Database',
  707. e: 'dbname (Existing PostgreSQL Database)'
  708. },
  709. {
  710. serviceConfigProperties: [
  711. {name: 'oozie_database', value: 'Existing Oracle Database'},
  712. {name: 'oozie_existing_oracle_database', value: 'dbname'}
  713. ],
  714. m: 'Existing Oracle Database',
  715. e: 'dbname (Existing Oracle Database)'
  716. }
  717. ]).forEach(function(test) {
  718. it(test.m, function() {
  719. sinon.stub(installerStep8Controller.get('wizardController'), 'getDBProperty', function() {
  720. return test.serviceConfigProperties;
  721. });
  722. var dbComponent = installerStep8Controller.loadOozieDbValue();
  723. expect(dbComponent).to.equal(test.e);
  724. installerStep8Controller.get('wizardController').getDBProperty.restore();
  725. });
  726. });
  727. });
  728. describe('#loadNagiosAdminValue', function() {
  729. it('should use serviceConfigProperties nagios_web_login and nagios_contact', function() {
  730. installerStep8Controller.set('content', {
  731. serviceConfigProperties: [
  732. {name: 'nagios_web_login', value: 'admin'},
  733. {name: 'nagios_contact', value: 'admin@admin.com'}
  734. ]
  735. });
  736. var nagiosAdmin = installerStep8Controller.loadNagiosAdminValue();
  737. expect(nagiosAdmin).to.equal('admin / (admin@admin.com)');
  738. });
  739. });
  740. describe('#submit', function() {
  741. beforeEach(function() {
  742. sinon.stub(installerStep8Controller, 'submitProceed', Em.K);
  743. sinon.spy(App, 'showConfirmationPopup');
  744. });
  745. afterEach(function() {
  746. installerStep8Controller.submitProceed.restore();
  747. App.showConfirmationPopup.restore();
  748. });
  749. Em.A([
  750. {
  751. controllerName: 'addHostController',
  752. securityEnabled: true,
  753. e: true
  754. },
  755. {
  756. controllerName: 'addHostController',
  757. securityEnabled: false,
  758. e: false
  759. },
  760. {
  761. controllerName: 'addServiceController',
  762. securityEnabled: true,
  763. e: false
  764. },
  765. {
  766. controllerName: 'addServiceController',
  767. securityEnabled: false,
  768. e: false
  769. }
  770. ]).forEach(function (test) {
  771. it(test.controllerName + ' ' + test.securityEnabled.toString(), function () {
  772. installerStep8Controller.reopen({isSubmitDisabled: false, securityEnabled: test.securityEnabled, content: {controllerName: test.controllerName}});
  773. installerStep8Controller.submit();
  774. if (test.e) {
  775. expect(App.showConfirmationPopup.calledOnce).to.equal(true);
  776. expect(installerStep8Controller.submitProceed.called).to.equal(false);
  777. }
  778. else {
  779. expect(App.showConfirmationPopup.called).to.equal(false);
  780. expect(installerStep8Controller.submitProceed.calledOnce).to.equal(true);
  781. }
  782. });
  783. });
  784. it('should call submitProceed when Ok clicked', function() {
  785. installerStep8Controller.reopen({isSubmitDisabled: false, securityEnabled: true, content: {controllerName: 'addHostController'}});
  786. installerStep8Controller.submit().onPrimary();
  787. expect(installerStep8Controller.submitProceed.calledOnce).to.equal(true);
  788. });
  789. it('shouldn\'t do nothing if isSubmitDisabled is true', function() {
  790. installerStep8Controller.reopen({isSubmitDisabled: true});
  791. installerStep8Controller.submit();
  792. expect(App.showConfirmationPopup.called).to.equal(false);
  793. expect(installerStep8Controller.submitProceed.called).to.equal(false);
  794. });
  795. });
  796. describe('#getExistingClusterNamesSuccessCallBack', function() {
  797. it('should set clusterNames received from server', function() {
  798. var data = {
  799. items:[
  800. {Clusters: {cluster_name: 'c1'}},
  801. {Clusters: {cluster_name: 'c2'}},
  802. {Clusters: {cluster_name: 'c3'}}
  803. ]
  804. },
  805. clasterNames = ['c1','c2','c3'];
  806. installerStep8Controller.getExistingClusterNamesSuccessCallBack(data);
  807. expect(installerStep8Controller.get('clusterNames')).to.eql(clasterNames);
  808. });
  809. });
  810. describe('#getExistingClusterNamesErrorCallback', function() {
  811. it('should set [] to clusterNames', function() {
  812. installerStep8Controller.set('clusterNames', ['c1', 'c2']);
  813. installerStep8Controller.getExistingClusterNamesErrorCallback();
  814. expect(installerStep8Controller.get('clusterNames')).to.eql([]);
  815. });
  816. });
  817. describe('#deleteClusters', function() {
  818. it('should call App.ajax.send for each provided clusterName', function() {
  819. sinon.stub(App.ajax, 'send', Em.K);
  820. var clusterNames = ['h1', 'h2', 'h3'];
  821. installerStep8Controller.deleteClusters(clusterNames);
  822. expect(App.ajax.send.callCount).to.equal(clusterNames.length);
  823. clusterNames.forEach(function(n, i) {
  824. expect(App.ajax.send.getCall(i).args[0].data).to.eql({name: n, isLast: i == clusterNames.length - 1});
  825. });
  826. App.ajax.send.restore();
  827. });
  828. });
  829. describe('#createSelectedServicesData', function() {
  830. it('should reformat provided data', function() {
  831. var selectedServices = [
  832. Em.Object.create({serviceName: 's1'}),
  833. Em.Object.create({serviceName: 's2'}),
  834. Em.Object.create({serviceName: 's3'})
  835. ];
  836. var expected = [
  837. {"ServiceInfo": { "service_name": 's1' }},
  838. {"ServiceInfo": { "service_name": 's2' }},
  839. {"ServiceInfo": { "service_name": 's3' }}
  840. ];
  841. installerStep8Controller.reopen({selectedServices: selectedServices});
  842. var createdData = installerStep8Controller.createSelectedServicesData();
  843. expect(createdData).to.eql(expected);
  844. });
  845. });
  846. describe('#createRegisterHostData', function() {
  847. it('should return empty data if no hosts', function() {
  848. sinon.stub(installerStep8Controller, 'getRegisteredHosts', function() {return [];});
  849. expect(installerStep8Controller.createRegisterHostData()).to.eql([]);
  850. installerStep8Controller.getRegisteredHosts.restore();
  851. });
  852. it('should return computed data', function() {
  853. var data = [
  854. {isInstalled: false, hostName: 'h1'},
  855. {isInstalled: true, hostName: 'h2'},
  856. {isInstalled: false, hostName: 'h3'}
  857. ];
  858. var expected = [
  859. {"Hosts": { "host_name": 'h1'}},
  860. {"Hosts": { "host_name": 'h3'}}
  861. ];
  862. sinon.stub(installerStep8Controller, 'getRegisteredHosts', function() {return data;});
  863. expect(installerStep8Controller.createRegisterHostData()).to.eql(expected);
  864. installerStep8Controller.getRegisteredHosts.restore();
  865. });
  866. });
  867. describe('#createZooCfgObj', function() {
  868. it('should affect zoo.cfg properties', function() {
  869. var configs = [
  870. {filename: 'zoo.cfg', value: 'a&b', name: 'p1'},
  871. {filename: 'zoo.cfg', value: 'a<b', name: 'p2'},
  872. {filename: 'zoo.cfg', value: 'a>b', name: 'p3'},
  873. {filename: 'zoo.cfg', value: 'a"b', name: 'p4'},
  874. {filename: 'zoo.cfg', value: 'a'b', name: 'p5'}
  875. ],
  876. expected = {
  877. type: 'zoo.cfg',
  878. tag: 'version1',
  879. properties: {
  880. p1: 'a&b',
  881. p2: 'a<b',
  882. p3: 'a>b',
  883. p4: 'a"b',
  884. p5: 'a'b'
  885. }
  886. };
  887. installerStep8Controller.reopen({configs: configs});
  888. expect(installerStep8Controller.createZooCfgObj('version1')).to.eql(expected);
  889. });
  890. });
  891. describe('#createStormSiteObj', function() {
  892. it('should replace quote \'"\' to "\'" for some properties', function() {
  893. var configs = [
  894. {filename: 'storm-site.xml', value: ["a", "b"], name: 'storm.zookeeper.servers'}
  895. ],
  896. expected = {
  897. type: 'storm-site',
  898. tag: 'version1',
  899. properties: {
  900. 'storm.zookeeper.servers': '[\'a\',\'b\']'
  901. }
  902. };
  903. installerStep8Controller.reopen({configs: configs});
  904. expect(installerStep8Controller.createStormSiteObj('version1')).to.eql(expected);
  905. });
  906. it('should not escape special characters', function() {
  907. var configs = [
  908. {filename: 'storm-site.xml', value: "abc\n\t", name: 'nimbus.childopts'},
  909. {filename: 'storm-site.xml', value: "a\nb", name: 'supervisor.childopts'},
  910. {filename: 'storm-site.xml', value: "a\t\tb", name: 'worker.childopts'}
  911. ],
  912. expected = {
  913. type: 'storm-site',
  914. tag: 'version1',
  915. properties: {
  916. 'nimbus.childopts': 'abc\n\t',
  917. 'supervisor.childopts': 'a\nb',
  918. 'worker.childopts': 'a\t\tb'
  919. }
  920. };
  921. installerStep8Controller.reopen({configs: configs});
  922. expect(installerStep8Controller.createStormSiteObj('version1')).to.eql(expected);
  923. });
  924. });
  925. describe('#ajaxQueueFinished', function() {
  926. it('should call App.router.next', function() {
  927. sinon.stub(App.router, 'send', Em.K);
  928. installerStep8Controller.ajaxQueueFinished();
  929. expect(App.router.send.calledWith('next')).to.equal(true);
  930. App.router.send.restore();
  931. });
  932. });
  933. describe('#addRequestToAjaxQueue', function() {
  934. describe('testMode = true', function() {
  935. before(function() {
  936. App.set('testMode', true);
  937. });
  938. after(function() {
  939. App.set('testMode', false);
  940. });
  941. it('shouldn\'t do nothing', function() {
  942. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  943. installerStep8Controller.get('ajaxRequestsQueue').clear();
  944. installerStep8Controller.addRequestToAjaxQueue({});
  945. expect(installerStep8Controller.get('ajaxRequestsQueue.queue.length')).to.equal(0);
  946. });
  947. });
  948. describe('testMode = true', function() {
  949. before(function() {
  950. App.set('testMode', false);
  951. });
  952. it('should add request', function() {
  953. var clusterName = 'c1';
  954. installerStep8Controller.reopen({clusterName: clusterName});
  955. installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
  956. installerStep8Controller.get('ajaxRequestsQueue').clear();
  957. installerStep8Controller.addRequestToAjaxQueue({name:'name', data:{}});
  958. var request = installerStep8Controller.get('ajaxRequestsQueue.queue.firstObject');
  959. expect(request.error).to.equal('ajaxQueueRequestErrorCallback');
  960. expect(request.data.cluster).to.equal(clusterName);
  961. });
  962. });
  963. });
  964. describe('#ajaxQueueRequestErrorCallback', function() {
  965. var obj = Em.Object.create({
  966. registerErrPopup: Em.K,
  967. setStepsEnable: Em.K
  968. });
  969. beforeEach(function() {
  970. sinon.stub(App.router, 'get', function() {
  971. return obj;
  972. });
  973. sinon.spy(obj, 'registerErrPopup');
  974. sinon.spy(obj, 'setStepsEnable');
  975. });
  976. afterEach(function() {
  977. App.router.get.restore();
  978. obj.registerErrPopup.restore();
  979. obj.setStepsEnable.restore();
  980. });
  981. it('should set hasErrorOccurred true', function () {
  982. installerStep8Controller.set('hasErrorOccurred', false);
  983. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  984. expect(installerStep8Controller.get('hasErrorOccurred')).to.equal(true);
  985. });
  986. it('should set isSubmitDisabled false', function () {
  987. installerStep8Controller.set('isSubmitDisabled', true);
  988. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  989. expect(installerStep8Controller.get('isSubmitDisabled')).to.equal(false);
  990. });
  991. it('should set isBackBtnDisabled false', function () {
  992. installerStep8Controller.set('isBackBtnDisabled', true);
  993. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  994. expect(installerStep8Controller.get('isBackBtnDisabled')).to.equal(false);
  995. });
  996. it('should call setStepsEnable', function () {
  997. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  998. expect(obj.setStepsEnable.calledOnce).to.equal(true);
  999. });
  1000. it('should call registerErrPopup', function () {
  1001. installerStep8Controller.ajaxQueueRequestErrorCallback({responseText: '{"message": ""}'});
  1002. expect(obj.registerErrPopup.calledOnce).to.equal(true);
  1003. });
  1004. });
  1005. describe('#removeInstalledServicesConfigurationGroups', function() {
  1006. beforeEach(function() {
  1007. sinon.stub(App.config, 'deleteConfigGroup', Em.K);
  1008. });
  1009. afterEach(function() {
  1010. App.config.deleteConfigGroup.restore();
  1011. });
  1012. it('should call App.config.deleteConfigGroup for each received group', function() {
  1013. var groups = [{}, {}, {}];
  1014. installerStep8Controller.removeInstalledServicesConfigurationGroups(groups);
  1015. expect(App.config.deleteConfigGroup.callCount).to.equal(groups.length);
  1016. });
  1017. });
  1018. describe('#addDynamicProperties', function() {
  1019. it('shouldn\'t add property', function() {
  1020. var serviceConfigProperties = [
  1021. {name: 'templeton.hive.properties'}
  1022. ],
  1023. configs = [];
  1024. installerStep8Controller.reopen({content: {serviceConfigProperties: serviceConfigProperties}});
  1025. installerStep8Controller.addDynamicProperties(configs);
  1026. expect(configs.length).to.equal(0);
  1027. });
  1028. it('should add property', function() {
  1029. var serviceConfigProperties = [],
  1030. configs = [];
  1031. installerStep8Controller.reopen({content: {serviceConfigProperties: serviceConfigProperties}});
  1032. installerStep8Controller.addDynamicProperties(configs);
  1033. expect(configs.length).to.equal(1);
  1034. });
  1035. });
  1036. describe('#formatProperties', function() {
  1037. });
  1038. describe('#applyInstalledServicesConfigurationGroup', function() {
  1039. beforeEach(function() {
  1040. sinon.stub($, 'ajax', Em.K);
  1041. sinon.stub(App.router, 'get', function() {
  1042. return configurationController;
  1043. });
  1044. });
  1045. afterEach(function() {
  1046. $.ajax.restore();
  1047. App.router.get.restore();
  1048. });
  1049. it('should do ajax request for each config group', function() {
  1050. var configGroups = [{ConfigGroup: {id:''}}, {ConfigGroup: {id:''}}];
  1051. installerStep8Controller.applyInstalledServicesConfigurationGroup(configGroups);
  1052. expect($.ajax.callCount).to.equal(configGroups.length);
  1053. });
  1054. });
  1055. describe('#getExistingClusterNames', function() {
  1056. beforeEach(function() {
  1057. sinon.stub(App.ajax, 'send', Em.K);
  1058. });
  1059. afterEach(function() {
  1060. App.ajax.send.restore();
  1061. });
  1062. it('should do ajax request', function() {
  1063. installerStep8Controller.getExistingClusterNames();
  1064. expect(App.ajax.send.calledOnce).to.be.true;
  1065. });
  1066. });
  1067. describe('#loadUiSideConfigs', function() {
  1068. beforeEach(function() {
  1069. sinon.stub(installerStep8Controller, 'addDynamicProperties', Em.K);
  1070. sinon.stub(installerStep8Controller, 'getGlobConfigValueWithOverrides', function(t, v, n) {
  1071. return {
  1072. value: v,
  1073. overrides: []
  1074. }
  1075. });
  1076. sinon.stub(App.config, 'setConfigValue', Em.K);
  1077. });
  1078. afterEach(function() {
  1079. installerStep8Controller.addDynamicProperties.restore();
  1080. installerStep8Controller.getGlobConfigValueWithOverrides.restore();
  1081. App.config.setConfigValue.restore();
  1082. });
  1083. it('all configs witohut foreignKey', function() {
  1084. var configMapping = [
  1085. {foreignKey: null, templateName: 't1', value: 'v1', name: 'c1', filename: 'f1'},
  1086. {foreignKey: null, templateName: 't2', value: 'v2', name: 'c2', filename: 'f2'},
  1087. {foreignKey: null, templateName: 't3', value: 'v3', name: 'c3', filename: 'f2'},
  1088. {foreignKey: null, templateName: 't4', value: 'v4', name: 'c4', filename: 'f1'}
  1089. ];
  1090. var uiConfigs = installerStep8Controller.loadUiSideConfigs(configMapping);
  1091. expect(uiConfigs.length).to.equal(configMapping.length);
  1092. expect(uiConfigs.everyProperty('id', 'site property')).to.be.true;
  1093. uiConfigs.forEach(function(c, index) {
  1094. expect(c.overrides).to.be.an.array;
  1095. expect(c.value).to.equal(configMapping[index].value);
  1096. expect(c.name).to.equal(configMapping[index].name);
  1097. expect(c.filename).to.equal(configMapping[index].filename);
  1098. });
  1099. });
  1100. it('some configs witohut foreignKey', function() {
  1101. var configMapping = [
  1102. {foreignKey: null, templateName: 't1', value: 'v1', name: 'c1', filename: 'f1'},
  1103. {foreignKey: null, templateName: 't2', value: 'v2', name: 'c2', filename: 'f2'},
  1104. {foreignKey: null, templateName: 't3', value: 'v3', name: 'c3', filename: 'f2'},
  1105. {foreignKey: null, templateName: 't4', value: 'v4', name: 'c4', filename: 'f1'},
  1106. {foreignKey: 'fk1', templateName: 't5', value: 'v5', name: 'c5', filename: 'f1'},
  1107. {foreignKey: 'fk2', templateName: 't6', value: 'v6', name: 'c6', filename: 'f1'},
  1108. {foreignKey: 'fk3', templateName: 't7', value: 'v7', name: 'c7', filename: 'f2'},
  1109. {foreignKey: 'fk4', templateName: 't8', value: 'v8', name: 'c8', filename: 'f2'}
  1110. ];
  1111. var uiConfigs = installerStep8Controller.loadUiSideConfigs(configMapping);
  1112. expect(uiConfigs.length).to.equal(configMapping.length);
  1113. expect(uiConfigs.everyProperty('id', 'site property')).to.be.true;
  1114. uiConfigs.forEach(function(c, index) {
  1115. if (Em.isNone(configMapping[index].foreignKey))
  1116. expect(c.overrides).to.be.an.array;
  1117. expect(c.value).to.equal(configMapping[index].value);
  1118. expect(c.name).to.equal(configMapping[index].name);
  1119. expect(c.filename).to.equal(configMapping[index].filename);
  1120. });
  1121. });
  1122. });
  1123. describe('Queued requests', function() {
  1124. beforeEach(function() {
  1125. sinon.stub(installerStep8Controller, 'addRequestToAjaxQueue', Em.K);
  1126. });
  1127. afterEach(function() {
  1128. installerStep8Controller.addRequestToAjaxQueue.restore();
  1129. });
  1130. describe('#createCluster', function() {
  1131. it('shouldn\'t add request to queue if not installerController used', function() {
  1132. installerStep8Controller.reopen({content: {controllerName: 'addServiceController'}});
  1133. installerStep8Controller.createCluster();
  1134. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1135. });
  1136. it('App.currentStackVersion should be changed if localRepo selected', function() {
  1137. App.set('currentStackVersion', 'HDP-1.1.1');
  1138. installerStep8Controller.reopen({content: {controllerName: 'installerController', installOptions: {localRepo: true}}});
  1139. var data = {
  1140. data: JSON.stringify({ "Clusters": {"version": 'HDPLocal-1.1.1' }})
  1141. };
  1142. installerStep8Controller.createCluster();
  1143. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data).to.eql(data);
  1144. });
  1145. it('App.currentStackVersion shouldn\'t be changed if localRepo ins\'t selected', function() {
  1146. App.set('currentStackVersion', 'HDP-1.1.1');
  1147. installerStep8Controller.reopen({content: {controllerName: 'installerController', installOptions: {localRepo: false}}});
  1148. var data = {
  1149. data: JSON.stringify({ "Clusters": {"version": 'HDP-1.1.1' }})
  1150. };
  1151. installerStep8Controller.createCluster();
  1152. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data).to.eql(data);
  1153. });
  1154. });
  1155. describe('#createSelectedServices', function() {
  1156. it('shouldn\'t do nothing if no data', function() {
  1157. sinon.stub(installerStep8Controller, 'createSelectedServicesData', function() {return [];});
  1158. installerStep8Controller.createSelectedServices();
  1159. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1160. installerStep8Controller.createSelectedServicesData.restore();
  1161. });
  1162. it('should call addRequestToAjaxQueue with computed data', function() {
  1163. var data = [
  1164. {"ServiceInfo": { "service_name": 's1' }},
  1165. {"ServiceInfo": { "service_name": 's2' }},
  1166. {"ServiceInfo": { "service_name": 's3' }}
  1167. ];
  1168. sinon.stub(installerStep8Controller, 'createSelectedServicesData', function() {return data;});
  1169. installerStep8Controller.createSelectedServices();
  1170. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data).to.eql({data: JSON.stringify(data)});
  1171. installerStep8Controller.createSelectedServicesData.restore();
  1172. });
  1173. });
  1174. describe('#registerHostsToCluster', function() {
  1175. it('shouldn\'t do nothing if no data', function() {
  1176. sinon.stub(installerStep8Controller, 'createRegisterHostData', function() {return [];});
  1177. installerStep8Controller.registerHostsToCluster();
  1178. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1179. installerStep8Controller.createRegisterHostData.restore();
  1180. });
  1181. it('should call addRequestToAjaxQueue with computed data', function() {
  1182. var data = [
  1183. {"Hosts": { "host_name": 'h1'}},
  1184. {"Hosts": { "host_name": 'h3'}}
  1185. ];
  1186. sinon.stub(installerStep8Controller, 'createRegisterHostData', function() {return data;});
  1187. installerStep8Controller.registerHostsToCluster();
  1188. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data).to.eql({data: JSON.stringify(data)});
  1189. installerStep8Controller.createRegisterHostData.restore();
  1190. });
  1191. });
  1192. describe('#registerHostsToComponent', function() {
  1193. it('shouldn\'t do request if no hosts provided', function() {
  1194. installerStep8Controller.registerHostsToComponent([]);
  1195. expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
  1196. });
  1197. it('should do request if hostNames are provided', function() {
  1198. var hostNames = ['h1', 'h2'],
  1199. componentName = 'c1';
  1200. installerStep8Controller.registerHostsToComponent(hostNames, componentName);
  1201. var data = JSON.parse(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data);
  1202. expect(data.RequestInfo.query).to.equal('Hosts/host_name=h1|Hosts/host_name=h2');
  1203. expect(data.Body.host_components[0].HostRoles.component_name).to.equal('c1');
  1204. });
  1205. });
  1206. describe('#applyConfigurationsToCluster', function() {
  1207. it('should call addRequestToAjaxQueue', function() {
  1208. var serviceConfigTags = [
  1209. {
  1210. type: 'hdfs',
  1211. tag: 'tag1',
  1212. properties: [
  1213. {},
  1214. {}
  1215. ]
  1216. }
  1217. ],
  1218. data = '['+JSON.stringify({
  1219. Clusters: {
  1220. desired_config: [serviceConfigTags[0]]
  1221. }
  1222. })+']';
  1223. installerStep8Controller.reopen({
  1224. selectedServices: [
  1225. Em.Object.create({
  1226. isSelected: true,
  1227. isInstalled: false,
  1228. configTypesRendered: {hdfs:'tag1'}
  1229. })
  1230. ]
  1231. });
  1232. installerStep8Controller.applyConfigurationsToCluster(serviceConfigTags);
  1233. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data).to.eql({data: data});
  1234. });
  1235. it('should call addRequestToAjaxQueue with core-site if addServiceController', function() {
  1236. var serviceConfigTags = [
  1237. {
  1238. type: 'oozie',
  1239. tag: 'tag1',
  1240. properties: [
  1241. {},
  1242. {}
  1243. ]
  1244. },
  1245. {
  1246. type: 'core-site',
  1247. tag: 'tag1',
  1248. properties: [
  1249. {}
  1250. ]
  1251. },
  1252. {
  1253. type: 'cluster-env',
  1254. tag: 'tag1',
  1255. properties: [
  1256. {}
  1257. ]
  1258. }
  1259. ];
  1260. data = '['+ JSON.stringify({Clusters: {
  1261. desired_config: [serviceConfigTags[0]]
  1262. }
  1263. }) + ',' +
  1264. JSON.stringify({Clusters: {
  1265. desired_config: [serviceConfigTags[1]]
  1266. }
  1267. }) + ',' +
  1268. JSON.stringify({Clusters: {
  1269. desired_config: [serviceConfigTags[2]]
  1270. }
  1271. }) + ']';
  1272. installerStep8Controller.reopen({
  1273. selectedServices: [
  1274. Em.Object.create({
  1275. isSelected: true,
  1276. isInstalled: false,
  1277. configTypesRendered: {'oozie': 'tag1' }
  1278. })
  1279. ],
  1280. content: {
  1281. controllerName: 'addServiceController'
  1282. }
  1283. });
  1284. installerStep8Controller.applyConfigurationsToCluster(serviceConfigTags);
  1285. var sendData = installerStep8Controller.addRequestToAjaxQueue.args[0][0].data;
  1286. expect(sendData).to.eql({data: data});
  1287. });
  1288. });
  1289. describe('#applyConfigurationGroups', function() {
  1290. it('should call addRequestToAjaxQueue', function() {
  1291. var data = [{}, {}];
  1292. installerStep8Controller.applyConfigurationGroups(data);
  1293. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data).to.eql({data: JSON.stringify(data)});
  1294. });
  1295. });
  1296. describe('#newServiceComponentErrorCallback', function() {
  1297. it('should add request for new component', function() {
  1298. var serviceName = 's1',
  1299. componentName = 'c1';
  1300. installerStep8Controller.newServiceComponentErrorCallback({}, {}, '', {}, {serviceName: serviceName, componentName: componentName});
  1301. var data = JSON.parse(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data);
  1302. expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.serviceName).to.equal(serviceName);
  1303. expect(data.components[0].ServiceComponentInfo.component_name).to.equal(componentName);
  1304. });
  1305. });
  1306. describe('#createAdditionalHostComponents', function() {
  1307. beforeEach(function() {
  1308. sinon.stub(installerStep8Controller, 'registerHostsToComponent', Em.K);
  1309. });
  1310. afterEach(function() {
  1311. installerStep8Controller.registerHostsToComponent.restore();
  1312. });
  1313. it('should add GANGLIA MONITOR (1)', function() {
  1314. installerStep8Controller.reopen({
  1315. getRegisteredHosts: function() {
  1316. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1317. },
  1318. content: {
  1319. services: [
  1320. Em.Object.create({serviceName: 'GANGLIA', isSelected: true, isInstalled: false})
  1321. ]
  1322. }
  1323. });
  1324. installerStep8Controller.createAdditionalHostComponents();
  1325. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  1326. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
  1327. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
  1328. });
  1329. it('should add GANGLIA MONITOR (2)', function() {
  1330. installerStep8Controller.reopen({
  1331. getRegisteredHosts: function() {
  1332. return [{hostName: 'h1', isInstalled: true}, {hostName: 'h2', isInstalled: false}];
  1333. },
  1334. content: {
  1335. services: [
  1336. Em.Object.create({serviceName: 'GANGLIA', isSelected: true, isInstalled: true})
  1337. ]
  1338. }
  1339. });
  1340. installerStep8Controller.createAdditionalHostComponents();
  1341. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  1342. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h2']);
  1343. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
  1344. });
  1345. var newDatabases = [
  1346. {name: 'New MySQL Database',
  1347. component: 'MYSQL_SERVER'
  1348. },
  1349. {name: 'New PostgreSQL Database',
  1350. component: 'POSTGRESQL_SERVER'
  1351. },
  1352. ];
  1353. newDatabases.forEach(function (db) {
  1354. it('should add {0}'.format(db.component), function() {
  1355. installerStep8Controller.reopen({
  1356. getRegisteredHosts: function() {
  1357. return [{hostName: 'h1'}, {hostName: 'h2'}];
  1358. },
  1359. content: {
  1360. masterComponentHosts: [
  1361. {component: 'HIVE_SERVER', hostName: 'h1'},
  1362. {component: 'HIVE_SERVER', hostName: 'h2'}
  1363. ],
  1364. services: [
  1365. Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false})
  1366. ],
  1367. serviceConfigProperties: [
  1368. {name: 'hive_database', value: db.name}
  1369. ]
  1370. }
  1371. });
  1372. installerStep8Controller.createAdditionalHostComponents();
  1373. expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
  1374. expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
  1375. expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal(db.component);
  1376. });
  1377. });
  1378. });
  1379. });
  1380. });