config_test.js 53 KB

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