浏览代码

AMBARI-14399 Ranger error counter works wrong in some cases. (ababiichuk)

AndriyBabiychuk 9 年之前
父节点
当前提交
d7d0ba288b

+ 5 - 7
ambari-web/app/controllers/main/service/info/configs.js

@@ -122,13 +122,11 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader, A
    * Number of errors in the configs in the selected service (only for AdvancedTab if App supports Enhanced Configs)
    * @type {number}
    */
-  errorsCount: function () {
-    return this.get('selectedService.configs').filter(function (config) {
-      return Em.isNone(config.get('widgetType'));
-    }).filter(function(config) {
-      return !config.get('isValid') || (config.get('overrides') || []).someProperty('isValid', false);
-    }).filterProperty('isVisible').length;
-  }.property('selectedService.configs.@each.isValid', 'selectedService.configs.@each.isVisible', 'selectedService.configs.@each.overrideErrorTrigger'),
+  errorsCount: function() {
+    return this.get('selectedService.configsWithErrors').filter(function(c) {
+      return Em.isNone(c.get('widget'));
+    }).length;
+  }.property('selectedService.configsWithErrors'),
 
   /**
    * Determines if Save-button should be disabled

+ 6 - 13
ambari-web/app/controllers/wizard/step7_controller.js

@@ -132,13 +132,11 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
    * Number of errors in the configs in the selected service
    * @type {number}
    */
-  errorsCount: function () {
-    return this.get('selectedService.configs').filter(function (config) {
-      return Em.isNone(config.get('widgetType'));
-    }).filter(function(config) {
-      return !config.get('isValid') || (config.get('overrides') || []).someProperty('isValid', false);
-    }).filterProperty('isVisible').length;
-  }.property('selectedService.configs.@each.isValid', 'selectedService.configs.@each.isVisible','selectedService.configs.@each.overrideErrorTrigger'),
+  errorsCount: function() {
+    return this.get('selectedService.configsWithErrors').filter(function(c) {
+      return Em.isNone(c.get('widget'));
+    }).length;
+  }.property('selectedService.configsWithErrors.length'),
 
   /**
    * Should Next-button be disabled
@@ -665,12 +663,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
             } else if (configCondition.get('type') === 'config') {
               //simulate section wrapper for condition type "config"
               themeResource = Em.Object.create({
-                configProperties: [
-                  Em.Object.create({
-                    name: configCondition.get('configName'),
-                    fileName: configCondition.get('fileName')
-                  })
-                ]
+                configProperties: [App.config.configId(configCondition.get('configName'), configCondition.get('fileName'))]
               });
             }
             if (themeResource) {

+ 35 - 52
ambari-web/app/models/configs/objects/service_config.js

@@ -21,24 +21,47 @@ var App = require('app');
 App.ServiceConfig = Ember.Object.extend({
   serviceName: '',
   configCategories: [],
-  configs: null,
+  configCategoriesMap: function() {
+    var categoriesMap = {};
+    this.get('configCategories').forEach(function(c) {
+      if (!categoriesMap[c.get('name')]) categoriesMap[c.get('name')] = c;
+    });
+    return categoriesMap;
+  }.property('configCategories.[]'),
+  configs: [],
   restartRequired: false,
   restartRequiredMessage: '',
   restartRequiredHostsAndComponents: {},
   configGroups: [],
   dependentServiceNames: [],
   initConfigsLength: 0, // configs length after initialization in order to watch changes
-  errorCount: function () {
-    var overrideErrors = 0,
-      masterErrors = 0,
-      slaveErrors = 0,
-      configs = this.get('configs'),
-      configCategories = this.get('configCategories'),
-      enhancedConfigsErrors = 0;
-    configCategories.forEach(function (_category) {
-      slaveErrors += _category.get('slaveErrorCount');
-      _category.set('nonSlaveErrorCount', 0);
+
+  errorCount: Em.computed.alias('configsWithErrors.length'),
+
+  visibleProperties: function() {
+    return this.get('configs').filter(function(c) {
+      return c.get('isVisible') && !c.get('hiddenBySection');
+    });
+  }.property('configs.@each.isVisible', 'configs.@each.hiddenBySection'),
+
+  configsWithErrors: function() {
+    return this.get('visibleProperties').filter(function(c) {
+      return !c.get('isValid') || !c.get('isValidOverride');
     });
+  }.property('visibleProperties.@each.isValid', 'visibleProperties.@each.isValidOverride'),
+
+  observeErrors: function() {
+    this.get('configCategories').setEach('errorCount', 0);
+    this.get('configsWithErrors').forEach(function(c) {
+      if (this.get('configCategoriesMap')[c.get('category')]) {
+        this.get('configCategoriesMap')[c.get('category')].incrementProperty('errorCount');
+      }
+    }, this);
+  }.observes('configsWithErrors'),
+
+  observeForeignKeys: function() {
+    //TODO refactor or move this login to other place
+    var configs = this.get('configs');
     configs.forEach(function (item) {
       if (item.get('isVisible')) {
         var options = item.get('options');
@@ -55,29 +78,7 @@ App.ServiceConfig = Ember.Object.extend({
         }
       }
     });
-    configs.forEach(function (item) {
-      var category = configCategories.findProperty('name', item.get('category'));
-      if (category && !item.get('isValid') && item.get('isVisible') && !item.get('widgetType')) {
-        category.incrementProperty('nonSlaveErrorCount');
-        masterErrors++;
-      }
-      if (!item.get('isValid') && item.get('widgetType') && item.get('isVisible') && !item.get('hiddenBySection')) {
-        enhancedConfigsErrors++;
-      }
-      if (item.get('overrides')) {
-        item.get('overrides').forEach(function (e) {
-          if (e.error) {
-            if (category && !Em.get(e, 'parentSCP.widget')) {
-              category.incrementProperty('nonSlaveErrorCount');
-            }
-            overrideErrors++;
-          }
-        });
-      }
-    });
-    return masterErrors + slaveErrors + overrideErrors + enhancedConfigsErrors;
-  }.property('configs.@each.isValid', 'configs.@each.isVisible', 'configCategories.@each.slaveErrorCount', 'configs.@each.overrideErrorTrigger'),
-
+  }.observes('configs.@each.isVisible'),
   /**
    * checks if for example for kdc_type, the value isn't just the pretty version of the saved value, for example mit-kdc
    * and Existing MIT KDC are the same value, but they are interpreted as being changed. This function fixes that
@@ -118,24 +119,6 @@ App.ServiceConfig = Ember.Object.extend({
   }
 });
 
-App.SlaveConfigs = Ember.Object.extend({
-  componentName: null,
-  displayName: null,
-  hosts: null,
-  groups: null
-});
-
-App.Group = Ember.Object.extend({
-  name: null,
-  hostNames: null,
-  properties: null,
-  errorCount: function () {
-    if (this.get('properties')) {
-      return this.get('properties').filterProperty('isValid', false).filterProperty('isVisible', true).get('length');
-    }
-  }.property('properties.@each.isValid', 'properties.@each.isVisible')
-});
-
 App.ConfigSiteTag = Ember.Object.extend({
   site: DS.attr('string'),
   tag: DS.attr('string'),

+ 1 - 32
ambari-web/app/models/configs/objects/service_config_category.js

@@ -24,7 +24,6 @@ App.ServiceConfigCategory = Ember.Object.extend({
    *  We cant have spaces in the name as this is being used as HTML element id while rendering. Hence we introduced 'displayName' where we can have spaces like 'Secondary Name Node' etc.
    */
   displayName: null,
-  slaveConfigs: null,
   /**
    * check whether to show custom view in category instead of default
    */
@@ -40,38 +39,8 @@ App.ServiceConfigCategory = Ember.Object.extend({
    * Can this category add new properties. Used for custom configurations.
    */
   canAddProperty: false,
-  nonSlaveErrorCount: 0,
-  primaryName: function () {
-    switch (this.get('name')) {
-      case 'DataNode':
-        return 'DATANODE';
-        break;
-      case 'TaskTracker':
-        return 'TASKTRACKER';
-        break;
-      case 'RegionServer':
-        return 'HBASE_REGIONSERVER';
-    }
-    return null;
-  }.property('name'),
 
-
-  isForMasterComponent: Em.computed.existsIn('name', ['NameNode', 'SNameNode', 'JobTracker', 'HBase Master', 'Oozie Master',
-    'Hive Metastore', 'WebHCat Server', 'ZooKeeper Server', 'Ganglia']),
-
-  isForSlaveComponent: Em.computed.existsIn('name', ['DataNode', 'TaskTracker', 'RegionServer']),
-
-  slaveErrorCount: function () {
-    var length = 0;
-    if (this.get('slaveConfigs.groups')) {
-      this.get('slaveConfigs.groups').forEach(function (_group) {
-        length += _group.get('errorCount');
-      }, this);
-    }
-    return length;
-  }.property('slaveConfigs.groups.@each.errorCount'),
-
-  errorCount: Em.computed.sumProperties('slaveErrorCount', 'nonSlaveErrorCount'),
+  errorCount: 0,
 
   isAdvanced : function(){
     var name = this.get('name');

+ 7 - 6
ambari-web/app/models/configs/objects/service_config_property.js

@@ -169,9 +169,8 @@ App.ServiceConfigProperty = Em.Object.extend({
       }
     });
     return originalSCPIssued || overridesIssue;
-  }.property('errorMessage', 'warnMessage', 'overrideErrorTrigger'),
+  }.property('errorMessage', 'warnMessage', 'overrides.@each.warnMessage', 'overrides.@each.errorMessage'),
 
-  overrideErrorTrigger: 0, //Trigger for overridable property error
   index: null, //sequence number in category
   editDone: false, //Text field: on focusOut: true, on focusIn: false
   isNotSaved: false, // user property was added but not saved
@@ -202,11 +201,13 @@ App.ServiceConfigProperty = Em.Object.extend({
   additionalView: null,
 
   /**
-   * On Overridable property error message, change overrideErrorTrigger value to recount number of errors service have
+   * Is property has active override with error
    */
-  observeErrors: function () {
-    this.set("overrideErrorTrigger", this.get("overrideErrorTrigger") + 1);
-  }.observes("overrides.@each.errorMessage"),
+  isValidOverride: function () {
+    return this.get('overrides.length') ? !this.get('overrides').find(function(o) {
+     return Em.get(o, 'isEditable') && Em.get(o, 'errorMessage');
+    }) : true;
+  }.property("overrides.@each.errorMessage"),
   /**
    * No override capabilities for fields which are not edtiable
    * and fields which represent master hosts.

+ 13 - 5
ambari-web/app/models/configs/theme/sub_section.js

@@ -94,17 +94,25 @@ App.SubSection = DS.Model.extend({
 
   showTabs: Em.computed.and('hasTabs', 'someSubSectionTabIsVisible'),
 
+  visibleProperties: function() {
+    return this.get('configs').filter(function(c) {
+      return c.get('isVisible') && !c.get('hiddenBySection');
+    });
+  }.property('configs.@each.isVisible', 'configs.@each.hiddenBySection'),
+
+  visibleTabs: Em.computed.filterBy('subSectionTabs', 'isVisible', true),
+
   /**
    * Number of the errors in all configs
    * @type {number}
    */
   errorsCount: function () {
-    var visibleTabs = this.get('subSectionTabs').filterProperty('isVisible');
-    var subSectionTabsErrors = visibleTabs.length ? visibleTabs.mapProperty('errorsCount').reduce(Em.sum, 0) : 0;
-    return subSectionTabsErrors + this.get('configs').filter(function(config) {
-      return config.get('isVisible') && (!config.get('isValid') || (config.get('overrides') || []).someProperty('isValid', false));
+    var propertiesWithErrors = this.get('visibleProperties').filter(function(c) {
+      return !c.get('isValid') || !c.get('isValidOverride');
     }).length;
-  }.property('configs.@each.isValid', 'configs.@each.isVisible', 'configs.@each.overrideErrorTrigger', 'subSectionTabs.@each.isVisible', 'subSectionTabs.@each.errorsCount'),
+    var tabsWithErrors = this.get('visibleTabs').mapProperty('errorsCount').reduce(Em.sum, 0);
+    return propertiesWithErrors + tabsWithErrors;
+  }.property('visibleProperties.@each.isValid', 'visibleProperties.@each.isValidOverride', 'visibleTabs.@each.errorsCount'),
 
   /**
    * @type {boolean}

+ 11 - 10
ambari-web/app/models/configs/theme/sub_section_tab.js

@@ -55,15 +55,21 @@ App.SubSectionTab = DS.Model.extend({
    */
   isActive: DS.attr('boolean', {defaultValue: false}),
 
+  visibleProperties: function() {
+    return this.get('configs').filter(function(c) {
+      return c.get('isVisible') && !c.get('hiddenBySection');
+    });
+  }.property('configs.@each.isVisible', 'configs.@each.hiddenBySection'),
+
   /**
    * Number of the errors in all configs
    * @type {number}
    */
   errorsCount: function () {
-    return this.get('configs').filter(function(config) {
-      return config.get('isVisible') && (!config.get('isValid') || (config.get('overrides') || []).someProperty('isValid', false));
+    return this.get('visibleProperties').filter(function(config) {
+      return !config.get('isValid') || !config.get('isValidOverride');
     }).length;
-  }.property('configs.@each.isVisible', 'configs.@each.isValid', 'configs.@each.overrideErrorTrigger'),
+  }.property('visibleProperties.@each.isValid', 'visibleProperties.@each.isValidOverride'),
 
   /**
    * If the visibility of subsection is dependent on a value of some config
@@ -75,17 +81,12 @@ App.SubSectionTab = DS.Model.extend({
    * If there is no configs, subsection can't be hidden
    * @type {boolean}
    */
-  isHiddenByFilter: function () {
-    var configs = this.get('configs').filter(function(c) {
-      return !c.get('hiddenBySection') && c.get('isVisible');
-    });
-    return configs.length ? configs.everyProperty('isHiddenByFilter', true) : false;
-  }.property('configs.@each.isHiddenByFilter'),
+  isHiddenByFilter: Em.computed.everyBy('visibleProperties', 'isHiddenByFilter', true),
 
   /**
    * @type {boolean}
    */
-  someConfigIsVisible: Em.computed.someBy('configs', 'isVisible', true),
+  someConfigIsVisible: Em.computed.gt('visibleProperties.length', 0),
 
   /**
    * Determines if subsection is visible

+ 6 - 24
ambari-web/test/controllers/main/service/info/config_test.js

@@ -778,30 +778,12 @@ describe("App.MainServiceInfoConfigsController", function () {
 
     it('should ignore configs with widgets (enhanced configs)', function () {
 
-      mainServiceInfoConfigsController.reopen({selectedService: {
-        configs: [
-          Em.Object.create({isVisible: true, widgetType: 'type', isValid: false}),
-          Em.Object.create({isVisible: true, widgetType: 'type', isValid: true}),
-          Em.Object.create({isVisible: true, isValid: true}),
-          Em.Object.create({isVisible: true, isValid: false})
-        ]
-      }});
-
-      expect(mainServiceInfoConfigsController.get('errorsCount')).to.equal(1);
-
-    });
-
-    it('should ignore configs with widgets (enhanced configs) and hidden configs', function () {
-
-      mainServiceInfoConfigsController.reopen({selectedService: {
-        configs: [
-          Em.Object.create({isVisible: true, widgetType: 'type', isValid: false}),
-          Em.Object.create({isVisible: true, widgetType: 'type', isValid: true}),
-          Em.Object.create({isVisible: false, isValid: false}),
-          Em.Object.create({isVisible: true, isValid: true}),
-          Em.Object.create({isVisible: true, isValid: false})
-        ]
-      }});
+      mainServiceInfoConfigsController.reopen({selectedService: Em.Object.create({
+        configsWithErrors: Em.A([
+          Em.Object.create({widget: {}}),
+          Em.Object.create({widget: null})
+        ])
+      })});
 
       expect(mainServiceInfoConfigsController.get('errorsCount')).to.equal(1);
 

+ 7 - 24
ambari-web/test/controllers/wizard/step7_test.js

@@ -1531,30 +1531,13 @@ describe('App.InstallerStep7Controller', function () {
 
     it('should ignore configs with widgets (enhanced configs)', function () {
 
-      installerStep7Controller.reopen({selectedService: {
-        configs: [
-          Em.Object.create({isVisible: true, widgetType: 'type', isValid: false}),
-          Em.Object.create({isVisible: true, widgetType: 'type', isValid: true}),
-          Em.Object.create({isVisible: true, isValid: true}),
-          Em.Object.create({isVisible: true, isValid: false})
-        ]
-      }});
-
-      expect(installerStep7Controller.get('errorsCount')).to.equal(1);
-
-    });
-
-    it('should ignore configs with widgets (enhanced configs) and hidden configs', function () {
-
-      installerStep7Controller.reopen({selectedService: {
-        configs: [
-          Em.Object.create({isVisible: true, widgetType: 'type', isValid: false}),
-          Em.Object.create({isVisible: true, widgetType: 'type', isValid: true}),
-          Em.Object.create({isVisible: false, isValid: false}),
-          Em.Object.create({isVisible: true, isValid: true}),
-          Em.Object.create({isVisible: true, isValid: false})
-        ]
-      }});
+      installerStep7Controller.reopen({selectedService: Em.Object.create({
+          configsWithErrors: Em.A([
+            Em.Object.create({widget: {}}),
+            Em.Object.create({widget: null})
+          ])
+        })
+      });
 
       expect(installerStep7Controller.get('errorsCount')).to.equal(1);
 

+ 2 - 130
ambari-web/test/models/configs/objects/service_config_category_test.js

@@ -21,87 +21,7 @@ var App = require('app');
 require('models/configs/objects/service_config_category');
 require('models/configs/objects/service_config_property');
 
-var serviceConfigCategory,
-  nameCases = [
-    {
-      name: 'DataNode',
-      primary: 'DATANODE'
-    },
-    {
-      name: 'TaskTracker',
-      primary: 'TASKTRACKER'
-    },
-    {
-      name: 'RegionServer',
-      primary: 'HBASE_REGIONSERVER'
-    },
-    {
-      name: 'name',
-      primary: null
-    }
-  ],
-  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'),
-  groupsData = {
-    groups: [
-      Em.Object.create({
-        errorCount: 1
-      }),
-      Em.Object.create({
-        errorCount: 2
-      })
-    ]
-  };
+var serviceConfigCategory;
 
 function getCategory() {
   return App.ServiceConfigCategory.create();
@@ -113,54 +33,6 @@ describe('App.ServiceConfigCategory', function () {
     serviceConfigCategory = getCategory();
   });
 
-  App.TestAliases.testAsComputedSumProperties(getCategory(), 'errorCount', ['slaveErrorCount', 'nonSlaveErrorCount']);
-
-  describe('#primaryName', function () {
-    nameCases.forEach(function (item) {
-      it('should return ' + item.primary, function () {
-        serviceConfigCategory.set('name', item.name);
-        expect(serviceConfigCategory.get('primaryName')).to.equal(item.primary);
-      })
-    });
-  });
-
-  describe('#isForMasterComponent', function () {
-    masters.forEach(function (item) {
-      it('should be true for ' + item.name, function () {
-        serviceConfigCategory.set('name', item.name);
-        expect(serviceConfigCategory.get('isForMasterComponent')).to.be.true;
-      });
-    });
-    it('should be false', function () {
-      serviceConfigCategory.set('name', 'name');
-      expect(serviceConfigCategory.get('isForMasterComponent')).to.be.false;
-    });
-  });
-
-  describe('#isForSlaveComponent', function () {
-    slaves.forEach(function (item) {
-      it('should be true for ' + item.name, function () {
-        serviceConfigCategory.set('name', item.name);
-        expect(serviceConfigCategory.get('isForSlaveComponent')).to.be.true;
-      });
-    });
-    it('should be false', function () {
-      serviceConfigCategory.set('name', 'name');
-      expect(serviceConfigCategory.get('isForSlaveComponent')).to.be.false;
-    });
-  });
-
-  describe('#slaveErrorCount', function () {
-    it('should be 0', function () {
-      serviceConfigCategory.set('slaveConfigs', []);
-      expect(serviceConfigCategory.get('slaveErrorCount')).to.equal(0);
-    });
-    it('should sum all errorCount values', function () {
-      serviceConfigCategory.set('slaveConfigs', groupsData);
-      expect(serviceConfigCategory.get('slaveErrorCount')).to.equal(3);
-    });
-  });
-
   describe('#isAdvanced', function () {
     it('should be true', function () {
       serviceConfigCategory.set('name', 'Advanced');
@@ -172,4 +44,4 @@ describe('App.ServiceConfigCategory', function () {
     });
   });
 
-});
+});

+ 0 - 9
ambari-web/test/models/configs/objects/service_config_property_test.js

@@ -335,15 +335,6 @@ describe('App.ServiceConfigProperty', function () {
 
   App.TestAliases.testAsComputedAnd(getProperty(), 'hideFinalIcon', ['!isFinal', 'isNotEditable']);
 
-  describe('#overrideErrorTrigger', function () {
-    it('should be an increment', function () {
-      serviceConfigProperty.set('overrides', configsData[0].overrides);
-      expect(serviceConfigProperty.get('overrideErrorTrigger')).to.equal(1);
-      serviceConfigProperty.set('overrides', []);
-      expect(serviceConfigProperty.get('overrideErrorTrigger')).to.equal(2);
-    });
-  });
-
   describe('#isPropertyOverridable', function () {
     overridableFalseData.forEach(function (item) {
       it('should be false', function () {

+ 54 - 161
ambari-web/test/models/configs/objects/service_config_test.js

@@ -21,178 +21,71 @@ var App = require('app');
 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]];
+  group, 
+  configs = [
+      Em.Object.create({
+        'name': 'p1',
+        'isVisible': true,
+        'hiddenBySection': false,
+        'isValid': true,
+        'isValidOverride': true
+      }),
+      Em.Object.create({
+        'name': 'p2',
+        'isVisible': false,
+        'hiddenBySection': false,
+        'isValid': true,
+        'isValidOverride': true
+      }),
+      Em.Object.create({
+        'name': 'p3',
+        'isVisible': true,
+        'hiddenBySection': true,
+        'isValid': true,
+        'isValidOverride': true
+      }),
+      Em.Object.create({
+        'name': 'p4',
+        'isVisible': true,
+        'hiddenBySection': false,
+        'isValid': false,
+        'isValidOverride': true
+      }),
+      Em.Object.create({
+        'name': 'p5',
+        'isVisible': true,
+        'hiddenBySection': false,
+        'isValid': true,
+        'isValidOverride': false
+      })
+  ];
 
 describe('App.ServiceConfig', function () {
 
   beforeEach(function () {
-    serviceConfig = App.ServiceConfig.create();
+    serviceConfig = App.ServiceConfig.create({
+      configs: configs
+    });
   });
 
-  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('#visibleProperties', function() {
+    it('returns collection of properties that should be shown', function() {
+      expect(serviceConfig.get('visibleProperties').mapProperty('name')).to.be.eql(['p1','p4','p5']);
     });
   });
 
-});
-
-describe('App.Group', function () {
-
-  beforeEach(function () {
-    group = App.Group.create();
+  describe('#configsWithErrors', function() {
+    it('returns collection of properties with errors', function() {
+      expect(serviceConfig.get('configsWithErrors').mapProperty('name')).to.be.eql(['p4', 'p5']);
+    })
   });
 
-  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);
+  describe('#errorCount', function() {
+    it('returns collection of properties with errors', function() {
+      serviceConfig.reopen({
+        configsWithErrors: [{}, {}]
+      });
+      expect(serviceConfig.get('errorCount')).to.equal(2);
     });
   });
-
 });

+ 4 - 6
ambari-web/test/models/configs/sub_section_test.js

@@ -52,15 +52,13 @@ describe('App.SubSection', function () {
       expect(model.get('errorsCount')).to.equal(3);
     });
 
-    it('should use configs.@each.overrideErrorTrigger', function() {
+    it('should use configs.@each.isValidOverride', function() {
       // original value is valid
       var validOriginalSCP = model.get('configs').objectAt(0);
       // add override with not valid value
-      validOriginalSCP.set('overrides', [
-        App.ServiceConfigProperty.create({ isValid: false }),
-        App.ServiceConfigProperty.create({ isValid: true })
-      ]);
-      expect(model.get('errorsCount')).to.equal(4);
+      validOriginalSCP.set('isValidOverride', false);
+      validOriginalSCP.set('isValid', true);
+      expect(model.get('errorsCount')).to.equal(3);
     });
 
   });