step7_test.js 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154
  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 numberUtils = require('utils/number_utils');
  20. require('mixins/common/localStorage');
  21. require('models/config_group');
  22. require('controllers/wizard/step7_controller');
  23. var installerStep7Controller;
  24. describe('App.InstallerStep7Controller', function () {
  25. beforeEach(function () {
  26. sinon.stub(App.config, 'setPreDefinedServiceConfigs', Em.K);
  27. installerStep7Controller = App.WizardStep7Controller.create({
  28. content: {
  29. advancedServiceConfig: [],
  30. serviceConfigProperties: []
  31. },
  32. applyServicesConfigs: Em.K
  33. });
  34. });
  35. afterEach(function() {
  36. App.config.setPreDefinedServiceConfigs.restore();
  37. });
  38. describe('#installedServiceNames', function () {
  39. var tests = Em.A([
  40. {
  41. content: Em.Object.create({
  42. controllerName: 'installerController',
  43. services: Em.A([
  44. Em.Object.create({
  45. isInstalled: true,
  46. serviceName: 'SQOOP'
  47. }),
  48. Em.Object.create({
  49. isInstalled: true,
  50. serviceName: 'HDFS'
  51. })
  52. ])
  53. }),
  54. e: ['SQOOP', 'HDFS'],
  55. m: 'installerController with SQOOP'
  56. },
  57. {
  58. content: Em.Object.create({
  59. controllerName: 'installerController',
  60. services: Em.A([
  61. Em.Object.create({
  62. isInstalled: true,
  63. serviceName: 'HIVE'
  64. }),
  65. Em.Object.create({
  66. isInstalled: true,
  67. serviceName: 'HDFS'
  68. })
  69. ])
  70. }),
  71. e: ['HIVE', 'HDFS'],
  72. m: 'installerController without SQOOP'
  73. },
  74. {
  75. content: Em.Object.create({
  76. controllerName: 'addServiceController',
  77. services: Em.A([
  78. Em.Object.create({
  79. isInstalled: true,
  80. serviceName: 'HIVE'
  81. }),
  82. Em.Object.create({
  83. isInstalled: true,
  84. serviceName: 'HDFS'
  85. })
  86. ])
  87. }),
  88. e: ['HIVE', 'HDFS'],
  89. m: 'addServiceController without SQOOP'
  90. }
  91. ]);
  92. tests.forEach(function (test) {
  93. it(test.m, function () {
  94. installerStep7Controller.set('content', test.content);
  95. expect(installerStep7Controller.get('installedServiceNames')).to.include.members(test.e);
  96. expect(test.e).to.include.members(installerStep7Controller.get('installedServiceNames'));
  97. });
  98. });
  99. });
  100. describe('#isSubmitDisabled', function () {
  101. it('should be true if miscModalVisible', function () {
  102. installerStep7Controller.reopen({miscModalVisible: true});
  103. expect(installerStep7Controller.get('isSubmitDisabled')).to.equal(true);
  104. });
  105. it('should be true if some of stepConfigs has errors', function () {
  106. installerStep7Controller.reopen({
  107. miscModalVisible: false,
  108. stepConfigs: [
  109. {
  110. showConfig: true,
  111. errorCount: 1
  112. }
  113. ]
  114. });
  115. expect(installerStep7Controller.get('isSubmitDisabled')).to.equal(true);
  116. });
  117. it('should be false if all of stepConfigs don\'t have errors and miscModalVisible is false', function () {
  118. installerStep7Controller.reopen({
  119. miscModalVisible: false,
  120. stepConfigs: [
  121. {
  122. showConfig: true,
  123. errorCount: 0
  124. }
  125. ]
  126. });
  127. expect(installerStep7Controller.get('isSubmitDisabled')).to.equal(false);
  128. });
  129. });
  130. describe('#selectedServiceNames', function () {
  131. it('should use content.services as source of data', function () {
  132. installerStep7Controller.set('content', {
  133. services: [
  134. {isSelected: true, isInstalled: false, serviceName: 's1'},
  135. {isSelected: false, isInstalled: false, serviceName: 's2'},
  136. {isSelected: true, isInstalled: true, serviceName: 's3'},
  137. {isSelected: false, isInstalled: false, serviceName: 's4'},
  138. {isSelected: true, isInstalled: false, serviceName: 's5'},
  139. {isSelected: false, isInstalled: false, serviceName: 's6'},
  140. {isSelected: true, isInstalled: true, serviceName: 's7'},
  141. {isSelected: false, isInstalled: false, serviceName: 's8'}
  142. ]
  143. });
  144. var expected = ['s1', 's5'];
  145. expect(installerStep7Controller.get('selectedServiceNames')).to.eql(expected);
  146. });
  147. });
  148. describe('#allSelectedServiceNames', function () {
  149. it('should use content.services as source of data', function () {
  150. installerStep7Controller.set('content', {
  151. services: [
  152. Em.Object.create({isSelected: true, isInstalled: false, serviceName: 's1'}),
  153. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's2'}),
  154. Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's3'}),
  155. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's4'}),
  156. Em.Object.create({isSelected: true, isInstalled: false, serviceName: 's5'}),
  157. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's6'}),
  158. Em.Object.create({isSelected: true, isInstalled: true, serviceName: 's7'}),
  159. Em.Object.create({isSelected: false, isInstalled: false, serviceName: 's8'})
  160. ]
  161. });
  162. var expected = ['s1', 's3', 's5', 's7'];
  163. expect(installerStep7Controller.get('allSelectedServiceNames')).to.eql(expected);
  164. });
  165. });
  166. describe('#masterComponentHosts', function () {
  167. it('should be equal to content.masterComponentHosts', function () {
  168. var masterComponentHosts = [
  169. {},
  170. {},
  171. {}
  172. ];
  173. installerStep7Controller.reopen({content: {masterComponentHosts: masterComponentHosts}});
  174. expect(installerStep7Controller.get('masterComponentHosts')).to.eql(masterComponentHosts);
  175. });
  176. });
  177. describe('#slaveComponentHosts', function () {
  178. it('should be equal to content.slaveGroupProperties', function () {
  179. var slaveGroupProperties = [
  180. {},
  181. {},
  182. {}
  183. ];
  184. installerStep7Controller.reopen({content: {slaveGroupProperties: slaveGroupProperties}});
  185. expect(installerStep7Controller.get('slaveComponentHosts')).to.eql(slaveGroupProperties);
  186. });
  187. });
  188. describe('#clearStep', function () {
  189. it('should clear stepConfigs', function () {
  190. installerStep7Controller.set('stepConfigs', [
  191. {},
  192. {}
  193. ]);
  194. installerStep7Controller.clearStep();
  195. expect(installerStep7Controller.get('stepConfigs.length')).to.equal(0);
  196. });
  197. it('should clear filter', function () {
  198. installerStep7Controller.set('filter', 'filter');
  199. installerStep7Controller.clearStep();
  200. expect(installerStep7Controller.get('filter')).to.equal('');
  201. });
  202. it('should set for each filterColumns "selected" false', function () {
  203. installerStep7Controller.set('filterColumns', [
  204. {selected: true},
  205. {selected: false},
  206. {selected: true}
  207. ]);
  208. installerStep7Controller.clearStep();
  209. expect(installerStep7Controller.get('filterColumns').everyProperty('selected', false)).to.equal(true);
  210. });
  211. });
  212. describe('#loadInstalledServicesConfigGroups', function () {
  213. before(function () {
  214. sinon.stub(App.ajax, 'send', Em.K);
  215. });
  216. after(function () {
  217. App.ajax.send.restore();
  218. });
  219. it('should do ajax request for each received service name', function () {
  220. var serviceNames = ['s1', 's2', 's3'];
  221. installerStep7Controller.loadInstalledServicesConfigGroups(serviceNames);
  222. expect(App.ajax.send.callCount).to.equal(serviceNames.length);
  223. });
  224. });
  225. describe('#getConfigTags', function () {
  226. before(function () {
  227. sinon.stub(App.ajax, 'send', Em.K);
  228. });
  229. after(function () {
  230. App.ajax.send.restore();
  231. });
  232. it('should do ajax-request', function () {
  233. installerStep7Controller.getConfigTags();
  234. expect(App.ajax.send.calledOnce).to.equal(true);
  235. });
  236. });
  237. describe('#setGroupsToDelete', function () {
  238. beforeEach(function () {
  239. installerStep7Controller.set('wizardController', Em.Object.create(App.LocalStorage, {name: 'tdk'}));
  240. });
  241. it('should add new groups to groupsToDelete', function () {
  242. var groupsToDelete = [
  243. {id: '1'},
  244. {id: '2'}
  245. ],
  246. groups = [
  247. Em.Object.create({id: '3'}),
  248. Em.Object.create(),
  249. Em.Object.create({id: '5'})
  250. ],
  251. expected = [
  252. {id: "1"},
  253. {id: "2"},
  254. {id: "3"},
  255. {id: "5"}
  256. ];
  257. installerStep7Controller.set('groupsToDelete', groupsToDelete);
  258. installerStep7Controller.setGroupsToDelete(groups);
  259. expect(installerStep7Controller.get('groupsToDelete')).to.eql(expected);
  260. expect(installerStep7Controller.get('wizardController').getDBProperty('groupsToDelete')).to.eql(expected);
  261. });
  262. });
  263. describe('#selectConfigGroup', function () {
  264. beforeEach(function () {
  265. installerStep7Controller.reopen({content: {services: []}});
  266. sinon.stub(installerStep7Controller, 'switchConfigGroupConfigs', Em.K);
  267. });
  268. afterEach(function () {
  269. installerStep7Controller.switchConfigGroupConfigs.restore();
  270. });
  271. it('should set selectedConfigGroup', function () {
  272. var group = {':': []};
  273. installerStep7Controller.selectConfigGroup({context: group});
  274. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(group);
  275. });
  276. });
  277. describe('#addOverrideProperty', function () {
  278. it('should add override property', function () {
  279. var groupName = 'groupName',
  280. selectedService = {configGroups: [Em.Object.create({name: groupName, properties: []})]},
  281. selectedConfigGroup = {name: groupName},
  282. serviceConfigProperty = Em.Object.create({overrides: []}),
  283. expected = Em.Object.create({
  284. value: '',
  285. isOriginalSCP: false,
  286. isEditable: true
  287. });
  288. installerStep7Controller.reopen({selectedService: selectedService, selectedConfigGroup: selectedConfigGroup});
  289. var newSCP = installerStep7Controller.addOverrideProperty(serviceConfigProperty);
  290. Em.keys(expected).forEach(function (k) {
  291. expect(newSCP.get(k)).to.equal(expected.get(k));
  292. });
  293. var group = installerStep7Controller.get('selectedService.configGroups').findProperty('name', groupName);
  294. expect(newSCP.get('group')).to.eql(group);
  295. expect(newSCP.get('parentSCP')).to.eql(serviceConfigProperty);
  296. expect(group.get('properties.length')).to.equal(1);
  297. });
  298. });
  299. describe('#resolveStormConfigs', function () {
  300. beforeEach(function () {
  301. installerStep7Controller.reopen({
  302. content: {services: []},
  303. wizardController: Em.Object.create({
  304. hosts: {'h1': {name: 'host1', id: 'h1'}},
  305. masterComponentHosts: [{component: 'GANGLIA_SERVER', host_id: 'h1'}],
  306. getDBProperty: function (k) {
  307. return this.get(k);
  308. }
  309. })
  310. });
  311. });
  312. it('shouldn\'t do nothing if Ganglia and Storm are installed', function () {
  313. var installedServiceNames = ['GANGLIA', 'STORM'],
  314. configs = [
  315. {name: 'nimbus.childopts', value: '.jar=host=host2', defaultValue: ''},
  316. {name: 'supervisor.childopts', value: '.jar=host=host2', defaultValue: ''},
  317. {name: 'worker.childopts', value: '.jar=host=host2', defaultValue: ''}
  318. ],
  319. expected = [
  320. {name: 'nimbus.childopts', value: '.jar=host=host2', defaultValue: ''},
  321. {name: 'supervisor.childopts', value: '.jar=host=host2', defaultValue: ''},
  322. {name: 'worker.childopts', value: '.jar=host=host2', defaultValue: ''}
  323. ];
  324. installerStep7Controller.reopen({installedServiceNames: installedServiceNames});
  325. installerStep7Controller.resolveStormConfigs(configs);
  326. expect(configs).to.eql(expected);
  327. });
  328. it('shouldn\'t do nothing if Ganglia is in allSelectedServiceNames', function () {
  329. var allSelectedServiceNames = ['GANGLIA'],
  330. configs = [
  331. {name: 'nimbus.childopts', value: '.jar=host=host2', defaultValue: ''},
  332. {name: 'supervisor.childopts', value: '.jar=host=host2', defaultValue: ''},
  333. {name: 'worker.childopts', value: '.jar=host=host2', defaultValue: ''}
  334. ],
  335. expected = [
  336. {name: 'nimbus.childopts', value: '.jar=host=host1', defaultValue: '.jar=host=host1', forceUpdate: true},
  337. {name: 'supervisor.childopts', value: '.jar=host=host1', defaultValue: '.jar=host=host1', forceUpdate: true},
  338. {name: 'worker.childopts', value: '.jar=host=host1', defaultValue: '.jar=host=host1', forceUpdate: true}
  339. ];
  340. installerStep7Controller.reopen({allSelectedServiceNames: allSelectedServiceNames});
  341. installerStep7Controller.resolveStormConfigs(configs);
  342. Em.keys(expected[0]).forEach(function (k) {
  343. expect(configs.mapProperty(k)).to.eql(expected.mapProperty(k));
  344. });
  345. });
  346. it('shouldn\'t do nothing if Ganglia is in installedServiceNames (2)', function () {
  347. var installedServiceNames = ['GANGLIA'],
  348. configs = [
  349. {name: 'nimbus.childopts', value: '.jar=host=host2', defaultValue: ''},
  350. {name: 'supervisor.childopts', value: '.jar=host=host2', defaultValue: ''},
  351. {name: 'worker.childopts', value: '.jar=host=host2', defaultValue: ''}
  352. ],
  353. expected = [
  354. {name: 'nimbus.childopts', value: '.jar=host=host1', defaultValue: '.jar=host=host1', forceUpdate: true},
  355. {name: 'supervisor.childopts', value: '.jar=host=host1', defaultValue: '.jar=host=host1', forceUpdate: true},
  356. {name: 'worker.childopts', value: '.jar=host=host1', defaultValue: '.jar=host=host1', forceUpdate: true}
  357. ];
  358. installerStep7Controller.reopen({installedServiceNames: installedServiceNames});
  359. installerStep7Controller.resolveStormConfigs(configs);
  360. Em.keys(expected[0]).forEach(function (k) {
  361. expect(configs.mapProperty(k)).to.eql(expected.mapProperty(k));
  362. });
  363. });
  364. });
  365. describe('#resolveServiceDependencyConfigs', function () {
  366. beforeEach(function () {
  367. sinon.stub(installerStep7Controller, 'resolveStormConfigs', Em.K);
  368. });
  369. afterEach(function () {
  370. installerStep7Controller.resolveStormConfigs.restore();
  371. });
  372. it('should call resolveStormConfigs if serviceName is STORM', function () {
  373. var serviceName = 'STORM', configs = [
  374. {},
  375. {},
  376. {}
  377. ];
  378. installerStep7Controller.resolveServiceDependencyConfigs(serviceName, configs);
  379. expect(installerStep7Controller.resolveStormConfigs.calledWith(configs)).to.equal(true);
  380. });
  381. });
  382. describe('#selectedServiceObserver', function () {
  383. beforeEach(function () {
  384. installerStep7Controller.reopen({content: {services: []}});
  385. sinon.stub(installerStep7Controller, 'switchConfigGroupConfigs', Em.K);
  386. });
  387. afterEach(function () {
  388. installerStep7Controller.switchConfigGroupConfigs.restore();
  389. });
  390. it('shouldn\'t do nothing if App.supports.hostOverridesInstaller is false', function () {
  391. App.set('supports.hostOverridesInstaller', false);
  392. var configGroups = [
  393. {},
  394. {}
  395. ],
  396. selectedConfigGroup = {};
  397. installerStep7Controller.reopen({configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
  398. installerStep7Controller.selectedServiceObserver();
  399. expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
  400. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
  401. });
  402. it('shouldn\'t do nothing if selectedService is null', function () {
  403. App.set('supports.hostOverridesInstaller', true);
  404. var configGroups = [
  405. {},
  406. {}
  407. ],
  408. selectedConfigGroup = {};
  409. installerStep7Controller.reopen({selectedService: null, configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
  410. installerStep7Controller.selectedServiceObserver();
  411. expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
  412. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
  413. });
  414. it('shouldn\'t do nothing if selectedService.serviceName is MISC', function () {
  415. App.set('supports.hostOverridesInstaller', true);
  416. var configGroups = [
  417. {},
  418. {}
  419. ],
  420. selectedConfigGroup = {};
  421. installerStep7Controller.reopen({selectedService: {serviceName: 'MISC'}, configGroups: configGroups, selectedConfigGroup: selectedConfigGroup});
  422. installerStep7Controller.selectedServiceObserver();
  423. expect(installerStep7Controller.get('configGroups')).to.eql(configGroups);
  424. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(selectedConfigGroup);
  425. });
  426. it('should update configGroups and selectedConfigGroup', function () {
  427. App.set('supports.hostOverridesInstaller', true);
  428. var defaultGroup = {isDefault: true, n: 'n2'},
  429. configGroups = [
  430. {isDefault: false, n: 'n1'},
  431. defaultGroup,
  432. {n: 'n3'}
  433. ],
  434. selectedConfigGroup = {};
  435. installerStep7Controller.reopen({selectedService: {serviceName: 's1', configGroups: configGroups}});
  436. installerStep7Controller.selectedServiceObserver();
  437. expect(installerStep7Controller.get('configGroups').mapProperty('n')).to.eql(['n2', 'n1', 'n3']);
  438. expect(installerStep7Controller.get('selectedConfigGroup')).to.eql(defaultGroup);
  439. });
  440. });
  441. describe('#loadConfigGroups', function () {
  442. beforeEach(function () {
  443. installerStep7Controller.reopen({
  444. wizardController: Em.Object.create({
  445. allHosts: [
  446. {hostName: 'h1'},
  447. {hostName: 'h2'},
  448. {hostName: 'h3'}
  449. ]
  450. })
  451. });
  452. });
  453. it('shouldn\'t do nothing if only MISC available', function () {
  454. var configGroups = [
  455. {}
  456. ];
  457. installerStep7Controller.reopen({
  458. stepConfigs: [Em.Object.create({serviceName: 'MISC', configGroups: configGroups})]
  459. });
  460. installerStep7Controller.loadConfigGroups([]);
  461. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups')).to.eql(configGroups);
  462. });
  463. it('should set configGroups for service if they don\'t exist', function () {
  464. var configGroups = [],
  465. serviceName = 'HDFS',
  466. serviceConfigGroups = [
  467. {service: {id: 's1'}}
  468. ];
  469. installerStep7Controller.reopen({
  470. stepConfigs: [Em.Object.create({serviceName: serviceName, displayName: serviceName, configGroups: configGroups})]
  471. });
  472. var manageCGController = App.router.get('manageConfigGroupsController');
  473. sinon.stub(manageCGController, 'hostsToPublic', function(data){return ['c6401','c6402','c6403']});
  474. installerStep7Controller.loadConfigGroups(serviceConfigGroups);
  475. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups.length')).to.equal(1);
  476. var group = installerStep7Controller.get('stepConfigs.firstObject.configGroups.firstObject');
  477. expect(group.get('name')).to.equal(serviceName + ' Default');
  478. expect(group.get('description').contains(serviceName)).to.equal(true);
  479. expect(group.get('isDefault')).to.equal(true);
  480. expect(group.get('hosts')).to.eql(['h1', 'h2', 'h3']);
  481. expect(group.get('service.id')).to.equal(serviceName);
  482. expect(group.get('serviceName')).to.equal(serviceName);
  483. manageCGController.hostsToPublic.restore();
  484. });
  485. it('should update configGroups for service (only default group)', function () {
  486. var configGroups = [],
  487. serviceName = 'HDFS',
  488. serviceConfigGroups = [
  489. {service: {id: 'HDFS'}, isDefault: true, n: 'n1'}
  490. ];
  491. installerStep7Controller.reopen({
  492. stepConfigs: [Em.Object.create({serviceName: serviceName, displayName: serviceName, configGroups: configGroups})]
  493. });
  494. installerStep7Controller.loadConfigGroups(serviceConfigGroups);
  495. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault').get('n')).to.equal('n1');
  496. });
  497. it('should update configGroups for service', function () {
  498. var configGroups = [],
  499. serviceName = 'HDFS',
  500. properties = [
  501. { name: "p1", filename: "file.xml" },
  502. { name: "p2", filename: "file.xml" }
  503. ],
  504. serviceConfigGroups = [
  505. {service: {id: 'HDFS'}, properties: properties.slice(), isDefault: true, n: 'n1'},
  506. {service: {id: 'HDFS'}, properties: properties.slice(), isDefault: false, n: 'n2'}
  507. ];
  508. installerStep7Controller.reopen({
  509. stepConfigs: [Em.Object.create({serviceName: serviceName, configGroups: configGroups, configs: properties})]
  510. });
  511. installerStep7Controller.loadConfigGroups(serviceConfigGroups);
  512. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups.length')).to.equal(2);
  513. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault').get('n')).to.equal('n1');
  514. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault', false).get('properties').everyProperty('group.n', 'n2')).to.equal(true);
  515. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault', false).get('parentConfigGroup.n')).to.equal('n1');
  516. });
  517. });
  518. describe('#_getDisplayedConfigGroups', function () {
  519. it('should return [] if no selected group', function () {
  520. installerStep7Controller.reopen({
  521. content: {services: []},
  522. selectedConfigGroup: null
  523. });
  524. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([]);
  525. });
  526. it('should return default config group if another selected', function () {
  527. var defaultGroup = Em.Object.create({isDefault: false});
  528. installerStep7Controller.reopen({
  529. content: {services: []},
  530. selectedConfigGroup: defaultGroup
  531. });
  532. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([defaultGroup]);
  533. });
  534. it('should return other groups if default selected', function () {
  535. var defaultGroup = Em.Object.create({isDefault: true}),
  536. cfgG = Em.Object.create({isDefault: true}),
  537. configGroups = Em.A([
  538. Em.Object.create({isDefault: false}),
  539. Em.Object.create({isDefault: false}),
  540. cfgG,
  541. Em.Object.create({isDefault: false})
  542. ]);
  543. installerStep7Controller.reopen({
  544. content: {services: []},
  545. selectedConfigGroup: defaultGroup,
  546. selectedService: {configGroups: configGroups}
  547. });
  548. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql(configGroups.without(cfgG));
  549. });
  550. });
  551. describe('#_setEditableValue', function () {
  552. it('shouldn\'t update config if no selectedConfigGroup', function () {
  553. installerStep7Controller.reopen({
  554. selectedConfigGroup: null
  555. });
  556. var config = Em.Object.create({isEditable: null});
  557. var updatedConfig = installerStep7Controller._setEditableValue(config);
  558. expect(updatedConfig.get('isEditable')).to.be.null;
  559. });
  560. it('should set isEditable equal to selectedGroup.isDefault if service not installed', function () {
  561. var isDefault = true;
  562. installerStep7Controller.reopen({
  563. installedServiceNames: [],
  564. selectedService: {serviceName: 'abc'},
  565. selectedConfigGroup: Em.Object.create({isDefault: isDefault})
  566. });
  567. var config = Em.Object.create({isEditable: null});
  568. var updatedConfig = installerStep7Controller._setEditableValue(config);
  569. expect(updatedConfig.get('isEditable')).to.equal(isDefault);
  570. installerStep7Controller.toggleProperty('selectedConfigGroup.isDefault');
  571. updatedConfig = installerStep7Controller._setEditableValue(config);
  572. expect(updatedConfig.get('isEditable')).to.equal(!isDefault);
  573. });
  574. Em.A([
  575. {
  576. isEditable: false,
  577. isReconfigurable: false,
  578. isDefault: true,
  579. e: false
  580. },
  581. {
  582. isEditable: true,
  583. isReconfigurable: true,
  584. isDefault: true,
  585. e: true
  586. },
  587. {
  588. isEditable: false,
  589. isReconfigurable: true,
  590. isDefault: false,
  591. e: false
  592. },
  593. {
  594. isEditable: true,
  595. isReconfigurable: false,
  596. isDefault: false,
  597. e: false
  598. }
  599. ]).forEach(function (test) {
  600. it('service installed, isEditable = ' + test.isEditable.toString() + ', isReconfigurable = ' + test.isReconfigurable.toString(), function () {
  601. var config = Em.Object.create({
  602. isReconfigurable: test.isReconfigurable,
  603. isEditable: test.isEditable
  604. });
  605. installerStep7Controller.reopen({
  606. installedServiceNames: Em.A(['a']),
  607. selectedService: Em.Object.create({serviceName: 'a'}),
  608. selectedConfigGroup: Em.Object.create({isDefault: test.isDefault})
  609. });
  610. var updateConfig = installerStep7Controller._setEditableValue(config);
  611. expect(updateConfig.get('isEditable')).to.equal(test.e);
  612. });
  613. });
  614. });
  615. describe('#_setOverrides', function () {
  616. it('shouldn\'t update config if no selectedConfigGroup', function () {
  617. installerStep7Controller.reopen({
  618. selectedConfigGroup: null
  619. });
  620. var config = Em.Object.create({overrides: null});
  621. var updatedConfig = installerStep7Controller._setOverrides(config, []);
  622. expect(updatedConfig.get('overrides')).to.be.null;
  623. });
  624. it('no overrideToAdd', function () {
  625. var isDefault = true,
  626. name = 'n1',
  627. config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
  628. overrides = Em.A([
  629. Em.Object.create({name: name, value: 'v1'}),
  630. Em.Object.create({name: name, value: 'v2'}),
  631. Em.Object.create({name: 'n2', value: 'v3'})
  632. ]);
  633. installerStep7Controller.reopen({
  634. overrideToAdd: null,
  635. selectedConfigGroup: Em.Object.create({
  636. isDefault: isDefault
  637. })
  638. });
  639. var updatedConfig = installerStep7Controller._setOverrides(config, overrides);
  640. expect(updatedConfig.get('overrides.length')).to.equal(2);
  641. expect(updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
  642. expect(updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
  643. });
  644. it('overrideToAdd exists', function () {
  645. var isDefault = true,
  646. name = 'n1',
  647. config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
  648. overrides = Em.A([
  649. Em.Object.create({name: name, value: 'v1'}),
  650. Em.Object.create({name: name, value: 'v2'}),
  651. Em.Object.create({name: 'n2', value: 'v3'})
  652. ]);
  653. installerStep7Controller.reopen({
  654. overrideToAdd: Em.Object.create({name: name}),
  655. selectedService: {configGroups: [Em.Object.create({name: 'n', properties: []})]},
  656. selectedConfigGroup: Em.Object.create({
  657. isDefault: isDefault,
  658. name: 'n'
  659. })
  660. });
  661. var updatedConfig = installerStep7Controller._setOverrides(config, overrides);
  662. expect(updatedConfig.get('overrides.length')).to.equal(3);
  663. expect(updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
  664. expect(updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
  665. });
  666. });
  667. describe('#switchConfigGroupConfigs', function () {
  668. it('if selectedConfigGroup is null, serviceConfigs shouldn\'t be changed', function () {
  669. installerStep7Controller.reopen({
  670. selectedConfigGroup: null,
  671. content: {services: []},
  672. serviceConfigs: {configs: [
  673. {overrides: []},
  674. {overrides: []}
  675. ]}
  676. });
  677. installerStep7Controller.switchConfigGroupConfigs();
  678. expect(installerStep7Controller.get('serviceConfigs.configs').everyProperty('overrides.length', 0)).to.equal(true);
  679. });
  680. it('should set configs for serviceConfigs', function () {
  681. var configGroups = [
  682. Em.Object.create({
  683. properties: [
  684. {name: 'g1', value: 'v1'},
  685. {name: 'g2', value: 'v2'}
  686. ]
  687. })
  688. ];
  689. sinon.stub(installerStep7Controller, '_getDisplayedConfigGroups', function () {
  690. return configGroups;
  691. });
  692. sinon.stub(installerStep7Controller, '_setEditableValue', function (config) {
  693. config.set('isEditable', true);
  694. return config;
  695. });
  696. installerStep7Controller.reopen({
  697. selectedConfigGroup: Em.Object.create({isDefault: true, name: 'g1'}),
  698. content: {services: []},
  699. selectedService: {configs: Em.A([Em.Object.create({name: 'g1', overrides: [], properties: []}), Em.Object.create({name: 'g2', overrides: []})])},
  700. serviceConfigs: {configs: [Em.Object.create({name: 'g1'})]}
  701. });
  702. installerStep7Controller.switchConfigGroupConfigs();
  703. var configs = installerStep7Controller.get('selectedService.configs');
  704. expect(configs.findProperty('name', 'g1').get('overrides').length).to.equal(1);
  705. expect(configs.findProperty('name', 'g2').get('overrides').length).to.equal(1);
  706. expect(configs.everyProperty('isEditable', true)).to.equal(true);
  707. installerStep7Controller._getDisplayedConfigGroups.restore();
  708. installerStep7Controller._setEditableValue.restore();
  709. });
  710. });
  711. describe('#selectProperService', function () {
  712. Em.A([
  713. {
  714. name: 'addServiceController',
  715. stepConfigs: [
  716. {selected: false, name: 'n1'},
  717. {selected: true, name: 'n2'},
  718. {selected: true, name: 'n3'}
  719. ],
  720. e: 'n2'
  721. },
  722. {
  723. name: 'installerController',
  724. stepConfigs: [
  725. {showConfig: false, name: 'n1'},
  726. {showConfig: false, name: 'n2'},
  727. {showConfig: true, name: 'n3'}
  728. ],
  729. e: 'n3'
  730. }
  731. ]).forEach(function (test) {
  732. it(test.name, function () {
  733. sinon.stub(installerStep7Controller, 'selectedServiceObserver', Em.K);
  734. installerStep7Controller.reopen({
  735. wizardController: Em.Object.create({
  736. name: test.name
  737. }),
  738. stepConfigs: test.stepConfigs
  739. });
  740. installerStep7Controller.selectProperService();
  741. expect(installerStep7Controller.get('selectedService.name')).to.equal(test.e);
  742. installerStep7Controller.selectedServiceObserver.restore();
  743. });
  744. });
  745. });
  746. describe('#setStepConfigs', function () {
  747. beforeEach(function () {
  748. installerStep7Controller.reopen({
  749. content: {services: []},
  750. wizardController: Em.Object.create({
  751. getDBProperty: function (key) {
  752. return this.get(key);
  753. }
  754. })
  755. });
  756. });
  757. afterEach(function () {
  758. App.config.renderConfigs.restore();
  759. });
  760. it('if wizard isn\'t addService, should set output of App.config.renderConfigs', function () {
  761. var serviceConfigs = Em.A([
  762. {},
  763. {}
  764. ]);
  765. sinon.stub(App.config, 'renderConfigs', function () {
  766. return serviceConfigs;
  767. });
  768. installerStep7Controller.set('wizardController.name', 'installerController');
  769. installerStep7Controller.setStepConfigs([], []);
  770. expect(installerStep7Controller.get('stepConfigs')).to.eql(serviceConfigs);
  771. });
  772. it('addServiceWizard used', function () {
  773. var serviceConfigs = Em.A([Em.Object.create({serviceName: 's1'}), Em.Object.create({serviceName: 's2'})]);
  774. installerStep7Controller.set('wizardController.name', 'addServiceController');
  775. installerStep7Controller.reopen({selectedServiceNames: ['s2']});
  776. sinon.stub(App.config, 'renderConfigs', function () {
  777. return serviceConfigs;
  778. });
  779. installerStep7Controller.setStepConfigs([], []);
  780. expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
  781. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 's2').get('selected')).to.equal(true);
  782. });
  783. it('addServiceWizard used, HA enabled', function () {
  784. sinon.stub(App, 'get', function (k) {
  785. if (k === 'isHaEnabled') {
  786. return true;
  787. }
  788. return Em.get(App, k);
  789. });
  790. var serviceConfigs = Em.A([
  791. Em.Object.create({
  792. serviceName: 'HDFS',
  793. configs: [
  794. {category: 'SECONDARY_NAMENODE'},
  795. {category: 'SECONDARY_NAMENODE'},
  796. {category: 'NameNode'},
  797. {category: 'NameNode'},
  798. {category: 'SECONDARY_NAMENODE'}
  799. ]
  800. }),
  801. Em.Object.create({serviceName: 's2'})]
  802. );
  803. installerStep7Controller.set('wizardController.name', 'addServiceController');
  804. installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
  805. sinon.stub(App.config, 'renderConfigs', function () {
  806. return serviceConfigs;
  807. });
  808. installerStep7Controller.setStepConfigs([], []);
  809. expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
  810. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('selected')).to.equal(true);
  811. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
  812. App.get.restore();
  813. });
  814. });
  815. describe('#checkHostOverrideInstaller', function () {
  816. beforeEach(function () {
  817. sinon.stub(installerStep7Controller, 'loadConfigGroups', Em.K);
  818. sinon.stub(installerStep7Controller, 'loadInstalledServicesConfigGroups', Em.K);
  819. });
  820. afterEach(function () {
  821. installerStep7Controller.loadConfigGroups.restore();
  822. installerStep7Controller.loadInstalledServicesConfigGroups.restore();
  823. App.get.restore();
  824. });
  825. Em.A([
  826. {
  827. hostOverridesInstaller: false,
  828. installedServiceNames: [],
  829. m: 'hostOverridesInstaller is false, installedServiceNames is empty',
  830. e: {
  831. loadConfigGroups: false,
  832. loadInstalledServicesConfigGroups: false
  833. }
  834. },
  835. {
  836. hostOverridesInstaller: false,
  837. installedServiceNames: ['s1', 's2'],
  838. m: 'hostOverridesInstaller is false, installedServiceNames is n\'t empty',
  839. e: {
  840. loadConfigGroups: false,
  841. loadInstalledServicesConfigGroups: false
  842. }
  843. },
  844. {
  845. hostOverridesInstaller: true,
  846. installedServiceNames: [],
  847. m: 'hostOverridesInstaller is true, installedServiceNames is empty',
  848. e: {
  849. loadConfigGroups: true,
  850. loadInstalledServicesConfigGroups: false
  851. }
  852. },
  853. {
  854. hostOverridesInstaller: true,
  855. installedServiceNames: ['s1', 's2', 's3'],
  856. m: 'hostOverridesInstaller is true, installedServiceNames isn\'t empty',
  857. e: {
  858. loadConfigGroups: true,
  859. loadInstalledServicesConfigGroups: true
  860. }
  861. }
  862. ]).forEach(function (test) {
  863. it(test.m, function () {
  864. sinon.stub(App, 'get', function (k) {
  865. if (k === 'supports.hostOverridesInstaller') return test.hostOverridesInstaller;
  866. return Em.get(App, k);
  867. });
  868. installerStep7Controller.reopen({installedServiceNames: test.installedServiceNames});
  869. installerStep7Controller.checkHostOverrideInstaller();
  870. if (test.e.loadConfigGroups) {
  871. expect(installerStep7Controller.loadConfigGroups.calledOnce).to.equal(true);
  872. }
  873. else {
  874. expect(installerStep7Controller.loadConfigGroups.called).to.equal(false);
  875. }
  876. if (test.e.loadInstalledServicesConfigGroups) {
  877. expect(installerStep7Controller.loadInstalledServicesConfigGroups.calledOnce).to.equal(true);
  878. }
  879. else {
  880. expect(installerStep7Controller.loadInstalledServicesConfigGroups.called).to.equal(false);
  881. }
  882. });
  883. });
  884. });
  885. describe('#loadStep', function () {
  886. beforeEach(function () {
  887. installerStep7Controller.reopen({
  888. content: {services: []},
  889. wizardController: Em.Object.create({
  890. getDBProperty: function (k) {
  891. return this.get(k);
  892. }
  893. })
  894. });
  895. sinon.stub(App.config, 'mergePreDefinedWithStored', Em.K);
  896. sinon.stub(App.config, 'addAdvancedConfigs', Em.K);
  897. sinon.stub(App.config, 'addCustomConfigs', Em.K);
  898. sinon.stub(App.config, 'fileConfigsIntoTextarea', Em.K);
  899. sinon.stub(installerStep7Controller, 'clearStep', Em.K);
  900. sinon.stub(installerStep7Controller, 'getConfigTags', Em.K);
  901. sinon.stub(installerStep7Controller, 'setInstalledServiceConfigs', Em.K);
  902. sinon.stub(installerStep7Controller, 'resolveServiceDependencyConfigs', Em.K);
  903. sinon.stub(installerStep7Controller, 'setStepConfigs', Em.K);
  904. sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
  905. sinon.stub(installerStep7Controller, 'activateSpecialConfigs', Em.K);
  906. sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
  907. sinon.stub(App.router, 'send', Em.K);
  908. });
  909. afterEach(function () {
  910. App.config.mergePreDefinedWithStored.restore();
  911. App.config.addAdvancedConfigs.restore();
  912. App.config.addCustomConfigs.restore();
  913. App.config.fileConfigsIntoTextarea.restore();
  914. installerStep7Controller.clearStep.restore();
  915. installerStep7Controller.getConfigTags.restore();
  916. installerStep7Controller.setInstalledServiceConfigs.restore();
  917. installerStep7Controller.resolveServiceDependencyConfigs.restore();
  918. installerStep7Controller.setStepConfigs.restore();
  919. installerStep7Controller.checkHostOverrideInstaller.restore();
  920. installerStep7Controller.activateSpecialConfigs.restore();
  921. installerStep7Controller.selectProperService.restore();
  922. App.router.send.restore();
  923. });
  924. it('should call clearStep', function () {
  925. installerStep7Controller.loadStep();
  926. expect(installerStep7Controller.clearStep.calledOnce).to.equal(true);
  927. });
  928. it('shouldn\'t do nothing if isAdvancedConfigLoaded is false', function () {
  929. installerStep7Controller.set('isAdvancedConfigLoaded', false);
  930. installerStep7Controller.loadStep();
  931. expect(installerStep7Controller.clearStep.called).to.equal(false);
  932. });
  933. it('should use App.config to map configs', function () {
  934. installerStep7Controller.loadStep();
  935. expect(App.config.mergePreDefinedWithStored.calledOnce).to.equal(true);
  936. expect(App.config.addAdvancedConfigs.calledOnce).to.equal(true);
  937. expect(App.config.addCustomConfigs.calledOnce).to.equal(true);
  938. });
  939. Em.A([
  940. {
  941. allSelectedServiceNames: ['YARN'],
  942. capacitySchedulerUi: false,
  943. e: true
  944. },
  945. {
  946. allSelectedServiceNames: ['YARN'],
  947. capacitySchedulerUi: true,
  948. e: false
  949. },
  950. {
  951. allSelectedServiceNames: ['HDFS'],
  952. capacitySchedulerUi: false,
  953. e: false
  954. },
  955. {
  956. allSelectedServiceNames: ['HDFS'],
  957. capacitySchedulerUi: true,
  958. e: false
  959. }
  960. ]).forEach(function (test) {
  961. it('allSelectedServiceNames = ' + JSON.stringify(test.allSelectedServiceNames) + ', capacitySchedulerUi = ' + test.capacitySchedulerUi.toString(), function () {
  962. sinon.stub(App, 'get', function (k) {
  963. if (k === 'supports.capacitySchedulerUi') return test.capacitySchedulerUi;
  964. return Em.get(App, k);
  965. });
  966. installerStep7Controller.reopen({allSelectedServiceNames: test.allSelectedServiceNames});
  967. installerStep7Controller.loadStep();
  968. if (test.e) {
  969. expect(App.config.fileConfigsIntoTextarea.calledOnce).to.equal(true);
  970. }
  971. else {
  972. expect(App.config.fileConfigsIntoTextarea.called).to.equal(false);
  973. }
  974. App.get.restore();
  975. });
  976. });
  977. it('should call setInstalledServiceConfigs for addServiceController', function () {
  978. installerStep7Controller.set('wizardController.name', 'addServiceController');
  979. installerStep7Controller.loadStep();
  980. expect(installerStep7Controller.setInstalledServiceConfigs.calledOnce).to.equal(true);
  981. });
  982. });
  983. describe('#_updateValueForCheckBoxConfig', function () {
  984. Em.A([
  985. {
  986. v: 'true',
  987. e: true
  988. },
  989. {
  990. v: 'false',
  991. e: false
  992. }
  993. ]).forEach(function (test) {
  994. it(test.v, function () {
  995. var serviceConfigProperty = Em.Object.create({value: test.v});
  996. installerStep7Controller._updateValueForCheckBoxConfig(serviceConfigProperty);
  997. expect(serviceConfigProperty.get('value')).to.equal(test.e);
  998. expect(serviceConfigProperty.get('defaultValue')).to.equal(test.e);
  999. });
  1000. });
  1001. });
  1002. describe('#_updateIsEditableFlagForConfig', function () {
  1003. Em.A([
  1004. {
  1005. isAdmin: false,
  1006. isReconfigurable: false,
  1007. isHostsConfigsPage: true,
  1008. defaultGroupSelected: false,
  1009. m: 'false for non-admin users',
  1010. e: false
  1011. },
  1012. {
  1013. isAdmin: true,
  1014. isReconfigurable: false,
  1015. isHostsConfigsPage: true,
  1016. defaultGroupSelected: false,
  1017. m: 'false if defaultGroupSelected is false and isHostsConfigsPage is true',
  1018. e: false
  1019. },
  1020. {
  1021. isAdmin: true,
  1022. isReconfigurable: false,
  1023. isHostsConfigsPage: true,
  1024. defaultGroupSelected: true,
  1025. m: 'false if defaultGroupSelected is true and isHostsConfigsPage is true',
  1026. e: false
  1027. },
  1028. {
  1029. isAdmin: true,
  1030. isReconfigurable: false,
  1031. isHostsConfigsPage: false,
  1032. defaultGroupSelected: false,
  1033. m: 'false if defaultGroupSelected is false and isHostsConfigsPage is false',
  1034. e: false
  1035. },
  1036. {
  1037. isAdmin: true,
  1038. isReconfigurable: true,
  1039. isHostsConfigsPage: false,
  1040. defaultGroupSelected: true,
  1041. m: 'equal to isReconfigurable if defaultGroupSelected is true and isHostsConfigsPage is false',
  1042. e: true
  1043. }
  1044. ]).forEach(function (test) {
  1045. it(test.m, function () {
  1046. sinon.stub(App, 'get', function (k) {
  1047. if (k === 'isAdmin') return test.isAdmin;
  1048. return Em.get(App, k);
  1049. });
  1050. installerStep7Controller.reopen({isHostsConfigsPage: test.isHostsConfigsPage});
  1051. var serviceConfigProperty = Em.Object.create({
  1052. isReconfigurable: test.isReconfigurable
  1053. });
  1054. installerStep7Controller._updateIsEditableFlagForConfig(serviceConfigProperty, test.defaultGroupSelected);
  1055. App.get.restore();
  1056. expect(serviceConfigProperty.get('isEditable')).to.equal(test.e);
  1057. });
  1058. });
  1059. });
  1060. describe('#_updateOverridesForConfig', function () {
  1061. it('should set empty array', function () {
  1062. var serviceConfigProperty = Em.Object.create({
  1063. overrides: null
  1064. }), component = Em.Object.create();
  1065. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1066. expect(serviceConfigProperty.get('overrides')).to.eql(Em.A([]));
  1067. });
  1068. it('host overrides not supported', function () {
  1069. var serviceConfigProperty = Em.Object.create({
  1070. overrides: [
  1071. {value: 'new value'}
  1072. ]
  1073. }), component = Em.Object.create({selectedConfigGroup: {isDefault: false}});
  1074. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1075. expect(serviceConfigProperty.get('overrides').length).to.equal(1);
  1076. expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
  1077. expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
  1078. expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
  1079. });
  1080. it('host overrides supported', function () {
  1081. sinon.stub(App, 'get', function (k) {
  1082. if (k === 'supports.hostOverrides') return true;
  1083. return Em.get(App, k);
  1084. });
  1085. var serviceConfigProperty = Em.Object.create({
  1086. overrides: [
  1087. {value: 'new value', group: Em.Object.create({name: 'n1'})}
  1088. ]
  1089. }),
  1090. component = Em.Object.create({
  1091. selectedConfigGroup: {isDefault: true},
  1092. configGroups: Em.A([
  1093. Em.Object.create({name: 'n1', properties: []})
  1094. ])
  1095. });
  1096. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1097. App.get.restore();
  1098. expect(serviceConfigProperty.get('overrides').length).to.equal(1);
  1099. expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
  1100. expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
  1101. expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
  1102. expect(component.get('configGroups.firstObject.properties').length).to.equal(1);
  1103. expect(component.get('configGroups.firstObject.properties.firstObject.isEditable')).to.equal(false);
  1104. expect(component.get('configGroups.firstObject.properties.firstObject.group')).to.be.object;
  1105. });
  1106. });
  1107. });