ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-11782. DataNode directories overrides values with "\n" symbol (onechiporenko)
Date Mon, 08 Jun 2015 12:03:31 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 226c791c1 -> 6fdb2ea76


AMBARI-11782. DataNode directories overrides values with "\n" symbol (onechiporenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6fdb2ea7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6fdb2ea7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6fdb2ea7

Branch: refs/heads/branch-2.1
Commit: 6fdb2ea763d4e46e4ae8825e4fd0c0ff572f8474
Parents: 226c791
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Mon Jun 8 14:56:04 2015 +0300
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Mon Jun 8 15:02:51 2015 +0300

----------------------------------------------------------------------
 .../configs/objects/service_config_property.js  | 24 ++++++++++--
 .../objects/service_config_property_test.js     | 39 ++++++++++++++++++++
 .../widgets/list_config_widget_view_test.js     |  1 +
 3 files changed, 61 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdb2ea7/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 f7dcd2d..799c79f 100644
--- a/ambari-web/app/models/configs/objects/service_config_property.js
+++ b/ambari-web/app/models/configs/objects/service_config_property.js
@@ -475,14 +475,14 @@ App.ServiceConfigProperty = Em.Object.extend({
   _validateOverrides: function () {
     var self = this;
     var isError = false;
-    var value = '' + this.get('value');
+    var value = this._getValueForCheck(this.get('value'));
     var isOriginalSCP = this.get('isOriginalSCP');
     var supportsFinal = this.get('supportsFinal');
     var isFinal = this.get('isFinal');
     var parentSCP = this.get('parentSCP');
     if (!isOriginalSCP) {
       if (!Em.isNone(parentSCP)) {
-        if (value === '' + parentSCP.get('value')) {
+        if (value === this._getValueForCheck(parentSCP.get('value'))) {
           if (supportsFinal) {
             if (isFinal === parentSCP.get('isFinal')) {
               this.set('errorMessage', Em.I18n.t('config.override.valueEqualToParentConfig'));
@@ -499,7 +499,7 @@ App.ServiceConfigProperty = Em.Object.extend({
           if (overrides) {
             overrides.forEach(function (override) {
               if (self == override) return;
-              if (value === '' + override.get('value')) {
+              if (value === self._getValueForCheck(override.get('value'))) {
                 if (supportsFinal) {
                   if (isFinal === parentSCP.get('isFinal')) {
                     self.set('errorMessage', Em.I18n.t('config.override.valueEqualToAnotherOverrideConfig'));
@@ -517,6 +517,24 @@ App.ServiceConfigProperty = Em.Object.extend({
       }
     }
     return isError;
+  },
+
+  /**
+   * Some values should be little bit changed before checking for overrides values
+   * `directories`-values should be "trimmed" for multiple mew-line symbols
+   * @param {string} value
+   * @returns {string}
+   * @private
+   */
+  _getValueForCheck: function (value) {
+    value = '' + value;
+    switch(this.get('displayType')) {
+      case 'directories':
+        return value.replace(/(\n\r?)+/g, '\n');
+        break;
+      default:
+        return value;
+    }
   }
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdb2ea7/ambari-web/test/models/configs/objects/service_config_property_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/objects/service_config_property_test.js b/ambari-web/test/models/configs/objects/service_config_property_test.js
index 08f9cb0..c932d87 100644
--- a/ambari-web/test/models/configs/objects/service_config_property_test.js
+++ b/ambari-web/test/models/configs/objects/service_config_property_test.js
@@ -568,6 +568,19 @@ describe('App.ServiceConfigProperty', function () {
             ]
           })
         }
+      },
+      {
+        m: '`directories`-config with almost equal value',
+        e: true,
+        c: {
+          value: "/hadoop/hdfs/data\n\n",
+          displayType: 'directories',
+          supportsFinal: false,
+          isOriginalSCP: false,
+          parentSCP: App.ServiceConfigProperty.create({
+            value: "/hadoop/hdfs/data\n"
+          })
+        }
       }
     ]).forEach(function (test) {
       it(test.m, function () {
@@ -613,4 +626,30 @@ describe('App.ServiceConfigProperty', function () {
 
   });
 
+  describe('#_getValueForCheck', function () {
+
+    beforeEach(function () {
+      serviceConfigProperty.setProperties({
+        value: "/hadoop/hdfs/data\n",
+        displayType: 'directories',
+        supportsFinal: false,
+        isOriginalSCP: true,
+        overrides: [
+          Em.Object.create({
+            value: "/hadoop/hdfs/data\n\n"
+          })
+        ]
+      });
+    });
+
+    it('should trim value', function () {
+      expect(serviceConfigProperty._getValueForCheck(serviceConfigProperty.get('value'))).to.equal('/hadoop/hdfs/data\n');
+    });
+
+    it('should trim value 2', function () {
+      expect(serviceConfigProperty._getValueForCheck(serviceConfigProperty.get('overrides.0.value'))).to.equal('/hadoop/hdfs/data\n');
+    });
+
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fdb2ea7/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js
b/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js
index 63e8f25..3db2dcb 100644
--- a/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js
+++ b/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js
@@ -27,6 +27,7 @@ describe('App.ListConfigWidgetView', function () {
       initPopover: Em.K,
       config: Em.Object.create({
         _validateOverrides: App.ServiceConfigProperty.prototype._validateOverrides,
+        _getValueForCheck: App.ServiceConfigProperty.prototype._getValueForCheck,
         validate: App.ServiceConfigProperty.prototype.validate,
         name: 'a.b.c',
         savedValue: '2,1',


Mime
View raw message