yarn_test.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. var modelSetup = require('test/init_model_test');
  20. require('models/service/yarn');
  21. var yarnService,
  22. yarnServiceData = {
  23. id: 'yarn'
  24. },
  25. configs = [
  26. {
  27. properties: {
  28. 'yarn.timeline-service.webapp.address': '0.0.0.0:0000'
  29. },
  30. tag: 'version2',
  31. type: 'yarn-site'
  32. }
  33. ];
  34. describe('App.YARNService', function () {
  35. beforeEach(function () {
  36. yarnService = App.YARNService.createRecord(yarnServiceData);
  37. });
  38. afterEach(function () {
  39. modelSetup.deleteRecord(yarnService);
  40. });
  41. describe('#ahsWebPort', function () {
  42. afterEach(function () {
  43. App.db.setConfigs([]);
  44. });
  45. it('should be 8188 as default', function () {
  46. App.db.setConfigs([]);
  47. expect(yarnService.get('ahsWebPort')).to.equal('8188');
  48. });
  49. it('should get value from configs', function () {
  50. App.db.setConfigs(configs);
  51. expect(yarnService.get('ahsWebPort')).to.equal('0000');
  52. });
  53. });
  54. describe('#queueFormatted', function () {
  55. it('should return formatted string', function () {
  56. yarnService.set('queue', '{"root":{"default":{}}}');
  57. expect(yarnService.get('queueFormatted')).to.equal('default (/root)<br/>');
  58. });
  59. });
  60. describe('#queuesCount', function () {
  61. it('should be 1', function () {
  62. yarnService.set('queue', '{"root":{"default":{}}}');
  63. expect(yarnService.get('queuesCount')).to.equal(1);
  64. });
  65. });
  66. describe('#maxMemory', function () {
  67. it('should add availableMemory to allocatedMemory', function () {
  68. yarnService.set('allocatedMemory', 1024);
  69. yarnService.set('availableMemory', 2048);
  70. expect(yarnService.get('maxMemory')).to.equal(3072);
  71. });
  72. });
  73. describe('#allQueueNames', function () {
  74. it('should list all queue names as array', function () {
  75. yarnService.set('queue', '{"root":{"default":{}}}');
  76. expect(yarnService.get('allQueueNames')).to.eql(['root', 'root/default']);
  77. });
  78. });
  79. describe('#childQueueNames', function () {
  80. it('should list child queue names as array', function () {
  81. yarnService.set('queue', '{"root":{"default":{}}}');
  82. expect(yarnService.get('childQueueNames')).to.eql(['root/default']);
  83. });
  84. });
  85. /*
  86. describe('#nodeManagersCountLost', function () {
  87. nodeCountCases.forEach(function (item) {
  88. it('should be ' + item.nodeManagersCountLost, function () {
  89. setHostComponents();
  90. for (var prop in item.assets) {
  91. yarnService.set(prop, item.assets[prop]);
  92. };
  93. expect(yarnService.get('nodeManagersCountLost')).to.equal(item.nodeManagersCountLost);
  94. });
  95. });
  96. });
  97. */
  98. });