123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- /**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
- var App = require('app');
- require('mappers/stack_service_mapper');
- describe('App.stackServiceMapper', function () {
- describe('#map', function () {
- var data = {
- "items": [
- {
- "StackServices" : {
- "comments" : "A high-throughput distributed messaging system",
- "custom_commands" : [ ],
- "display_name" : "Kafka",
- "required_services" : [
- "ZOOKEEPER"
- ],
- "service_check_supported" : true,
- "service_name" : "KAFKA",
- "service_version" : "0.8.1.2.2",
- "stack_name" : "HDP",
- "stack_version" : "2.2",
- "config_types" : {
- "kafka-broker" : {
- "supports" : {
- "adding_forbidden" : "false",
- "do_not_extend" : "false",
- "final" : "false"
- }
- },
- "kafka-env" : {
- "supports" : {
- "adding_forbidden" : "false",
- "do_not_extend" : "false",
- "final" : "false"
- }
- },
- "kafka-log4j" : {
- "supports" : {
- "adding_forbidden" : "false",
- "do_not_extend" : "false",
- "final" : "false"
- }
- }
- }
- },
- "components" : [
- {
- "StackServiceComponents" : {
- "cardinality" : "1+",
- "component_category" : "MASTER",
- "component_name" : "KAFKA_BROKER",
- "custom_commands" : [ ],
- "display_name" : "Kafka Broker",
- "is_client" : false,
- "is_master" : true,
- "service_name" : "KAFKA",
- "stack_name" : "HDP",
- "stack_version" : "2.2"
- },
- "dependencies" : [
- {
- "Dependencies" : {
- "component_name" : "ZOOKEEPER_SERVER",
- "dependent_component_name" : "KAFKA_BROKER",
- "dependent_service_name" : "KAFKA",
- "scope" : "cluster",
- "stack_name" : "HDP",
- "stack_version" : "2.2"
- }
- }
- ]
- }
- ],
- "artifacts" : [
- {
- "Artifacts" : {
- "artifact_name": "widget_descriptor"
- }
- }
- ]
- },
- {
- "StackServices" : {
- "service_name" : "ZOOKEEPER"
- },
- "components" : [ ],
- "artifacts" : [ ]
- },
- {
- "StackServices" : {
- "service_name" : "KERBEROS"
- },
- "components" : [ ],
- "artifacts" : [ ]
- },
- {
- "StackServices" : {
- "service_name" : "HDFS"
- },
- "components" : [ ],
- "artifacts" : [ ]
- },
- {
- "StackServices" : {
- "service_name" : "ACCUMULO"
- },
- "components" : [ ],
- "artifacts" : [ ]
- },
- {
- "StackServices" : {
- "service_name" : "HIVE"
- },
- "components" : [
- {
- "StackServiceComponents" : {
- "component_name" : "MYSQL_SERVER",
- "custom_commands" : [
- "CLEAN"
- ]
- },
- "dependencies" : [ ]
- }
- ],
- "artifacts" : [ ]
- }
- ]
- },
- sortedServiceNames = ["HDFS", "HIVE", "ZOOKEEPER", "KAFKA", "KERBEROS", "ACCUMULO"],
- serviceResult = {
- id: "KAFKA",
- serviceName: "KAFKA",
- displayName: "Kafka",
- configTypes: {
- "kafka-broker" : {
- "supports" : {
- "adding_forbidden" : "false",
- "do_not_extend" : "false",
- "final" : "false"
- }
- },
- "kafka-env" : {
- "supports" : {
- "adding_forbidden" : "false",
- "do_not_extend" : "false",
- "final" : "false"
- }
- },
- "kafka-log4j" : {
- "supports" : {
- "adding_forbidden" : "false",
- "do_not_extend" : "false",
- "final" : "false"
- }
- }
- },
- comments: "A high-throughput distributed messaging system",
- serviceVersion: "0.8.1.2.2",
- stackName: "HDP",
- isInstalled: false,
- isInstallable: true,
- isServiceWithWidgets: false,
- serviceCheckSupported: true,
- requiredServices: ["ZOOKEEPER"]
- },
- componentResult = {
- id: "KAFKA_BROKER",
- componentName: "KAFKA_BROKER",
- displayName: "Kafka Broker",
- cardinality: "1+",
- customCommands: [],
- serviceName: "KAFKA",
- componentCategory: "MASTER",
- isMaster: true,
- isClient: false,
- stackName: "HDP",
- stackVersion: "2.2",
- dependencies: [
- {
- componentName: "ZOOKEEPER_SERVER",
- scope : "cluster"
- }
- ]
- };
- beforeEach(function () {
- App.stackServiceMapper.clearStackModels();
- });
- it('should sort and map data about services with their components', function () {
- App.stackServiceMapper.map(data);
- var services = App.StackService.find(),
- components = App.StackServiceComponent.find(),
- kafkaService = services.findProperty('serviceName', 'KAFKA');
- expect(services.mapProperty('serviceName')).to.eql(sortedServiceNames);
- expect(kafkaService.get('serviceComponents.length')).to.equal(1);
- Em.keys(serviceResult).forEach(function (key) {
- expect(kafkaService.get(key)).to.eql(serviceResult[key]);
- });
- Em.keys(componentResult).forEach(function (key) {
- expect(kafkaService.get('serviceComponents').toArray()[0].get(key)).to.eql(componentResult[key]);
- });
- Em.keys(componentResult).forEach(function (key) {
- expect(components.findProperty('componentName', 'KAFKA_BROKER').get(key)).to.eql(componentResult[key]);
- });
- expect(services.findProperty('serviceName', 'KERBEROS').get('isInstallable')).to.be.false;
- expect(services.findProperty('serviceName', 'KERBEROS').get('isSelected')).to.be.false;
- expect(components.findProperty('componentName', 'MYSQL_SERVER').get('customCommands')).to.be.empty;
- });
- });
- });
|