step7_test.js 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149
  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. getDBProperty: function () {
  305. return [
  306. {component: 'GANGLIA_SERVER', hostName: 'h1'}
  307. ];
  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=', defaultValue: ''},
  316. {name: 'supervisor.childopts', value: '.jar=host=', defaultValue: ''},
  317. {name: 'worker.childopts', value: '.jar=host=', defaultValue: ''}
  318. ],
  319. expected = [
  320. {name: 'nimbus.childopts', value: '.jar=host=', defaultValue: ''},
  321. {name: 'supervisor.childopts', value: '.jar=host=', defaultValue: ''},
  322. {name: 'worker.childopts', value: '.jar=host=', 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=', defaultValue: ''},
  332. {name: 'supervisor.childopts', value: '.jar=host=', defaultValue: ''},
  333. {name: 'worker.childopts', value: '.jar=host=', defaultValue: ''}
  334. ],
  335. expected = [
  336. {name: 'nimbus.childopts', value: 'h1', defaultValue: 'h1', forceUpdate: true},
  337. {name: 'supervisor.childopts', value: 'h1', defaultValue: 'h1', forceUpdate: true},
  338. {name: 'worker.childopts', value: 'h1', defaultValue: 'h1', 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=', defaultValue: ''},
  350. {name: 'supervisor.childopts', value: '.jar=host=', defaultValue: ''},
  351. {name: 'worker.childopts', value: '.jar=host=', defaultValue: ''}
  352. ],
  353. expected = [
  354. {name: 'nimbus.childopts', value: 'h1', defaultValue: 'h1', forceUpdate: true},
  355. {name: 'supervisor.childopts', value: 'h1', defaultValue: 'h1', forceUpdate: true},
  356. {name: 'worker.childopts', value: 'h1', defaultValue: 'h1', 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. installerStep7Controller.loadConfigGroups(serviceConfigGroups);
  473. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups.length')).to.equal(1);
  474. var group = installerStep7Controller.get('stepConfigs.firstObject.configGroups.firstObject');
  475. expect(group.get('name')).to.equal(serviceName + ' Default');
  476. expect(group.get('description').contains(serviceName)).to.equal(true);
  477. expect(group.get('isDefault')).to.equal(true);
  478. expect(group.get('hosts')).to.eql(['h1', 'h2', 'h3']);
  479. expect(group.get('service.id')).to.equal(serviceName);
  480. expect(group.get('serviceName')).to.equal(serviceName);
  481. });
  482. it('should update configGroups for service (only default group)', function () {
  483. var configGroups = [],
  484. serviceName = 'HDFS',
  485. serviceConfigGroups = [
  486. {service: {id: 'HDFS'}, isDefault: true, n: 'n1'}
  487. ];
  488. installerStep7Controller.reopen({
  489. stepConfigs: [Em.Object.create({serviceName: serviceName, displayName: serviceName, configGroups: configGroups})]
  490. });
  491. installerStep7Controller.loadConfigGroups(serviceConfigGroups);
  492. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault').get('n')).to.equal('n1');
  493. });
  494. it('should update configGroups for service', function () {
  495. var configGroups = [],
  496. serviceName = 'HDFS',
  497. properties = [
  498. { name: "p1", filename: "file.xml" },
  499. { name: "p2", filename: "file.xml" }
  500. ],
  501. serviceConfigGroups = [
  502. {service: {id: 'HDFS'}, properties: properties.slice(), isDefault: true, n: 'n1'},
  503. {service: {id: 'HDFS'}, properties: properties.slice(), isDefault: false, n: 'n2'}
  504. ];
  505. installerStep7Controller.reopen({
  506. stepConfigs: [Em.Object.create({serviceName: serviceName, configGroups: configGroups, configs: properties})]
  507. });
  508. installerStep7Controller.loadConfigGroups(serviceConfigGroups);
  509. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups.length')).to.equal(2);
  510. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault').get('n')).to.equal('n1');
  511. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault', false).get('properties').everyProperty('group.n', 'n2')).to.equal(true);
  512. expect(installerStep7Controller.get('stepConfigs.firstObject.configGroups').findProperty('isDefault', false).get('parentConfigGroup.n')).to.equal('n1');
  513. });
  514. });
  515. describe('#_getDisplayedConfigGroups', function () {
  516. it('should return [] if no selected group', function () {
  517. installerStep7Controller.reopen({
  518. content: {services: []},
  519. selectedConfigGroup: null
  520. });
  521. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([]);
  522. });
  523. it('should return default config group if another selected', function () {
  524. var defaultGroup = Em.Object.create({isDefault: false});
  525. installerStep7Controller.reopen({
  526. content: {services: []},
  527. selectedConfigGroup: defaultGroup
  528. });
  529. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql([defaultGroup]);
  530. });
  531. it('should return other groups if default selected', function () {
  532. var defaultGroup = Em.Object.create({isDefault: true}),
  533. cfgG = Em.Object.create({isDefault: true}),
  534. configGroups = Em.A([
  535. Em.Object.create({isDefault: false}),
  536. Em.Object.create({isDefault: false}),
  537. cfgG,
  538. Em.Object.create({isDefault: false})
  539. ]);
  540. installerStep7Controller.reopen({
  541. content: {services: []},
  542. selectedConfigGroup: defaultGroup,
  543. selectedService: {configGroups: configGroups}
  544. });
  545. expect(installerStep7Controller._getDisplayedConfigGroups()).to.eql(configGroups.without(cfgG));
  546. });
  547. });
  548. describe('#_setEditableValue', function () {
  549. it('shouldn\'t update config if no selectedConfigGroup', function () {
  550. installerStep7Controller.reopen({
  551. selectedConfigGroup: null
  552. });
  553. var config = Em.Object.create({isEditable: null});
  554. var updatedConfig = installerStep7Controller._setEditableValue(config);
  555. expect(updatedConfig.get('isEditable')).to.be.null;
  556. });
  557. it('should set isEditable equal to selectedGroup.isDefault if service not installed', function () {
  558. var isDefault = true;
  559. installerStep7Controller.reopen({
  560. installedServiceNames: [],
  561. selectedService: {serviceName: 'abc'},
  562. selectedConfigGroup: Em.Object.create({isDefault: isDefault})
  563. });
  564. var config = Em.Object.create({isEditable: null});
  565. var updatedConfig = installerStep7Controller._setEditableValue(config);
  566. expect(updatedConfig.get('isEditable')).to.equal(isDefault);
  567. installerStep7Controller.toggleProperty('selectedConfigGroup.isDefault');
  568. updatedConfig = installerStep7Controller._setEditableValue(config);
  569. expect(updatedConfig.get('isEditable')).to.equal(!isDefault);
  570. });
  571. Em.A([
  572. {
  573. isEditable: false,
  574. isReconfigurable: false,
  575. isDefault: true,
  576. e: false
  577. },
  578. {
  579. isEditable: true,
  580. isReconfigurable: true,
  581. isDefault: true,
  582. e: true
  583. },
  584. {
  585. isEditable: false,
  586. isReconfigurable: true,
  587. isDefault: false,
  588. e: false
  589. },
  590. {
  591. isEditable: true,
  592. isReconfigurable: false,
  593. isDefault: false,
  594. e: false
  595. }
  596. ]).forEach(function (test) {
  597. it('service installed, isEditable = ' + test.isEditable.toString() + ', isReconfigurable = ' + test.isReconfigurable.toString(), function () {
  598. var config = Em.Object.create({
  599. isReconfigurable: test.isReconfigurable,
  600. isEditable: test.isEditable
  601. });
  602. installerStep7Controller.reopen({
  603. installedServiceNames: Em.A(['a']),
  604. selectedService: Em.Object.create({serviceName: 'a'}),
  605. selectedConfigGroup: Em.Object.create({isDefault: test.isDefault})
  606. });
  607. var updateConfig = installerStep7Controller._setEditableValue(config);
  608. expect(updateConfig.get('isEditable')).to.equal(test.e);
  609. });
  610. });
  611. });
  612. describe('#_setOverrides', function () {
  613. it('shouldn\'t update config if no selectedConfigGroup', function () {
  614. installerStep7Controller.reopen({
  615. selectedConfigGroup: null
  616. });
  617. var config = Em.Object.create({overrides: null});
  618. var updatedConfig = installerStep7Controller._setOverrides(config, []);
  619. expect(updatedConfig.get('overrides')).to.be.null;
  620. });
  621. it('no overrideToAdd', function () {
  622. var isDefault = true,
  623. name = 'n1',
  624. config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
  625. overrides = Em.A([
  626. Em.Object.create({name: name, value: 'v1'}),
  627. Em.Object.create({name: name, value: 'v2'}),
  628. Em.Object.create({name: 'n2', value: 'v3'})
  629. ]);
  630. installerStep7Controller.reopen({
  631. overrideToAdd: null,
  632. selectedConfigGroup: Em.Object.create({
  633. isDefault: isDefault
  634. })
  635. });
  636. var updatedConfig = installerStep7Controller._setOverrides(config, overrides);
  637. expect(updatedConfig.get('overrides.length')).to.equal(2);
  638. expect(updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
  639. expect(updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
  640. });
  641. it('overrideToAdd exists', function () {
  642. var isDefault = true,
  643. name = 'n1',
  644. config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
  645. overrides = Em.A([
  646. Em.Object.create({name: name, value: 'v1'}),
  647. Em.Object.create({name: name, value: 'v2'}),
  648. Em.Object.create({name: 'n2', value: 'v3'})
  649. ]);
  650. installerStep7Controller.reopen({
  651. overrideToAdd: Em.Object.create({name: name}),
  652. selectedService: {configGroups: [Em.Object.create({name: 'n', properties: []})]},
  653. selectedConfigGroup: Em.Object.create({
  654. isDefault: isDefault,
  655. name: 'n'
  656. })
  657. });
  658. var updatedConfig = installerStep7Controller._setOverrides(config, overrides);
  659. expect(updatedConfig.get('overrides.length')).to.equal(3);
  660. expect(updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
  661. expect(updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
  662. });
  663. });
  664. describe('#switchConfigGroupConfigs', function () {
  665. it('if selectedConfigGroup is null, serviceConfigs shouldn\'t be changed', function () {
  666. installerStep7Controller.reopen({
  667. selectedConfigGroup: null,
  668. content: {services: []},
  669. serviceConfigs: {configs: [
  670. {overrides: []},
  671. {overrides: []}
  672. ]}
  673. });
  674. installerStep7Controller.switchConfigGroupConfigs();
  675. expect(installerStep7Controller.get('serviceConfigs.configs').everyProperty('overrides.length', 0)).to.equal(true);
  676. });
  677. it('should set configs for serviceConfigs', function () {
  678. var configGroups = [
  679. Em.Object.create({
  680. properties: [
  681. {name: 'g1', value: 'v1'},
  682. {name: 'g2', value: 'v2'}
  683. ]
  684. })
  685. ];
  686. sinon.stub(installerStep7Controller, '_getDisplayedConfigGroups', function () {
  687. return configGroups;
  688. });
  689. sinon.stub(installerStep7Controller, '_setEditableValue', function (config) {
  690. config.set('isEditable', true);
  691. return config;
  692. });
  693. installerStep7Controller.reopen({
  694. selectedConfigGroup: Em.Object.create({isDefault: true, name: 'g1'}),
  695. content: {services: []},
  696. selectedService: {configs: Em.A([Em.Object.create({name: 'g1', overrides: [], properties: []}), Em.Object.create({name: 'g2', overrides: []})])},
  697. serviceConfigs: {configs: [Em.Object.create({name: 'g1'})]}
  698. });
  699. installerStep7Controller.switchConfigGroupConfigs();
  700. var configs = installerStep7Controller.get('selectedService.configs');
  701. expect(configs.findProperty('name', 'g1').get('overrides').length).to.equal(1);
  702. expect(configs.findProperty('name', 'g2').get('overrides').length).to.equal(1);
  703. expect(configs.everyProperty('isEditable', true)).to.equal(true);
  704. installerStep7Controller._getDisplayedConfigGroups.restore();
  705. installerStep7Controller._setEditableValue.restore();
  706. });
  707. });
  708. describe('#selectProperService', function () {
  709. Em.A([
  710. {
  711. name: 'addServiceController',
  712. stepConfigs: [
  713. {selected: false, name: 'n1'},
  714. {selected: true, name: 'n2'},
  715. {selected: true, name: 'n3'}
  716. ],
  717. e: 'n2'
  718. },
  719. {
  720. name: 'installerController',
  721. stepConfigs: [
  722. {showConfig: false, name: 'n1'},
  723. {showConfig: false, name: 'n2'},
  724. {showConfig: true, name: 'n3'}
  725. ],
  726. e: 'n3'
  727. }
  728. ]).forEach(function (test) {
  729. it(test.name, function () {
  730. sinon.stub(installerStep7Controller, 'selectedServiceObserver', Em.K);
  731. installerStep7Controller.reopen({
  732. wizardController: Em.Object.create({
  733. name: test.name
  734. }),
  735. stepConfigs: test.stepConfigs
  736. });
  737. installerStep7Controller.selectProperService();
  738. expect(installerStep7Controller.get('selectedService.name')).to.equal(test.e);
  739. installerStep7Controller.selectedServiceObserver.restore();
  740. });
  741. });
  742. });
  743. describe('#setStepConfigs', function () {
  744. beforeEach(function () {
  745. installerStep7Controller.reopen({
  746. content: {services: []},
  747. wizardController: Em.Object.create({
  748. getDBProperty: function (key) {
  749. return this.get(key);
  750. }
  751. })
  752. });
  753. });
  754. afterEach(function () {
  755. App.config.renderConfigs.restore();
  756. });
  757. it('if wizard isn\'t addService, should set output of App.config.renderConfigs', function () {
  758. var serviceConfigs = Em.A([
  759. {},
  760. {}
  761. ]);
  762. sinon.stub(App.config, 'renderConfigs', function () {
  763. return serviceConfigs;
  764. });
  765. installerStep7Controller.set('wizardController.name', 'installerController');
  766. installerStep7Controller.setStepConfigs([], []);
  767. expect(installerStep7Controller.get('stepConfigs')).to.eql(serviceConfigs);
  768. });
  769. it('addServiceWizard used', function () {
  770. var serviceConfigs = Em.A([Em.Object.create({serviceName: 's1'}), Em.Object.create({serviceName: 's2'})]);
  771. installerStep7Controller.set('wizardController.name', 'addServiceController');
  772. installerStep7Controller.reopen({selectedServiceNames: ['s2']});
  773. sinon.stub(App.config, 'renderConfigs', function () {
  774. return serviceConfigs;
  775. });
  776. installerStep7Controller.setStepConfigs([], []);
  777. expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
  778. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 's2').get('selected')).to.equal(true);
  779. });
  780. it('addServiceWizard used, HA enabled', function () {
  781. sinon.stub(App, 'get', function (k) {
  782. if (k === 'isHaEnabled') {
  783. return true;
  784. }
  785. return Em.get(App, k);
  786. });
  787. var serviceConfigs = Em.A([
  788. Em.Object.create({
  789. serviceName: 'HDFS',
  790. configs: [
  791. {category: 'SECONDARY_NAMENODE'},
  792. {category: 'SECONDARY_NAMENODE'},
  793. {category: 'NameNode'},
  794. {category: 'NameNode'},
  795. {category: 'SECONDARY_NAMENODE'}
  796. ]
  797. }),
  798. Em.Object.create({serviceName: 's2'})]
  799. );
  800. installerStep7Controller.set('wizardController.name', 'addServiceController');
  801. installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
  802. sinon.stub(App.config, 'renderConfigs', function () {
  803. return serviceConfigs;
  804. });
  805. installerStep7Controller.setStepConfigs([], []);
  806. expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
  807. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('selected')).to.equal(true);
  808. expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
  809. App.get.restore();
  810. });
  811. });
  812. describe('#checkHostOverrideInstaller', function () {
  813. beforeEach(function () {
  814. sinon.stub(installerStep7Controller, 'loadConfigGroups', Em.K);
  815. sinon.stub(installerStep7Controller, 'loadInstalledServicesConfigGroups', Em.K);
  816. });
  817. afterEach(function () {
  818. installerStep7Controller.loadConfigGroups.restore();
  819. installerStep7Controller.loadInstalledServicesConfigGroups.restore();
  820. App.get.restore();
  821. });
  822. Em.A([
  823. {
  824. hostOverridesInstaller: false,
  825. installedServiceNames: [],
  826. m: 'hostOverridesInstaller is false, installedServiceNames is empty',
  827. e: {
  828. loadConfigGroups: false,
  829. loadInstalledServicesConfigGroups: false
  830. }
  831. },
  832. {
  833. hostOverridesInstaller: false,
  834. installedServiceNames: ['s1', 's2'],
  835. m: 'hostOverridesInstaller is false, installedServiceNames is n\'t empty',
  836. e: {
  837. loadConfigGroups: false,
  838. loadInstalledServicesConfigGroups: false
  839. }
  840. },
  841. {
  842. hostOverridesInstaller: true,
  843. installedServiceNames: [],
  844. m: 'hostOverridesInstaller is true, installedServiceNames is empty',
  845. e: {
  846. loadConfigGroups: true,
  847. loadInstalledServicesConfigGroups: false
  848. }
  849. },
  850. {
  851. hostOverridesInstaller: true,
  852. installedServiceNames: ['s1', 's2', 's3'],
  853. m: 'hostOverridesInstaller is true, installedServiceNames isn\'t empty',
  854. e: {
  855. loadConfigGroups: true,
  856. loadInstalledServicesConfigGroups: true
  857. }
  858. }
  859. ]).forEach(function (test) {
  860. it(test.m, function () {
  861. sinon.stub(App, 'get', function (k) {
  862. if (k === 'supports.hostOverridesInstaller') return test.hostOverridesInstaller;
  863. return Em.get(App, k);
  864. });
  865. installerStep7Controller.reopen({installedServiceNames: test.installedServiceNames});
  866. installerStep7Controller.checkHostOverrideInstaller();
  867. if (test.e.loadConfigGroups) {
  868. expect(installerStep7Controller.loadConfigGroups.calledOnce).to.equal(true);
  869. }
  870. else {
  871. expect(installerStep7Controller.loadConfigGroups.called).to.equal(false);
  872. }
  873. if (test.e.loadInstalledServicesConfigGroups) {
  874. expect(installerStep7Controller.loadInstalledServicesConfigGroups.calledOnce).to.equal(true);
  875. }
  876. else {
  877. expect(installerStep7Controller.loadInstalledServicesConfigGroups.called).to.equal(false);
  878. }
  879. });
  880. });
  881. });
  882. describe('#loadStep', function () {
  883. beforeEach(function () {
  884. installerStep7Controller.reopen({
  885. content: {services: []},
  886. wizardController: Em.Object.create({
  887. getDBProperty: function (k) {
  888. return this.get(k);
  889. }
  890. })
  891. });
  892. sinon.stub(App.config, 'mergePreDefinedWithStored', Em.K);
  893. sinon.stub(App.config, 'addAdvancedConfigs', Em.K);
  894. sinon.stub(App.config, 'addCustomConfigs', Em.K);
  895. sinon.stub(App.config, 'fileConfigsIntoTextarea', Em.K);
  896. sinon.stub(installerStep7Controller, 'clearStep', Em.K);
  897. sinon.stub(installerStep7Controller, 'getConfigTags', Em.K);
  898. sinon.stub(installerStep7Controller, 'setInstalledServiceConfigs', Em.K);
  899. sinon.stub(installerStep7Controller, 'resolveServiceDependencyConfigs', Em.K);
  900. sinon.stub(installerStep7Controller, 'setStepConfigs', Em.K);
  901. sinon.stub(installerStep7Controller, 'checkHostOverrideInstaller', Em.K);
  902. sinon.stub(installerStep7Controller, 'activateSpecialConfigs', Em.K);
  903. sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
  904. sinon.stub(App.router, 'send', Em.K);
  905. });
  906. afterEach(function () {
  907. App.config.mergePreDefinedWithStored.restore();
  908. App.config.addAdvancedConfigs.restore();
  909. App.config.addCustomConfigs.restore();
  910. App.config.fileConfigsIntoTextarea.restore();
  911. installerStep7Controller.clearStep.restore();
  912. installerStep7Controller.getConfigTags.restore();
  913. installerStep7Controller.setInstalledServiceConfigs.restore();
  914. installerStep7Controller.resolveServiceDependencyConfigs.restore();
  915. installerStep7Controller.setStepConfigs.restore();
  916. installerStep7Controller.checkHostOverrideInstaller.restore();
  917. installerStep7Controller.activateSpecialConfigs.restore();
  918. installerStep7Controller.selectProperService.restore();
  919. App.router.send.restore();
  920. });
  921. it('should call clearStep', function () {
  922. installerStep7Controller.loadStep();
  923. expect(installerStep7Controller.clearStep.calledOnce).to.equal(true);
  924. });
  925. it('shouldn\'t do nothing if isAdvancedConfigLoaded is false', function () {
  926. installerStep7Controller.set('isAdvancedConfigLoaded', false);
  927. installerStep7Controller.loadStep();
  928. expect(installerStep7Controller.clearStep.called).to.equal(false);
  929. });
  930. it('should use App.config to map configs', function () {
  931. installerStep7Controller.loadStep();
  932. expect(App.config.mergePreDefinedWithStored.calledOnce).to.equal(true);
  933. expect(App.config.addAdvancedConfigs.calledOnce).to.equal(true);
  934. expect(App.config.addCustomConfigs.calledOnce).to.equal(true);
  935. });
  936. Em.A([
  937. {
  938. allSelectedServiceNames: ['YARN'],
  939. capacitySchedulerUi: false,
  940. e: true
  941. },
  942. {
  943. allSelectedServiceNames: ['YARN'],
  944. capacitySchedulerUi: true,
  945. e: false
  946. },
  947. {
  948. allSelectedServiceNames: ['HDFS'],
  949. capacitySchedulerUi: false,
  950. e: false
  951. },
  952. {
  953. allSelectedServiceNames: ['HDFS'],
  954. capacitySchedulerUi: true,
  955. e: false
  956. }
  957. ]).forEach(function (test) {
  958. it('allSelectedServiceNames = ' + JSON.stringify(test.allSelectedServiceNames) + ', capacitySchedulerUi = ' + test.capacitySchedulerUi.toString(), function () {
  959. sinon.stub(App, 'get', function (k) {
  960. if (k === 'supports.capacitySchedulerUi') return test.capacitySchedulerUi;
  961. return Em.get(App, k);
  962. });
  963. installerStep7Controller.reopen({allSelectedServiceNames: test.allSelectedServiceNames});
  964. installerStep7Controller.loadStep();
  965. if (test.e) {
  966. expect(App.config.fileConfigsIntoTextarea.calledOnce).to.equal(true);
  967. }
  968. else {
  969. expect(App.config.fileConfigsIntoTextarea.called).to.equal(false);
  970. }
  971. App.get.restore();
  972. });
  973. });
  974. it('should call setInstalledServiceConfigs for addServiceController', function () {
  975. installerStep7Controller.set('wizardController.name', 'addServiceController');
  976. installerStep7Controller.loadStep();
  977. expect(installerStep7Controller.setInstalledServiceConfigs.calledOnce).to.equal(true);
  978. });
  979. });
  980. describe('#_updateValueForCheckBoxConfig', function () {
  981. Em.A([
  982. {
  983. v: 'true',
  984. e: true
  985. },
  986. {
  987. v: 'false',
  988. e: false
  989. }
  990. ]).forEach(function (test) {
  991. it(test.v, function () {
  992. var serviceConfigProperty = Em.Object.create({value: test.v});
  993. installerStep7Controller._updateValueForCheckBoxConfig(serviceConfigProperty);
  994. expect(serviceConfigProperty.get('value')).to.equal(test.e);
  995. expect(serviceConfigProperty.get('defaultValue')).to.equal(test.e);
  996. });
  997. });
  998. });
  999. describe('#_updateIsEditableFlagForConfig', function () {
  1000. Em.A([
  1001. {
  1002. isAdmin: false,
  1003. isReconfigurable: false,
  1004. isHostsConfigsPage: true,
  1005. defaultGroupSelected: false,
  1006. m: 'false for non-admin users',
  1007. e: false
  1008. },
  1009. {
  1010. isAdmin: true,
  1011. isReconfigurable: false,
  1012. isHostsConfigsPage: true,
  1013. defaultGroupSelected: false,
  1014. m: 'false if defaultGroupSelected is false and isHostsConfigsPage is true',
  1015. e: false
  1016. },
  1017. {
  1018. isAdmin: true,
  1019. isReconfigurable: false,
  1020. isHostsConfigsPage: true,
  1021. defaultGroupSelected: true,
  1022. m: 'false if defaultGroupSelected is true and isHostsConfigsPage is true',
  1023. e: false
  1024. },
  1025. {
  1026. isAdmin: true,
  1027. isReconfigurable: false,
  1028. isHostsConfigsPage: false,
  1029. defaultGroupSelected: false,
  1030. m: 'false if defaultGroupSelected is false and isHostsConfigsPage is false',
  1031. e: false
  1032. },
  1033. {
  1034. isAdmin: true,
  1035. isReconfigurable: true,
  1036. isHostsConfigsPage: false,
  1037. defaultGroupSelected: true,
  1038. m: 'equal to isReconfigurable if defaultGroupSelected is true and isHostsConfigsPage is false',
  1039. e: true
  1040. }
  1041. ]).forEach(function (test) {
  1042. it(test.m, function () {
  1043. sinon.stub(App, 'get', function (k) {
  1044. if (k === 'isAdmin') return test.isAdmin;
  1045. return Em.get(App, k);
  1046. });
  1047. installerStep7Controller.reopen({isHostsConfigsPage: test.isHostsConfigsPage});
  1048. var serviceConfigProperty = Em.Object.create({
  1049. isReconfigurable: test.isReconfigurable
  1050. });
  1051. installerStep7Controller._updateIsEditableFlagForConfig(serviceConfigProperty, test.defaultGroupSelected);
  1052. App.get.restore();
  1053. expect(serviceConfigProperty.get('isEditable')).to.equal(test.e);
  1054. });
  1055. });
  1056. });
  1057. describe('#_updateOverridesForConfig', function () {
  1058. it('should set empty array', function () {
  1059. var serviceConfigProperty = Em.Object.create({
  1060. overrides: null
  1061. }), component = Em.Object.create();
  1062. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1063. expect(serviceConfigProperty.get('overrides')).to.eql(Em.A([]));
  1064. });
  1065. it('host overrides not supported', function () {
  1066. var serviceConfigProperty = Em.Object.create({
  1067. overrides: [
  1068. {value: 'new value'}
  1069. ]
  1070. }), component = Em.Object.create({selectedConfigGroup: {isDefault: false}});
  1071. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1072. expect(serviceConfigProperty.get('overrides').length).to.equal(1);
  1073. expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
  1074. expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
  1075. expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
  1076. });
  1077. it('host overrides supported', function () {
  1078. sinon.stub(App, 'get', function (k) {
  1079. if (k === 'supports.hostOverrides') return true;
  1080. return Em.get(App, k);
  1081. });
  1082. var serviceConfigProperty = Em.Object.create({
  1083. overrides: [
  1084. {value: 'new value', group: Em.Object.create({name: 'n1'})}
  1085. ]
  1086. }),
  1087. component = Em.Object.create({
  1088. selectedConfigGroup: {isDefault: true},
  1089. configGroups: Em.A([
  1090. Em.Object.create({name: 'n1', properties: []})
  1091. ])
  1092. });
  1093. installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
  1094. App.get.restore();
  1095. expect(serviceConfigProperty.get('overrides').length).to.equal(1);
  1096. expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
  1097. expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
  1098. expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
  1099. expect(component.get('configGroups.firstObject.properties').length).to.equal(1);
  1100. expect(component.get('configGroups.firstObject.properties.firstObject.isEditable')).to.equal(false);
  1101. expect(component.get('configGroups.firstObject.properties.firstObject.group')).to.be.object;
  1102. });
  1103. });
  1104. });