stack_service_mapper_test.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. {
  117. "StackServiceComponents" : {
  118. "cardinality" : "1+",
  119. "component_category" : "SLAVE",
  120. "component_name" : "DATANODE",
  121. "custom_commands" : [ ],
  122. "decommission_allowed" : true,
  123. "bulk_commands_display_name" : "DataNodes",
  124. "bulk_commands_master_component_name" : "NAMENODE",
  125. "has_bulk_commands_definition" : true,
  126. "reassign_allowed" : true,
  127. "cardinality" : "1+",
  128. "display_name" : "DataNode",
  129. "is_client" : false,
  130. "is_master" : true,
  131. "service_name" : "HDFS",
  132. "stack_name" : "HDP"
  133. },
  134. "dependencies" : []
  135. }
  136. ],
  137. "artifacts" : [ ]
  138. },
  139. {
  140. "StackServices" : {
  141. "service_name" : "ACCUMULO"
  142. },
  143. "components" : [ ],
  144. "artifacts" : [ ]
  145. },
  146. {
  147. "StackServices" : {
  148. "service_name" : "HIVE"
  149. },
  150. "components" : [
  151. {
  152. "StackServiceComponents" : {
  153. "component_name" : "MYSQL_SERVER",
  154. "custom_commands" : [
  155. "CLEAN"
  156. ]
  157. },
  158. "dependencies" : [ ]
  159. }
  160. ],
  161. "artifacts" : [ ]
  162. }
  163. ]
  164. },
  165. sortedServiceNames = ["HDFS", "HIVE", "ZOOKEEPER", "ACCUMULO", "KAFKA", "KERBEROS"],
  166. serviceResult = {
  167. id: "KAFKA",
  168. serviceName: "KAFKA",
  169. displayName: "Kafka",
  170. configTypes: {
  171. "kafka-broker" : {
  172. "supports" : {
  173. "adding_forbidden" : "false",
  174. "do_not_extend" : "false",
  175. "final" : "false"
  176. }
  177. },
  178. "kafka-env" : {
  179. "supports" : {
  180. "adding_forbidden" : "false",
  181. "do_not_extend" : "false",
  182. "final" : "false"
  183. }
  184. },
  185. "kafka-log4j" : {
  186. "supports" : {
  187. "adding_forbidden" : "false",
  188. "do_not_extend" : "false",
  189. "final" : "false"
  190. }
  191. }
  192. },
  193. comments: "A high-throughput distributed messaging system",
  194. serviceVersion: "0.8.1.2.2",
  195. stackName: "HDP",
  196. isInstalled: false,
  197. isInstallable: true,
  198. isServiceWithWidgets: false,
  199. serviceCheckSupported: true,
  200. requiredServices: ["ZOOKEEPER"]
  201. },
  202. componentResult = {
  203. id: "KAFKA_BROKER",
  204. componentName: "KAFKA_BROKER",
  205. displayName: "Kafka Broker",
  206. cardinality: "1+",
  207. customCommands: [],
  208. serviceName: "KAFKA",
  209. componentCategory: "MASTER",
  210. isMaster: true,
  211. isClient: false,
  212. stackName: "HDP",
  213. stackVersion: "2.2",
  214. dependencies: [
  215. {
  216. componentName: "ZOOKEEPER_SERVER",
  217. scope : "cluster"
  218. }
  219. ]
  220. };
  221. beforeEach(function () {
  222. App.stackServiceMapper.clearStackModels();
  223. });
  224. it('should sort and map data about services with their components', function () {
  225. App.stackServiceMapper.map(data);
  226. var services = App.StackService.find(),
  227. components = App.StackServiceComponent.find(),
  228. kafkaService = services.findProperty('serviceName', 'KAFKA');
  229. expect(services.mapProperty('serviceName')).to.eql(sortedServiceNames);
  230. expect(kafkaService.get('serviceComponents.length')).to.equal(1);
  231. Em.keys(serviceResult).forEach(function (key) {
  232. expect(kafkaService.get(key)).to.eql(serviceResult[key]);
  233. });
  234. Em.keys(componentResult).forEach(function (key) {
  235. expect(kafkaService.get('serviceComponents').toArray()[0].get(key)).to.eql(componentResult[key]);
  236. });
  237. Em.keys(componentResult).forEach(function (key) {
  238. expect(components.findProperty('componentName', 'KAFKA_BROKER').get(key)).to.eql(componentResult[key]);
  239. });
  240. expect(services.findProperty('serviceName', 'KERBEROS').get('isInstallable')).to.be.false;
  241. expect(services.findProperty('serviceName', 'KERBEROS').get('isSelected')).to.be.false;
  242. expect(components.findProperty('componentName', 'MYSQL_SERVER').get('customCommands')).to.be.empty;
  243. expect(components.findProperty('componentName', 'DATANODE').get('hasBulkCommandsDefinition')).to.be.true;
  244. expect(components.findProperty('componentName', 'DATANODE').get('bulkCommandsDisplayName')).to.eql("DataNodes");
  245. expect(components.findProperty('componentName', 'DATANODE').get('bulkCommandsMasterComponentName')).to.eql("NAMENODE");
  246. expect(components.findProperty('componentName', 'DATANODE').get('decommissionAllowed')).to.be.true;
  247. expect(components.findProperty('componentName', 'DATANODE').get('reassignAllowed')).to.be.true;
  248. });
  249. });
  250. });