stack_service_mapper_test.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with this
  4. * work for additional information regarding copyright ownership. The ASF
  5. * licenses this file to you under the Apache License, Version 2.0 (the
  6. * "License"); you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. * License for the specific language governing permissions and limitations under
  15. * the License.
  16. */
  17. var App = require('app');
  18. require('mappers/stack_service_mapper');
  19. describe('App.stackServiceMapper', function () {
  20. describe('#map', function () {
  21. var data = {
  22. "items": [
  23. {
  24. "StackServices" : {
  25. "comments" : "A high-throughput distributed messaging system",
  26. "custom_commands" : [ ],
  27. "display_name" : "Kafka",
  28. "required_services" : [
  29. "ZOOKEEPER"
  30. ],
  31. "service_check_supported" : true,
  32. "service_name" : "KAFKA",
  33. "service_version" : "0.8.1.2.2",
  34. "stack_name" : "HDP",
  35. "stack_version" : "2.2",
  36. "config_types" : {
  37. "kafka-broker" : {
  38. "supports" : {
  39. "adding_forbidden" : "false",
  40. "do_not_extend" : "false",
  41. "final" : "false"
  42. }
  43. },
  44. "kafka-env" : {
  45. "supports" : {
  46. "adding_forbidden" : "false",
  47. "do_not_extend" : "false",
  48. "final" : "false"
  49. }
  50. },
  51. "kafka-log4j" : {
  52. "supports" : {
  53. "adding_forbidden" : "false",
  54. "do_not_extend" : "false",
  55. "final" : "false"
  56. }
  57. }
  58. }
  59. },
  60. "components" : [
  61. {
  62. "StackServiceComponents" : {
  63. "cardinality" : "1+",
  64. "component_category" : "MASTER",
  65. "component_name" : "KAFKA_BROKER",
  66. "custom_commands" : [ ],
  67. "display_name" : "Kafka Broker",
  68. "is_client" : false,
  69. "is_master" : true,
  70. "service_name" : "KAFKA",
  71. "stack_name" : "HDP",
  72. "stack_version" : "2.2"
  73. },
  74. "dependencies" : [
  75. {
  76. "Dependencies" : {
  77. "component_name" : "ZOOKEEPER_SERVER",
  78. "dependent_component_name" : "KAFKA_BROKER",
  79. "dependent_service_name" : "KAFKA",
  80. "scope" : "cluster",
  81. "stack_name" : "HDP",
  82. "stack_version" : "2.2"
  83. }
  84. }
  85. ]
  86. }
  87. ],
  88. "artifacts" : [
  89. {
  90. "Artifacts" : {
  91. "artifact_name": "widget_descriptor"
  92. }
  93. }
  94. ]
  95. },
  96. {
  97. "StackServices" : {
  98. "service_name" : "ZOOKEEPER"
  99. },
  100. "components" : [ ],
  101. "artifacts" : [ ]
  102. },
  103. {
  104. "StackServices" : {
  105. "service_name" : "KERBEROS"
  106. },
  107. "components" : [ ],
  108. "artifacts" : [ ]
  109. },
  110. {
  111. "StackServices" : {
  112. "service_name" : "HDFS"
  113. },
  114. "components" : [ ],
  115. "artifacts" : [ ]
  116. },
  117. {
  118. "StackServices" : {
  119. "service_name" : "ACCUMULO"
  120. },
  121. "components" : [ ],
  122. "artifacts" : [ ]
  123. },
  124. {
  125. "StackServices" : {
  126. "service_name" : "HIVE"
  127. },
  128. "components" : [
  129. {
  130. "StackServiceComponents" : {
  131. "component_name" : "MYSQL_SERVER",
  132. "custom_commands" : [
  133. "CLEAN"
  134. ]
  135. },
  136. "dependencies" : [ ]
  137. }
  138. ],
  139. "artifacts" : [ ]
  140. }
  141. ]
  142. },
  143. sortedServiceNames = ["HDFS", "HIVE", "ZOOKEEPER", "KAFKA", "KERBEROS", "ACCUMULO"],
  144. serviceResult = {
  145. id: "KAFKA",
  146. serviceName: "KAFKA",
  147. displayName: "Kafka",
  148. configTypes: {
  149. "kafka-broker" : {
  150. "supports" : {
  151. "adding_forbidden" : "false",
  152. "do_not_extend" : "false",
  153. "final" : "false"
  154. }
  155. },
  156. "kafka-env" : {
  157. "supports" : {
  158. "adding_forbidden" : "false",
  159. "do_not_extend" : "false",
  160. "final" : "false"
  161. }
  162. },
  163. "kafka-log4j" : {
  164. "supports" : {
  165. "adding_forbidden" : "false",
  166. "do_not_extend" : "false",
  167. "final" : "false"
  168. }
  169. }
  170. },
  171. comments: "A high-throughput distributed messaging system",
  172. serviceVersion: "0.8.1.2.2",
  173. stackName: "HDP",
  174. isInstalled: false,
  175. isInstallable: true,
  176. isServiceWithWidgets: false,
  177. serviceCheckSupported: true,
  178. requiredServices: ["ZOOKEEPER"]
  179. },
  180. componentResult = {
  181. id: "KAFKA_BROKER",
  182. componentName: "KAFKA_BROKER",
  183. displayName: "Kafka Broker",
  184. cardinality: "1+",
  185. customCommands: [],
  186. serviceName: "KAFKA",
  187. componentCategory: "MASTER",
  188. isMaster: true,
  189. isClient: false,
  190. stackName: "HDP",
  191. stackVersion: "2.2",
  192. dependencies: [
  193. {
  194. componentName: "ZOOKEEPER_SERVER",
  195. scope : "cluster"
  196. }
  197. ]
  198. };
  199. beforeEach(function () {
  200. App.stackServiceMapper.clearStackModels();
  201. });
  202. it('should sort and map data about services with their components', function () {
  203. App.stackServiceMapper.map(data);
  204. var services = App.StackService.find(),
  205. components = App.StackServiceComponent.find(),
  206. kafkaService = services.findProperty('serviceName', 'KAFKA');
  207. expect(services.mapProperty('serviceName')).to.eql(sortedServiceNames);
  208. expect(kafkaService.get('serviceComponents.length')).to.equal(1);
  209. Em.keys(serviceResult).forEach(function (key) {
  210. expect(kafkaService.get(key)).to.eql(serviceResult[key]);
  211. });
  212. Em.keys(componentResult).forEach(function (key) {
  213. expect(kafkaService.get('serviceComponents').toArray()[0].get(key)).to.eql(componentResult[key]);
  214. });
  215. Em.keys(componentResult).forEach(function (key) {
  216. expect(components.findProperty('componentName', 'KAFKA_BROKER').get(key)).to.eql(componentResult[key]);
  217. });
  218. expect(services.findProperty('serviceName', 'KERBEROS').get('isInstallable')).to.be.false;
  219. expect(services.findProperty('serviceName', 'KERBEROS').get('isSelected')).to.be.false;
  220. expect(components.findProperty('componentName', 'MYSQL_SERVER').get('customCommands')).to.be.empty;
  221. });
  222. });
  223. });