Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 22ff2a33d -> 35ac6fbfc


http://git-wip-us.apache.org/repos/asf/ambari/blob/35ac6fbf/ambari-web/app/models/configs/objects/service_config_property.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/objects/service_config_property.js 
b/ambari-web/app/models/configs/objects/service_config_property.js
index b961d3f..2107999 100644
--- a/ambari-web/app/models/configs/objects/service_config_property.js
+++ b/ambari-web/app/models/configs/objects/service_config_property.js
@@ -21,7 +21,6 @@ var validator = require('utils/validator');
 
 App.ServiceConfigProperty = Em.Object.extend({
 
-  id: '', //either 'puppet var' or 'site property'
   name: '',
   displayName: '',
 
@@ -205,7 +204,7 @@ App.ServiceConfigProperty = Em.Object.extend({
   }.property('isUserProperty', 'isOriginalSCP', 'overrides.length'),
 
   init: function () {
-    if ((this.get('id') === 'puppet var') && this.get('value') == '') {
+    if (this.get('value') == '') {
       if (this.get('savedValue')) {
         this.set('value', this.get('savedValue'));
       } else if (this.get('recommendedValue')) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/35ac6fbf/ambari-web/app/models/configs/stack_config_property.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/stack_config_property.js 
b/ambari-web/app/models/configs/stack_config_property.js
index 3a0ea9a..1289662 100644
--- a/ambari-web/app/models/configs/stack_config_property.js
+++ b/ambari-web/app/models/configs/stack_config_property.js
@@ -190,6 +190,90 @@ App.StackConfigProperty = DS.Model.extend({
   index: DS.attr('number', {defaultValue: null}),
 
   /**
+   * defines if the property can be overriden in the host config group
+   * @type {boolean}
+   */
+  isOverridable: function() {
+    var result = true;
+    if (this.get('valueAttributes') && 
!Em.none(this.get('valueAttributes.overridable'))) {
+      result =  !!this.get('valueAttributes.overridable');
+    }
+    return result;
+  }.property('valueAttributes.overridable'),
+
+  /**
+   * defines if the property is visible or hidden
+   * @type {boolean}
+   */
+  isVisible: function() {
+    var result = true;
+    if (this.get('valueAttributes') && 
!Em.none(this.get('valueAttributes.visible'))) {
+      result =  !!this.get('valueAttributes.visible');
+    }
+    return result;
+  }.property('valueAttributes.visible'),
+
+  /**
+   * defines if the value of property can be left empty or not
+   * @type {boolean}
+   */
+  isRequired: function() {
+    var result = true;
+    if (this.get('valueAttributes') && 
!Em.none(this.get('valueAttributes.empty_value_valid'))) {
+      result =  !this.get('valueAttributes.empty_value_valid');
+    }
+    return result;
+  }.property('valueAttributes.empty_value_valid'),
+
+  /**
+   * defines if the value of property can be reconfigured post-install
+   * @type {boolean}
+   */
+  isReconfigurable: function() {
+    var result = true;
+    if (this.get('valueAttributes') && 
!Em.none(this.get('valueAttributes.editable_only_at_install'))) {
+      result =  !this.get('valueAttributes.editable_only_at_install');
+    }
+    return result;
+  }.property('valueAttributes.editable_only_at_install'),
+
+  /**
+   * defines if the name of the property is visible or hidden
+   * @type {boolean}
+   */
+  showLabel: function() {
+    var result = true;
+    if (this.get('valueAttributes') && 
!Em.none(this.get('valueAttributes.show_property_name'))) {
+      result =  !!this.get('valueAttributes.show_property_name');
+    }
+    return result;
+  }.property('valueAttributes.show_property_name'),
+
+  /**
+   * defines if the property is editable or not
+   * @type {boolean}
+   */
+  isEditable: function() {
+    var result = true;
+    if (this.get('valueAttributes') && 
!Em.none(this.get('valueAttributes.read_only'))) {
+      result =  !!this.get('valueAttributes.read_only');
+    }
+    return result;
+  }.property('valueAttributes.read_only'),
+
+  /**
+   * defines if the property is editable or not
+   * @type {boolean}
+   */
+  unit: function() {
+    var result = '';
+    if (this.get('valueAttributes') && 
!Em.empty(this.get('valueAttributes.unit'))) {
+      result =  this.get('valueAttributes.unit');
+    }
+    return result;
+  }.property('valueAttributes.unit'),
+
+  /**
    * Does config property has a valid value defined in the stack
    * @type {boolean}
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/35ac6fbf/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 82b255f..4c8d67e 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -808,7 +808,6 @@ App.config = Em.Object.create({
     var checkboxProperties = ['ignore_groupsusers_create', 'override_uid'];
     if (Em.isArray(config.property_type)) {
       if (config.property_type.contains('USER') || 
config.property_type.contains('ADDITIONAL_USER_PROPERTY') || 
config.property_type.contains('GROUP')) {
-        propertyData.id = "puppet var";
         propertyData.category = 'Users and Groups';
         propertyData.isVisible = !App.get('isHadoopWindowsStack');
         propertyData.serviceName = 'MISC';
@@ -1320,10 +1319,7 @@ App.config = Em.Object.create({
   generateConfigPropertiesByName: function (names, properties) {
     return names.map(function (item) {
       var baseObj = {
-        name: item,
-        displayName: item,
-        isVisible: true,
-        isReconfigurable: true
+        name: item
       };
       if (properties) return $.extend(baseObj, properties);
       else return baseObj;

http://git-wip-us.apache.org/repos/asf/ambari/blob/35ac6fbf/ambari-web/test/data/HDP2.2/site_properties_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/data/HDP2.2/site_properties_test.js 
b/ambari-web/test/data/HDP2.2/site_properties_test.js
new file mode 100644
index 0000000..82d0ab1
--- /dev/null
+++ b/ambari-web/test/data/HDP2.2/site_properties_test.js
@@ -0,0 +1,68 @@
+/**
+ * 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('utils/helper');
+var siteProperties = require('data/HDP2.2/site_properties').configProperties;
+
+describe('hdp2SiteProperties', function () {
+  /**
+   * @stackProperties: All the properties that are derived from stack 
definition
+   */
+  var stackProperties = siteProperties.filter(function(item){
+    return  (!(item.isRequiredByAgent === false || item.filename === 
'alert_notification' || item.category === 'Ambari Principals'))
+  });
+
+  stackProperties.forEach(function(siteProperty){
+    /**
+     * Following config attributes are stack driven and should be defined in 
the stack metainfo instead of ambari-web site-properties file
+     * isVisible
+     * isOverridable
+     * value
+     * recommendedValue
+     * isReconfigurable
+     * isRequired
+     * displayName
+     * description
+     * showLabel
+     * unit
+     */
+    it('Check attributes of "' + siteProperty.filename + '/' + 
siteProperty.name  + '"' + '. Stack driven attributes should be undefined ', 
function () {
+      expect(siteProperty.isVisible).to.equal(undefined);
+      expect(siteProperty.value).to.equal(undefined);
+      expect(siteProperty.recommendedValue).to.equal(undefined);
+      expect(siteProperty.description).to.equal(undefined);
+      expect(siteProperty.isReconfigurable).to.equal(undefined);
+      expect(siteProperty.isRequired).to.equal(undefined);
+      expect(siteProperty.displayName).to.equal(undefined);
+      expect(siteProperty.showLabel).to.equal(undefined);
+      expect(siteProperty.unit).to.equal(undefined);
+    });
+
+    /**
+     * Following config attributes uniquely represent a config property
+     * name
+     * filename
+     */
+    it('Check primary attributes of "' + siteProperty.filename + '/' + 
siteProperty.name  + '"' + '. Attributes that uniquely represent a property 
should be defined ', function () {
+      expect(siteProperty.name).to.not.equal(undefined);
+      expect(siteProperty.filename).to.not.equal(undefined);
+    });
+  });
+
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/35ac6fbf/ambari-web/test/data/HDP2.3/site_properties_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/data/HDP2.3/site_properties_test.js 
b/ambari-web/test/data/HDP2.3/site_properties_test.js
new file mode 100644
index 0000000..45c841f
--- /dev/null
+++ b/ambari-web/test/data/HDP2.3/site_properties_test.js
@@ -0,0 +1,68 @@
+/**
+ * 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('utils/helper');
+var siteProperties = require('data/HDP2.3/site_properties').configProperties;
+
+describe('hdp2SiteProperties', function () {
+  /**
+   * @stackProperties: All the properties that are derived from stack 
definition
+   */
+  var stackProperties = siteProperties.filter(function(item){
+    return  (!(item.isRequiredByAgent === false || item.filename === 
'alert_notification' || item.category === 'Ambari Principals'))
+  });
+
+  stackProperties.forEach(function(siteProperty){
+    /**
+     * Following config attributes are stack driven and should be defined in 
the stack metainfo instead of ambari-web site-properties file
+     * isVisible
+     * isOverridable
+     * value
+     * recommendedValue
+     * isReconfigurable
+     * isRequired
+     * displayName
+     * description
+     * showLabel
+     * unit
+     */
+    it('Check attributes of "' + siteProperty.filename + '/' + 
siteProperty.name  + '"' + '. Stack driven attributes should be undefined ', 
function () {
+      expect(siteProperty.isVisible).to.equal(undefined);
+      expect(siteProperty.value).to.equal(undefined);
+      expect(siteProperty.recommendedValue).to.equal(undefined);
+      expect(siteProperty.description).to.equal(undefined);
+      expect(siteProperty.isReconfigurable).to.equal(undefined);
+      expect(siteProperty.isRequired).to.equal(undefined);
+      expect(siteProperty.displayName).to.equal(undefined);
+      expect(siteProperty.showLabel).to.equal(undefined);
+      expect(siteProperty.unit).to.equal(undefined);
+    });
+
+    /**
+     * Following config attributes uniquely represent a config property
+     * name
+     * filename
+     */
+    it('Check primary attributes of "' + siteProperty.filename + '/' + 
siteProperty.name  + '"' + '. Attributes that uniquely represent a property 
should be defined ', function () {
+      expect(siteProperty.name).to.not.equal(undefined);
+      expect(siteProperty.filename).to.not.equal(undefined);
+    });
+  });
+
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/35ac6fbf/ambari-web/test/data/HDP2/site_properties_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/data/HDP2/site_properties_test.js 
b/ambari-web/test/data/HDP2/site_properties_test.js
index ced9376..4fcce33 100644
--- a/ambari-web/test/data/HDP2/site_properties_test.js
+++ b/ambari-web/test/data/HDP2/site_properties_test.js
@@ -21,48 +21,47 @@ require('utils/helper');
 var siteProperties = require('data/HDP2/site_properties').configProperties;
 
 describe('hdp2SiteProperties', function () {
-
-  // No site properties should be made invisible
-  siteProperties.forEach(function(siteProperty){
-    it('Check invisible attribute of "' + siteProperty.name  + '"' + '. It 
should not be defined ', function () {
-      expect(siteProperty.isVisible).to.equal(undefined);
-    });
-  });
-
-  // No site properties should have value and recommendedValue defined on 
client side.
-  // These should be always retrieved from server.
-
-    siteProperties.forEach(function(siteProperty){
-      it('Check value and recommendedValue attribute of "' + siteProperty.name 
+ '"' + '. It should not be defined ', function () {
-        expect(siteProperty.value).to.equal(undefined);
-        expect(siteProperty.recommendedValue).to.equal(undefined);
-    });
+  /**
+   * @stackProperties: All the properties that are derived from stack 
definition
+   */
+  var stackProperties = siteProperties.filter(function(item){
+    return  (!(item.isRequiredByAgent === false || item.filename === 
'alert_notification' || item.category === 'Ambari Principals'))
   });
 
-  // No site properties should have description field duplicated on client 
side.
-  // These should be always retrieved from server.
-  siteProperties.forEach(function(siteProperty){
-    it('Check description attribute of "' + siteProperty.name + '"' + '. It 
should not be defined ', function () {
+  stackProperties.forEach(function(siteProperty){
+    /**
+     * Following config attributes are stack driven and should be defined in 
the stack metainfo instead of ambari-web site-properties file
+     * isVisible
+     * isOverridable
+     * value
+     * recommendedValue
+     * isReconfigurable
+     * isRequired
+     * displayName
+     * description
+     * showLabel
+     * unit
+     */
+    it('Check attributes of "' + siteProperty.filename + '/' + 
siteProperty.name  + '"' + '. Stack driven attributes should be undefined ', 
function () {
+      expect(siteProperty.isVisible).to.equal(undefined);
+      expect(siteProperty.value).to.equal(undefined);
+      expect(siteProperty.recommendedValue).to.equal(undefined);
       expect(siteProperty.description).to.equal(undefined);
+      expect(siteProperty.isReconfigurable).to.equal(undefined);
+      expect(siteProperty.isRequired).to.equal(undefined);
+      expect(siteProperty.displayName).to.equal(undefined);
+      expect(siteProperty.showLabel).to.equal(undefined);
+      expect(siteProperty.unit).to.equal(undefined);
     });
-  });
-
-  // All the site properties should be persisted in the configuration tag
-  // So isRequiredByAgent should be never defined over here
-  // These should be always retrieved from server and saved in the correct 
configuration resource via API.
-  siteProperties.forEach(function(siteProperty){
-    it('Check isRequiredByAgent attribute of "' + siteProperty.name + '"' + '. 
It should not be defined ', function () {
-      expect(siteProperty.isRequiredByAgent).to.equal(undefined);
-    });
-  });
-
-  // All Falcon site properties should be mapped to site file. There is a 
property with same name (*.domain)
-  // in different site files of Falcon service
 
-    var falconSiteProperties = 
siteProperties.filterProperty('serviceName','FALCON');
-    falconSiteProperties.forEach(function(siteProperty){
-      it('Check filename attribute for "' + siteProperty.name + '"' + ' 
property of Falcon service. It should be defined ', function () {
-        expect(siteProperty).to.have.property('filename');
+    /**
+     * Following config attributes uniquely represent a config property
+     * name
+     * filename
+     */
+    it('Check primary attributes of "' + siteProperty.filename + '/' + 
siteProperty.name  + '"' + '. Attributes that uniquely represent a property 
should be defined ', function () {
+      expect(siteProperty.name).to.not.equal(undefined);
+      expect(siteProperty.filename).to.not.equal(undefined);
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/35ac6fbf/ambari-web/test/utils/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/config_test.js 
b/ambari-web/test/utils/config_test.js
index b7a0514..ebadb29 100644
--- a/ambari-web/test/utils/config_test.js
+++ b/ambari-web/test/utils/config_test.js
@@ -329,55 +329,13 @@ describe('App.config', function () {
     });
   });
 
-  describe('#preDefinedSiteProperties-bigtop', function () {
-    before(function() {
-      setups.setupStackVersion(this, 'BIGTOP-0.8');
-      sinon.stub(App.StackService, 'find').returns([
-        {
-          serviceName: 'HIVE'
-        }
-      ]);
-    });
-
-    it('bigtop should use New PostgreSQL Database as its default hive 
metastore database', function () {
-      App.StackService.createRecord({serviceName: 'HIVE'});
-      
expect(App.config.get('preDefinedSiteProperties').findProperty('recommendedValue',
 'New PostgreSQL Database')).to.be.ok;
-    });
-
-    after(function() {
-      App.StackService.find.restore();
-      setups.restoreStackVersion(this);
-    });
-  });
-
-  describe('#preDefinedSiteProperties-hdp2', function () {
-    before(function () {
-      setups.setupStackVersion(this, 'HDP-2.0');
-      sinon.stub(App.StackService, 'find').returns([
-        {
-          serviceName: 'HIVE'
-        }
-      ]);
-    });
-
-    it('HDP2 should use New MySQL Database as its default hive metastore 
database', function () {
-      App.StackService.createRecord({serviceName: 'HIVE'});
-      
expect(App.config.get('preDefinedSiteProperties').findProperty('recommendedValue',
 'New MySQL Database')).to.be.ok;
-    });
-
-    after(function() {
-      App.StackService.find.restore();
-      setups.restoreStackVersion(this);
-    });
-  });
-
   describe('#generateConfigPropertiesByName', function() {
     var tests = [
       {
         names: ['property_1', 'property_2'],
         properties: undefined,
         e: {
-          keys: ['name', 'displayName', 'isVisible', 'isReconfigurable']
+          keys: ['name']
         },
         m: 'Should generate base property object without additional fields'
       },
@@ -385,7 +343,7 @@ describe('App.config', function () {
         names: ['property_1', 'property_2'],
         properties: { category: 'SomeCat', serviceName: 'SERVICE_NAME' },
         e: {
-          keys: ['name', 'displayName', 'isVisible', 'isReconfigurable', 
'category', 'serviceName']
+          keys: ['name', 'category', 'serviceName']
         },
         m: 'Should generate base property object without additional fields'
       }
@@ -514,7 +472,6 @@ describe('App.config', function () {
           property_name: 'hdfs_user'
         },
         output: {
-          id: 'puppet var',
           category: 'Users and Groups',
           isVisible: true,
           serviceName: 'MISC',
@@ -533,7 +490,6 @@ describe('App.config', function () {
           service_name: 'KNOX'
         },
         output: {
-          id: 'puppet var',
           category: 'Users and Groups',
           isVisible: true,
           serviceName: 'MISC',

Reply via email to