You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/09/17 17:25:58 UTC

[1/2] ambari git commit: AMBARI-13131. Quick link for Ranger with HDP 2.2 does not track https port value (alexantonenko)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 8f0a8e351 -> 04521ee88


AMBARI-13131. Quick link for Ranger with HDP 2.2 does not track https port value (alexantonenko)


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

Branch: refs/heads/branch-2.1
Commit: 04521ee8819adfca5b9424af3477e12bcca723b0
Parents: 299ed12
Author: Alex Antonenko <hi...@gmail.com>
Authored: Thu Sep 17 18:19:48 2015 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Thu Sep 17 18:25:53 2015 +0300

----------------------------------------------------------------------
 .../app/views/common/quick_view_link_view.js      |  6 +++---
 .../test/views/common/quick_link_view_test.js     | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/04521ee8/ambari-web/app/views/common/quick_view_link_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/quick_view_link_view.js b/ambari-web/app/views/common/quick_view_link_view.js
index 8fe5d0c..5421e67 100644
--- a/ambari-web/app/views/common/quick_view_link_view.js
+++ b/ambari-web/app/views/common/quick_view_link_view.js
@@ -455,16 +455,16 @@ App.QuickViewLinks = Em.View.extend({
    */
   setPort: function (item, protocol, config) {
     var configProperties = this.get('configProperties');
-    var config = config || item.get('http_config');
+    var configProp = config || item.get('http_config');
     var defaultPort = item.get('default_http_port');
     if (protocol === 'https' && (config || item.get('https_config'))) {
-      config = config || item.get('https_config');
+      configProp = config || item.get('https_config');
       if (item.get('default_https_port')) {
         defaultPort = item.get('default_https_port');
       }
     }
     var site = configProperties.findProperty('type', item.get('site'));
-    var propertyValue = site && site.properties && site.properties[config];
+    var propertyValue = site && site.properties && site.properties[configProp];
     if (!propertyValue) {
       if (item.get('service_id') == 'RANGER') {
         // HDP 2.3

http://git-wip-us.apache.org/repos/asf/ambari/blob/04521ee8/ambari-web/test/views/common/quick_link_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/quick_link_view_test.js b/ambari-web/test/views/common/quick_link_view_test.js
index 92075e7..3d38836 100644
--- a/ambari-web/test/views/common/quick_link_view_test.js
+++ b/ambari-web/test/views/common/quick_link_view_test.js
@@ -118,6 +118,24 @@ describe('App.QuickViewLinks', function () {
         }]
       }),
       Em.Object.create({
+        'service_id': 'YARN',
+        'protocol': 'https',
+        'http_config': 'http_config',
+        'https_config': 'https_config',
+        'site': 'yarn-site',
+        'result': '9090',
+        'default_http_port': '8088',
+        'default_https_port': '8090',
+        'regex': '\\w*:(\\d+)',
+        'configProperties': [{
+          'type': 'yarn-site',
+          'properties': {
+            'http_config': 'h:9088',
+            'https_config': 'h:9090'
+          }
+        }]
+      }),
+      Em.Object.create({
         'service_id': 'RANGER',
         'protocol': 'http',
         'http_config': 'http_config',


[2/2] ambari git commit: AMBARI-13130. Configs: compare does not return results (alexantonenko)

Posted by al...@apache.org.
AMBARI-13130. Configs: compare does not return results (alexantonenko)


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

Branch: refs/heads/branch-2.1
Commit: 299ed1270ed3e2eae9e056e5bf055cad296b8d0e
Parents: 8f0a8e3
Author: Alex Antonenko <hi...@gmail.com>
Authored: Thu Sep 17 18:17:16 2015 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Thu Sep 17 18:25:53 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/data/HDP2.3/site_properties.js   |   2 +-
 .../mixins/common/configs/configs_comparator.js |  26 ++++-
 .../app/templates/wizard/master_hosts.hbs       |   2 +-
 ambari-web/app/utils/object_utils.js            |  94 +++++++++++++++++
 ambari-web/app/views/common/controls_view.js    |  12 ++-
 .../main/service/info/config_test.js            |   2 +-
 ambari-web/test/utils/object_utils_test.js      | 101 +++++++++++++++++++
 7 files changed, 230 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/299ed127/ambari-web/app/data/HDP2.3/site_properties.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/HDP2.3/site_properties.js b/ambari-web/app/data/HDP2.3/site_properties.js
index b8e94e1..5516f4a 100644
--- a/ambari-web/app/data/HDP2.3/site_properties.js
+++ b/ambari-web/app/data/HDP2.3/site_properties.js
@@ -202,7 +202,7 @@ hdp23properties.push({
     "filename": "ranger-kms-audit.xml",
     "category": "Advanced ranger-kms-audit",
     "serviceName": "RANGER_KMS"
-  },        
+  },
   {
     "id": "site property",
     "name": "ranger-yarn-plugin-enabled",

http://git-wip-us.apache.org/repos/asf/ambari/blob/299ed127/ambari-web/app/mixins/common/configs/configs_comparator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/configs_comparator.js b/ambari-web/app/mixins/common/configs/configs_comparator.js
index 5bd5b08..263e356 100644
--- a/ambari-web/app/mixins/common/configs/configs_comparator.js
+++ b/ambari-web/app/mixins/common/configs/configs_comparator.js
@@ -17,6 +17,7 @@
  */
 
 var App = require('app');
+var objectUtils = require('utils/object_utils');
 
 App.ConfigsComparator = Em.Mixin.create({
 
@@ -45,7 +46,6 @@ App.ConfigsComparator = Em.Mixin.create({
       } else {
         compareServiceVersions = [this.get('compareServiceVersion').get('version')];
       }
-
       this.getCompareVersionConfigs(compareServiceVersions).done(function (json) {
         allConfigs.setEach('isEditable', false);
         self.initCompareConfig(allConfigs, json);
@@ -147,7 +147,7 @@ App.ConfigsComparator = Em.Mixin.create({
     } else {
       allConfigs.forEach(function (serviceConfig) {
         var serviceCfgVersionMap = serviceVersionMap[this.get('compareServiceVersion').get('version')];
-        var compareConfig = serviceCfgVersionMap[serviceConfig.name + '-' + App.config.getConfigTagFromFileName(serviceConfig.filename)]
+        var compareConfig = serviceCfgVersionMap[serviceConfig.name + '-' + App.config.getConfigTagFromFileName(serviceConfig.filename)];
         this.setCompareDefaultGroupConfig(serviceConfig, compareConfig);
       }, this);
     }
@@ -248,7 +248,7 @@ App.ConfigsComparator = Em.Mixin.create({
     Em.set(serviceConfig, 'isComparison', true);
 
     //if config isn't reconfigurable then it can't have changed value to compare
-    if (compareConfig && (Em.get(serviceConfig, 'isReconfigurable') || Em.get(serviceConfig, 'isUserProperty'))) {
+    if (compareConfig) {
       compareObject = this.getComparisonConfig(serviceConfig, compareConfig);
       Em.set(serviceConfig, 'hasCompareDiffs', Em.get(serviceConfig, 'isMock') || this.hasCompareDiffs(serviceConfig, compareObject));
       Em.get(serviceConfig, 'compareConfigs').push(compareObject);
@@ -257,6 +257,7 @@ App.ConfigsComparator = Em.Mixin.create({
       Em.get(serviceConfig, 'compareConfigs').push(this.getMockComparisonConfig(serviceConfig, this.get('compareServiceVersion.version')));
       Em.set(serviceConfig, 'hasCompareDiffs', true);
     }
+
     return serviceConfig;
   },
 
@@ -269,7 +270,24 @@ App.ConfigsComparator = Em.Mixin.create({
    * @method hasCompareDiffs
    */
   hasCompareDiffs: function (originalConfig, compareConfig) {
-    return (Em.get(originalConfig, 'value') !== Em.get(compareConfig, 'value')) || (!!Em.get(originalConfig, 'isFinal') !== !!Em.get(compareConfig, 'isFinal'));
+    var originalValue = Em.get(originalConfig, 'value');
+    var compareValue = Em.get(compareConfig, 'value');
+
+    if (originalValue.toArray) {
+      originalValue = originalValue.toArray();
+    }
+    if (compareValue.toArray) {
+      compareValue = compareValue.toArray();
+    }
+
+    if (originalValue instanceof Array) {
+      originalValue.sort();
+    }
+    if (compareValue instanceof Array) {
+      compareValue.sort();
+    }
+
+    return (!objectUtils.deepEqual(originalValue, compareValue)) || (!!Em.get(originalConfig, 'isFinal') !== !!Em.get(compareConfig, 'isFinal'));
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/299ed127/ambari-web/app/templates/wizard/master_hosts.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/wizard/master_hosts.hbs b/ambari-web/app/templates/wizard/master_hosts.hbs
index c147528..a879842 100644
--- a/ambari-web/app/templates/wizard/master_hosts.hbs
+++ b/ambari-web/app/templates/wizard/master_hosts.hbs
@@ -20,7 +20,7 @@
   {{t installer.noHostsAssigned}}
 {{/if}}
 {{#if view.hasOneHost}}
-  {{value}}
+  {{view.formatValue}}
 {{/if}}
 {{#if view.hasMultipleHosts}}
   <a href="#" {{action showHosts target="view"}}>{{value.firstObject}} {{t and}} {{view.otherLength}}</a>

http://git-wip-us.apache.org/repos/asf/ambari/blob/299ed127/ambari-web/app/utils/object_utils.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/object_utils.js b/ambari-web/app/utils/object_utils.js
index c647a6a..294fb95 100644
--- a/ambari-web/app/utils/object_utils.js
+++ b/ambari-web/app/utils/object_utils.js
@@ -51,6 +51,100 @@ module.exports = {
     return r(obj);
   },
 
+  deepEqual: function() {
+    var i, l, leftChain, rightChain;
+    var values = arguments;
+    function compare2Objects (x, y) {
+      var p;
+      if (isNaN(x) && isNaN(y) && typeof x === 'number' && typeof y === 'number') {
+        return true;
+      }
+
+      if (x === y) {
+        return true;
+      }
+
+      if ((typeof x === 'function' && typeof y === 'function') ||
+        (x instanceof Date && y instanceof Date) ||
+        (x instanceof RegExp && y instanceof RegExp) ||
+        (x instanceof String && y instanceof String) ||
+        (x instanceof Number && y instanceof Number)) {
+         return x.toString() === y.toString();
+      }
+
+      if (!(x instanceof Object && y instanceof Object)) {
+        return false;
+      }
+
+      if (x.isPrototypeOf(y) || y.isPrototypeOf(x)) {
+        return false;
+      }
+
+      if (x.constructor !== y.constructor) {
+        return false;
+      }
+
+      if (x.prototype !== y.prototype) {
+        return false;
+      }
+
+      if (leftChain.indexOf(x) > -1 || rightChain.indexOf(y) > -1) {
+        return false;
+      }
+
+      for (p in y) {
+        if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {
+            return false;
+        }
+        else if (typeof y[p] !== typeof x[p]) {
+            return false;
+        }
+      }
+
+      for (p in x) {
+        if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {
+          return false;
+        }
+        else if (typeof y[p] !== typeof x[p]) {
+          return false;
+        }
+        switch (typeof (x[p])) {
+          case 'object':
+          case 'function':
+            leftChain.push(x);
+            rightChain.push(y);
+            if (!compare2Objects (x[p], y[p])) {
+                return false;
+            }
+            leftChain.pop();
+            rightChain.pop();
+            break;
+          default:
+            if (x[p] !== y[p]) {
+                return false;
+            }
+            break;
+        }
+      }
+
+      return true;
+    }
+
+    if (arguments.length < 1) {
+      return true;
+    }
+
+    for (i = 1, l = arguments.length; i < l; i++) {
+      leftChain = [];
+      rightChain = [];
+      if (!compare2Objects(arguments[0], arguments[i])) {
+        return false;
+      }
+    }
+
+    return true;
+  },
+
   recursiveTree: function(obj) {
     if (!(obj instanceof Object)) {
       return null;

http://git-wip-us.apache.org/repos/asf/ambari/blob/299ed127/ambari-web/app/views/common/controls_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/controls_view.js b/ambari-web/app/views/common/controls_view.js
index 758e0af..839f26f 100644
--- a/ambari-web/app/views/common/controls_view.js
+++ b/ambari-web/app/views/common/controls_view.js
@@ -830,12 +830,20 @@ App.ServiceConfigMultipleHostsDisplay = Ember.Mixin.create(App.ServiceConfigHost
     return this.get('value').length === 0;
   }.property('value'),
 
+  formatValue: function() {
+    if (Em.isArray(this.get('value')) && this.get('value').length === 1) {
+      return this.get('value.firstObject');
+    } else {
+      return this.get('value');
+    }
+  }.property('value'),
+
   hasOneHost: function () {
-    return this.get('value').length === 1;
+    return !Em.isArray(this.get('value')) || this.get('value').length === 1;
   }.property('value'),
 
   hasMultipleHosts: function () {
-    return this.get('value').length > 1;
+    return Em.isArray(this.get('value')) && this.get('value').length > 1;
   }.property('value'),
 
   otherLength: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/299ed127/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 6c6c459..846a438 100644
--- a/ambari-web/test/controllers/main/service/info/config_test.js
+++ b/ambari-web/test/controllers/main/service/info/config_test.js
@@ -789,7 +789,7 @@ describe("App.MainServiceInfoConfigsController", function () {
       expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({}).compareConfigs.length).to.equal(0);
     });
     it("empty service config and comparison passed, expect that setCompareDefaultGroupConfig will not run anything", function() {
-      expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({},{}).compareConfigs.length).to.equal(0);
+      expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({},{}).compareConfigs).to.eql(["compConfig"]);
     });
     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});

http://git-wip-us.apache.org/repos/asf/ambari/blob/299ed127/ambari-web/test/utils/object_utils_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/object_utils_test.js b/ambari-web/test/utils/object_utils_test.js
index 92c0cfe..1c84d78 100644
--- a/ambari-web/test/utils/object_utils_test.js
+++ b/ambari-web/test/utils/object_utils_test.js
@@ -77,4 +77,105 @@ describe('utils/object_utils', function() {
       });
     });
   });
+
+  describe('#deepEqual', function() {
+    it('simple values', function() {
+      expect(objectUtils.deepEqual(true, true)).to.true;
+    });
+    it('simple values strict', function() {
+      expect(objectUtils.deepEqual(true, 1)).to.false;
+    });
+    it('simple with complex', function() {
+      expect(objectUtils.deepEqual(true, {})).to.false;
+    });
+    it('complex with simple', function() {
+      expect(objectUtils.deepEqual({}, 2)).to.false;
+    });
+    it('simple objects', function() {
+      var a = {
+        value: 1
+      };
+      var b = {
+        value: 1
+      };
+      expect(objectUtils.deepEqual(a, b)).to.true;
+    });
+    it('simple objects failed', function() {
+      var a = {
+        value: 1,
+        c: 1
+      };
+      var b = {
+        value: 1
+      };
+      expect(objectUtils.deepEqual(a, b)).to.false;
+    });
+    it('complex objects', function() {
+      var a = {
+        value: 1,
+        c: {
+          d: {
+            x: {
+              val: 1
+            }
+          }
+        }
+      };
+      var b = {
+        value: 1,
+        c: {
+          d: {
+            x: {
+              val: 1
+            }
+          }
+        }
+      };
+      expect(objectUtils.deepEqual(a, b)).to.true;
+    });
+    it('complex objects failed', function() {
+      var a = {
+        value: 1,
+        c: {
+          d: {
+            x: {
+              val: 1
+            }
+          }
+        }
+      };
+      var b = {
+        value: 1,
+        c: {
+          d: {
+            x: {
+              val: 2
+            }
+          }
+        }
+      };
+      expect(objectUtils.deepEqual(a, b)).to.false;
+    });
+    it('complex array', function() {
+      var a = [1,2,{a: 2}, 4, {b:{}}];
+      var b = [1,2,{a: 2}, 4, {b:{}}];
+      expect(objectUtils.deepEqual(a, b)).to.true;
+    });
+    it('complex array failed', function() {
+      var a = [1,3,{a: 2}, 4, {b:{}}];
+      var b = [1,2,{a: 2}, 4, {b:{}}];
+      expect(objectUtils.deepEqual(a, b)).to.false;
+    });
+    it('simple array', function() {
+      var a = [1,3];
+      var b = [1,3];
+      expect(objectUtils.deepEqual(a, b)).to.true;
+    });
+    it('simple array failed', function() {
+      var a = [3,1];
+      var b = [1,3];
+      expect(objectUtils.deepEqual(a, b)).to.false;
+    });
+  });
+
 });