ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject [1/6] ambari git commit: AMBARI-13069. Attributes of configuration property should be stack API driven. (jaimin)
Date Sat, 12 Sep 2015 01:04:45 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 93a2106a6 -> 70ca85005


http://git-wip-us.apache.org/repos/asf/ambari/blob/70ca8500/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 15c5451..991a397 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/70ca8500/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 a1925a4..c9e2a3f 100644
--- a/ambari-web/app/models/configs/stack_config_property.js
+++ b/ambari-web/app/models/configs/stack_config_property.js
@@ -187,7 +187,91 @@ App.StackConfigProperty = DS.Model.extend({
   /**
    * @type {boolean}
    */
-  index: DS.attr('number', {defaultValue: null})
+  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')
 });
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/70ca8500/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index a578f34..a09b83b 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -813,7 +813,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';
@@ -1325,10 +1324,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/70ca8500/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/70ca8500/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/70ca8500/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/70ca8500/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 6aabc2d..2a6f50e 100644
--- a/ambari-web/test/utils/config_test.js
+++ b/ambari-web/test/utils/config_test.js
@@ -344,28 +344,13 @@ describe('App.config', function () {
     });
   });
 
-  describe('#preDefinedSiteProperties-hdp2', function () {
-    before(function() {
-      setups.setupStackVersion(this, 'HDP-2.0');
-    });
-
-    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() {
-      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'
       },
@@ -373,7 +358,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'
       }
@@ -502,7 +487,6 @@ describe('App.config', function () {
           property_name: 'hdfs_user'
         },
         output: {
-          id: 'puppet var',
           category: 'Users and Groups',
           isVisible: true,
           serviceName: 'MISC',
@@ -521,7 +505,6 @@ describe('App.config', function () {
           service_name: 'KNOX'
         },
         output: {
-          id: 'puppet var',
           category: 'Users and Groups',
           isVisible: true,
           serviceName: 'MISC',


Mime
View raw message