123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- /**
- * 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');
- var configPropertyHelper = require('utils/configs/config_property_helper');
- require('models/configs/objects/service_config');
- var serviceConfig,
- group,
- configsData = [
- Ember.Object.create({
- category: 'c0',
- overrides: [
- {
- error: true,
- errorMessage: 'error'
- },
- {
- error: true
- },
- {}
- ]
- }),
- Ember.Object.create({
- category: 'c1',
- isValid: false,
- isVisible: true
- }),
- Ember.Object.create({
- category: 'c0',
- isValid: true,
- isVisible: true
- }),
- Ember.Object.create({
- category: 'c1',
- isValid: false,
- isVisible: false
- })
- ],
- configCategoriesData = [
- Em.Object.create({
- name: 'c0',
- slaveErrorCount: 1
- }),
- Em.Object.create({
- name: 'c1',
- slaveErrorCount: 2
- })
- ],
- components = [
- {
- name: 'NameNode',
- master: true
- },
- {
- name: 'SNameNode',
- master: true
- },
- {
- name: 'JobTracker',
- master: true
- },
- {
- name: 'HBase Master',
- master: true
- },
- {
- name: 'Oozie Master',
- master: true
- },
- {
- name: 'Hive Metastore',
- master: true
- },
- {
- name: 'WebHCat Server',
- master: true
- },
- {
- name: 'ZooKeeper Server',
- master: true
- },
- {
- name: 'Ganglia',
- master: true
- },
- {
- name: 'DataNode',
- slave: true
- },
- {
- name: 'TaskTracker',
- slave: true
- },
- {
- name: 'RegionServer',
- slave: true
- }
- ],
- masters = components.filterProperty('master'),
- slaves = components.filterProperty('slave'),
- groupNoErrorsData = [].concat(configsData.slice(2)),
- groupErrorsData = [configsData[1]];
- describe('App.ServiceConfig', function () {
- beforeEach(function () {
- serviceConfig = App.ServiceConfig.create();
- });
- describe('#errorCount', function () {
- it('should be 0', function () {
- serviceConfig.setProperties({
- configs: [],
- configCategories: []
- });
- expect(serviceConfig.get('errorCount')).to.equal(0);
- });
- it('should sum counts of all errors', function () {
- serviceConfig.setProperties({
- configs: configsData,
- configCategories: configCategoriesData
- });
- expect(serviceConfig.get('errorCount')).to.equal(6);
- expect(serviceConfig.get('configCategories').findProperty('name', 'c0').get('nonSlaveErrorCount')).to.equal(2);
- expect(serviceConfig.get('configCategories').findProperty('name', 'c1').get('nonSlaveErrorCount')).to.equal(1);
- });
- it('should include invalid properties with widgets', function() {
- serviceConfig.setProperties({
- configs: [
- Em.Object.create({
- isValid: false,
- widgetType: 'type',
- isVisible: true,
- category: 'some1'
- }),
- Em.Object.create({
- isValid: false,
- widgetType: 'type',
- isVisible: true,
- category: 'some2'
- }),
- Em.Object.create({
- isValid: false,
- widgetType: null,
- isVisible: true,
- category: 'some2'
- }),
- Em.Object.create({
- isValid: false,
- widgetType: 'type',
- isVisible: true
- })
- ],
- configCategories: [
- Em.Object.create({ name: 'some1', slaveErrorCount: 0}),
- Em.Object.create({ name: 'some2', slaveErrorCount: 0})
- ]
- });
- expect(serviceConfig.get('errorCount')).to.equal(4);
- });
- });
- });
- describe('App.Group', function () {
- beforeEach(function () {
- group = App.Group.create();
- });
- describe('#errorCount', function () {
- it('should be 0', function () {
- group.set('properties', groupNoErrorsData);
- expect(group.get('errorCount')).to.equal(0);
- });
- it('should be 1', function () {
- group.set('properties', groupErrorsData);
- expect(group.get('errorCount')).to.equal(1);
- });
- });
- });
|