ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject git commit: AMBARI-7873 Config history: comparing two versions with removed properties shows 'Undefined' on HDP-2.1. (ababiichuk)
Date Tue, 21 Oct 2014 10:59:43 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 05974f917 -> 122dae73f


AMBARI-7873 Config history: comparing two versions with removed properties shows 'Undefined'
on HDP-2.1. (ababiichuk)


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

Branch: refs/heads/branch-1.7.0
Commit: 122dae73f6e9e51089325e0b785fac85267d2c79
Parents: 05974f9
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Mon Oct 20 21:31:39 2014 +0300
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Tue Oct 21 13:58:00 2014 +0300

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    | 19 ++++++------
 ambari-web/app/messages.js                      |  1 +
 .../common/configs/compare_property.hbs         |  8 ++---
 .../main/service/info/config_test.js            | 31 ++++++++++++++++++++
 4 files changed, 46 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/122dae73/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 67d095b..839cdb0 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -664,7 +664,9 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
       }, this);
     } else {
       allConfigs.forEach(function (serviceConfig) {
-        this.setCompareDefaultGroupConfig(serviceConfig, serviceVersionMap[this.get('compareServiceVersion').get('version')]);
+        var serviceCfgVersionMap = serviceVersionMap[this.get('compareServiceVersion').get('version')];
+        var compareConfig = serviceCfgVersionMap[serviceConfig.name + '-' + App.config.getConfigTagFromFileName(serviceConfig.filename)]
+        this.setCompareDefaultGroupConfig(serviceConfig, compareConfig);
       }, this);
     }
   },
@@ -713,7 +715,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
     compareObject.isMock = true;
     compareObject.displayType = 'label';
     compareObject = App.ServiceConfigProperty.create(compareObject);
-    compareObject.set('value', 'Undefined');
+    compareObject.set('value', Em.I18n.t('common.property.undefined'));
     return compareObject;
   },
 
@@ -744,25 +746,24 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
   /**
    * set compare properties to service config of default group
    * @param serviceConfig
-   * @param serviceVersionMap
+   * @param compareConfig
    */
-  setCompareDefaultGroupConfig: function (serviceConfig, serviceVersionMap) {
-    // map the property in the compare version to compare with current serviceConfig
-    var compareConfig = serviceVersionMap[serviceConfig.name + '-' + App.config.getConfigTagFromFileName(serviceConfig.filename)];
+  setCompareDefaultGroupConfig: function (serviceConfig, compareConfig) {
     var compareObject = {};
 
     serviceConfig.compareConfigs = [];
     serviceConfig.isComparison = true;
 
     //if config isn't reconfigurable then it can't have changed value to compare
-    if (compareConfig && serviceConfig.isReconfigurable) {
+    if (compareConfig && (serviceConfig.isReconfigurable || serviceConfig.isUserProperty))
{
       compareObject = this.getComparisonConfig(serviceConfig, compareConfig);
       serviceConfig.hasCompareDiffs = serviceConfig.isMock || this.hasCompareDiffs(serviceConfig,
compareObject);
       serviceConfig.compareConfigs.push(compareObject);
     } else if (serviceConfig.isUserProperty) {
-      serviceConfig.compareConfigs.push(this.getMockComparisonConfig(serviceConfig, this.get('compareServiceVersion').get('version')));
+      serviceConfig.compareConfigs.push(this.getMockComparisonConfig(serviceConfig, this.get('compareServiceVersion.version')));
       serviceConfig.hasCompareDiffs = true;
     }
+    return serviceConfig;
   },
 
   /**
@@ -798,7 +799,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
       name: name,
       filename: filename,
       serviceName: serviceName,
-      value: "Undefined",
+      value: Em.I18n.t('common.property.undefined'),
       isMock: true,
       displayType: 'label'
     };

http://git-wip-us.apache.org/repos/asf/ambari/blob/122dae73/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 89329b1..bb4db2e 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -221,6 +221,7 @@ Em.I18n.translations = {
   'common.latest': 'Latest',
   'common.custom': 'Custom',
   'common.continueAnyway': 'Continue Anyway',
+  'common.property.undefined': "Undefined",
 
   'passiveState.turnOn':'Turn On Maintenance Mode',
   'passiveState.turnOff':'Turn Off Maintenance Mode',

http://git-wip-us.apache.org/repos/asf/ambari/blob/122dae73/ambari-web/app/templates/common/configs/compare_property.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/configs/compare_property.hbs b/ambari-web/app/templates/common/configs/compare_property.hbs
index 3e6ddbe..04667f4 100644
--- a/ambari-web/app/templates/common/configs/compare_property.hbs
+++ b/ambari-web/app/templates/common/configs/compare_property.hbs
@@ -19,11 +19,11 @@
 {{#each compareConfig in view.serviceConfigProperty.compareConfigs}}
     <div {{bindAttr class=":control-group :overrideField"}}>
       {{view compareConfig.viewClass serviceConfigBinding="compareConfig"}}
+      <span class="label label-info">{{compareConfig.serviceVersion.versionText}}</span>
+      {{#if compareConfig.serviceVersion.isCurrent}}
+        <span class="label label-success">{{t common.current}}</span>
+      {{/if}}
       {{#unless compareConfig.isMock}}
-          <span class="label label-info">{{compareConfig.serviceVersion.versionText}}</span>
-        {{#if compareConfig.serviceVersion.isCurrent}}
-            <span class="label label-success">{{t common.current}}</span>
-        {{/if}}
         {{#if compareConfig.supportsFinal}}
             <a disabled="disabled" {{bindAttr class=":btn :btn-small :btn-final compareConfig.isFinal:active
compareConfig.hideFinalIcon:hidden" }}>
                 <i class="icon-lock"></i>

http://git-wip-us.apache.org/repos/asf/ambari/blob/122dae73/ambari-web/test/controllers/main/service/info/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js
index e11ad38..d865339 100644
--- a/ambari-web/test/controllers/main/service/info/config_test.js
+++ b/ambari-web/test/controllers/main/service/info/config_test.js
@@ -1187,4 +1187,35 @@ describe("App.MainServiceInfoConfigsController", function () {
       });
     });
   });
+
+  describe("setCompareDefaultGroupConfig", function () {
+    beforeEach(function () {
+      sinon.stub(mainServiceInfoConfigsController, "getComparisonConfig").returns("compConfig");
+      sinon.stub(mainServiceInfoConfigsController, "getMockComparisonConfig").returns("mockConfig");
+      sinon.stub(mainServiceInfoConfigsController, "hasCompareDiffs").returns(true);
+    });
+    afterEach(function () {
+      mainServiceInfoConfigsController.getComparisonConfig.restore();
+      mainServiceInfoConfigsController.getMockComparisonConfig.restore();
+      mainServiceInfoConfigsController.hasCompareDiffs.restore();
+    });
+    it("expect that setCompareDefaultGroupConfig will not run anything", function () {
+      expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({}).compareConfigs.length).to.equal(0);
+    });
+    it("expect that setCompareDefaultGroupConfig will not run anything", function () {
+      expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({}, {}).compareConfigs.length).to.equal(0);
+    });
+    it("expect that serviceConfig.compareConfigs will be getMockComparisonConfig", function
() {
+      expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isUserProperty:
true}, null)).to.eql({compareConfigs: ["mockConfig"], isUserProperty: true, isComparison:
true, hasCompareDiffs: true});
+    });
+    it("expect that serviceConfig.compareConfigs will be getComparisonConfig", function ()
{
+      expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isUserProperty:
true}, {})).to.eql({compareConfigs: ["compConfig"], isUserProperty: true, isComparison: true,
hasCompareDiffs: true});
+    });
+    it("expect that serviceConfig.compareConfigs will be getComparisonConfig", function ()
{
+      expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isReconfigurable:
true}, {})).to.eql({compareConfigs: ["compConfig"], isReconfigurable: true, isComparison:
true, hasCompareDiffs: true});
+    });
+    it("expect that serviceConfig.compareConfigs will be getComparisonConfig", function ()
{
+      expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isReconfigurable:
true, isMock: true}, {})).to.eql({compareConfigs: ["compConfig"], isReconfigurable: true,
isMock: true, isComparison: true, hasCompareDiffs: true});
+    });
+  });
 });


Mime
View raw message