app_test.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. describe('#App', function() {
  20. describe('App.components', function() {
  21. it('slaves and masters should not intersect', function() {
  22. var intersected = App.get('components.slaves').filter(function(item){
  23. return App.get('components.masters').contains(item);
  24. });
  25. expect(intersected).to.eql([]);
  26. });
  27. it('decommissionAllowed', function() {
  28. expect(App.get('components.decommissionAllowed')).to.eql(["DATANODE", "TASKTRACKER", "NODEMANAGER", "HBASE_REGIONSERVER"]);
  29. });
  30. it('addableToHost', function() {
  31. expect(App.get('components.addableToHost')).to.eql(["DATANODE", "TASKTRACKER", "NODEMANAGER", "HBASE_REGIONSERVER", "HBASE_MASTER", "ZOOKEEPER_SERVER", "SUPERVISOR"]);
  32. });
  33. });
  34. describe('Disable/enable components', function() {
  35. var testableComponent = {
  36. service_name: 'YARN',
  37. component_name: 'APP_TIMELINE_SERVER'
  38. };
  39. var expectedInfo = {
  40. componentName: 'APP_TIMELINE_SERVER',
  41. properties: {
  42. global_properties: ['ats_host', 'apptimelineserver_heapsize'],
  43. site_properties: ['yarn.ahs.store.class', 'yarn.ats.store.class', 'yarn.ats.leveldb-timeline-store.path']
  44. },
  45. reviewConfigs: {
  46. component_name: 'APP_TIMELINE_SERVER'
  47. },
  48. configCategory: {
  49. name: 'AppTimelineServer'
  50. }
  51. };
  52. var globalProperties = require('data/HDP2/global_properties');
  53. var siteProperties = require('data/HDP2/site_properties');
  54. var serviceComponents = require('data/service_components');
  55. var reviewConfigs = require('data/review_configs');
  56. var disableResult;
  57. App.set('currentStackVersion', 'HDP-2.1.1');
  58. App.set('handleStackDependencyTest', true);
  59. describe('#disableComponent()', function() {
  60. disableResult = App.disableComponent(testableComponent);
  61. // copy
  62. var _globalProperties = $.extend({}, globalProperties);
  63. var _siteProperties = $.extend({}, siteProperties);
  64. var _serviceComponents = $.extend({}, serviceComponents);
  65. var _reviewConfigs = JSON.parse(JSON.stringify(reviewConfigs));
  66. describe('result validation', function() {
  67. it('component name should be "' + expectedInfo.componentName + '"', function() {
  68. expect(disableResult.get('componentName')).to.eql(expectedInfo.componentName);
  69. });
  70. it('config category name should be "' + expectedInfo.configCategory.name +'"', function() {
  71. expect(disableResult.get('configCategory.name')).to.eql(expectedInfo.configCategory.name);
  72. });
  73. for(var siteName in expectedInfo.properties) {
  74. (function(site) {
  75. expectedInfo.properties[site].forEach(function(property) {
  76. it(property + ' present in ' + site, function() {
  77. expect(disableResult.get('properties.' + site).mapProperty('name')).to.include(property);
  78. });
  79. }, this);
  80. })(siteName);
  81. }
  82. it('site and global properties should not be equal', function() {
  83. expect(disableResult.get('properties.global_properties')).to.not.include.members(disableResult.get('properties.site_properties'));
  84. });
  85. });
  86. describe('effect validation',function() {
  87. it('should remove component from service_components object', function() {
  88. expect(_serviceComponents.findProperty('component_name', testableComponent.component_name)).to.be.undefined;
  89. });
  90. it('should remove global properties of component', function() {
  91. expect(_globalProperties.configProperties.mapProperty('name')).to.not.include.members(expectedInfo.properties.global_properties);
  92. });
  93. it('should remove site properties of component', function() {
  94. expect(_siteProperties.configProperties.mapProperty('name')).to.not.include.members(expectedInfo.properties.site_properties);
  95. });
  96. it('should remove review config for component', function() {
  97. var reviewConfig = _reviewConfigs.findProperty('config_name', 'services')
  98. .config_value.findProperty('service_name', testableComponent.service_name)
  99. .service_components.mapProperty('component_name');
  100. expect(reviewConfig).to.not.include(expectedInfo.reviewConfigs.component_name);
  101. });
  102. });
  103. });
  104. describe('#enableComponent', function() {
  105. App.enableComponent(disableResult);
  106. it('should add component to service_components object', function() {
  107. expect(serviceComponents.findProperty('component_name', testableComponent.component_name)).to.exist;
  108. });
  109. it('should add global properties of component', function() {
  110. expect(globalProperties.configProperties.mapProperty('name')).to.include.members(expectedInfo.properties.global_properties);
  111. });
  112. it('should add site properties of component', function() {
  113. expect(siteProperties.configProperties.mapProperty('name')).to.include.members(expectedInfo.properties.site_properties);
  114. });
  115. it('should add review config for component', function() {
  116. var reviewConfig = reviewConfigs.findProperty('config_name', 'services')
  117. .config_value.findProperty('service_name', testableComponent.service_name)
  118. .get('service_components').mapProperty('component_name');
  119. expect(reviewConfig).to.include(expectedInfo.reviewConfigs.component_name);
  120. });
  121. });
  122. });
  123. });