config_test.js 49 KB

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