config_initializer_test.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972
  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('models/configs/objects/service_config_property');
  20. require('utils/configs/config_initializer');
  21. var serviceConfigProperty;
  22. describe('App.ConfigInitializer', function () {
  23. beforeEach(function () {
  24. serviceConfigProperty = App.ServiceConfigProperty.create();
  25. });
  26. describe('#setRecommendedValue', function () {
  27. it('should change the recommended value', function () {
  28. serviceConfigProperty.set('recommendedValue', 'value0');
  29. App.ConfigInitializer.setRecommendedValue(serviceConfigProperty, /\d/, '1');
  30. expect(serviceConfigProperty.get('recommendedValue')).to.equal('value1');
  31. });
  32. });
  33. describe('#initialValue', function () {
  34. var cases = {
  35. 'kafka.ganglia.metrics.host': [
  36. {
  37. message: 'kafka.ganglia.metrics.host property should have the value of ganglia hostname when ganglia is selected',
  38. localDB: {
  39. masterComponentHosts: [
  40. {
  41. component: 'GANGLIA_SERVER',
  42. hostName: 'c6401'
  43. }
  44. ]
  45. },
  46. expected: 'c6401'
  47. },
  48. {
  49. message: 'kafka.ganglia.metrics.host property should have the value "localhost" when ganglia is not selected',
  50. localDB: {
  51. masterComponentHosts: [
  52. {
  53. component: 'NAMENODE',
  54. hostName: 'c6401'
  55. }
  56. ]
  57. },
  58. expected: 'localhost'
  59. }
  60. ],
  61. 'hive_database': [
  62. {
  63. alwaysEnableManagedMySQLForHive: true,
  64. currentStateName: '',
  65. isManagedMySQLForHiveEnabled: false,
  66. receivedValue: 'New MySQL Database',
  67. value: 'New MySQL Database',
  68. options: [
  69. {
  70. displayName: 'New MySQL Database'
  71. }
  72. ],
  73. hidden: false
  74. },
  75. {
  76. alwaysEnableManagedMySQLForHive: false,
  77. currentStateName: 'configs',
  78. isManagedMySQLForHiveEnabled: false,
  79. receivedValue: 'New MySQL Database',
  80. value: 'New MySQL Database',
  81. options: [
  82. {
  83. displayName: 'New MySQL Database'
  84. }
  85. ],
  86. hidden: false
  87. },
  88. {
  89. alwaysEnableManagedMySQLForHive: false,
  90. currentStateName: '',
  91. isManagedMySQLForHiveEnabled: true,
  92. receivedValue: 'New MySQL Database',
  93. value: 'New MySQL Database',
  94. options: [
  95. {
  96. displayName: 'New MySQL Database'
  97. }
  98. ],
  99. hidden: false
  100. },
  101. {
  102. alwaysEnableManagedMySQLForHive: false,
  103. currentStateName: '',
  104. isManagedMySQLForHiveEnabled: false,
  105. receivedValue: 'New MySQL Database',
  106. value: 'Existing MySQL Database',
  107. options: [
  108. {
  109. displayName: 'New MySQL Database'
  110. }
  111. ],
  112. hidden: true
  113. },
  114. {
  115. alwaysEnableManagedMySQLForHive: false,
  116. currentStateName: '',
  117. isManagedMySQLForHiveEnabled: false,
  118. receivedValue: 'New PostgreSQL Database',
  119. value: 'New PostgreSQL Database',
  120. options: [
  121. {
  122. displayName: 'New MySQL Database'
  123. }
  124. ],
  125. hidden: true
  126. }
  127. ],
  128. 'hbase.zookeeper.quorum': [
  129. {
  130. filename: 'hbase-site.xml',
  131. value: 'host0,host1',
  132. recommendedValue: 'host0,host1',
  133. title: 'should set ZooKeeper Server hostnames'
  134. },
  135. {
  136. filename: 'ams-hbase-site.xml',
  137. value: 'localhost',
  138. recommendedValue: null,
  139. title: 'should ignore ZooKeeper Server hostnames'
  140. }
  141. ],
  142. 'hivemetastore_host': {
  143. localDB: {
  144. masterComponentHosts: [
  145. {
  146. component: 'HIVE_METASTORE',
  147. hostName: 'h0'
  148. },
  149. {
  150. component: 'HIVE_METASTORE',
  151. hostName: 'h1'
  152. }
  153. ]
  154. },
  155. value: ['h0', 'h1'],
  156. title: 'array that contains names of hosts with Hive Metastore'
  157. },
  158. 'hive_master_hosts': {
  159. localDB: {
  160. masterComponentHosts: [
  161. {
  162. component: 'HIVE_SERVER',
  163. hostName: 'h0'
  164. },
  165. {
  166. component: 'HIVE_METASTORE',
  167. hostName: 'h0'
  168. },
  169. {
  170. component: 'HIVE_METASTORE',
  171. hostName: 'h1'
  172. },
  173. {
  174. component: 'WEBHCAT_SERVER',
  175. hostName: 'h2'
  176. }
  177. ]
  178. },
  179. value: 'h0,h1',
  180. title: 'comma separated list of hosts with Hive Server and Metastore'
  181. },
  182. 'hive.metastore.uris': {
  183. localDB: {
  184. masterComponentHosts: [
  185. {
  186. component: 'HIVE_METASTORE',
  187. hostName: 'h0'
  188. },
  189. {
  190. component: 'HIVE_METASTORE',
  191. hostName: 'h1'
  192. }
  193. ]
  194. },
  195. dependencies: {
  196. 'hive.metastore.uris': 'thrift://localhost:9083'
  197. },
  198. filename: 'hive-site.xml',
  199. recommendedValue: 'thrift://localhost:9083',
  200. value: 'thrift://h0:9083,thrift://h1:9083',
  201. title: 'comma separated list of Metastore hosts with thrift prefix and port'
  202. },
  203. 'templeton.hive.properties': {
  204. localDB: {
  205. masterComponentHosts: [
  206. {
  207. component: 'HIVE_METASTORE',
  208. hostName: 'h0'
  209. },
  210. {
  211. component: 'HIVE_METASTORE',
  212. hostName: 'h1'
  213. }
  214. ]
  215. },
  216. dependencies: {
  217. 'hive.metastore.uris': 'thrift://localhost:9083'
  218. },
  219. recommendedValue: 'hive.metastore.local=false,hive.metastore.uris=thrift://localhost:9083,hive.metastore.sasl.enabled=false',
  220. value: 'hive.metastore.local=false,hive.metastore.uris=thrift://h0:9083\\,thrift://h1:9083,hive.metastore.sasl.enabled=false,hive.metastore.execute.setugi=true',
  221. title: 'should add relevant hive.metastore.uris value'
  222. },
  223. 'yarn.resourcemanager.zk-address': {
  224. localDB: {
  225. masterComponentHosts: [
  226. {
  227. component: 'ZOOKEEPER_SERVER',
  228. hostName: 'h0'
  229. },
  230. {
  231. component: 'ZOOKEEPER_SERVER',
  232. hostName: 'h1'
  233. }
  234. ]
  235. },
  236. dependencies: {
  237. clientPort: '2182'
  238. },
  239. recommendedValue: 'localhost:2181',
  240. value: 'h0:2182,h1:2182',
  241. title: 'should add ZK host and port dynamically'
  242. },
  243. 'knox_gateway_host': {
  244. localDB: {
  245. masterComponentHosts: [
  246. {
  247. component: 'KNOX_GATEWAY',
  248. hostName: 'h0'
  249. },
  250. {
  251. component: 'KNOX_GATEWAY',
  252. hostName: 'h1'
  253. }
  254. ]
  255. },
  256. value: ['h0', 'h1'],
  257. title: 'array that contains names of hosts with Knox Gateway'
  258. },
  259. 'atlas.rest.address': [
  260. {
  261. localDB: {
  262. masterComponentHosts: [
  263. {
  264. component: 'ZOOKEEPER_SERVER',
  265. hostName: 'h0'
  266. },
  267. {
  268. component: 'ZOOKEEPER_SERVER',
  269. hostName: 'h1'
  270. }
  271. ]
  272. },
  273. dependencies: {
  274. 'atlas.enableTLS': false,
  275. 'atlas.server.http.port': 21000,
  276. 'atlas.server.https.port': 21443
  277. },
  278. value: 'http://h0:21000,http://h1:21000',
  279. title: 'TLS is not enabled'
  280. },
  281. {
  282. localDB: {
  283. masterComponentHosts: [
  284. {
  285. component: 'ZOOKEEPER_SERVER',
  286. hostName: 'h0'
  287. },
  288. {
  289. component: 'ZOOKEEPER_SERVER',
  290. hostName: 'h1'
  291. }
  292. ]
  293. },
  294. dependencies: {
  295. 'atlas.enableTLS': true,
  296. 'atlas.server.http.port': 21000,
  297. 'atlas.server.https.port': 21443
  298. },
  299. value: 'https://h0:21443,https://h1:21443',
  300. title: 'TLS is enabled'
  301. }
  302. ]
  303. };
  304. cases['atlas.rest.address'].forEach(function (test) {
  305. it(test.title, function () {
  306. serviceConfigProperty.setProperties({
  307. name: 'atlas.rest.address',
  308. value: ''
  309. });
  310. App.ConfigInitializer.initialValue(serviceConfigProperty, test.localDB, test.dependencies);
  311. expect(serviceConfigProperty.get('value')).to.equal(test.value);
  312. expect(serviceConfigProperty.get('recommendedValue')).to.equal(test.value);
  313. });
  314. });
  315. cases['kafka.ganglia.metrics.host'].forEach(function (item) {
  316. it(item.message, function () {
  317. serviceConfigProperty.setProperties({
  318. name: 'kafka.ganglia.metrics.host',
  319. value: 'localhost'
  320. });
  321. App.ConfigInitializer.initialValue(serviceConfigProperty, item.localDB, []);
  322. expect(serviceConfigProperty.get('value')).to.equal(item.expected);
  323. });
  324. });
  325. describe('hive_database', function () {
  326. beforeEach(function () {
  327. this.stub = sinon.stub(App, 'get');
  328. });
  329. afterEach(function () {
  330. App.get.restore();
  331. });
  332. cases.hive_database.forEach(function (item) {
  333. var title = 'hive_database value should be set to {0}';
  334. describe(title.format(item.value), function () {
  335. beforeEach(function () {
  336. this.stub
  337. .withArgs('supports.alwaysEnableManagedMySQLForHive').returns(item.alwaysEnableManagedMySQLForHive)
  338. .withArgs('router.currentState.name').returns(item.currentStateName)
  339. .withArgs('isManagedMySQLForHiveEnabled').returns(item.isManagedMySQLForHiveEnabled);
  340. serviceConfigProperty.setProperties({
  341. name: 'hive_database',
  342. value: item.receivedValue,
  343. options: item.options
  344. });
  345. App.ConfigInitializer.initialValue(serviceConfigProperty, {}, []);
  346. });
  347. it('value is ' + item.value, function () {
  348. expect(serviceConfigProperty.get('value')).to.equal(item.value);
  349. });
  350. it('`New MySQL Database` is ' + (item.hidden ? '' : 'not') + ' hidden', function () {
  351. expect(serviceConfigProperty.get('options').findProperty('displayName', 'New MySQL Database').hidden).to.equal(item.hidden);
  352. });
  353. });
  354. });
  355. });
  356. cases['hbase.zookeeper.quorum'].forEach(function (item) {
  357. it(item.title, function () {
  358. serviceConfigProperty.setProperties({
  359. name: 'hbase.zookeeper.quorum',
  360. value: 'localhost',
  361. 'filename': item.filename
  362. });
  363. App.ConfigInitializer.initialValue(serviceConfigProperty, {
  364. masterComponentHosts: {
  365. filterProperty: function () {
  366. return {
  367. mapProperty: function () {
  368. return ['host0', 'host1'];
  369. }
  370. };
  371. }
  372. }
  373. }, []);
  374. expect(serviceConfigProperty.get('value')).to.equal(item.value);
  375. expect(serviceConfigProperty.get('recommendedValue')).to.equal(item.recommendedValue);
  376. });
  377. });
  378. it(cases.hive_master_hosts.title, function () {
  379. serviceConfigProperty.set('name', 'hive_master_hosts');
  380. App.ConfigInitializer.initialValue(serviceConfigProperty, cases.hive_master_hosts.localDB, []);
  381. expect(serviceConfigProperty.get('value')).to.equal(cases.hive_master_hosts.value);
  382. });
  383. it(cases['hive.metastore.uris'].title, function () {
  384. serviceConfigProperty.setProperties({
  385. name: 'hive.metastore.uris',
  386. recommendedValue: cases['hive.metastore.uris'].recommendedValue,
  387. filename: 'hive-site.xml'
  388. });
  389. App.ConfigInitializer.initialValue(serviceConfigProperty, cases['hive.metastore.uris'].localDB, {'hive.metastore.uris': cases['hive.metastore.uris'].recommendedValue});
  390. expect(serviceConfigProperty.get('value')).to.equal(cases['hive.metastore.uris'].value);
  391. expect(serviceConfigProperty.get('recommendedValue')).to.equal(cases['hive.metastore.uris'].value);
  392. });
  393. it(cases['templeton.hive.properties'].title, function () {
  394. serviceConfigProperty.setProperties({
  395. name: 'templeton.hive.properties',
  396. recommendedValue: cases['templeton.hive.properties'].recommendedValue,
  397. value: cases['templeton.hive.properties'].recommendedValue
  398. });
  399. App.ConfigInitializer.initialValue(serviceConfigProperty, cases['templeton.hive.properties'].localDB, {'hive.metastore.uris': cases['templeton.hive.properties'].recommendedValue});
  400. expect(serviceConfigProperty.get('value')).to.equal(cases['templeton.hive.properties'].value);
  401. expect(serviceConfigProperty.get('recommendedValue')).to.equal(cases['templeton.hive.properties'].value);
  402. });
  403. it(cases['yarn.resourcemanager.zk-address'].title, function () {
  404. serviceConfigProperty.setProperties({
  405. name: 'yarn.resourcemanager.zk-address',
  406. recommendedValue: cases['yarn.resourcemanager.zk-address'].recommendedValue
  407. });
  408. App.ConfigInitializer.initialValue(serviceConfigProperty, cases['yarn.resourcemanager.zk-address'].localDB, cases['yarn.resourcemanager.zk-address'].dependencies);
  409. expect(serviceConfigProperty.get('value')).to.equal(cases['yarn.resourcemanager.zk-address'].value);
  410. expect(serviceConfigProperty.get('recommendedValue')).to.equal(cases['yarn.resourcemanager.zk-address'].value);
  411. });
  412. function getLocalDBForSingleComponent(component) {
  413. return {
  414. masterComponentHosts: [
  415. {
  416. component: component,
  417. hostName: 'h1'
  418. },
  419. {
  420. component: 'FAKE_COMPONENT',
  421. hostName: 'FAKE_HOST'
  422. }
  423. ]
  424. };
  425. }
  426. function getLocalDBForMultipleComponents(component, count) {
  427. var ret = {
  428. masterComponentHosts: [{
  429. component: 'FAKE_COMPONENT',
  430. hostName: 'FAKE_HOST'
  431. }]
  432. };
  433. for (var i = 1; i <= count; i++) {
  434. ret.masterComponentHosts.push({
  435. component: component,
  436. hostName: 'h' + i
  437. })
  438. }
  439. return ret;
  440. }
  441. Em.A([
  442. {
  443. config: 'dfs.namenode.rpc-address',
  444. localDB: getLocalDBForSingleComponent('NAMENODE'),
  445. rValue: 'c6401.ambari.apache.org:8020',
  446. expectedValue: 'h1:8020'
  447. },
  448. {
  449. config: 'dfs.http.address',
  450. localDB: getLocalDBForSingleComponent('NAMENODE'),
  451. rValue: 'c6401.ambari.apache.org:8020',
  452. expectedValue: 'h1:8020'
  453. },
  454. {
  455. config: 'dfs.namenode.http-address',
  456. localDB: getLocalDBForSingleComponent('NAMENODE'),
  457. rValue: 'c6401.ambari.apache.org:8020',
  458. expectedValue: 'h1:8020'
  459. },
  460. {
  461. config: 'dfs.https.address',
  462. localDB: getLocalDBForSingleComponent('NAMENODE'),
  463. rValue: 'c6401.ambari.apache.org:8020',
  464. expectedValue: 'h1:8020'
  465. },
  466. {
  467. config: 'dfs.namenode.https-address',
  468. localDB: getLocalDBForSingleComponent('NAMENODE'),
  469. rValue: 'c6401.ambari.apache.org:8020',
  470. expectedValue: 'h1:8020'
  471. },
  472. {
  473. config: 'fs.default.name',
  474. localDB: getLocalDBForSingleComponent('NAMENODE'),
  475. rValue: 'hdfs://c6401.ambari.apache.org:8020',
  476. expectedValue: 'hdfs://h1:8020'
  477. },
  478. {
  479. config: 'fs.defaultFS',
  480. localDB: getLocalDBForSingleComponent('NAMENODE'),
  481. rValue: 'hdfs://c6401.ambari.apache.org:8020',
  482. expectedValue: 'hdfs://h1:8020'
  483. },
  484. {
  485. config: 'hbase.rootdir',
  486. localDB: getLocalDBForSingleComponent('NAMENODE'),
  487. rValue: 'hdfs://c6401.ambari.apache.org:8020',
  488. expectedValue: 'hdfs://h1:8020'
  489. },
  490. {
  491. config: 'instance.volumes',
  492. localDB: getLocalDBForSingleComponent('NAMENODE'),
  493. rValue: 'hdfs://c6401.ambari.apache.org:8020',
  494. expectedValue: 'hdfs://h1:8020'
  495. },
  496. {
  497. config: 'dfs.secondary.http.address',
  498. localDB: getLocalDBForSingleComponent('SECONDARY_NAMENODE'),
  499. rValue: 'c6401.ambari.apache.org:50090',
  500. expectedValue: 'h1:50090'
  501. },
  502. {
  503. config: 'dfs.namenode.secondary.http-address',
  504. localDB: getLocalDBForSingleComponent('SECONDARY_NAMENODE'),
  505. rValue: 'c6401.ambari.apache.org:50090',
  506. expectedValue: 'h1:50090'
  507. },
  508. {
  509. config: 'yarn.log.server.url',
  510. localDB: getLocalDBForSingleComponent('HISTORYSERVER'),
  511. rValue: 'http://localhost:19888/jobhistory/logs',
  512. expectedValue: 'http://h1:19888/jobhistory/logs'
  513. },
  514. {
  515. config: 'mapreduce.jobhistory.webapp.address',
  516. localDB: getLocalDBForSingleComponent('HISTORYSERVER'),
  517. rValue: 'c6407.ambari.apache.org:19888',
  518. expectedValue: 'h1:19888'
  519. },
  520. {
  521. config: 'mapreduce.jobhistory.address',
  522. localDB: getLocalDBForSingleComponent('HISTORYSERVER'),
  523. rValue: 'c6407.ambari.apache.org:19888',
  524. expectedValue: 'h1:19888'
  525. },
  526. {
  527. config: 'yarn.resourcemanager.hostname',
  528. localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
  529. rValue: 'c6407.ambari.apache.org',
  530. expectedValue: 'h1'
  531. },
  532. {
  533. config: 'yarn.resourcemanager.resource-tracker.address',
  534. localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
  535. rValue: 'c6407.ambari.apache.org:123',
  536. expectedValue: 'h1:123'
  537. },
  538. {
  539. config: 'yarn.resourcemanager.webapp.https.address',
  540. localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
  541. rValue: 'c6407.ambari.apache.org:123',
  542. expectedValue: 'h1:123'
  543. },
  544. {
  545. config: 'yarn.resourcemanager.webapp.address',
  546. localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
  547. rValue: 'c6407.ambari.apache.org:123',
  548. expectedValue: 'h1:123'
  549. },
  550. {
  551. config: 'yarn.resourcemanager.scheduler.address',
  552. localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
  553. rValue: 'c6407.ambari.apache.org:123',
  554. expectedValue: 'h1:123'
  555. },
  556. {
  557. config: 'yarn.resourcemanager.address',
  558. localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
  559. rValue: 'c6407.ambari.apache.org:123',
  560. expectedValue: 'h1:123'
  561. },
  562. {
  563. config: 'yarn.resourcemanager.admin.address',
  564. localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
  565. rValue: 'c6407.ambari.apache.org:123',
  566. expectedValue: 'h1:123'
  567. },
  568. {
  569. config: 'yarn.timeline-service.webapp.address',
  570. localDB: getLocalDBForSingleComponent('APP_TIMELINE_SERVER'),
  571. rValue: 'c6407.ambari.apache.org:432',
  572. expectedValue: 'h1:432'
  573. },
  574. {
  575. config: 'yarn.timeline-service.address',
  576. localDB: getLocalDBForSingleComponent('APP_TIMELINE_SERVER'),
  577. rValue: 'c6407.ambari.apache.org:432',
  578. expectedValue: 'h1:432'
  579. },
  580. {
  581. config: 'yarn.timeline-service.webapp.https.address',
  582. localDB: getLocalDBForSingleComponent('APP_TIMELINE_SERVER'),
  583. rValue: 'c6407.ambari.apache.org:432',
  584. expectedValue: 'h1:432'
  585. },
  586. {
  587. config: 'mapred.job.tracker',
  588. localDB: getLocalDBForSingleComponent('JOBTRACKER'),
  589. rValue: 'c6407.ambari.apache.org:111',
  590. expectedValue: 'h1:111'
  591. },
  592. {
  593. config: 'mapred.job.tracker.http.address',
  594. localDB: getLocalDBForSingleComponent('JOBTRACKER'),
  595. rValue: 'c6407.ambari.apache.org:111',
  596. expectedValue: 'h1:111'
  597. },
  598. {
  599. config: 'mapreduce.history.server.http.address',
  600. localDB: getLocalDBForSingleComponent('HISTORYSERVER'),
  601. rValue: 'c6407.ambari.apache.org:555',
  602. expectedValue: 'h1:555'
  603. },
  604. {
  605. config: 'oozie.base.url',
  606. localDB: getLocalDBForSingleComponent('OOZIE_SERVER'),
  607. rValue: 'http://localhost:11000/oozie',
  608. expectedValue: 'http://h1:11000/oozie'
  609. },
  610. {
  611. config: 'nimbus.host',
  612. localDB: getLocalDBForSingleComponent('NIMBUS'),
  613. rValue: 'localhost',
  614. expectedValue: 'h1'
  615. },
  616. {
  617. config: '*.broker.url',
  618. localDB: getLocalDBForSingleComponent('FALCON_SERVER'),
  619. rValue: 'tcp://localhost:61616',
  620. expectedValue: 'tcp://h1:61616'
  621. },
  622. {
  623. config: 'storm.zookeeper.servers',
  624. localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
  625. rValue: "['c6401.ambari.apache.org','c6402.ambari.apache.org']",
  626. expectedValue: ['h1', 'h2', 'h3']
  627. },
  628. {
  629. config: 'nimbus.seeds',
  630. localDB: getLocalDBForMultipleComponents('NIMBUS', 3),
  631. rValue: "['c6401.ambari.apache.org','c6402.ambari.apache.org']",
  632. expectedValue: ['h1', 'h2', 'h3']
  633. },
  634. {
  635. config: 'hawq_master_address_host',
  636. localDB: getLocalDBForSingleComponent('HAWQMASTER'),
  637. rValue: 'localhost',
  638. expectedValue: 'h1'
  639. },
  640. {
  641. config: 'hawq_standby_address_host',
  642. localDB: getLocalDBForSingleComponent('HAWQSTANDBY'),
  643. rValue: 'localhost',
  644. expectedValue: 'h1'
  645. },
  646. {
  647. config: 'hawq_dfs_url',
  648. localDB: getLocalDBForSingleComponent('NAMENODE'),
  649. rValue: 'localhost:8020/hawq_data',
  650. expectedValue: 'h1:8020/hawq_data'
  651. },
  652. {
  653. config: 'hawq_rm_yarn_address',
  654. localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
  655. rValue: 'localhost:8032',
  656. expectedValue: 'h1:8032'
  657. },
  658. {
  659. config: 'hawq_rm_yarn_scheduler_address',
  660. localDB: getLocalDBForSingleComponent('RESOURCEMANAGER'),
  661. rValue: 'localhost:8030',
  662. expectedValue: 'h1:8030'
  663. },
  664. {
  665. config: 'hadoop_host',
  666. localDB: getLocalDBForSingleComponent('NAMENODE'),
  667. rValue: 'localhost',
  668. expectedValue: 'h1'
  669. },
  670. {
  671. config: 'hive_master_hosts',
  672. localDB: getLocalDBForMultipleComponents('HIVE_METASTORE', 3),
  673. rValue: '',
  674. expectedValue: 'h1,h2,h3'
  675. },
  676. {
  677. config: 'hive_master_hosts',
  678. localDB: getLocalDBForMultipleComponents('HIVE_SERVER', 3),
  679. rValue: '',
  680. expectedValue: 'h1,h2,h3'
  681. },
  682. {
  683. config: 'zookeeper.connect',
  684. localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
  685. rValue: 'localhost:2181',
  686. expectedValue: 'h1:2181,h2:2181,h3:2181'
  687. },
  688. {
  689. config: 'hive.zookeeper.quorum',
  690. localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
  691. rValue: 'localhost:2181',
  692. expectedValue: 'h1:2181,h2:2181,h3:2181'
  693. },
  694. {
  695. config: 'templeton.zookeeper.hosts',
  696. localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
  697. rValue: 'localhost:2181',
  698. expectedValue: 'h1:2181,h2:2181,h3:2181'
  699. },
  700. {
  701. config: 'hadoop.registry.zk.quorum',
  702. localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
  703. rValue: 'localhost:2181',
  704. expectedValue: 'h1:2181,h2:2181,h3:2181'
  705. },
  706. {
  707. config: 'hive.cluster.delegation.token.store.zookeeper.connectString',
  708. localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
  709. rValue: 'localhost:2181',
  710. expectedValue: 'h1:2181,h2:2181,h3:2181'
  711. },
  712. {
  713. config: 'instance.zookeeper.host',
  714. localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
  715. rValue: 'localhost:2181',
  716. expectedValue: 'h1:2181,h2:2181,h3:2181'
  717. },
  718. {
  719. config: 'templeton.hive.properties',
  720. localDB: getLocalDBForMultipleComponents('HIVE_METASTORE', 2),
  721. rValue: 'hive.metastore.local=false,hive.metastore.uris=thrift://localhost:9933,hive.metastore.sasl.enabled=false',
  722. dependencies: {
  723. 'hive.metastore.uris': 'thrift://localhost:9083'
  724. },
  725. expectedValue: 'hive.metastore.local=false,hive.metastore.uris=thrift://h1:9083\\,thrift://h2:9083,hive.metastore.sasl.enabled=false'
  726. },
  727. {
  728. config: 'hbase.zookeeper.quorum',
  729. m: 'hbase.zookeeper.quorum hbase-site.xml',
  730. localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
  731. rValue: 'c6401.ambari.apache.org,c6402.ambari.apache.org',
  732. expectedValue: 'h1,h2,h3',
  733. filename: 'hbase-site.xml'
  734. },
  735. {
  736. config: 'hbase.zookeeper.quorum',
  737. m: 'hbase.zookeeper.quorum not-hbase-site.xml',
  738. localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
  739. rValue: 'localhost',
  740. expectedValue: '',
  741. expectedRValue: 'localhost',
  742. filename: 'not-hbase-site.xml'
  743. },
  744. {
  745. config: 'yarn.resourcemanager.zk-address',
  746. localDB: getLocalDBForMultipleComponents('ZOOKEEPER_SERVER', 3),
  747. rValue: 'localhost:2181',
  748. dependencies: {
  749. 'clientPort': '3333'
  750. },
  751. expectedValue: 'h1:3333,h2:3333,h3:3333'
  752. },
  753. {
  754. config: 'RANGER_HOST',
  755. localDB: getLocalDBForSingleComponent('RANGER_ADMIN'),
  756. rValue: 'locahost',
  757. expectedValue: 'h1'
  758. },
  759. {
  760. config: 'hive.metastore.uris',
  761. filename: 'hive-site.xml',
  762. localDB: getLocalDBForMultipleComponents('HIVE_METASTORE', 2),
  763. dependencies: {
  764. 'hive.metastore.uris': 'thrift://localhost:9083'
  765. },
  766. rValue: 'thrift://localhost:9083',
  767. expectedValue: 'thrift://h1:9083,thrift://h2:9083'
  768. }
  769. ]).forEach(function (test) {
  770. describe(test.m || test.config, function () {
  771. beforeEach(function () {
  772. serviceConfigProperty.setProperties({
  773. name: test.config,
  774. recommendedValue: test.rValue,
  775. filename: test.filename
  776. });
  777. App.ConfigInitializer.initialValue(serviceConfigProperty, test.localDB, test.dependencies);
  778. });
  779. it('value is ' + test.expectedValue, function () {
  780. expect(serviceConfigProperty.get('value')).to.eql(test.expectedValue);
  781. });
  782. if (Em.isNone(test.expectedRValue)) {
  783. it('recommendedValue is ' + test.expectedValue, function () {
  784. expect(serviceConfigProperty.get('recommendedValue')).to.eql(test.expectedValue);
  785. });
  786. }
  787. else {
  788. it('recommendedValue is ' + test.expectedRValue, function () {
  789. expect(serviceConfigProperty.get('recommendedValue')).to.eql(test.expectedRValue);
  790. });
  791. }
  792. });
  793. });
  794. });
  795. describe('#getHiveMetastoreUris', function () {
  796. var cases = [
  797. {
  798. hosts: [
  799. {
  800. hostName: 'h0',
  801. component: 'HIVE_SERVER'
  802. },
  803. {
  804. hostName: 'h1',
  805. component: 'HIVE_METASTORE'
  806. },
  807. {
  808. hostName: 'h2',
  809. component: 'HIVE_METASTORE'
  810. }
  811. ],
  812. recommendedValue: 'thrift://localhost:9083',
  813. expected: 'thrift://h1:9083,thrift://h2:9083',
  814. title: 'typical case'
  815. },
  816. {
  817. hosts: [
  818. {
  819. hostName: 'h0',
  820. component: 'HIVE_SERVER'
  821. }
  822. ],
  823. recommendedValue: 'thrift://localhost:9083',
  824. expected: '',
  825. title: 'no Metastore hosts in DB'
  826. },
  827. {
  828. hosts: [
  829. {
  830. hostName: 'h0',
  831. component: 'HIVE_SERVER'
  832. },
  833. {
  834. hostName: 'h1',
  835. component: 'HIVE_METASTORE'
  836. },
  837. {
  838. hostName: 'h2',
  839. component: 'HIVE_METASTORE'
  840. }
  841. ],
  842. recommendedValue: '',
  843. expected: '',
  844. title: 'default value without port'
  845. },
  846. {
  847. hosts: [
  848. {
  849. hostName: 'h0',
  850. component: 'HIVE_SERVER'
  851. },
  852. {
  853. hostName: 'h1',
  854. component: 'HIVE_METASTORE'
  855. },
  856. {
  857. hostName: 'h2',
  858. component: 'HIVE_METASTORE'
  859. }
  860. ],
  861. expected: '',
  862. title: 'no default value specified'
  863. }
  864. ];
  865. cases.forEach(function (item) {
  866. it(item.title, function () {
  867. expect(App.ConfigInitializer.getHiveMetastoreUris(item.hosts, item.recommendedValue)).to.equal(item.expected);
  868. });
  869. });
  870. });
  871. describe('initializerTypes', function () {
  872. var types = App.ConfigInitializer.get('initializerTypes');
  873. Em.keys(types).forEach(function(type) {
  874. it(type, function() {
  875. var methodName = types[type].method;
  876. expect(methodName).to.be.a.string;
  877. expect(methodName).to.have.length.above(0);
  878. expect(App.ConfigInitializer[methodName]).to.be.a.function;
  879. });
  880. });
  881. });
  882. describe('initializers', function () {
  883. var initializers = App.ConfigInitializer.get('initializers');
  884. var types = App.ConfigInitializer.get('initializerTypes');
  885. var typeNames = types.mapProperty('name');
  886. Em.keys(initializers).forEach(function (configName) {
  887. it(configName, function () {
  888. var type = initializers[configName].type;
  889. expect(typeNames).to.contain(type);
  890. });
  891. });
  892. });
  893. describe('uniqueInitializers', function () {
  894. var uniqueInitializers = App.ConfigInitializer.get('uniqueInitializers');
  895. var uniqueInitializersNames = Em.keys(uniqueInitializers).map(function (key) {
  896. return uniqueInitializers[key];
  897. });
  898. it('should contains only unique methods', function () {
  899. expect(uniqueInitializersNames.length).to.equal(uniqueInitializersNames.uniq().length);
  900. });
  901. uniqueInitializersNames.forEach(function (name) {
  902. it(name, function () {
  903. expect(App.ConfigInitializer[name]).to.be.a.function;
  904. });
  905. });
  906. });
  907. describe('winReplacersMap', function () {
  908. var winReplacersMap = App.ConfigInitializer.get('winReplacersMap');
  909. var winReplacerNames = Em.keys(winReplacersMap).map(function (key) {
  910. return winReplacersMap[key];
  911. });
  912. it('should contains only unique methods', function () {
  913. expect(winReplacerNames.length).to.equal(winReplacerNames.uniq().length);
  914. });
  915. winReplacerNames.forEach(function (name) {
  916. it(name, function () {
  917. expect(App.ConfigInitializer[name]).to.be.a.function;
  918. });
  919. });
  920. });
  921. });