config_test.js 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433
  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. require('controllers/main/service/info/configs');
  20. var batchUtils = require('utils/batch_scheduled_requests');
  21. var mainServiceInfoConfigsController = null;
  22. describe("App.MainServiceInfoConfigsController", function () {
  23. beforeEach(function () {
  24. mainServiceInfoConfigsController = App.MainServiceInfoConfigsController.create({});
  25. });
  26. describe("#showSavePopup", function () {
  27. var tests = [
  28. {
  29. path: false,
  30. event: false,
  31. action: "onSave",
  32. m: "save configs without path/event",
  33. results: [
  34. {
  35. method: "restartServicePopup",
  36. called: true
  37. },
  38. {
  39. method: "selectConfigGroup",
  40. called: false
  41. }
  42. ]
  43. },
  44. {
  45. path: true,
  46. event: true,
  47. action: "onSave",
  48. m: "save configs with path/event",
  49. results: [
  50. {
  51. method: "restartServicePopup",
  52. called: true
  53. },
  54. {
  55. method: "selectConfigGroup",
  56. called: false
  57. }
  58. ]
  59. },
  60. {
  61. path: false,
  62. event: false,
  63. action: "onDiscard",
  64. m: "discard changes without path/event",
  65. results: [
  66. {
  67. method: "restartServicePopup",
  68. called: false
  69. },
  70. {
  71. method: "selectConfigGroup",
  72. called: false
  73. }
  74. ]
  75. },
  76. {
  77. path: false,
  78. event: true,
  79. action: "onDiscard",
  80. m: "discard changes with event",
  81. results: [
  82. {
  83. method: "restartServicePopup",
  84. called: false
  85. },
  86. {
  87. method: "selectConfigGroup",
  88. called: true
  89. },
  90. {
  91. field: "hash",
  92. value: "hash"
  93. }
  94. ]
  95. },
  96. {
  97. path: true,
  98. event: false,
  99. action: "onDiscard",
  100. m: "discard changes with path",
  101. results: [
  102. {
  103. method: "restartServicePopup",
  104. called: false
  105. },
  106. {
  107. method: "selectConfigGroup",
  108. called: false
  109. },
  110. {
  111. field: "forceTransition",
  112. value: true
  113. }
  114. ]
  115. }
  116. ];
  117. beforeEach(function () {
  118. sinon.stub(mainServiceInfoConfigsController, "restartServicePopup", Em.K);
  119. sinon.stub(mainServiceInfoConfigsController, "selectConfigGroup", Em.K);
  120. sinon.stub(mainServiceInfoConfigsController, "getHash", function () {
  121. return "hash"
  122. });
  123. App.router.route = Em.K;
  124. });
  125. afterEach(function () {
  126. mainServiceInfoConfigsController.restartServicePopup.restore();
  127. mainServiceInfoConfigsController.selectConfigGroup.restore();
  128. mainServiceInfoConfigsController.getHash.restore();
  129. });
  130. tests.forEach(function (t) {
  131. t.results.forEach(function (r) {
  132. it(t.m + " " + r.method + " " + r.field, function () {
  133. mainServiceInfoConfigsController.showSavePopup(t.path, t.event)[t.action]();
  134. if (r.method) {
  135. expect(mainServiceInfoConfigsController[r.method].calledOnce).to.equal(r.called);
  136. } else if (r.field) {
  137. expect(mainServiceInfoConfigsController.get(r.field)).to.equal(r.value);
  138. }
  139. }, this);
  140. });
  141. }, this);
  142. });
  143. describe("#hasUnsavedChanges", function () {
  144. beforeEach(function () {
  145. sinon.stub(mainServiceInfoConfigsController, "getHash", function () {
  146. return "hash"
  147. });
  148. });
  149. afterEach(function () {
  150. mainServiceInfoConfigsController.getHash.restore();
  151. });
  152. it("with unsaved", function () {
  153. mainServiceInfoConfigsController.set("hash", "hash1");
  154. expect(mainServiceInfoConfigsController.hasUnsavedChanges()).to.equal(true);
  155. });
  156. it("without unsaved", function () {
  157. mainServiceInfoConfigsController.set("hash", "hash");
  158. expect(mainServiceInfoConfigsController.hasUnsavedChanges()).to.equal(false);
  159. });
  160. });
  161. describe("#manageConfigurationGroup", function () {
  162. beforeEach(function () {
  163. sinon.stub(mainServiceInfoConfigsController, "manageConfigurationGroups", Em.K);
  164. });
  165. afterEach(function () {
  166. mainServiceInfoConfigsController.manageConfigurationGroups.restore();
  167. });
  168. it("run manageConfigurationGroups", function () {
  169. mainServiceInfoConfigsController.manageConfigurationGroup();
  170. expect(mainServiceInfoConfigsController.manageConfigurationGroups.calledOnce).to.equal(true);
  171. });
  172. });
  173. describe("#addOverrideProperty", function () {
  174. var serviceConfigProperty = Em.Object.create({
  175. overrides: []
  176. });
  177. var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
  178. newSCP.set('value', '');
  179. newSCP.set('isOriginalSCP', false);
  180. newSCP.set('parentSCP', serviceConfigProperty);
  181. newSCP.set('isEditable', true);
  182. it("add new overridden property", function () {
  183. mainServiceInfoConfigsController.addOverrideProperty(serviceConfigProperty);
  184. expect(serviceConfigProperty.get("overrides")[0]).to.eql(newSCP);
  185. });
  186. });
  187. describe("#showComponentsShouldBeRestarted", function () {
  188. var tests = [
  189. {
  190. input: {
  191. 'publicHostName1': ['TaskTracker'],
  192. 'publicHostName2': ['JobTracker', 'TaskTracker']
  193. },
  194. components: "2 TaskTrackers, 1 JobTracker",
  195. text: Em.I18n.t('service.service.config.restartService.shouldBeRestarted').format(Em.I18n.t('common.components'))
  196. },
  197. {
  198. input: {
  199. 'publicHostName1': ['TaskTracker']
  200. },
  201. components: "1 TaskTracker",
  202. text: Em.I18n.t('service.service.config.restartService.shouldBeRestarted').format(Em.I18n.t('common.component'))
  203. }
  204. ];
  205. beforeEach(function () {
  206. sinon.stub(mainServiceInfoConfigsController, "showItemsShouldBeRestarted", Em.K);
  207. mainServiceInfoConfigsController.set("content", {restartRequiredHostsAndComponents: ""});
  208. });
  209. afterEach(function () {
  210. mainServiceInfoConfigsController.showItemsShouldBeRestarted.restore();
  211. mainServiceInfoConfigsController.set("content", undefined);
  212. });
  213. tests.forEach(function (t) {
  214. it("trigger showItemsShouldBeRestarted popup with components", function () {
  215. mainServiceInfoConfigsController.set("content.restartRequiredHostsAndComponents", t.input);
  216. mainServiceInfoConfigsController.showComponentsShouldBeRestarted();
  217. expect(mainServiceInfoConfigsController.showItemsShouldBeRestarted.calledWith(t.components, t.text)).to.equal(true);
  218. });
  219. });
  220. });
  221. describe("#showHostsShouldBeRestarted", function () {
  222. var tests = [
  223. {
  224. input: {
  225. 'publicHostName1': ['TaskTracker'],
  226. 'publicHostName2': ['JobTracker', 'TaskTracker']
  227. },
  228. hosts: "publicHostName1, publicHostName2",
  229. text: Em.I18n.t('service.service.config.restartService.shouldBeRestarted').format(Em.I18n.t('common.hosts'))
  230. },
  231. {
  232. input: {
  233. 'publicHostName1': ['TaskTracker']
  234. },
  235. hosts: "publicHostName1",
  236. text: Em.I18n.t('service.service.config.restartService.shouldBeRestarted').format(Em.I18n.t('common.host'))
  237. }
  238. ];
  239. beforeEach(function () {
  240. sinon.stub(mainServiceInfoConfigsController, "showItemsShouldBeRestarted", Em.K);
  241. mainServiceInfoConfigsController.set("content", {restartRequiredHostsAndComponents: ""});
  242. });
  243. afterEach(function () {
  244. mainServiceInfoConfigsController.showItemsShouldBeRestarted.restore();
  245. mainServiceInfoConfigsController.set("content", undefined);
  246. });
  247. tests.forEach(function (t) {
  248. it("trigger showItemsShouldBeRestarted popup with hosts", function () {
  249. mainServiceInfoConfigsController.set("content.restartRequiredHostsAndComponents", t.input);
  250. mainServiceInfoConfigsController.showHostsShouldBeRestarted();
  251. expect(mainServiceInfoConfigsController.showItemsShouldBeRestarted.calledWith(t.hosts, t.text)).to.equal(true);
  252. });
  253. });
  254. });
  255. describe("rollingRestartStaleConfigSlaveComponents", function () {
  256. var tests = [
  257. {
  258. componentName: {
  259. context: "ComponentName"
  260. },
  261. displayName: "displayName",
  262. passiveState: "ON"
  263. },
  264. {
  265. componentName: {
  266. context: "ComponentName1"
  267. },
  268. displayName: "displayName1",
  269. passiveState: "OFF"
  270. }
  271. ];
  272. beforeEach(function () {
  273. mainServiceInfoConfigsController.set("content", {displayName: "", passiveState: ""});
  274. sinon.stub(batchUtils, "launchHostComponentRollingRestart", Em.K);
  275. });
  276. afterEach(function () {
  277. batchUtils.launchHostComponentRollingRestart.restore();
  278. });
  279. tests.forEach(function (t) {
  280. it("trigger rollingRestartStaleConfigSlaveComponents", function () {
  281. mainServiceInfoConfigsController.set("content.displayName", t.displayName);
  282. mainServiceInfoConfigsController.set("content.passiveState", t.passiveState);
  283. mainServiceInfoConfigsController.rollingRestartStaleConfigSlaveComponents(t.componentName);
  284. expect(batchUtils.launchHostComponentRollingRestart.calledWith(t.componentName.context, t.displayName, t.passiveState == "ON", true)).to.equal(true);
  285. });
  286. });
  287. });
  288. describe("#restartAllStaleConfigComponents", function () {
  289. beforeEach(function () {
  290. sinon.stub(batchUtils, "restartAllServiceHostComponents", Em.K);
  291. });
  292. afterEach(function () {
  293. batchUtils.restartAllServiceHostComponents.restore();
  294. });
  295. it("trigger restartAllServiceHostComponents", function () {
  296. mainServiceInfoConfigsController.restartAllStaleConfigComponents().onPrimary();
  297. expect(batchUtils.restartAllServiceHostComponents.calledOnce).to.equal(true);
  298. });
  299. });
  300. describe("#doCancel", function () {
  301. beforeEach(function () {
  302. sinon.stub(Em.run, 'once', Em.K);
  303. });
  304. afterEach(function () {
  305. Em.run.once.restore();
  306. });
  307. it("trigger onConfigGroupChange", function () {
  308. mainServiceInfoConfigsController.doCancel();
  309. expect(Em.run.once.calledWith(mainServiceInfoConfigsController, "onConfigGroupChange")).to.equal(true);
  310. });
  311. });
  312. describe("#getCurrentServiceComponents", function () {
  313. var t = Em.Object.create({
  314. content: Em.Object.create({
  315. hostComponents: [
  316. Em.Object.create({
  317. componentName: "componentName1",
  318. displayName: "displayName1"
  319. }),
  320. Em.Object.create({
  321. componentName: "componentName2",
  322. displayName: "displayName2"
  323. })
  324. ]
  325. }),
  326. validComponents: Em.A([
  327. Em.Object.create({
  328. componentName: "componentName1",
  329. displayName: "displayName1",
  330. selected: false
  331. }),
  332. Em.Object.create({
  333. componentName: "componentName2",
  334. displayName: "displayName2",
  335. selected: false
  336. })
  337. ])
  338. });
  339. beforeEach(function () {
  340. mainServiceInfoConfigsController.set("content", { hostComponents: Em.A([])});
  341. });
  342. it("get current service components", function () {
  343. mainServiceInfoConfigsController.get("content.hostComponents").push(t.content.hostComponents[0]);
  344. var com = mainServiceInfoConfigsController.get("getCurrentServiceComponents");
  345. expect(com[0]).to.eql(t.validComponents[0]);
  346. });
  347. });
  348. describe("#getMasterComponentHostValue", function () {
  349. var tests = [
  350. {
  351. content: {
  352. hostComponents: [
  353. Em.Object.create({
  354. componentName: "componentName1",
  355. hostName: "hostName"
  356. })
  357. ]
  358. },
  359. result: "hostName",
  360. multiple: false,
  361. m: "returns hostname"
  362. },
  363. {
  364. content: {
  365. hostComponents: [
  366. Em.Object.create({
  367. componentName: "componentName2",
  368. hostName: "hostName1"
  369. }),
  370. Em.Object.create({
  371. componentName: "componentName2",
  372. hostName: "hostName2"
  373. })
  374. ]
  375. },
  376. result: ["hostName1","hostName2"],
  377. multiple: true,
  378. m: "returns hostnames"
  379. }
  380. ];
  381. tests.forEach(function(t){
  382. beforeEach(function () {
  383. mainServiceInfoConfigsController.set("content", { hostComponents: []});
  384. });
  385. it(t.m, function () {
  386. mainServiceInfoConfigsController.set("content.hostComponents", t.content.hostComponents);
  387. expect(mainServiceInfoConfigsController.getMasterComponentHostValue(t.content.hostComponents[0].componentName, t.multiple)).to.eql(t.result);
  388. });
  389. });
  390. });
  391. describe("#setServerConfigValue", function () {
  392. it("parsing storm.zookeeper.servers property in non standart method", function () {
  393. expect(mainServiceInfoConfigsController.setServerConfigValue("storm.zookeeper.servers", ["a", "b"])).to.equal('[\'a\',\'b\']');
  394. });
  395. it("parsing default properties", function () {
  396. expect(mainServiceInfoConfigsController.setServerConfigValue("any.other.property", "value")).to.equal("value");
  397. });
  398. });
  399. describe("#createSiteObj", function () {
  400. var tests = [
  401. {
  402. siteName: "hdfs-site",
  403. tagName: "version1",
  404. siteObj: Em.A([
  405. {
  406. name: "property1",
  407. value: "value1"
  408. },
  409. {
  410. name: "property2",
  411. value: "value2<"
  412. },
  413. {
  414. name: "property_heapsize",
  415. value: "value3"
  416. },
  417. {
  418. name: "property_permsize",
  419. value: "value4m"
  420. }
  421. ]),
  422. result: {
  423. "type": "hdfs-site",
  424. "tag": "version1",
  425. "properties": {
  426. "property1": "value1",
  427. "property2": "value2<",
  428. "property_heapsize": "value3m",
  429. "property_permsize": "value4m"
  430. }
  431. },
  432. m: "default"
  433. },
  434. {
  435. siteName: "falcon-startup.properties",
  436. tagName: "version1",
  437. siteObj: Em.A([
  438. {
  439. name: "property1",
  440. value: "value1"
  441. },
  442. {
  443. name: "property2",
  444. value: "value2<"
  445. }
  446. ]),
  447. result: {
  448. "type": "falcon-startup.properties",
  449. "tag": "version1",
  450. "properties": {
  451. "property1": "value1",
  452. "property2": "value2<"
  453. }
  454. },
  455. m: "for falcon-startup.properties"
  456. }
  457. ];
  458. tests.forEach(function (t) {
  459. it("create site object " + t.m, function () {
  460. expect(mainServiceInfoConfigsController.createSiteObj(t.siteName, t.tagName, t.siteObj)).to.deep.eql(t.result)
  461. });
  462. });
  463. });
  464. describe("#createCoreSiteObj", function () {
  465. var tests = [
  466. {
  467. tagName: "version1",
  468. uiConfigs: Em.A([
  469. Em.Object.create({
  470. name: "property1",
  471. value: "value1",
  472. filename: "core-site.xml"
  473. }),
  474. Em.Object.create({
  475. name: "property2",
  476. value: "value2<",
  477. filename: "core-site.xml"
  478. })
  479. ]),
  480. result: {
  481. "type": "core-site",
  482. "tag": "version1",
  483. "properties": {
  484. "property1": "value1",
  485. "property2": "value2<"
  486. }
  487. }
  488. }
  489. ];
  490. tests.forEach(function (t) {
  491. it("create core object", function () {
  492. mainServiceInfoConfigsController.set("uiConfigs", t.uiConfigs);
  493. expect(mainServiceInfoConfigsController.createCoreSiteObj(t.tagName)).to.deep.eql(t.result);
  494. });
  495. });
  496. });
  497. describe("#doPUTClusterConfigurationSites", function () {
  498. var sc = [
  499. Em.Object.create({
  500. configs: [
  501. Em.Object.create({
  502. name: '_heapsize',
  503. value: '1024m'
  504. }),
  505. Em.Object.create({
  506. name: '_newsize',
  507. value: '1024m'
  508. }),
  509. Em.Object.create({
  510. name: '_maxnewsize',
  511. value: '1024m'
  512. })
  513. ]
  514. })
  515. ],
  516. scExc = [
  517. Em.Object.create({
  518. configs: [
  519. Em.Object.create({
  520. name: 'hadoop_heapsize',
  521. value: '1024m'
  522. }),
  523. Em.Object.create({
  524. name: 'yarn_heapsize',
  525. value: '1024m'
  526. }),
  527. Em.Object.create({
  528. name: 'nodemanager_heapsize',
  529. value: '1024m'
  530. }),
  531. Em.Object.create({
  532. name: 'resourcemanager_heapsize',
  533. value: '1024m'
  534. }),
  535. Em.Object.create({
  536. name: 'apptimelineserver_heapsize',
  537. value: '1024m'
  538. }),
  539. Em.Object.create({
  540. name: 'jobhistory_heapsize',
  541. value: '1024m'
  542. })
  543. ]
  544. })
  545. ];
  546. beforeEach(function () {
  547. sinon.stub(App.router, 'getClusterName', function() {
  548. return 'clName';
  549. });
  550. sinon.stub(App.ajax, "send", Em.K);
  551. });
  552. afterEach(function () {
  553. App.ajax.send.restore();
  554. App.router.getClusterName.restore();
  555. });
  556. it("ajax request to put clsuter cfg", function () {
  557. mainServiceInfoConfigsController.set('stepConfigs', sc);
  558. expect(mainServiceInfoConfigsController.doPUTClusterConfigurationSites([])).to.equal(mainServiceInfoConfigsController.get("doPUTClusterConfigurationSiteResult"));
  559. expect(App.ajax.send.calledOnce).to.be.true;
  560. });
  561. it('values should be parsed', function () {
  562. mainServiceInfoConfigsController.set('stepConfigs', sc);
  563. mainServiceInfoConfigsController.doPUTClusterConfigurationSites([]);
  564. expect(mainServiceInfoConfigsController.get('stepConfigs')[0].get('configs').mapProperty('value').uniq()).to.eql(['1024m']);
  565. });
  566. it('values should not be parsed', function () {
  567. mainServiceInfoConfigsController.set('stepConfigs', scExc);
  568. mainServiceInfoConfigsController.doPUTClusterConfigurationSites([]);
  569. expect(mainServiceInfoConfigsController.get('stepConfigs')[0].get('configs').mapProperty('value').uniq()).to.eql(['1024m']);
  570. });
  571. });
  572. describe("#isConfigChanged", function () {
  573. var tests = [
  574. {
  575. loadedConfig: {
  576. apptimelineserver_heapsize: "1024",
  577. hbase_log_dir: "/var/log/hbase",
  578. lzo_enabled: "true"
  579. },
  580. savingConfig: {
  581. apptimelineserver_heapsize: "1024",
  582. hbase_log_dir: "/var/log/hbase",
  583. lzo_enabled: "true"
  584. },
  585. m: "configs doesn't changed",
  586. res: false
  587. },
  588. {
  589. loadedConfig: {
  590. apptimelineserver_heapsize: "1024",
  591. hbase_log_dir: "/var/log/hbase",
  592. lzo_enabled: "true"
  593. },
  594. savingConfig: {
  595. apptimelineserver_heapsize: "1024",
  596. hbase_log_dir: "/var/log/hbase",
  597. lzo_enabled: "false"
  598. },
  599. m: "configs changed",
  600. res: true
  601. },
  602. {
  603. loadedConfig: {
  604. apptimelineserver_heapsize: "1024",
  605. hbase_log_dir: "/var/log/hbase"
  606. },
  607. savingConfig: {
  608. apptimelineserver_heapsize: "1024",
  609. hbase_log_dir: "/var/log/hbase",
  610. lzo_enabled: "false"
  611. },
  612. m: "add new config",
  613. res: true
  614. }
  615. ];
  616. tests.forEach(function(t){
  617. it(t.m, function () {
  618. expect(mainServiceInfoConfigsController.isConfigChanged(t.loadedConfig, t.savingConfig)).to.equal(t.res);
  619. });
  620. });
  621. });
  622. describe("#isDirChanged", function() {
  623. describe("when service name is HDFS", function() {
  624. beforeEach(function() {
  625. mainServiceInfoConfigsController.set('content', Ember.Object.create ({ serviceName: 'HDFS' }));
  626. });
  627. describe("when isHadoop2Stack is true", function() {
  628. var tests = [
  629. {
  630. it: "should set dirChanged to false if none of the properties exist",
  631. expect: false,
  632. config: Ember.Object.create ({})
  633. },
  634. {
  635. it: "should set dirChanged to true if dfs.namenode.name.dir is not default",
  636. expect: true,
  637. config: Ember.Object.create ({
  638. name: 'dfs.namenode.name.dir',
  639. isNotDefaultValue: true
  640. })
  641. },
  642. {
  643. it: "should set dirChanged to false if dfs.namenode.name.dir is default",
  644. expect: false,
  645. config: Ember.Object.create ({
  646. name: 'dfs.namenode.name.dir',
  647. isNotDefaultValue: false
  648. })
  649. },
  650. {
  651. it: "should set dirChanged to true if dfs.namenode.checkpoint.dir is not default",
  652. expect: true,
  653. config: Ember.Object.create ({
  654. name: 'dfs.namenode.checkpoint.dir',
  655. isNotDefaultValue: true
  656. })
  657. },
  658. {
  659. it: "should set dirChanged to false if dfs.namenode.checkpoint.dir is default",
  660. expect: false,
  661. config: Ember.Object.create ({
  662. name: 'dfs.namenode.checkpoint.dir',
  663. isNotDefaultValue: false
  664. })
  665. },
  666. {
  667. it: "should set dirChanged to true if dfs.datanode.data.dir is not default",
  668. expect: true,
  669. config: Ember.Object.create ({
  670. name: 'dfs.datanode.data.dir',
  671. isNotDefaultValue: true
  672. })
  673. },
  674. {
  675. it: "should set dirChanged to false if dfs.datanode.data.dir is default",
  676. expect: false,
  677. config: Ember.Object.create ({
  678. name: 'dfs.datanode.data.dir',
  679. isNotDefaultValue: false
  680. })
  681. }
  682. ];
  683. beforeEach(function() {
  684. sinon.stub(App, 'get').returns(true);
  685. });
  686. afterEach(function() {
  687. App.get.restore();
  688. });
  689. tests.forEach(function(test) {
  690. it(test.it, function() {
  691. mainServiceInfoConfigsController.set('stepConfigs', [Ember.Object.create ({ configs: [test.config], serviceName: 'HDFS' })]);
  692. expect(mainServiceInfoConfigsController.isDirChanged()).to.equal(test.expect);
  693. })
  694. });
  695. });
  696. describe("when isHadoop2Stack is false", function() {
  697. var tests = [
  698. {
  699. it: "should set dirChanged to false if none of the properties exist",
  700. expect: false,
  701. config: Ember.Object.create ({})
  702. },
  703. {
  704. it: "should set dirChanged to true if dfs.name.dir is not default",
  705. expect: true,
  706. config: Ember.Object.create ({
  707. name: 'dfs.name.dir',
  708. isNotDefaultValue: true
  709. })
  710. },
  711. {
  712. it: "should set dirChanged to false if dfs.name.dir is default",
  713. expect: false,
  714. config: Ember.Object.create ({
  715. name: 'dfs.name.dir',
  716. isNotDefaultValue: false
  717. })
  718. },
  719. {
  720. it: "should set dirChanged to true if fs.checkpoint.dir is not default",
  721. expect: true,
  722. config: Ember.Object.create ({
  723. name: 'fs.checkpoint.dir',
  724. isNotDefaultValue: true
  725. })
  726. },
  727. {
  728. it: "should set dirChanged to false if fs.checkpoint.dir is default",
  729. expect: false,
  730. config: Ember.Object.create ({
  731. name: 'fs.checkpoint.dir',
  732. isNotDefaultValue: false
  733. })
  734. },
  735. {
  736. it: "should set dirChanged to true if dfs.data.dir is not default",
  737. expect: true,
  738. config: Ember.Object.create ({
  739. name: 'dfs.data.dir',
  740. isNotDefaultValue: true
  741. })
  742. },
  743. {
  744. it: "should set dirChanged to false if dfs.data.dir is default",
  745. expect: false,
  746. config: Ember.Object.create ({
  747. name: 'dfs.data.dir',
  748. isNotDefaultValue: false
  749. })
  750. }
  751. ];
  752. beforeEach(function() {
  753. sinon.stub(App, 'get').returns(false);
  754. });
  755. afterEach(function() {
  756. App.get.restore();
  757. });
  758. tests.forEach(function(test) {
  759. it(test.it, function() {
  760. mainServiceInfoConfigsController.set('stepConfigs', [Ember.Object.create ({ configs: [test.config], serviceName: 'HDFS' })]);
  761. expect(mainServiceInfoConfigsController.isDirChanged()).to.equal(test.expect);
  762. })
  763. });
  764. });
  765. });
  766. describe("when service name is MAPREDUCE", function() {
  767. beforeEach(function() {
  768. mainServiceInfoConfigsController.set('content', Ember.Object.create ({ serviceName: 'MAPREDUCE' }));
  769. });
  770. var tests = [
  771. {
  772. it: "should set dirChanged to false if none of the properties exist",
  773. expect: false,
  774. config: Ember.Object.create ({})
  775. },
  776. {
  777. it: "should set dirChanged to true if mapred.local.dir is not default",
  778. expect: true,
  779. config: Ember.Object.create ({
  780. name: 'mapred.local.dir',
  781. isNotDefaultValue: true
  782. })
  783. },
  784. {
  785. it: "should set dirChanged to false if mapred.local.dir is default",
  786. expect: false,
  787. config: Ember.Object.create ({
  788. name: 'mapred.local.dir',
  789. isNotDefaultValue: false
  790. })
  791. },
  792. {
  793. it: "should set dirChanged to true if mapred.system.dir is not default",
  794. expect: true,
  795. config: Ember.Object.create ({
  796. name: 'mapred.system.dir',
  797. isNotDefaultValue: true
  798. })
  799. },
  800. {
  801. it: "should set dirChanged to false if mapred.system.dir is default",
  802. expect: false,
  803. config: Ember.Object.create ({
  804. name: 'mapred.system.dir',
  805. isNotDefaultValue: false
  806. })
  807. }
  808. ];
  809. tests.forEach(function(test) {
  810. it(test.it, function() {
  811. mainServiceInfoConfigsController.set('stepConfigs', [Ember.Object.create ({ configs: [test.config], serviceName: 'MAPREDUCE' })]);
  812. expect(mainServiceInfoConfigsController.isDirChanged()).to.equal(test.expect);
  813. })
  814. });
  815. });
  816. });
  817. describe("#addDynamicProperties", function() {
  818. var tests = [
  819. {
  820. stepConfigs: [Em.Object.create({
  821. serviceName: "HIVE",
  822. configs: []
  823. })],
  824. content: Em.Object.create({
  825. serviceName: "HIVE"
  826. }),
  827. m: "add dynamic property",
  828. addDynamic: true
  829. },
  830. {
  831. stepConfigs: [Em.Object.create({
  832. serviceName: "HIVE",
  833. configs: [
  834. Em.Object.create({
  835. name: "templeton.hive.properties"
  836. })
  837. ]
  838. })],
  839. content: Em.Object.create({
  840. serviceName: "HIVE"
  841. }),
  842. m: "don't add dynamic property (already included)",
  843. addDynamic: false
  844. },
  845. {
  846. stepConfigs: [Em.Object.create({
  847. serviceName: "HDFS",
  848. configs: []
  849. })],
  850. content: Em.Object.create({
  851. serviceName: "HDFS"
  852. }),
  853. m: "don't add dynamic property (wrong service)",
  854. addDynamic: false
  855. }
  856. ];
  857. var dynamicProperty = {
  858. "name": "templeton.hive.properties",
  859. "templateName": ["hivemetastore_host"],
  860. "foreignKey": null,
  861. "value": "hive.metastore.local=false,hive.metastore.uris=thrift://<templateName[0]>:9083,hive.metastore.sasl.enabled=yes,hive.metastore.execute.setugi=true,hive.metastore.warehouse.dir=/apps/hive/warehouse",
  862. "filename": "webhcat-site.xml"
  863. };
  864. tests.forEach(function(t) {
  865. it(t.m, function() {
  866. mainServiceInfoConfigsController.set("content", t.content);
  867. mainServiceInfoConfigsController.set("stepConfigs", t.stepConfigs);
  868. var configs = [];
  869. mainServiceInfoConfigsController.addDynamicProperties(configs);
  870. if (t.addDynamic){
  871. expect(configs.findProperty("name","templeton.hive.properties")).to.deep.eql(dynamicProperty);
  872. }
  873. });
  874. });
  875. });
  876. describe("#loadUiSideConfigs", function () {
  877. var t = {
  878. configMapping: [
  879. {
  880. foreignKey: null,
  881. templateName: "",
  882. value: "default",
  883. name: "name1",
  884. filename: "filename1"
  885. },
  886. {
  887. foreignKey: "notNull",
  888. templateName: "",
  889. value: "default2",
  890. name: "name2",
  891. filename: "filename2"
  892. }
  893. ],
  894. configMappingf: [
  895. {
  896. foreignKey: null,
  897. templateName: "",
  898. value: "default",
  899. name: "name1",
  900. filename: "filename1"
  901. }
  902. ],
  903. valueWithOverrides: {
  904. "value": "default",
  905. "overrides": {
  906. "value1": "value1",
  907. "value2": "value2"
  908. }
  909. },
  910. uiConfigs: [
  911. {
  912. "id": "site property",
  913. "name": "name1",
  914. "value": "default",
  915. "filename": "filename1",
  916. "overrides": {
  917. "value1": "value1",
  918. "value2": "value2"
  919. }
  920. }
  921. ]
  922. };
  923. beforeEach(function(){
  924. sinon.stub(mainServiceInfoConfigsController, "addDynamicProperties", Em.K);
  925. sinon.stub(mainServiceInfoConfigsController, "getGlobConfigValueWithOverrides", function () {
  926. return t.valueWithOverrides
  927. });
  928. });
  929. afterEach(function(){
  930. mainServiceInfoConfigsController.addDynamicProperties.restore();
  931. mainServiceInfoConfigsController.getGlobConfigValueWithOverrides.restore();
  932. });
  933. it("load ui config", function() {
  934. expect(mainServiceInfoConfigsController.loadUiSideConfigs(t.configMapping)[0]).to.deep.equal(t.uiConfigs[0]);
  935. expect(mainServiceInfoConfigsController.addDynamicProperties.calledWith(t.configMappingf)).to.equal(true);
  936. });
  937. });
  938. describe("#formatConfigValues", function () {
  939. var t = {
  940. configs: [
  941. Em.Object.create({ name: "p1", value: " v1 v1 ", displayType: "" }),
  942. Em.Object.create({ name: "p2", value: true, displayType: "" }),
  943. Em.Object.create({ name: "p3", value: " d1 ", displayType: "directory" }),
  944. Em.Object.create({ name: "p4", value: " d1 d2 d3 ", displayType: "directories" }),
  945. Em.Object.create({ name: "p5", value: " v1 ", displayType: "password" }),
  946. Em.Object.create({ name: "p6", value: " v ", displayType: "host" }),
  947. Em.Object.create({ name: "javax.jdo.option.ConnectionURL", value: " v1 ", displayType: "advanced" }),
  948. Em.Object.create({ name: "oozie.service.JPAService.jdbc.url", value: " v1 ", displayType: "advanced" })
  949. ],
  950. result: [
  951. Em.Object.create({ name: "p1", value: " v1 v1", displayType: "" }),
  952. Em.Object.create({ name: "p2", value: "true", displayType: "" }),
  953. Em.Object.create({ name: "p3", value: "d1", displayType: "directory" }),
  954. Em.Object.create({ name: "p4", value: "d1,d2,d3", displayType: "directories" }),
  955. Em.Object.create({ name: "p5", value: " v1 ", displayType: "password" }),
  956. Em.Object.create({ name: "p6", value: "v", displayType: "host" }),
  957. Em.Object.create({ name: "javax.jdo.option.ConnectionURL", value: " v1", displayType: "advanced" }),
  958. Em.Object.create({ name: "oozie.service.JPAService.jdbc.url", value: " v1", displayType: "advanced" })
  959. ]
  960. };
  961. it("format config values", function () {
  962. mainServiceInfoConfigsController.formatConfigValues(t.configs);
  963. expect(t.configs).to.deep.equal(t.result);
  964. });
  965. });
  966. describe("#createConfigObject", function() {
  967. var tests = [
  968. {
  969. siteName: "core-site",
  970. serviceName: "HDFS",
  971. method: "createCoreSiteObj"
  972. },
  973. {
  974. siteName: "core-site",
  975. serviceName: "ANY",
  976. method: false
  977. },
  978. {
  979. siteName: "any",
  980. method: "createSiteObj"
  981. },
  982. {
  983. siteName: "mapred-queue-acls",
  984. method: false
  985. }
  986. ];
  987. beforeEach(function() {
  988. sinon.stub(mainServiceInfoConfigsController, "createCoreSiteObj", Em.K);
  989. sinon.stub(mainServiceInfoConfigsController, "createSiteObj", Em.K);
  990. mainServiceInfoConfigsController.set("content", {});
  991. });
  992. afterEach(function() {
  993. mainServiceInfoConfigsController.createCoreSiteObj.restore();
  994. mainServiceInfoConfigsController.createSiteObj.restore();
  995. });
  996. tests.forEach(function(t) {
  997. it("create object for " + t.siteName + " run method " + t.method, function() {
  998. mainServiceInfoConfigsController.set("content.serviceName", t.serviceName);
  999. mainServiceInfoConfigsController.createConfigObject(t.siteName, "versrion1");
  1000. if (t.method) {
  1001. expect(mainServiceInfoConfigsController[t.method].calledOnce).to.equal(true);
  1002. } else {
  1003. expect(mainServiceInfoConfigsController["createCoreSiteObj"].calledOnce).to.equal(false);
  1004. expect(mainServiceInfoConfigsController["createSiteObj"].calledOnce).to.equal(false);
  1005. }
  1006. });
  1007. });
  1008. });
  1009. describe("#putConfigGroupChanges", function() {
  1010. var t = {
  1011. data: {
  1012. ConfigGroup: {
  1013. id: "id"
  1014. }
  1015. },
  1016. request: [{
  1017. ConfigGroup: {
  1018. id: "id"
  1019. }
  1020. }]
  1021. };
  1022. beforeEach(function() {
  1023. sinon.spy($,"ajax");
  1024. });
  1025. afterEach(function() {
  1026. $.ajax.restore();
  1027. });
  1028. it("updates configs groups", function() {
  1029. mainServiceInfoConfigsController.putConfigGroupChanges(t.data);
  1030. expect(JSON.parse($.ajax.args[0][0].data)).to.deep.equal(t.request);
  1031. });
  1032. });
  1033. describe("#setValueForCheckBox", function() {
  1034. var tests = [
  1035. {
  1036. serviceConfigPropertyInput: Em.Object.create({
  1037. value: "true",
  1038. defaultValue: "true",
  1039. displayType: 'checkbox'
  1040. }),
  1041. serviceConfigProperty: Em.Object.create({
  1042. value: true,
  1043. defaultValue: true,
  1044. displayType: 'checkbox'
  1045. })
  1046. },
  1047. {
  1048. serviceConfigPropertyInput: Em.Object.create({
  1049. value: "false",
  1050. defaultValue: "false",
  1051. displayType: 'checkbox'
  1052. }),
  1053. serviceConfigProperty: Em.Object.create({
  1054. value: false,
  1055. defaultValue: false,
  1056. displayType: 'checkbox'
  1057. })
  1058. },
  1059. {
  1060. serviceConfigPropertyInput: Em.Object.create({
  1061. value: "false",
  1062. defaultValue: "false"
  1063. }),
  1064. serviceConfigProperty: Em.Object.create({
  1065. value: "false",
  1066. defaultValue: "false"
  1067. })
  1068. }
  1069. ];
  1070. tests.forEach(function(t) {
  1071. it("set " + t.serviceConfigPropertyInput.value, function(){
  1072. var serviceConfigProperty = t.serviceConfigPropertyInput;
  1073. mainServiceInfoConfigsController.setValueForCheckBox(serviceConfigProperty);
  1074. expect(serviceConfigProperty).to.eql(t.serviceConfigProperty);
  1075. });
  1076. });
  1077. });
  1078. describe("#setEditability", function () {
  1079. var tests = [
  1080. {
  1081. isAdmin: true,
  1082. isHostsConfigsPage: false,
  1083. defaultGroupSelected: true,
  1084. isReconfigurable: true,
  1085. isEditable: true,
  1086. m: ""
  1087. },
  1088. {
  1089. isAdmin: false,
  1090. isHostsConfigsPage: false,
  1091. defaultGroupSelected: true,
  1092. isReconfigurable: true,
  1093. isEditable: false,
  1094. m: "(non admin)"
  1095. },
  1096. {
  1097. isAdmin: true,
  1098. isHostsConfigsPage: true,
  1099. defaultGroupSelected: true,
  1100. isReconfigurable: true,
  1101. isEditable: false,
  1102. m: "(isHostsConfigsPage)"
  1103. },
  1104. {
  1105. isAdmin: true,
  1106. isHostsConfigsPage: false,
  1107. defaultGroupSelected: false,
  1108. isReconfigurable: true,
  1109. isEditable: false,
  1110. m: "(defaultGroupSelected is false)"
  1111. },
  1112. {
  1113. isAdmin: true,
  1114. isHostsConfigsPage: false,
  1115. defaultGroupSelected: true,
  1116. isReconfigurable: false,
  1117. isEditable: false,
  1118. m: "(isReconfigurable is false)"
  1119. }
  1120. ];
  1121. var a = App.get('isAdmin');
  1122. afterEach(function () {
  1123. App.set('isAdmin', a);
  1124. });
  1125. tests.forEach(function(t) {
  1126. it("set isEditable " + t.isEditable + t.m, function(){
  1127. App.set('isAdmin', t.isAdmin);
  1128. mainServiceInfoConfigsController.set("isHostsConfigsPage", t.isHostsConfigsPage);
  1129. var serviceConfigProperty = Em.Object.create({
  1130. isReconfigurable: t.isReconfigurable
  1131. });
  1132. mainServiceInfoConfigsController.setEditability(serviceConfigProperty, t.defaultGroupSelected);
  1133. expect(serviceConfigProperty.get("isEditable")).to.equal(t.isEditable);
  1134. });
  1135. });
  1136. });
  1137. describe("#checkOverrideProperty", function () {
  1138. var tests = [{
  1139. overrideToAdd: {
  1140. name: "name1",
  1141. filename: "filename1"
  1142. },
  1143. componentConfig: {
  1144. configs: [
  1145. {
  1146. name: "name1",
  1147. filename: "filename2"
  1148. },
  1149. {
  1150. name: "name1",
  1151. filename: "filename1"
  1152. }
  1153. ]
  1154. },
  1155. add: true,
  1156. m: "add property"
  1157. },
  1158. {
  1159. overrideToAdd: {
  1160. name: "name1"
  1161. },
  1162. componentConfig: {
  1163. configs: [
  1164. {
  1165. name: "name2"
  1166. }
  1167. ]
  1168. },
  1169. add: false,
  1170. m: "don't add property, different names"
  1171. },
  1172. {
  1173. overrideToAdd: {
  1174. name: "name1",
  1175. filename: "filename1"
  1176. },
  1177. componentConfig: {
  1178. configs: [
  1179. {
  1180. name: "name1",
  1181. filename: "filename2"
  1182. }
  1183. ]
  1184. },
  1185. add: false,
  1186. m: "don't add property, different filenames"
  1187. },
  1188. {
  1189. overrideToAdd: null,
  1190. componentConfig: {},
  1191. add: false,
  1192. m: "don't add property, overrideToAdd is null"
  1193. }];
  1194. beforeEach(function() {
  1195. sinon.stub(mainServiceInfoConfigsController,"addOverrideProperty", Em.K)
  1196. });
  1197. afterEach(function() {
  1198. mainServiceInfoConfigsController.addOverrideProperty.restore();
  1199. });
  1200. tests.forEach(function(t) {
  1201. it(t.m, function() {
  1202. mainServiceInfoConfigsController.set("overrideToAdd", t.overrideToAdd);
  1203. mainServiceInfoConfigsController.checkOverrideProperty(t.componentConfig);
  1204. if(t.add) {
  1205. expect(mainServiceInfoConfigsController.addOverrideProperty.calledWith(t.overrideToAdd)).to.equal(true);
  1206. expect(mainServiceInfoConfigsController.get("overrideToAdd")).to.equal(null);
  1207. } else {
  1208. expect(mainServiceInfoConfigsController.addOverrideProperty.calledOnce).to.equal(false);
  1209. }
  1210. });
  1211. });
  1212. });
  1213. describe("#setValuesForOverrides", function() {
  1214. var tests = [
  1215. {
  1216. overrides: [
  1217. {name: "override1"},
  1218. {name: "override2"}
  1219. ],
  1220. _serviceConfigProperty: {},
  1221. serviceConfigProperty: Em.Object.create({overrides: Em.A([])}),
  1222. defaultGroupSelected: true
  1223. }
  1224. ];
  1225. beforeEach(function() {
  1226. sinon.stub(mainServiceInfoConfigsController, "createNewSCP", function(override) {return {name: override.name}})
  1227. });
  1228. afterEach(function() {
  1229. mainServiceInfoConfigsController.createNewSCP.restore();
  1230. });
  1231. tests.forEach(function(t) {
  1232. it("set values for overrides. use createNewSCP method to do this", function() {
  1233. var serviceConfigProperty = t.serviceConfigProperty;
  1234. mainServiceInfoConfigsController.setValuesForOverrides(t.overrides, serviceConfigProperty, t.serviceConfigProperty, t.defaultGroupSelected);
  1235. expect(serviceConfigProperty.get("overrides")[0]).to.eql(t.overrides[0]);
  1236. expect(serviceConfigProperty.get("overrides")[1]).to.eql(t.overrides[1]);
  1237. });
  1238. });
  1239. });
  1240. describe("#createConfigProperty", function() {
  1241. var tests = [
  1242. {
  1243. _serviceConfigProperty: {
  1244. overrides: {
  1245. }
  1246. },
  1247. defaultGroupSelected: true,
  1248. restartData: {},
  1249. serviceConfigsData: {},
  1250. serviceConfigProperty: {
  1251. overrides: null,
  1252. isOverridable: true
  1253. }
  1254. }];
  1255. beforeEach(function() {
  1256. sinon.stub(mainServiceInfoConfigsController, "setValueForCheckBox", Em.K);
  1257. sinon.stub(mainServiceInfoConfigsController, "setValidator", Em.K);
  1258. sinon.stub(mainServiceInfoConfigsController, "setValuesForOverrides", Em.K);
  1259. sinon.stub(mainServiceInfoConfigsController, "setEditability", Em.K);
  1260. });
  1261. afterEach(function() {
  1262. mainServiceInfoConfigsController.setValueForCheckBox.restore();
  1263. mainServiceInfoConfigsController.setValidator.restore();
  1264. mainServiceInfoConfigsController.setValuesForOverrides.restore();
  1265. mainServiceInfoConfigsController.setEditability.restore();
  1266. });
  1267. tests.forEach(function(t) {
  1268. it("create service config. run methods to correctly set object fileds", function() {
  1269. var result = mainServiceInfoConfigsController.createConfigProperty(t._serviceConfigProperty, t.defaultGroupSelected, t.restartData, t.serviceConfigsData);
  1270. expect(mainServiceInfoConfigsController.setValueForCheckBox.calledWith(t.serviceConfigProperty));
  1271. expect(mainServiceInfoConfigsController.setValidator.calledWith(t.serviceConfigProperty, t.serviceConfigsData));
  1272. expect(mainServiceInfoConfigsController.setValuesForOverrides.calledWith(t._serviceConfigProperty.overrides, t._serviceConfigProperty, t.serviceConfigProperty, t.defaultGroupSelected));
  1273. expect(mainServiceInfoConfigsController.setValidator.calledWith(t.serviceConfigProperty, t.defaultGroupSelected));
  1274. expect(result.getProperties('overrides','isOverridable')).to.eql(t.serviceConfigProperty);
  1275. });
  1276. });
  1277. });
  1278. describe("#createNewSCP", function() {
  1279. var tests = [
  1280. {
  1281. overrides: {
  1282. value: "value",
  1283. group: {
  1284. value: "group1"
  1285. }
  1286. },
  1287. _serviceConfigProperty: {},
  1288. serviceConfigProperty: Em.Object.create({
  1289. value: "parentSCP",
  1290. supportsFinal: true
  1291. }),
  1292. defaultGroupSelected: true,
  1293. newSCP: {
  1294. value: "value",
  1295. isOriginalSCP: false,
  1296. parentSCP:Em.Object.create({
  1297. value: "parentSCP",
  1298. supportsFinal: true
  1299. }),
  1300. group: {
  1301. value: "group1"
  1302. },
  1303. isEditable: false
  1304. }
  1305. }
  1306. ];
  1307. tests.forEach(function(t) {
  1308. it("", function() {
  1309. var newSCP = mainServiceInfoConfigsController.createNewSCP(t.overrides, t._serviceConfigProperty, t.serviceConfigProperty, t.defaultGroupSelected);
  1310. expect(newSCP.getProperties("value", "isOriginalSCP", "parentSCP", "group", "isEditable")).to.eql(t.newSCP);
  1311. });
  1312. });
  1313. });
  1314. describe("setCompareDefaultGroupConfig", function() {
  1315. beforeEach(function() {
  1316. sinon.stub(mainServiceInfoConfigsController, "getComparisonConfig").returns("compConfig");
  1317. sinon.stub(mainServiceInfoConfigsController, "getMockComparisonConfig").returns("mockConfig");
  1318. sinon.stub(mainServiceInfoConfigsController, "hasCompareDiffs").returns(true);
  1319. });
  1320. afterEach(function() {
  1321. mainServiceInfoConfigsController.getComparisonConfig.restore();
  1322. mainServiceInfoConfigsController.getMockComparisonConfig.restore();
  1323. mainServiceInfoConfigsController.hasCompareDiffs.restore();
  1324. });
  1325. it("expect that setCompareDefaultGroupConfig will not run anything", function() {
  1326. expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({}).compareConfigs.length).to.equal(0);
  1327. });
  1328. it("expect that setCompareDefaultGroupConfig will not run anything", function() {
  1329. expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({},{}).compareConfigs.length).to.equal(0);
  1330. });
  1331. it("expect that serviceConfig.compareConfigs will be getMockComparisonConfig", function() {
  1332. expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isUserProperty: true}, null)).to.eql({compareConfigs: ["mockConfig"], isUserProperty: true, isComparison: true, hasCompareDiffs: true});
  1333. });
  1334. it("expect that serviceConfig.compareConfigs will be getComparisonConfig", function() {
  1335. expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isUserProperty: true}, {})).to.eql({compareConfigs: ["compConfig"], isUserProperty: true, isComparison: true, hasCompareDiffs: true});
  1336. });
  1337. it("expect that serviceConfig.compareConfigs will be getComparisonConfig", function() {
  1338. expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isReconfigurable: true}, {})).to.eql({compareConfigs: ["compConfig"], isReconfigurable: true, isComparison: true, hasCompareDiffs: true});
  1339. });
  1340. it("expect that serviceConfig.compareConfigs will be getComparisonConfig", function() {
  1341. expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isReconfigurable: true, isMock: true}, {})).to.eql({compareConfigs: ["compConfig"], isReconfigurable: true, isMock: true, isComparison: true, hasCompareDiffs: true});
  1342. });
  1343. });
  1344. });