app_test.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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('Disable/enable components', function() {
  21. var testableComponent = Ember.Object.create({
  22. componentName: 'APP_TIMELINE_SERVER',
  23. serviceName: 'YARN'
  24. });
  25. var expectedInfo = {
  26. componentName: 'APP_TIMELINE_SERVER',
  27. properties: {
  28. global_properties: ['ats_host', 'apptimelineserver_heapsize'],
  29. site_properties: ['yarn.timeline-service.generic-application-history.store-class', 'yarn.timeline-service.store-class', 'yarn.timeline-service.leveldb-timeline-store.path']
  30. },
  31. reviewConfigs: {
  32. component_name: 'APP_TIMELINE_SERVER'
  33. },
  34. configCategory: {
  35. name: 'AppTimelineServer'
  36. }
  37. };
  38. var globalProperties = require('data/HDP2/global_properties');
  39. var siteProperties = require('data/HDP2/site_properties');
  40. var reviewConfigs = require('data/review_configs');
  41. var disableResult;
  42. App.set('currentStackVersion', 'HDP-2.1');
  43. App.set('handleStackDependencyTest', true);
  44. describe('#disableComponent()', function() {
  45. disableResult = App.disableComponent(testableComponent);
  46. // copy
  47. var _globalProperties = $.extend({}, globalProperties);
  48. var _siteProperties = $.extend({}, siteProperties);
  49. var _reviewConfigs = JSON.parse(JSON.stringify(reviewConfigs));
  50. describe('result validation', function() {
  51. it('component name should be "' + expectedInfo.componentName + '"', function() {
  52. expect(disableResult.get('componentName')).to.eql(expectedInfo.componentName);
  53. });
  54. it('config category name should be "' + expectedInfo.configCategory.name +'"', function() {
  55. expect(disableResult.get('configCategory.name')).to.eql(expectedInfo.configCategory.name);
  56. });
  57. for(var siteName in expectedInfo.properties) {
  58. (function(site) {
  59. expectedInfo.properties[site].forEach(function(property) {
  60. it(property + ' present in ' + site, function() {
  61. expect(disableResult.get('properties.' + site).mapProperty('name')).to.include(property);
  62. });
  63. }, this);
  64. })(siteName);
  65. }
  66. it('site and global properties should not be equal', function() {
  67. expect(disableResult.get('properties.global_properties')).to.not.include.members(disableResult.get('properties.site_properties'));
  68. });
  69. });
  70. describe('effect validation',function() {
  71. it('should remove global properties of component', function() {
  72. expect(_globalProperties.configProperties.mapProperty('name')).to.not.include.members(expectedInfo.properties.global_properties);
  73. });
  74. it('should remove site properties of component', function() {
  75. expect(_siteProperties.configProperties.mapProperty('name')).to.not.include.members(expectedInfo.properties.site_properties);
  76. });
  77. it('should remove review config for component', function() {
  78. var reviewConfig = _reviewConfigs.findProperty('config_name', 'services')
  79. .config_value.findProperty('service_name', testableComponent.get('serviceName'))
  80. .service_components.mapProperty('component_name');
  81. expect(reviewConfig).to.not.include(expectedInfo.reviewConfigs.component_name);
  82. });
  83. });
  84. });
  85. describe('#enableComponent', function() {
  86. App.enableComponent(disableResult);
  87. it('should add global properties of component', function() {
  88. expect(globalProperties.configProperties.mapProperty('name')).to.include.members(expectedInfo.properties.global_properties);
  89. });
  90. it('should add site properties of component', function() {
  91. expect(siteProperties.configProperties.mapProperty('name')).to.include.members(expectedInfo.properties.site_properties);
  92. });
  93. it('should add review config for component', function() {
  94. var reviewConfig = reviewConfigs.findProperty('config_name', 'services')
  95. .config_value.findProperty('service_name', testableComponent.get('serviceName'))
  96. .get('service_components').mapProperty('component_name');
  97. expect(reviewConfig).to.include(expectedInfo.reviewConfigs.component_name);
  98. });
  99. });
  100. });
  101. });