config_test.js 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300
  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. });
  309. describe("#getMasterComponentHostValue", function () {
  310. var tests = [
  311. {
  312. content: {
  313. hostComponents: [
  314. Em.Object.create({
  315. componentName: "componentName1",
  316. hostName: "hostName"
  317. })
  318. ]
  319. },
  320. result: "hostName",
  321. multiple: false,
  322. m: "returns hostname"
  323. },
  324. {
  325. content: {
  326. hostComponents: [
  327. Em.Object.create({
  328. componentName: "componentName2",
  329. hostName: "hostName1"
  330. }),
  331. Em.Object.create({
  332. componentName: "componentName2",
  333. hostName: "hostName2"
  334. })
  335. ]
  336. },
  337. result: ["hostName1","hostName2"],
  338. multiple: true,
  339. m: "returns hostnames"
  340. }
  341. ];
  342. tests.forEach(function(t){
  343. beforeEach(function () {
  344. mainServiceInfoConfigsController.set("content", { hostComponents: []});
  345. });
  346. it(t.m, function () {
  347. mainServiceInfoConfigsController.set("content.hostComponents", t.content.hostComponents);
  348. expect(mainServiceInfoConfigsController.getMasterComponentHostValue(t.content.hostComponents[0].componentName, t.multiple)).to.eql(t.result);
  349. });
  350. });
  351. });
  352. describe("#putChangedConfigurations", function () {
  353. var sc = [
  354. Em.Object.create({
  355. configs: [
  356. Em.Object.create({
  357. name: '_heapsize',
  358. value: '1024m'
  359. }),
  360. Em.Object.create({
  361. name: '_newsize',
  362. value: '1024m'
  363. }),
  364. Em.Object.create({
  365. name: '_maxnewsize',
  366. value: '1024m'
  367. })
  368. ]
  369. })
  370. ],
  371. scExc = [
  372. Em.Object.create({
  373. configs: [
  374. Em.Object.create({
  375. name: 'hadoop_heapsize',
  376. value: '1024m'
  377. }),
  378. Em.Object.create({
  379. name: 'yarn_heapsize',
  380. value: '1024m'
  381. }),
  382. Em.Object.create({
  383. name: 'nodemanager_heapsize',
  384. value: '1024m'
  385. }),
  386. Em.Object.create({
  387. name: 'resourcemanager_heapsize',
  388. value: '1024m'
  389. }),
  390. Em.Object.create({
  391. name: 'apptimelineserver_heapsize',
  392. value: '1024m'
  393. }),
  394. Em.Object.create({
  395. name: 'jobhistory_heapsize',
  396. value: '1024m'
  397. })
  398. ]
  399. })
  400. ];
  401. beforeEach(function () {
  402. sinon.stub(App.router, 'getClusterName', function() {
  403. return 'clName';
  404. });
  405. sinon.stub(App.ajax, "send", Em.K);
  406. });
  407. afterEach(function () {
  408. App.ajax.send.restore();
  409. App.router.getClusterName.restore();
  410. });
  411. it("ajax request to put cluster cfg", function () {
  412. mainServiceInfoConfigsController.set('stepConfigs', sc);
  413. expect(mainServiceInfoConfigsController.putChangedConfigurations([]));
  414. expect(App.ajax.send.calledOnce).to.be.true;
  415. });
  416. it('values should be parsed', function () {
  417. mainServiceInfoConfigsController.set('stepConfigs', sc);
  418. mainServiceInfoConfigsController.putChangedConfigurations([]);
  419. expect(mainServiceInfoConfigsController.get('stepConfigs')[0].get('configs').mapProperty('value').uniq()).to.eql(['1024m']);
  420. });
  421. it('values should not be parsed', function () {
  422. mainServiceInfoConfigsController.set('stepConfigs', scExc);
  423. mainServiceInfoConfigsController.putChangedConfigurations([]);
  424. expect(mainServiceInfoConfigsController.get('stepConfigs')[0].get('configs').mapProperty('value').uniq()).to.eql(['1024m']);
  425. });
  426. });
  427. describe("#isConfigChanged", function () {
  428. var tests = [
  429. {
  430. loadedConfig: {
  431. apptimelineserver_heapsize: "1024",
  432. hbase_log_dir: "/var/log/hbase",
  433. lzo_enabled: "true"
  434. },
  435. savingConfig: {
  436. apptimelineserver_heapsize: "1024",
  437. hbase_log_dir: "/var/log/hbase",
  438. lzo_enabled: "true"
  439. },
  440. m: "configs doesn't changed",
  441. res: false
  442. },
  443. {
  444. loadedConfig: {
  445. apptimelineserver_heapsize: "1024",
  446. hbase_log_dir: "/var/log/hbase",
  447. lzo_enabled: "true"
  448. },
  449. savingConfig: {
  450. apptimelineserver_heapsize: "1024",
  451. hbase_log_dir: "/var/log/hbase",
  452. lzo_enabled: "false"
  453. },
  454. m: "configs changed",
  455. res: true
  456. },
  457. {
  458. loadedConfig: {
  459. apptimelineserver_heapsize: "1024",
  460. hbase_log_dir: "/var/log/hbase"
  461. },
  462. savingConfig: {
  463. apptimelineserver_heapsize: "1024",
  464. hbase_log_dir: "/var/log/hbase",
  465. lzo_enabled: "false"
  466. },
  467. m: "add new config",
  468. res: true
  469. }
  470. ];
  471. tests.forEach(function(t){
  472. it(t.m, function () {
  473. expect(mainServiceInfoConfigsController.isConfigChanged(t.loadedConfig, t.savingConfig)).to.equal(t.res);
  474. });
  475. });
  476. });
  477. describe("#isDirChanged", function() {
  478. describe("when service name is HDFS", function() {
  479. beforeEach(function() {
  480. mainServiceInfoConfigsController.set('content', Ember.Object.create ({ serviceName: 'HDFS' }));
  481. });
  482. describe("for hadoop 2", function() {
  483. var tests = [
  484. {
  485. it: "should set dirChanged to false if none of the properties exist",
  486. expect: false,
  487. config: Ember.Object.create ({})
  488. },
  489. {
  490. it: "should set dirChanged to true if dfs.namenode.name.dir is not default",
  491. expect: true,
  492. config: Ember.Object.create ({
  493. name: 'dfs.namenode.name.dir',
  494. isNotDefaultValue: true
  495. })
  496. },
  497. {
  498. it: "should set dirChanged to false if dfs.namenode.name.dir is default",
  499. expect: false,
  500. config: Ember.Object.create ({
  501. name: 'dfs.namenode.name.dir',
  502. isNotDefaultValue: false
  503. })
  504. },
  505. {
  506. it: "should set dirChanged to true if dfs.namenode.checkpoint.dir is not default",
  507. expect: true,
  508. config: Ember.Object.create ({
  509. name: 'dfs.namenode.checkpoint.dir',
  510. isNotDefaultValue: true
  511. })
  512. },
  513. {
  514. it: "should set dirChanged to false if dfs.namenode.checkpoint.dir is default",
  515. expect: false,
  516. config: Ember.Object.create ({
  517. name: 'dfs.namenode.checkpoint.dir',
  518. isNotDefaultValue: false
  519. })
  520. },
  521. {
  522. it: "should set dirChanged to true if dfs.datanode.data.dir is not default",
  523. expect: true,
  524. config: Ember.Object.create ({
  525. name: 'dfs.datanode.data.dir',
  526. isNotDefaultValue: true
  527. })
  528. },
  529. {
  530. it: "should set dirChanged to false if dfs.datanode.data.dir is default",
  531. expect: false,
  532. config: Ember.Object.create ({
  533. name: 'dfs.datanode.data.dir',
  534. isNotDefaultValue: false
  535. })
  536. }
  537. ];
  538. beforeEach(function() {
  539. sinon.stub(App, 'get').returns(true);
  540. });
  541. afterEach(function() {
  542. App.get.restore();
  543. });
  544. tests.forEach(function(test) {
  545. it(test.it, function() {
  546. mainServiceInfoConfigsController.set('stepConfigs', [Ember.Object.create ({ configs: [test.config], serviceName: 'HDFS' })]);
  547. expect(mainServiceInfoConfigsController.isDirChanged()).to.equal(test.expect);
  548. })
  549. });
  550. });
  551. });
  552. });
  553. describe("#addDynamicProperties", function() {
  554. var tests = [
  555. {
  556. stepConfigs: [Em.Object.create({
  557. serviceName: "HIVE",
  558. configs: []
  559. })],
  560. content: Em.Object.create({
  561. serviceName: "HIVE"
  562. }),
  563. m: "add dynamic property",
  564. addDynamic: true
  565. },
  566. {
  567. stepConfigs: [Em.Object.create({
  568. serviceName: "HIVE",
  569. configs: [
  570. Em.Object.create({
  571. name: "templeton.hive.properties"
  572. })
  573. ]
  574. })],
  575. content: Em.Object.create({
  576. serviceName: "HIVE"
  577. }),
  578. m: "don't add dynamic property (already included)",
  579. addDynamic: false
  580. },
  581. {
  582. stepConfigs: [Em.Object.create({
  583. serviceName: "HDFS",
  584. configs: []
  585. })],
  586. content: Em.Object.create({
  587. serviceName: "HDFS"
  588. }),
  589. m: "don't add dynamic property (wrong service)",
  590. addDynamic: false
  591. }
  592. ];
  593. var dynamicProperty = {
  594. "name": "templeton.hive.properties",
  595. "templateName": ["hive.metastore.uris"],
  596. "foreignKey": null,
  597. "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",
  598. "filename": "webhcat-site.xml"
  599. };
  600. tests.forEach(function(t) {
  601. it(t.m, function() {
  602. mainServiceInfoConfigsController.set("content", t.content);
  603. mainServiceInfoConfigsController.set("stepConfigs", t.stepConfigs);
  604. var configs = [];
  605. mainServiceInfoConfigsController.addDynamicProperties(configs);
  606. if (t.addDynamic){
  607. expect(configs.findProperty("name","templeton.hive.properties")).to.deep.eql(dynamicProperty);
  608. }
  609. });
  610. });
  611. });
  612. describe("#loadUiSideConfigs", function () {
  613. var t = {
  614. configMapping: [
  615. {
  616. foreignKey: null,
  617. templateName: "",
  618. value: "default",
  619. name: "name1",
  620. filename: "filename1"
  621. },
  622. {
  623. foreignKey: "notNull",
  624. templateName: "",
  625. value: "default2",
  626. name: "name2",
  627. filename: "filename2"
  628. }
  629. ],
  630. configMappingf: [
  631. {
  632. foreignKey: null,
  633. templateName: "",
  634. value: "default",
  635. name: "name1",
  636. filename: "filename1"
  637. }
  638. ],
  639. valueWithOverrides: {
  640. "value": "default",
  641. "overrides": {
  642. "value1": "value1",
  643. "value2": "value2"
  644. }
  645. },
  646. uiConfigs: [
  647. {
  648. "id": "site property",
  649. "name": "name1",
  650. "value": "default",
  651. "filename": "filename1",
  652. "overrides": {
  653. "value1": "value1",
  654. "value2": "value2"
  655. }
  656. }
  657. ]
  658. };
  659. beforeEach(function(){
  660. sinon.stub(mainServiceInfoConfigsController, "addDynamicProperties", Em.K);
  661. sinon.stub(mainServiceInfoConfigsController, "getGlobConfigValueWithOverrides", function () {
  662. return t.valueWithOverrides
  663. });
  664. });
  665. afterEach(function(){
  666. mainServiceInfoConfigsController.addDynamicProperties.restore();
  667. mainServiceInfoConfigsController.getGlobConfigValueWithOverrides.restore();
  668. });
  669. it("load ui config", function() {
  670. expect(mainServiceInfoConfigsController.loadUiSideConfigs(t.configMapping)[0]).to.deep.equal(t.uiConfigs[0]);
  671. expect(mainServiceInfoConfigsController.addDynamicProperties.calledWith(t.configMappingf)).to.equal(true);
  672. expect(mainServiceInfoConfigsController.getGlobConfigValueWithOverrides.calledWith(t.configMapping[0].templateName, t.configMapping[0].value, t.configMapping[0].name)).to.equal(true);
  673. });
  674. });
  675. describe("#formatConfigValues", function () {
  676. var t = {
  677. configs: [
  678. Em.Object.create({ name: "p1", value: " v1 v1 ", displayType: "" }),
  679. Em.Object.create({ name: "p2", value: true, displayType: "" }),
  680. Em.Object.create({ name: "p3", value: " d1 ", displayType: "directory" }),
  681. Em.Object.create({ name: "p4", value: " d1 d2 d3 ", displayType: "directories" }),
  682. Em.Object.create({ name: "p5", value: " v1 ", displayType: "password" }),
  683. Em.Object.create({ name: "p6", value: " v ", displayType: "host" }),
  684. Em.Object.create({ name: "javax.jdo.option.ConnectionURL", value: " v1 ", displayType: "advanced" }),
  685. Em.Object.create({ name: "oozie.service.JPAService.jdbc.url", value: " v1 ", displayType: "advanced" })
  686. ],
  687. result: [
  688. Em.Object.create({ name: "p1", value: " v1 v1", displayType: "" }),
  689. Em.Object.create({ name: "p2", value: "true", displayType: "" }),
  690. Em.Object.create({ name: "p3", value: "d1", displayType: "directory" }),
  691. Em.Object.create({ name: "p4", value: "d1,d2,d3", displayType: "directories" }),
  692. Em.Object.create({ name: "p5", value: " v1 ", displayType: "password" }),
  693. Em.Object.create({ name: "p6", value: "v", displayType: "host" }),
  694. Em.Object.create({ name: "javax.jdo.option.ConnectionURL", value: " v1", displayType: "advanced" }),
  695. Em.Object.create({ name: "oozie.service.JPAService.jdbc.url", value: " v1", displayType: "advanced" })
  696. ]
  697. };
  698. it("format config values", function () {
  699. mainServiceInfoConfigsController.formatConfigValues(t.configs);
  700. expect(t.configs).to.deep.equal(t.result);
  701. });
  702. });
  703. describe("#putConfigGroupChanges", function() {
  704. var t = {
  705. data: {
  706. ConfigGroup: {
  707. id: "id"
  708. }
  709. },
  710. request: [{
  711. ConfigGroup: {
  712. id: "id"
  713. }
  714. }]
  715. };
  716. beforeEach(function() {
  717. sinon.spy($,"ajax");
  718. });
  719. afterEach(function() {
  720. $.ajax.restore();
  721. });
  722. it("updates configs groups", function() {
  723. mainServiceInfoConfigsController.putConfigGroupChanges(t.data);
  724. expect(JSON.parse($.ajax.args[0][0].data)).to.deep.equal(t.request);
  725. });
  726. });
  727. describe("#setEditability", function () {
  728. var tests = [
  729. {
  730. isAdmin: true,
  731. isHostsConfigsPage: false,
  732. defaultGroupSelected: true,
  733. isReconfigurable: true,
  734. isEditable: true,
  735. m: ""
  736. },
  737. {
  738. isAdmin: false,
  739. isHostsConfigsPage: false,
  740. defaultGroupSelected: true,
  741. isReconfigurable: true,
  742. isEditable: false,
  743. m: "(non admin)"
  744. },
  745. {
  746. isAdmin: true,
  747. isHostsConfigsPage: true,
  748. defaultGroupSelected: true,
  749. isReconfigurable: true,
  750. isEditable: false,
  751. m: "(isHostsConfigsPage)"
  752. },
  753. {
  754. isAdmin: true,
  755. isHostsConfigsPage: false,
  756. defaultGroupSelected: false,
  757. isReconfigurable: true,
  758. isEditable: false,
  759. m: "(defaultGroupSelected is false)"
  760. },
  761. {
  762. isAdmin: true,
  763. isHostsConfigsPage: false,
  764. defaultGroupSelected: true,
  765. isReconfigurable: false,
  766. isEditable: false,
  767. m: "(isReconfigurable is false)"
  768. }
  769. ];
  770. beforeEach(function(){
  771. this.mock = sinon.stub(App, 'isAccessible');
  772. });
  773. afterEach(function () {
  774. this.mock.restore();
  775. });
  776. tests.forEach(function(t) {
  777. it("set isEditable " + t.isEditable + t.m, function(){
  778. this.mock.returns(t.isAdmin);
  779. mainServiceInfoConfigsController.set("isHostsConfigsPage", t.isHostsConfigsPage);
  780. var serviceConfigProperty = Em.Object.create({
  781. isReconfigurable: t.isReconfigurable
  782. });
  783. mainServiceInfoConfigsController.setEditability(serviceConfigProperty, t.defaultGroupSelected);
  784. expect(serviceConfigProperty.get("isEditable")).to.equal(t.isEditable);
  785. });
  786. });
  787. });
  788. describe("#checkOverrideProperty", function () {
  789. var tests = [{
  790. overrideToAdd: {
  791. name: "name1",
  792. filename: "filename1"
  793. },
  794. componentConfig: {
  795. configs: [
  796. {
  797. name: "name1",
  798. filename: "filename2"
  799. },
  800. {
  801. name: "name1",
  802. filename: "filename1"
  803. }
  804. ]
  805. },
  806. add: true,
  807. m: "add property"
  808. },
  809. {
  810. overrideToAdd: {
  811. name: "name1"
  812. },
  813. componentConfig: {
  814. configs: [
  815. {
  816. name: "name2"
  817. }
  818. ]
  819. },
  820. add: false,
  821. m: "don't add property, different names"
  822. },
  823. {
  824. overrideToAdd: {
  825. name: "name1",
  826. filename: "filename1"
  827. },
  828. componentConfig: {
  829. configs: [
  830. {
  831. name: "name1",
  832. filename: "filename2"
  833. }
  834. ]
  835. },
  836. add: false,
  837. m: "don't add property, different filenames"
  838. },
  839. {
  840. overrideToAdd: null,
  841. componentConfig: {},
  842. add: false,
  843. m: "don't add property, overrideToAdd is null"
  844. }];
  845. beforeEach(function() {
  846. sinon.stub(mainServiceInfoConfigsController,"addOverrideProperty", Em.K)
  847. });
  848. afterEach(function() {
  849. mainServiceInfoConfigsController.addOverrideProperty.restore();
  850. });
  851. tests.forEach(function(t) {
  852. it(t.m, function() {
  853. mainServiceInfoConfigsController.set("overrideToAdd", t.overrideToAdd);
  854. mainServiceInfoConfigsController.checkOverrideProperty(t.componentConfig);
  855. if(t.add) {
  856. expect(mainServiceInfoConfigsController.addOverrideProperty.calledWith(t.overrideToAdd)).to.equal(true);
  857. expect(mainServiceInfoConfigsController.get("overrideToAdd")).to.equal(null);
  858. } else {
  859. expect(mainServiceInfoConfigsController.addOverrideProperty.calledOnce).to.equal(false);
  860. }
  861. });
  862. });
  863. });
  864. describe("#trackRequest()", function () {
  865. after(function(){
  866. mainServiceInfoConfigsController.set('requestInProgress', null);
  867. });
  868. it("should set requestInProgress", function () {
  869. mainServiceInfoConfigsController.trackRequest({'request': {}});
  870. expect(mainServiceInfoConfigsController.get('requestInProgress')).to.eql({'request': {}});
  871. });
  872. });
  873. describe("#setValuesForOverrides", function() {
  874. var tests = [
  875. {
  876. overrides: [
  877. {name: "override1"},
  878. {name: "override2"}
  879. ],
  880. _serviceConfigProperty: {},
  881. serviceConfigProperty: Em.Object.create({overrides: Em.A([])}),
  882. defaultGroupSelected: true
  883. }
  884. ];
  885. beforeEach(function() {
  886. sinon.stub(mainServiceInfoConfigsController, "createNewSCP", function(override) {return {name: override.name}})
  887. });
  888. afterEach(function() {
  889. mainServiceInfoConfigsController.createNewSCP.restore();
  890. });
  891. tests.forEach(function(t) {
  892. it("set values for overrides. use createNewSCP method to do this", function() {
  893. var serviceConfigProperty = t.serviceConfigProperty;
  894. mainServiceInfoConfigsController.setValuesForOverrides(t.overrides, serviceConfigProperty, t.serviceConfigProperty, t.defaultGroupSelected);
  895. expect(serviceConfigProperty.get("overrides")[0]).to.eql(t.overrides[0]);
  896. expect(serviceConfigProperty.get("overrides")[1]).to.eql(t.overrides[1]);
  897. });
  898. });
  899. });
  900. describe("#createConfigProperty", function() {
  901. var tests = [
  902. {
  903. _serviceConfigProperty: {
  904. overrides: {
  905. }
  906. },
  907. defaultGroupSelected: true,
  908. restartData: {},
  909. serviceConfigsData: {},
  910. serviceConfigProperty: {
  911. overrides: null,
  912. isOverridable: true
  913. }
  914. }];
  915. beforeEach(function() {
  916. sinon.stub(mainServiceInfoConfigsController, "setValuesForOverrides", Em.K);
  917. sinon.stub(mainServiceInfoConfigsController, "setEditability", Em.K);
  918. });
  919. afterEach(function() {
  920. mainServiceInfoConfigsController.setValuesForOverrides.restore();
  921. mainServiceInfoConfigsController.setEditability.restore();
  922. });
  923. tests.forEach(function(t) {
  924. it("create service config. run methods to correctly set object fileds", function() {
  925. var result = mainServiceInfoConfigsController.createConfigProperty(t._serviceConfigProperty, t.defaultGroupSelected, t.restartData, t.serviceConfigsData);
  926. expect(mainServiceInfoConfigsController.setValuesForOverrides.calledWith(t._serviceConfigProperty.overrides, t._serviceConfigProperty, t.serviceConfigProperty, t.defaultGroupSelected));
  927. expect(result.getProperties('overrides','isOverridable')).to.eql(t.serviceConfigProperty);
  928. });
  929. });
  930. });
  931. describe("#createNewSCP", function() {
  932. var tests = [
  933. {
  934. overrides: {
  935. value: "value",
  936. group: {
  937. value: "group1"
  938. }
  939. },
  940. _serviceConfigProperty: {},
  941. serviceConfigProperty: Em.Object.create({
  942. value: "parentSCP",
  943. supportsFinal: true
  944. }),
  945. defaultGroupSelected: true,
  946. newSCP: {
  947. value: "value",
  948. isOriginalSCP: false,
  949. parentSCP:Em.Object.create({
  950. value: "parentSCP",
  951. supportsFinal: true
  952. }),
  953. group: {
  954. value: "group1"
  955. },
  956. isEditable: false
  957. }
  958. }
  959. ];
  960. tests.forEach(function(t) {
  961. it("", function() {
  962. var newSCP = mainServiceInfoConfigsController.createNewSCP(t.overrides, t._serviceConfigProperty, t.serviceConfigProperty, t.defaultGroupSelected);
  963. expect(newSCP.getProperties("value", "isOriginalSCP", "parentSCP", "group", "isEditable")).to.eql(t.newSCP);
  964. });
  965. });
  966. });
  967. describe("#setCompareDefaultGroupConfig", function() {
  968. beforeEach(function() {
  969. sinon.stub(mainServiceInfoConfigsController, "getComparisonConfig").returns("compConfig");
  970. sinon.stub(mainServiceInfoConfigsController, "getMockComparisonConfig").returns("mockConfig");
  971. sinon.stub(mainServiceInfoConfigsController, "hasCompareDiffs").returns(true);
  972. });
  973. afterEach(function() {
  974. mainServiceInfoConfigsController.getComparisonConfig.restore();
  975. mainServiceInfoConfigsController.getMockComparisonConfig.restore();
  976. mainServiceInfoConfigsController.hasCompareDiffs.restore();
  977. });
  978. it("expect that setCompareDefaultGroupConfig will not run anything", function() {
  979. expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({}).compareConfigs.length).to.equal(0);
  980. });
  981. it("expect that setCompareDefaultGroupConfig will not run anything", function() {
  982. expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({},{}).compareConfigs.length).to.equal(0);
  983. });
  984. it("expect that serviceConfig.compareConfigs will be getMockComparisonConfig", function() {
  985. expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isUserProperty: true}, null)).to.eql({compareConfigs: ["mockConfig"], isUserProperty: true, isComparison: true, hasCompareDiffs: true});
  986. });
  987. it("expect that serviceConfig.compareConfigs will be getComparisonConfig", function() {
  988. expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isUserProperty: true}, {})).to.eql({compareConfigs: ["compConfig"], isUserProperty: true, isComparison: true, hasCompareDiffs: true});
  989. });
  990. it("expect that serviceConfig.compareConfigs will be getComparisonConfig", function() {
  991. expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isReconfigurable: true}, {})).to.eql({compareConfigs: ["compConfig"], isReconfigurable: true, isComparison: true, hasCompareDiffs: true});
  992. });
  993. it("expect that serviceConfig.compareConfigs will be getComparisonConfig", function() {
  994. expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isReconfigurable: true, isMock: true}, {})).to.eql({compareConfigs: ["compConfig"], isReconfigurable: true, isMock: true, isComparison: true, hasCompareDiffs: true});
  995. });
  996. });
  997. describe('#showSaveConfigsPopup', function () {
  998. var bodyView;
  999. describe('#bodyClass', function () {
  1000. beforeEach(function() {
  1001. sinon.stub(App.ajax, 'send', Em.K);
  1002. // default implementation
  1003. bodyView = mainServiceInfoConfigsController.showSaveConfigsPopup().get('bodyClass').create({
  1004. parentView: Em.View.create()
  1005. });
  1006. });
  1007. afterEach(function() {
  1008. App.ajax.send.restore();
  1009. });
  1010. describe('#componentsFilterSuccessCallback', function () {
  1011. it('check components with unknown state', function () {
  1012. bodyView = mainServiceInfoConfigsController.showSaveConfigsPopup('', true, '', {}, '', 'unknown', '').get('bodyClass').create({
  1013. parentView: Em.View.create()
  1014. });
  1015. bodyView.componentsFilterSuccessCallback({
  1016. items: [
  1017. {
  1018. ServiceComponentInfo: {
  1019. total_count: 4,
  1020. started_count: 2,
  1021. installed_count: 1,
  1022. component_name: 'c1'
  1023. },
  1024. host_components: [
  1025. {HostRoles: {host_name: 'h1'}}
  1026. ]
  1027. }
  1028. ]
  1029. });
  1030. var unknownHosts = bodyView.get('unknownHosts');
  1031. expect(unknownHosts.length).to.equal(1);
  1032. expect(unknownHosts[0]).to.eql({name: 'h1', components: 'C1'});
  1033. });
  1034. });
  1035. });
  1036. });
  1037. describe('#setHiveHostName', function () {
  1038. Em.A([
  1039. {
  1040. globals: [
  1041. Em.Object.create({name: 'hive_database', value: 'New MySQL Database'}),
  1042. Em.Object.create({name: 'hive_database_type', value: 'mysql'}),
  1043. Em.Object.create({name: 'hive_ambari_host', value: 'h1'}),
  1044. Em.Object.create({name: 'hive_hostname', value: 'h2'})
  1045. ],
  1046. 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'],
  1047. m: 'hive_database: New MySQL Database',
  1048. host: 'h2'
  1049. },
  1050. {
  1051. globals: [
  1052. Em.Object.create({name: 'hive_database', value: 'New PostgreSQL Database'}),
  1053. Em.Object.create({name: 'hive_database_type', value: 'mysql'}),
  1054. Em.Object.create({name: 'hive_ambari_host', value: 'h1'}),
  1055. Em.Object.create({name: 'hive_hostname', value: 'h2'})
  1056. ],
  1057. 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'],
  1058. m: 'hive_database: New PostgreSQL Database',
  1059. host: 'h2'
  1060. },
  1061. {
  1062. globals: [
  1063. Em.Object.create({name: 'hive_database', value: 'Existing MySQL Database'}),
  1064. Em.Object.create({name: 'hive_database_type', value: 'mysql'}),
  1065. Em.Object.create({name: 'hive_existing_mysql_host', value: 'h1'}),
  1066. Em.Object.create({name: 'hive_hostname', value: 'h2'})
  1067. ],
  1068. 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'],
  1069. m: 'hive_database: Existing MySQL Database',
  1070. host: 'h2'
  1071. },
  1072. {
  1073. globals: [
  1074. Em.Object.create({name: 'hive_database', value: 'Existing PostgreSQL Database'}),
  1075. Em.Object.create({name: 'hive_database_type', value: 'postgresql'}),
  1076. Em.Object.create({name: 'hive_existing_postgresql_host', value: 'h1'}),
  1077. Em.Object.create({name: 'hive_hostname', value: 'h2'})
  1078. ],
  1079. 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'],
  1080. m: 'hive_database: Existing PostgreSQL Database',
  1081. host: 'h2'
  1082. },
  1083. {
  1084. globals: [
  1085. Em.Object.create({name: 'hive_database', value: 'Existing Oracle Database'}),
  1086. Em.Object.create({name: 'hive_database_type', value: 'oracle'}),
  1087. Em.Object.create({name: 'hive_existing_oracle_host', value: 'h1'}),
  1088. Em.Object.create({name: 'hive_hostname', value: 'h2'})
  1089. ],
  1090. 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'],
  1091. m: 'hive_database: Existing Oracle Database',
  1092. host: 'h2'
  1093. },
  1094. {
  1095. globals: [
  1096. Em.Object.create({name: 'hive_database', value: 'Existing MSSQL Server database with SQL authentication'}),
  1097. Em.Object.create({name: 'hive_database_type', value: 'mssql'}),
  1098. Em.Object.create({name: 'hive_existing_mssql_server_host', value: 'h1'}),
  1099. Em.Object.create({name: 'hive_hostname', value: 'h2'})
  1100. ],
  1101. 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'],
  1102. m: 'hive_database: Existing MSSQL Server database with SQL authentication',
  1103. host: 'h2'
  1104. },
  1105. {
  1106. globals: [
  1107. Em.Object.create({name: 'hive_database', value: 'Existing MSSQL Server database with integrated authentication'}),
  1108. Em.Object.create({name: 'hive_database_type', value: 'mssql'}),
  1109. Em.Object.create({name: 'hive_existing_mssql_server_2_host', value: 'h1'}),
  1110. Em.Object.create({name: 'hive_hostname', value: 'h2'})
  1111. ],
  1112. 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'],
  1113. m: 'hive_database: Existing MSSQL Server database with integrated authentication',
  1114. host: 'h2'
  1115. }
  1116. ]).forEach(function (test) {
  1117. it(test.m, function () {
  1118. var configs = test.globals.slice();
  1119. test.removed.forEach(function (c) {
  1120. configs.pushObject(Em.Object.create({name: c}))
  1121. });
  1122. configs = mainServiceInfoConfigsController.setHiveHostName(configs);
  1123. test.removed.forEach(function (name) {
  1124. if (!Em.isNone(configs.findProperty('name', name))) console.log('!!!!', name);
  1125. expect(Em.isNone(configs.findProperty('name', name))).to.equal(true);
  1126. });
  1127. expect(configs.findProperty('name', 'hive_hostname').value).to.equal(test.host);
  1128. });
  1129. });
  1130. });
  1131. describe('#setOozieHostName', function () {
  1132. Em.A([
  1133. {
  1134. globals: [
  1135. Em.Object.create({name: 'oozie_database', value: 'New Derby Database'}),
  1136. Em.Object.create({name: 'oozie_ambari_host', value: 'h1'}),
  1137. Em.Object.create({name: 'oozie_hostname', value: 'h2'})
  1138. ],
  1139. 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'],
  1140. m: 'oozie_database: New Derby Database',
  1141. host: 'h2'
  1142. },
  1143. {
  1144. globals: [
  1145. Em.Object.create({name: 'oozie_database', value: 'New MySQL Database'}),
  1146. Em.Object.create({name: 'oozie_ambari_host', value: 'h1'}),
  1147. Em.Object.create({name: 'oozie_hostname', value: 'h2'})
  1148. ],
  1149. 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'],
  1150. m: 'oozie_database: New MySQL Database',
  1151. host: 'h1'
  1152. },
  1153. {
  1154. globals: [
  1155. Em.Object.create({name: 'oozie_database', value: 'Existing MySQL Database'}),
  1156. Em.Object.create({name: 'oozie_existing_mysql_host', value: 'h1'}),
  1157. Em.Object.create({name: 'oozie_hostname', value: 'h2'})
  1158. ],
  1159. 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'],
  1160. m: 'oozie_database: Existing MySQL Database',
  1161. host: 'h2'
  1162. },
  1163. {
  1164. globals: [
  1165. Em.Object.create({name: 'oozie_database', value: 'Existing PostgreSQL Database'}),
  1166. Em.Object.create({name: 'oozie_existing_postgresql_host', value: 'h1'}),
  1167. Em.Object.create({name: 'oozie_hostname', value: 'h2'})
  1168. ],
  1169. 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'],
  1170. m: 'oozie_database: Existing PostgreSQL Database',
  1171. host: 'h2'
  1172. },
  1173. {
  1174. globals: [
  1175. Em.Object.create({name: 'oozie_database', value: 'Existing Oracle Database'}),
  1176. Em.Object.create({name: 'oozie_existing_oracle_host', value: 'h1'}),
  1177. Em.Object.create({name: 'oozie_hostname', value: 'h2'})
  1178. ],
  1179. 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'],
  1180. m: 'oozie_database: Existing Oracle Database',
  1181. host: 'h2'
  1182. },
  1183. {
  1184. globals: [
  1185. Em.Object.create({name: 'oozie_database', value: 'Existing MSSQL Server database with SQL authentication'}),
  1186. Em.Object.create({name: 'oozie_existing_oracle_host', value: 'h1'}),
  1187. Em.Object.create({name: 'oozie_hostname', value: 'h2'})
  1188. ],
  1189. 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'],
  1190. m: 'oozie_database: Existing MSSQL Server database with SQL authentication',
  1191. host: 'h2'
  1192. },
  1193. {
  1194. globals: [
  1195. Em.Object.create({name: 'oozie_database', value: 'Existing MSSQL Server database with integrated authentication'}),
  1196. Em.Object.create({name: 'oozie_existing_oracle_host', value: 'h1'}),
  1197. Em.Object.create({name: 'oozie_hostname', value: 'h2'})
  1198. ],
  1199. 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'],
  1200. m: 'oozie_database: Existing MSSQL Server database with integrated authentication',
  1201. host: 'h2'
  1202. }
  1203. ]).forEach(function (test) {
  1204. it(test.m, function () {
  1205. var configs = test.globals.slice();
  1206. test.removed.forEach(function (c) {
  1207. if (!configs.findProperty('name', c)) {
  1208. configs.pushObject(Em.Object.create({name: c}))
  1209. }
  1210. });
  1211. configs = mainServiceInfoConfigsController.setOozieHostName(configs);
  1212. test.removed.forEach(function (name) {
  1213. expect(Em.isNone(configs.findProperty('name', name))).to.equal(true);
  1214. });
  1215. expect(configs.findProperty('name', 'oozie_hostname').value).to.equal(test.host);
  1216. });
  1217. });
  1218. });
  1219. });