service_config_test.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865
  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/service_config');
  20. var serviceConfig,
  21. serviceConfigCategory,
  22. group,
  23. serviceConfigProperty,
  24. serviceConfigPropertyInit,
  25. configsData = [
  26. Ember.Object.create({
  27. overrides: [
  28. {
  29. error: true,
  30. errorMessage: 'error'
  31. },
  32. {
  33. error: true
  34. },
  35. {}
  36. ]
  37. }),
  38. Ember.Object.create({
  39. isValid: false,
  40. isVisible: true
  41. }),
  42. Ember.Object.create({
  43. isValid: true,
  44. isVisible: true
  45. }),
  46. Ember.Object.create({
  47. isValid: false,
  48. isVisible: false
  49. })
  50. ],
  51. configCategoriesData = [
  52. Em.Object.create({
  53. slaveErrorCount: 1
  54. }),
  55. Em.Object.create({
  56. slaveErrorCount: 2
  57. })
  58. ],
  59. nameCases = [
  60. {
  61. name: 'DataNode',
  62. primary: 'DATANODE'
  63. },
  64. {
  65. name: 'TaskTracker',
  66. primary: 'TASKTRACKER'
  67. },
  68. {
  69. name: 'RegionServer',
  70. primary: 'HBASE_REGIONSERVER'
  71. },
  72. {
  73. name: 'name',
  74. primary: null
  75. }
  76. ],
  77. components = [
  78. {
  79. name: 'NameNode',
  80. master: true
  81. },
  82. {
  83. name: 'SNameNode',
  84. master: true
  85. },
  86. {
  87. name: 'JobTracker',
  88. master: true
  89. },
  90. {
  91. name: 'HBase Master',
  92. master: true
  93. },
  94. {
  95. name: 'Oozie Master',
  96. master: true
  97. },
  98. {
  99. name: 'Hive Metastore',
  100. master: true
  101. },
  102. {
  103. name: 'WebHCat Server',
  104. master: true
  105. },
  106. {
  107. name: 'ZooKeeper Server',
  108. master: true
  109. },
  110. {
  111. name: 'Nagios',
  112. master: true
  113. },
  114. {
  115. name: 'Ganglia',
  116. master: true
  117. },
  118. {
  119. name: 'DataNode',
  120. slave: true
  121. },
  122. {
  123. name: 'TaskTracker',
  124. slave: true
  125. },
  126. {
  127. name: 'RegionServer',
  128. slave: true
  129. }
  130. ],
  131. masters = components.filterProperty('master'),
  132. slaves = components.filterProperty('slave'),
  133. groupsData = {
  134. groups: [
  135. Em.Object.create({
  136. errorCount: 1
  137. }),
  138. Em.Object.create({
  139. errorCount: 2
  140. })
  141. ]
  142. },
  143. groupNoErrorsData = [].concat(configsData.slice(2)),
  144. groupErrorsData = [configsData[1]],
  145. overridableFalseData = [
  146. {
  147. isOverridable: false
  148. },
  149. {
  150. isEditable: false,
  151. overrides: configsData[0].overrides
  152. },
  153. {
  154. displayType: 'masterHost'
  155. }
  156. ],
  157. overridableTrueData = [
  158. {
  159. isOverridable: true,
  160. isEditable: true
  161. }, {
  162. isOverridable: true,
  163. overrides: []
  164. },
  165. {
  166. isOverridable: true
  167. }
  168. ],
  169. overriddenFalseData = [
  170. {
  171. overrides: null,
  172. isOriginalSCP: true
  173. },
  174. {
  175. overrides: [],
  176. isOriginalSCP: true
  177. }
  178. ],
  179. overriddenTrueData = [
  180. {
  181. overrides: configsData[0].overrides
  182. },
  183. {
  184. isOriginalSCP: false
  185. }
  186. ],
  187. removableFalseData = [
  188. {
  189. isEditable: false
  190. },
  191. {
  192. hasOverrides: true
  193. },
  194. {
  195. isUserProperty: false,
  196. isOriginalSCP: true
  197. }
  198. ],
  199. removableTrueData = [
  200. {
  201. isEditable: true,
  202. hasOverrides: false,
  203. isUserProperty: true
  204. },
  205. {
  206. isEditable: true,
  207. hasOverrides: false,
  208. isOriginalSCP: false
  209. }
  210. ],
  211. initPropertyData = [
  212. {
  213. initial: {
  214. displayType: 'password',
  215. value: 'value'
  216. },
  217. result: {
  218. retypedPassword: 'value'
  219. }
  220. },
  221. {
  222. initial: {
  223. id: 'puppet var',
  224. value: '',
  225. defaultValue: 'default'
  226. },
  227. result: {
  228. value: 'default'
  229. }
  230. }
  231. ],
  232. notDefaultFalseData = [
  233. {
  234. isEditable: false
  235. },
  236. {
  237. defaultValue: null
  238. },
  239. {
  240. value: 'value',
  241. defaultValue: 'value'
  242. }
  243. ],
  244. notDefaultTrueData = {
  245. isEditable: true,
  246. value: 'value',
  247. defaultValue: 'default'
  248. },
  249. types = ['masterHost', 'slaveHosts', 'masterHosts', 'slaveHost', 'radio button'],
  250. classCases = [
  251. {
  252. initial: {
  253. displayType: 'checkbox'
  254. },
  255. viewClass: App.ServiceConfigCheckbox
  256. },
  257. {
  258. initial: {
  259. displayType: 'password'
  260. },
  261. viewClass: App.ServiceConfigPasswordField
  262. },
  263. {
  264. initial: {
  265. displayType: 'combobox'
  266. },
  267. viewClass: App.ServiceConfigComboBox
  268. },
  269. {
  270. initial: {
  271. displayType: 'radio button'
  272. },
  273. viewClass: App.ServiceConfigRadioButtons
  274. },
  275. {
  276. initial: {
  277. displayType: 'directories'
  278. },
  279. viewClass: App.ServiceConfigTextArea
  280. },
  281. {
  282. initial: {
  283. displayType: 'content'
  284. },
  285. viewClass: App.ServiceConfigTextAreaContent
  286. },
  287. {
  288. initial: {
  289. displayType: 'multiLine'
  290. },
  291. viewClass: App.ServiceConfigTextArea
  292. },
  293. {
  294. initial: {
  295. displayType: 'custom'
  296. },
  297. viewClass: App.ServiceConfigBigTextArea
  298. },
  299. {
  300. initial: {
  301. displayType: 'masterHost'
  302. },
  303. viewClass: App.ServiceConfigMasterHostView
  304. },
  305. {
  306. initial: {
  307. displayType: 'masterHosts'
  308. },
  309. viewClass: App.ServiceConfigMasterHostsView
  310. },
  311. {
  312. initial: {
  313. displayType: 'slaveHosts'
  314. },
  315. viewClass: App.ServiceConfigSlaveHostsView
  316. },
  317. {
  318. initial: {
  319. unit: true,
  320. displayType: 'type'
  321. },
  322. viewClass: App.ServiceConfigTextFieldWithUnit
  323. },
  324. {
  325. initial: {
  326. unit: false,
  327. displayType: 'type'
  328. },
  329. viewClass: App.ServiceConfigTextField
  330. }
  331. ];
  332. describe('App.ServiceConfig', function () {
  333. beforeEach(function () {
  334. serviceConfig = App.ServiceConfig.create();
  335. });
  336. describe('#errorCount', function () {
  337. it('should be 0', function () {
  338. serviceConfig.setProperties({
  339. configs: [],
  340. configCategories: []
  341. });
  342. expect(serviceConfig.get('errorCount')).to.equal(0);
  343. });
  344. it('should sum counts of all errors', function () {
  345. serviceConfig.setProperties({
  346. configs: configsData,
  347. configCategories: configCategoriesData
  348. });
  349. expect(serviceConfig.get('errorCount')).to.equal(6);
  350. });
  351. });
  352. });
  353. describe('App.ServiceConfigCategory', function () {
  354. beforeEach(function () {
  355. serviceConfigCategory = App.ServiceConfigCategory.create();
  356. });
  357. describe('#primaryName', function () {
  358. nameCases.forEach(function (item) {
  359. it('should return ' + item.primary, function () {
  360. serviceConfigCategory.set('name', item.name);
  361. expect(serviceConfigCategory.get('primaryName')).to.equal(item.primary);
  362. })
  363. });
  364. });
  365. describe('#isForMasterComponent', function () {
  366. masters.forEach(function (item) {
  367. it('should be true for ' + item.name, function () {
  368. serviceConfigCategory.set('name', item.name);
  369. expect(serviceConfigCategory.get('isForMasterComponent')).to.be.true;
  370. });
  371. });
  372. it('should be false', function () {
  373. serviceConfigCategory.set('name', 'name');
  374. expect(serviceConfigCategory.get('isForMasterComponent')).to.be.false;
  375. });
  376. });
  377. describe('#isForSlaveComponent', function () {
  378. slaves.forEach(function (item) {
  379. it('should be true for ' + item.name, function () {
  380. serviceConfigCategory.set('name', item.name);
  381. expect(serviceConfigCategory.get('isForSlaveComponent')).to.be.true;
  382. });
  383. });
  384. it('should be false', function () {
  385. serviceConfigCategory.set('name', 'name');
  386. expect(serviceConfigCategory.get('isForSlaveComponent')).to.be.false;
  387. });
  388. });
  389. describe('#slaveErrorCount', function () {
  390. it('should be 0', function () {
  391. serviceConfigCategory.set('slaveConfigs', []);
  392. expect(serviceConfigCategory.get('slaveErrorCount')).to.equal(0);
  393. });
  394. it('should sum all errorCount values', function () {
  395. serviceConfigCategory.set('slaveConfigs', groupsData);
  396. expect(serviceConfigCategory.get('slaveErrorCount')).to.equal(3);
  397. });
  398. });
  399. describe('#isAdvanced', function () {
  400. it('should be true', function () {
  401. serviceConfigCategory.set('name', 'Advanced');
  402. expect(serviceConfigCategory.get('isAdvanced')).to.be.true;
  403. });
  404. it('should be false', function () {
  405. serviceConfigCategory.set('name', 'name');
  406. expect(serviceConfigCategory.get('isAdvanced')).to.be.false;
  407. });
  408. });
  409. });
  410. describe('App.Group', function () {
  411. beforeEach(function () {
  412. group = App.Group.create();
  413. });
  414. describe('#errorCount', function () {
  415. it('should be 0', function () {
  416. group.set('properties', groupNoErrorsData);
  417. expect(group.get('errorCount')).to.equal(0);
  418. });
  419. it('should be 1', function () {
  420. group.set('properties', groupErrorsData);
  421. expect(group.get('errorCount')).to.equal(1);
  422. });
  423. });
  424. });
  425. describe('App.ServiceConfigProperty', function () {
  426. beforeEach(function () {
  427. serviceConfigProperty = App.ServiceConfigProperty.create();
  428. });
  429. describe('#overrideErrorTrigger', function () {
  430. it('should be an increment', function () {
  431. serviceConfigProperty.set('overrides', configsData[0].overrides);
  432. expect(serviceConfigProperty.get('overrideErrorTrigger')).to.equal(1);
  433. serviceConfigProperty.set('overrides', []);
  434. expect(serviceConfigProperty.get('overrideErrorTrigger')).to.equal(2);
  435. });
  436. });
  437. describe('#isPropertyOverridable', function () {
  438. overridableFalseData.forEach(function (item) {
  439. it('should be false', function () {
  440. Em.keys(item).forEach(function (prop) {
  441. serviceConfigProperty.set(prop, item[prop]);
  442. });
  443. expect(serviceConfigProperty.get('isPropertyOverridable')).to.be.false;
  444. });
  445. });
  446. overridableTrueData.forEach(function (item) {
  447. it('should be true', function () {
  448. Em.keys(item).forEach(function (prop) {
  449. serviceConfigProperty.set(prop, item[prop]);
  450. });
  451. expect(serviceConfigProperty.get('isPropertyOverridable')).to.be.true;
  452. });
  453. });
  454. });
  455. describe('#isOverridden', function () {
  456. overriddenFalseData.forEach(function (item) {
  457. it('should be false', function () {
  458. Em.keys(item).forEach(function (prop) {
  459. serviceConfigProperty.set(prop, item[prop]);
  460. });
  461. expect(serviceConfigProperty.get('isOverridden')).to.be.false;
  462. });
  463. });
  464. overriddenTrueData.forEach(function (item) {
  465. it('should be true', function () {
  466. Em.keys(item).forEach(function (prop) {
  467. serviceConfigProperty.set(prop, item[prop]);
  468. });
  469. expect(serviceConfigProperty.get('isOverridden')).to.be.true;
  470. });
  471. });
  472. });
  473. describe('#isRemovable', function () {
  474. removableFalseData.forEach(function (item) {
  475. it('should be false', function () {
  476. Em.keys(item).forEach(function (prop) {
  477. serviceConfigProperty.set(prop, item[prop]);
  478. });
  479. expect(serviceConfigProperty.get('isRemovable')).to.be.false;
  480. });
  481. });
  482. removableTrueData.forEach(function (item) {
  483. it('should be true', function () {
  484. Em.keys(item).forEach(function (prop) {
  485. serviceConfigProperty.set(prop, item[prop]);
  486. });
  487. expect(serviceConfigProperty.get('isRemovable')).to.be.true;
  488. });
  489. });
  490. });
  491. describe('#init', function () {
  492. initPropertyData.forEach(function (item) {
  493. it('should set initial data', function () {
  494. serviceConfigPropertyInit = App.ServiceConfigProperty.create(item.initial);
  495. Em.keys(item.result).forEach(function (prop) {
  496. expect(serviceConfigPropertyInit.get(prop)).to.equal(item.result[prop]);
  497. });
  498. });
  499. });
  500. });
  501. describe('#isNotDefaultValue', function () {
  502. notDefaultFalseData.forEach(function (item) {
  503. it('should be false', function () {
  504. Em.keys(item).forEach(function (prop) {
  505. serviceConfigProperty.set(prop, item[prop]);
  506. });
  507. expect(serviceConfigProperty.get('isNotDefaultValue')).to.be.false;
  508. });
  509. });
  510. it('should be true', function () {
  511. Em.keys(notDefaultTrueData).forEach(function (prop) {
  512. serviceConfigProperty.set(prop, notDefaultTrueData[prop]);
  513. });
  514. expect(serviceConfigProperty.get('isNotDefaultValue')).to.be.true;
  515. });
  516. });
  517. describe('#cantBeUndone', function () {
  518. types.forEach(function (item) {
  519. it('should be true', function () {
  520. serviceConfigProperty.set('displayType', item);
  521. expect(serviceConfigProperty.get('cantBeUndone')).to.be.true;
  522. });
  523. });
  524. it('should be false', function () {
  525. serviceConfigProperty.set('displayType', 'type');
  526. expect(serviceConfigProperty.get('cantBeUndone')).to.be.false;
  527. });
  528. });
  529. describe('#setDefaultValue', function () {
  530. it('should change the default value', function () {
  531. serviceConfigProperty.set('defaultValue', 'value0');
  532. serviceConfigProperty.setDefaultValue(/\d/, '1');
  533. expect(serviceConfigProperty.get('defaultValue')).to.equal('value1');
  534. });
  535. });
  536. describe('#isValid', function () {
  537. it('should be true', function () {
  538. serviceConfigProperty.set('errorMessage', '');
  539. expect(serviceConfigProperty.get('isValid')).to.be.true;
  540. });
  541. it('should be false', function () {
  542. serviceConfigProperty.set('errorMessage', 'message');
  543. expect(serviceConfigProperty.get('isValid')).to.be.false;
  544. });
  545. });
  546. describe('#viewClass', function () {
  547. classCases.forEach(function (item) {
  548. it ('should be ' + item.viewClass, function () {
  549. Em.keys(item.initial).forEach(function (prop) {
  550. serviceConfigProperty.set(prop, item.initial[prop]);
  551. });
  552. expect(serviceConfigProperty.get('viewClass')).to.eql(item.viewClass);
  553. });
  554. });
  555. });
  556. describe('#validate', function () {
  557. it('not required', function () {
  558. serviceConfigProperty.setProperties({
  559. isRequired: false,
  560. value: ''
  561. });
  562. expect(serviceConfigProperty.get('errorMessage')).to.be.empty;
  563. expect(serviceConfigProperty.get('error')).to.be.false;
  564. });
  565. it('should validate', function () {
  566. serviceConfigProperty.setProperties({
  567. isRequired: true,
  568. value: 'value'
  569. });
  570. expect(serviceConfigProperty.get('errorMessage')).to.be.empty;
  571. expect(serviceConfigProperty.get('error')).to.be.false;
  572. });
  573. it('should fail', function () {
  574. serviceConfigProperty.setProperties({
  575. isRequired: true,
  576. value: 'value'
  577. });
  578. serviceConfigProperty.set('value', '');
  579. expect(serviceConfigProperty.get('errorMessage')).to.equal('This is required');
  580. expect(serviceConfigProperty.get('error')).to.be.true;
  581. });
  582. });
  583. describe('#initialValue', function () {
  584. var cases = {
  585. 'kafka.ganglia.metrics.host': [
  586. {
  587. message: 'kafka.ganglia.metrics.host property should have the value of ganglia hostname when ganglia is selected',
  588. localDB: {
  589. masterComponentHosts: [
  590. {
  591. component: 'GANGLIA_SERVER',
  592. hostName: 'c6401'
  593. }
  594. ]
  595. },
  596. expected: 'c6401'
  597. },
  598. {
  599. message: 'kafka.ganglia.metrics.host property should have the value "localhost" when ganglia is not selected',
  600. localDB: {
  601. masterComponentHosts: [
  602. {
  603. component: 'NAMENODE',
  604. hostName: 'c6401'
  605. }
  606. ]
  607. },
  608. expected: 'localhost'
  609. }
  610. ],
  611. 'hive_database': [
  612. {
  613. alwaysEnableManagedMySQLForHive: true,
  614. currentStateName: '',
  615. isManagedMySQLForHiveEnabled: false,
  616. receivedValue: 'New MySQL Database',
  617. value: 'New MySQL Database',
  618. options: [
  619. {
  620. displayName: 'New MySQL Database'
  621. }
  622. ],
  623. hidden: false
  624. },
  625. {
  626. alwaysEnableManagedMySQLForHive: false,
  627. currentStateName: 'configs',
  628. isManagedMySQLForHiveEnabled: false,
  629. receivedValue: 'New MySQL Database',
  630. value: 'New MySQL Database',
  631. options: [
  632. {
  633. displayName: 'New MySQL Database'
  634. }
  635. ],
  636. hidden: false
  637. },
  638. {
  639. alwaysEnableManagedMySQLForHive: false,
  640. currentStateName: '',
  641. isManagedMySQLForHiveEnabled: true,
  642. receivedValue: 'New MySQL Database',
  643. value: 'New MySQL Database',
  644. options: [
  645. {
  646. displayName: 'New MySQL Database'
  647. }
  648. ],
  649. hidden: false
  650. },
  651. {
  652. alwaysEnableManagedMySQLForHive: false,
  653. currentStateName: '',
  654. isManagedMySQLForHiveEnabled: false,
  655. receivedValue: 'New MySQL Database',
  656. value: 'Existing MySQL Database',
  657. options: [
  658. {
  659. displayName: 'New MySQL Database'
  660. }
  661. ],
  662. hidden: true
  663. },
  664. {
  665. alwaysEnableManagedMySQLForHive: false,
  666. currentStateName: '',
  667. isManagedMySQLForHiveEnabled: false,
  668. receivedValue: 'New PostgreSQL Database',
  669. value: 'New PostgreSQL Database',
  670. options: [
  671. {
  672. displayName: 'New MySQL Database'
  673. }
  674. ],
  675. hidden: true
  676. }
  677. ],
  678. 'hbase.zookeeper.quorum': [
  679. {
  680. filename: 'hbase-site.xml',
  681. value: 'host0,host1',
  682. defaultValue: 'host0,host1',
  683. title: 'should set ZooKeeper Server hostnames'
  684. },
  685. {
  686. filename: 'ams-hbase-site.xml',
  687. value: 'localhost',
  688. defaultValue: '',
  689. title: 'should ignore ZooKeeper Server hostnames'
  690. }
  691. ],
  692. 'hbase.tmp.dir': [
  693. {
  694. filename: 'hbase-site.xml',
  695. isUnionAllMountPointsCalled: true,
  696. title: 'unionAllMountPoints should be called'
  697. },
  698. {
  699. filename: 'ams-hbase-site.xml',
  700. isUnionAllMountPointsCalled: false,
  701. title: 'unionAllMountPoints shouldn\'t be called'
  702. }
  703. ],
  704. 'hivemetastore_host': {
  705. localDB: {
  706. masterComponentHosts: [
  707. {
  708. component: 'HIVE_METASTORE',
  709. hostName: 'h0'
  710. },
  711. {
  712. component: 'HIVE_METASTORE',
  713. hostName: 'h1'
  714. }
  715. ]
  716. },
  717. value: ['h0', 'h1'],
  718. title: 'array that contains names of hosts with Hive Metastore'
  719. },
  720. 'hive_master_hosts': {
  721. localDB: {
  722. masterComponentHosts: [
  723. {
  724. component: 'HIVE_SERVER',
  725. hostName: 'h0'
  726. },
  727. {
  728. component: 'HIVE_METASTORE',
  729. hostName: 'h0'
  730. },
  731. {
  732. component: 'HIVE_METASTORE',
  733. hostName: 'h1'
  734. },
  735. {
  736. component: 'WEBHCAT_SERVER',
  737. hostName: 'h2'
  738. }
  739. ]
  740. },
  741. value: 'h0,h1',
  742. title: 'comma separated list of hosts with Hive Server and Metastore'
  743. }
  744. };
  745. cases['kafka.ganglia.metrics.host'].forEach(function(item){
  746. it(item.message, function () {
  747. serviceConfigProperty.setProperties({
  748. name: 'kafka.ganglia.metrics.host',
  749. value: 'localhost'
  750. });
  751. serviceConfigProperty.initialValue(item.localDB);
  752. expect(serviceConfigProperty.get('value')).to.equal(item.expected);
  753. });
  754. });
  755. cases['hive_database'].forEach(function (item) {
  756. var title = 'hive_database value should be set to {0}';
  757. it(title.format(item.value), function () {
  758. sinon.stub(App, 'get')
  759. .withArgs('supports.alwaysEnableManagedMySQLForHive').returns(item.alwaysEnableManagedMySQLForHive)
  760. .withArgs('router.currentState.name').returns(item.currentStateName)
  761. .withArgs('isManagedMySQLForHiveEnabled').returns(item.isManagedMySQLForHiveEnabled);
  762. serviceConfigProperty.setProperties({
  763. name: 'hive_database',
  764. value: item.receivedValue,
  765. options: item.options
  766. });
  767. serviceConfigProperty.initialValue({});
  768. expect(serviceConfigProperty.get('value')).to.equal(item.value);
  769. expect(serviceConfigProperty.get('options').findProperty('displayName', 'New MySQL Database').hidden).to.equal(item.hidden);
  770. App.get.restore();
  771. });
  772. });
  773. cases['hbase.zookeeper.quorum'].forEach(function (item) {
  774. it(item.title, function () {
  775. serviceConfigProperty.setProperties({
  776. name: 'hbase.zookeeper.quorum',
  777. value: 'localhost',
  778. 'filename': item.filename
  779. });
  780. serviceConfigProperty.initialValue({
  781. masterComponentHosts: {
  782. filterProperty: function () {
  783. return {
  784. mapProperty: function () {
  785. return ['host0', 'host1'];
  786. }
  787. };
  788. }
  789. }
  790. });
  791. expect(serviceConfigProperty.get('value')).to.equal(item.value);
  792. expect(serviceConfigProperty.get('defaultValue')).to.equal(item.defaultValue);
  793. });
  794. });
  795. cases['hbase.tmp.dir'].forEach(function (item) {
  796. var isOnlyFirstOneNeeded = true,
  797. localDB = {
  798. p: 'v'
  799. };
  800. it(item.title, function () {
  801. sinon.stub(serviceConfigProperty, 'unionAllMountPoints', Em.K);
  802. serviceConfigProperty.setProperties({
  803. name: 'hbase.tmp.dir',
  804. filename: item.filename
  805. });
  806. serviceConfigProperty.initialValue(localDB);
  807. expect(serviceConfigProperty.unionAllMountPoints.calledWith(isOnlyFirstOneNeeded, localDB)).to.equal(item.isUnionAllMountPointsCalled);
  808. serviceConfigProperty.unionAllMountPoints.restore();
  809. });
  810. });
  811. it(cases['hivemetastore_host'].title, function () {
  812. serviceConfigProperty.set('name', 'hivemetastore_host');
  813. serviceConfigProperty.initialValue(cases['hivemetastore_host'].localDB);
  814. expect(serviceConfigProperty.get('value')).to.eql(cases['hivemetastore_host'].value);
  815. });
  816. it(cases['hive_master_hosts'].title, function () {
  817. serviceConfigProperty.set('name', 'hive_master_hosts');
  818. serviceConfigProperty.initialValue(cases['hive_master_hosts'].localDB);
  819. expect(serviceConfigProperty.get('value')).to.equal(cases['hive_master_hosts'].value);
  820. });
  821. });
  822. });