stack_service_mapper_test.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. /*eslint-disable */
  18. var App = require('app');
  19. require('mappers/stack_service_mapper');
  20. describe('App.stackServiceMapper', function () {
  21. describe('#map', function () {
  22. var data = {
  23. "items": [
  24. {
  25. "StackServices" : {
  26. "comments" : "A high-throughput distributed messaging system",
  27. "custom_commands" : [ ],
  28. "display_name" : "Kafka",
  29. "required_services" : [
  30. "ZOOKEEPER"
  31. ],
  32. "service_check_supported" : true,
  33. "service_name" : "KAFKA",
  34. "service_version" : "0.8.1.2.2",
  35. "stack_name" : "HDP",
  36. "stack_version" : "2.2",
  37. "config_types" : {
  38. "kafka-broker" : {
  39. "supports" : {
  40. "adding_forbidden" : "false",
  41. "do_not_extend" : "false",
  42. "final" : "false"
  43. }
  44. },
  45. "kafka-env" : {
  46. "supports" : {
  47. "adding_forbidden" : "false",
  48. "do_not_extend" : "false",
  49. "final" : "false"
  50. }
  51. },
  52. "kafka-log4j" : {
  53. "supports" : {
  54. "adding_forbidden" : "false",
  55. "do_not_extend" : "false",
  56. "final" : "false"
  57. }
  58. }
  59. }
  60. },
  61. "components" : [
  62. {
  63. "StackServiceComponents" : {
  64. "cardinality" : "1+",
  65. "component_category" : "MASTER",
  66. "component_name" : "KAFKA_BROKER",
  67. "custom_commands" : [ ],
  68. "display_name" : "Kafka Broker",
  69. "is_client" : false,
  70. "is_master" : true,
  71. "service_name" : "KAFKA",
  72. "stack_name" : "HDP",
  73. "stack_version" : "2.2"
  74. },
  75. "dependencies" : [
  76. {
  77. "Dependencies" : {
  78. "component_name" : "ZOOKEEPER_SERVER",
  79. "dependent_component_name" : "KAFKA_BROKER",
  80. "dependent_service_name" : "KAFKA",
  81. "scope" : "cluster",
  82. "stack_name" : "HDP",
  83. "stack_version" : "2.2"
  84. }
  85. }
  86. ]
  87. }
  88. ],
  89. "artifacts" : [
  90. {
  91. "Artifacts" : {
  92. "artifact_name": "widget_descriptor"
  93. }
  94. }
  95. ]
  96. },
  97. {
  98. "StackServices" : {
  99. "service_name" : "ZOOKEEPER"
  100. },
  101. "components" : [ ],
  102. "artifacts" : [ ]
  103. },
  104. {
  105. "StackServices" : {
  106. "service_name" : "KERBEROS"
  107. },
  108. "components" : [ ],
  109. "artifacts" : [ ]
  110. },
  111. {
  112. "StackServices" : {
  113. "service_name" : "HDFS"
  114. },
  115. "components" : [ ],
  116. "artifacts" : [ ]
  117. },
  118. {
  119. "StackServices" : {
  120. "service_name" : "ACCUMULO"
  121. },
  122. "components" : [ ],
  123. "artifacts" : [ ]
  124. },
  125. {
  126. "StackServices" : {
  127. "service_name" : "HIVE"
  128. },
  129. "components" : [
  130. {
  131. "StackServiceComponents" : {
  132. "component_name" : "MYSQL_SERVER",
  133. "custom_commands" : [
  134. "CLEAN"
  135. ]
  136. },
  137. "dependencies" : [ ]
  138. }
  139. ],
  140. "artifacts" : [ ]
  141. }
  142. ]
  143. },
  144. sortedServiceNames = ["HDFS", "HIVE", "ZOOKEEPER", "KAFKA", "KERBEROS", "ACCUMULO"],
  145. serviceResult = {
  146. id: "KAFKA",
  147. serviceName: "KAFKA",
  148. displayName: "Kafka",
  149. configTypes: {
  150. "kafka-broker" : {
  151. "supports" : {
  152. "adding_forbidden" : "false",
  153. "do_not_extend" : "false",
  154. "final" : "false"
  155. }
  156. },
  157. "kafka-env" : {
  158. "supports" : {
  159. "adding_forbidden" : "false",
  160. "do_not_extend" : "false",
  161. "final" : "false"
  162. }
  163. },
  164. "kafka-log4j" : {
  165. "supports" : {
  166. "adding_forbidden" : "false",
  167. "do_not_extend" : "false",
  168. "final" : "false"
  169. }
  170. }
  171. },
  172. comments: "A high-throughput distributed messaging system",
  173. serviceVersion: "0.8.1.2.2",
  174. stackName: "HDP",
  175. isInstalled: false,
  176. isInstallable: true,
  177. isServiceWithWidgets: false,
  178. serviceCheckSupported: true,
  179. requiredServices: ["ZOOKEEPER"]
  180. },
  181. componentResult = {
  182. id: "KAFKA_BROKER",
  183. componentName: "KAFKA_BROKER",
  184. displayName: "Kafka Broker",
  185. cardinality: "1+",
  186. customCommands: [],
  187. serviceName: "KAFKA",
  188. componentCategory: "MASTER",
  189. isMaster: true,
  190. isClient: false,
  191. stackName: "HDP",
  192. stackVersion: "2.2",
  193. dependencies: [
  194. {
  195. componentName: "ZOOKEEPER_SERVER",
  196. scope : "cluster"
  197. }
  198. ]
  199. };
  200. beforeEach(function () {
  201. App.stackServiceMapper.clearStackModels();
  202. });
  203. it('should sort and map data about services with their components', function () {
  204. App.stackServiceMapper.map(data);
  205. var services = App.StackService.find(),
  206. components = App.StackServiceComponent.find(),
  207. kafkaService = services.findProperty('serviceName', 'KAFKA');
  208. expect(services.mapProperty('serviceName')).to.eql(sortedServiceNames);
  209. expect(kafkaService.get('serviceComponents.length')).to.equal(1);
  210. Em.keys(serviceResult).forEach(function (key) {
  211. expect(kafkaService.get(key)).to.eql(serviceResult[key]);
  212. });
  213. Em.keys(componentResult).forEach(function (key) {
  214. expect(kafkaService.get('serviceComponents').toArray()[0].get(key)).to.eql(componentResult[key]);
  215. });
  216. Em.keys(componentResult).forEach(function (key) {
  217. expect(components.findProperty('componentName', 'KAFKA_BROKER').get(key)).to.eql(componentResult[key]);
  218. });
  219. expect(services.findProperty('serviceName', 'KERBEROS').get('isInstallable')).to.be.false;
  220. expect(services.findProperty('serviceName', 'KERBEROS').get('isSelected')).to.be.false;
  221. expect(components.findProperty('componentName', 'MYSQL_SERVER').get('customCommands')).to.be.empty;
  222. });
  223. });
  224. });