ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject ambari git commit: AMBARI-8383 AMS config properties initial value issues. (atkach)
Date Wed, 19 Nov 2014 12:52:08 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 27821a267 -> 8378fd6de


AMBARI-8383 AMS config properties initial value issues. (atkach)


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

Branch: refs/heads/trunk
Commit: 8378fd6de93e84a7e0bac1b5e27a548ba87ebf95
Parents: 27821a2
Author: Andrii Tkach <atkach@hortonworks.com>
Authored: Wed Nov 19 14:14:57 2014 +0200
Committer: Andrii Tkach <atkach@hortonworks.com>
Committed: Wed Nov 19 14:14:57 2014 +0200

----------------------------------------------------------------------
 .../app/controllers/wizard/step7_controller.js  |   4 +-
 ambari-web/app/models/service_config.js         |  20 +-
 ambari-web/test/models/service_config_test.js   | 304 ++++++++++++-------
 3 files changed, 199 insertions(+), 129 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8378fd6d/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index 2b6f570..88a3b5f 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -837,9 +837,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
{
     });
     configs.forEach(function (_config) {
       var nonServiceTab = require('data/service_configs');
-      if (_config.filename) {
-        var type = _config.filename.replace(/.xml$/, '');
-      }
+      var type = _config.filename ? App.config.getConfigTagFromFileName(_config.filename)
: null;
       var mappedConfigValue = type && configsMap[type] ? configsMap[type][_config.name]
: null;
       if (!Em.isNone(mappedConfigValue) && ((installedServiceNames && installedServiceNames.contains(_config.serviceName)
|| nonServiceTab.someProperty('serviceName', _config.serviceName)))) {
         // prevent overriding already edited properties

http://git-wip-us.apache.org/repos/asf/ambari/blob/8378fd6d/ambari-web/app/models/service_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service_config.js b/ambari-web/app/models/service_config.js
index 221e63c..5527ed1 100644
--- a/ambari-web/app/models/service_config.js
+++ b/ambari-web/app/models/service_config.js
@@ -531,8 +531,10 @@ App.ServiceConfigProperty = Ember.Object.extend({
         }
         break;
       case 'hbase.zookeeper.quorum':
-        var zkHosts = masterComponentHostsInDB.filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName');
-        this.setDefaultValue("(\\w*)", zkHosts);
+        if (this.get('filename') == 'hbase-site.xml') {
+          var zkHosts = masterComponentHostsInDB.filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName');
+          this.setDefaultValue("(\\w*)", zkHosts);
+        }
         break;
       case 'zookeeper.connect':
       case 'hive.zookeeper.quorum':
@@ -568,12 +570,16 @@ App.ServiceConfigProperty = Ember.Object.extend({
       case 'log.dirs':  // for Kafka Broker
         this.unionAllMountPoints(!isOnlyFirstOneNeeded, localDB);
         break;
+      case 'hbase.tmp.dir':
+        if (this.get('filename') == 'hbase-site.xml') {
+          this.unionAllMountPoints(isOnlyFirstOneNeeded, localDB);
+        }
+        break;
       case 'fs.checkpoint.dir':
       case 'dfs.namenode.checkpoint.dir':
       case 'yarn.timeline-service.leveldb-timeline-store.path':
       case 'dataDir':
       case 'oozie_data_dir':
-      case 'hbase.tmp.dir':
       case 'storm.local.dir':
       case '*.falcon.graph.storage.directory':
       case '*.falcon.graph.serialize.path':
@@ -676,11 +682,9 @@ App.ServiceConfigProperty = Ember.Object.extend({
         break;
       case 'hbase.tmp.dir':
         temp = slaveComponentHostsInDB.findProperty('componentName', 'HBASE_REGIONSERVER');
-        if (temp) {
-          temp.hosts.forEach(function (host) {
-            setOfHostNames.push(host.hostName);
-          }, this);
-        }
+        temp.hosts.forEach(function (host) {
+          setOfHostNames.push(host.hostName);
+        }, this);
         break;
       case 'storm.local.dir':
         temp = slaveComponentHostsInDB.findProperty('componentName', 'SUPERVISOR');

http://git-wip-us.apache.org/repos/asf/ambari/blob/8378fd6d/ambari-web/test/models/service_config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/service_config_test.js b/ambari-web/test/models/service_config_test.js
index 6929566..c49a99b 100644
--- a/ambari-web/test/models/service_config_test.js
+++ b/ambari-web/test/models/service_config_test.js
@@ -615,131 +615,199 @@ describe('App.ServiceConfigProperty', function () {
     });
   });
 
-});
+  describe('#initialValue', function () {
 
-describe('#initialValue - kafka.ganglia.metrics.host', function () {
+    var cases = {
+      'kafka.ganglia.metrics.host': [
+        {
+          message: 'kafka.ganglia.metrics.host property should have the value of ganglia
hostname when ganglia is selected',
+          localDB: {
+            masterComponentHosts: [
+              {
+                component: 'GANGLIA_SERVER',
+                hostName: 'c6401'
+              }
+            ]
+          },
+          expected: 'c6401'
+        },
+        {
+          message: 'kafka.ganglia.metrics.host property should have the value "localhost"
when ganglia is not selected',
+          localDB: {
+            masterComponentHosts: [
+              {
+                component: 'NAMENODE',
+                hostName: 'c6401'
+              }
+            ]
+          },
+          expected: 'localhost'
+        }
+      ],
+      'hive_database': [
+        {
+          alwaysEnableManagedMySQLForHive: true,
+          currentStateName: '',
+          isManagedMySQLForHiveEnabled: false,
+          receivedValue: 'New MySQL Database',
+          value: 'New MySQL Database',
+          options: [
+            {
+              displayName: 'New MySQL Database'
+            }
+          ],
+          hidden: false
+        },
+        {
+          alwaysEnableManagedMySQLForHive: false,
+          currentStateName: 'configs',
+          isManagedMySQLForHiveEnabled: false,
+          receivedValue: 'New MySQL Database',
+          value: 'New MySQL Database',
+          options: [
+            {
+              displayName: 'New MySQL Database'
+            }
+          ],
+          hidden: false
+        },
+        {
+          alwaysEnableManagedMySQLForHive: false,
+          currentStateName: '',
+          isManagedMySQLForHiveEnabled: true,
+          receivedValue: 'New MySQL Database',
+          value: 'New MySQL Database',
+          options: [
+            {
+              displayName: 'New MySQL Database'
+            }
+          ],
+          hidden: false
+        },
+        {
+          alwaysEnableManagedMySQLForHive: false,
+          currentStateName: '',
+          isManagedMySQLForHiveEnabled: false,
+          receivedValue: 'New MySQL Database',
+          value: 'Existing MySQL Database',
+          options: [
+            {
+              displayName: 'New MySQL Database'
+            }
+          ],
+          hidden: true
+        },
+        {
+          alwaysEnableManagedMySQLForHive: false,
+          currentStateName: '',
+          isManagedMySQLForHiveEnabled: false,
+          receivedValue: 'New PostgreSQL Database',
+          value: 'New PostgreSQL Database',
+          options: [
+            {
+              displayName: 'New MySQL Database'
+            }
+          ],
+          hidden: true
+        }
+      ],
+      'hbase.zookeeper.quorum': [
+        {
+          filename: 'hbase-site.xml',
+          value: 'host0,host1',
+          defaultValue: 'host0,host1',
+          title: 'should set ZooKeeper Server hostnames'
+        },
+        {
+          filename: 'ams-hbase-site.xml',
+          value: 'localhost',
+          defaultValue: '',
+          title: 'should ignore ZooKeeper Server hostnames'
+        }
+      ],
+      'hbase.tmp.dir': [
+        {
+          filename: 'hbase-site.xml',
+          isUnionAllMountPointsCalled: true,
+          title: 'unionAllMountPoints should be called'
+        },
+        {
+          filename: 'ams-hbase-site.xml',
+          isUnionAllMountPointsCalled: false,
+          title: 'unionAllMountPoints shouldn\'t be called'
+        }
+      ]
+    };
 
-  var tests = [
-    {
-      message: 'kafka.ganglia.metrics.host property should have the value of ganglia hostname
when ganglia is selected',
-      localDB: {masterComponentHosts: [
-        {component: 'GANGLIA_SERVER', hostName: 'c6401'}
-      ]},
-      expected: 'c6401'
-    },
-    {
-      message: 'kafka.ganglia.metrics.host property should have the value "localhost" when
ganglia is not selected',
-      localDB: {masterComponentHosts: [
-        {component: 'NAMENODE', hostName: 'c6401'}
-      ]},
-      expected: 'localhost'
-    }
-  ];
-  var serviceConfigProperty;
-  beforeEach(function () {
-    serviceConfigProperty = App.ServiceConfigProperty.create({name: 'kafka.ganglia.metrics.host',
value: 'localhost'});
-  });
-  tests.forEach(function(test){
-    it(test.message, function () {
-      serviceConfigProperty.initialValue(test.localDB);
-      expect(serviceConfigProperty.get('value')).to.equal(test.expected);
+    cases['kafka.ganglia.metrics.host'].forEach(function(item){
+      it(item.message, function () {
+        serviceConfigProperty.setProperties({
+          name: 'kafka.ganglia.metrics.host',
+          value: 'localhost'
+        });
+        serviceConfigProperty.initialValue(item.localDB);
+        expect(serviceConfigProperty.get('value')).to.equal(item.expected);
+      });
     });
-  });
-});
-
-describe('#initialValue - hive_database', function () {
-
-  var cases = [
-      {
-        alwaysEnableManagedMySQLForHive: true,
-        currentStateName: '',
-        isManagedMySQLForHiveEnabled: false,
-        receivedValue: 'New MySQL Database',
-        value: 'New MySQL Database',
-        options: [
-          {
-            displayName: 'New MySQL Database'
-          }
-        ],
-        hidden: false
-      },
-      {
-        alwaysEnableManagedMySQLForHive: false,
-        currentStateName: 'configs',
-        isManagedMySQLForHiveEnabled: false,
-        receivedValue: 'New MySQL Database',
-        value: 'New MySQL Database',
-        options: [
-          {
-            displayName: 'New MySQL Database'
-          }
-        ],
-        hidden: false
-      },
-      {
-        alwaysEnableManagedMySQLForHive: false,
-        currentStateName: '',
-        isManagedMySQLForHiveEnabled: true,
-        receivedValue: 'New MySQL Database',
-        value: 'New MySQL Database',
-        options: [
-          {
-            displayName: 'New MySQL Database'
-          }
-        ],
-        hidden: false
-      },
-      {
-        alwaysEnableManagedMySQLForHive: false,
-        currentStateName: '',
-        isManagedMySQLForHiveEnabled: false,
-        receivedValue: 'New MySQL Database',
-        value: 'Existing MySQL Database',
-        options: [
-          {
-            displayName: 'New MySQL Database'
-          }
-        ],
-        hidden: true
-      },
-      {
-        alwaysEnableManagedMySQLForHive: false,
-        currentStateName: '',
-        isManagedMySQLForHiveEnabled: false,
-        receivedValue: 'New PostgreSQL Database',
-        value: 'New PostgreSQL Database',
-        options: [
-          {
-            displayName: 'New MySQL Database'
-          }
-        ],
-        hidden: true
-      }
-    ],
-    title = 'value should be set to {0}';
 
-  beforeEach(function () {
-    serviceConfigProperty = App.ServiceConfigProperty.create({
-      name: 'hive_database'
+    cases['hive_database'].forEach(function (item) {
+      var title = 'hive_database value should be set to {0}';
+      it(title.format(item.value), function () {
+        sinon.stub(App, 'get')
+          .withArgs('supports.alwaysEnableManagedMySQLForHive').returns(item.alwaysEnableManagedMySQLForHive)
+          .withArgs('router.currentState.name').returns(item.currentStateName)
+          .withArgs('isManagedMySQLForHiveEnabled').returns(item.isManagedMySQLForHiveEnabled);
+        serviceConfigProperty.setProperties({
+          name: 'hive_database',
+          value: item.receivedValue,
+          options: item.options
+        });
+        serviceConfigProperty.initialValue({});
+        expect(serviceConfigProperty.get('value')).to.equal(item.value);
+        expect(serviceConfigProperty.get('options').findProperty('displayName', 'New MySQL
Database').hidden).to.equal(item.hidden);
+        App.get.restore();
+      });
     });
-  });
 
-  afterEach(function() {
-    App.get.restore();
-  });
+    cases['hbase.zookeeper.quorum'].forEach(function (item) {
+      it(item.title, function () {
+        serviceConfigProperty.setProperties({
+          name: 'hbase.zookeeper.quorum',
+          value: 'localhost',
+          'filename': item.filename
+        });
+        serviceConfigProperty.initialValue({
+          masterComponentHosts: {
+            filterProperty: function () {
+              return {
+                mapProperty: function () {
+                  return ['host0', 'host1'];
+                }
+              };
+            }
+          }
+        });
+        expect(serviceConfigProperty.get('value')).to.equal(item.value);
+        expect(serviceConfigProperty.get('defaultValue')).to.equal(item.defaultValue);
+      });
+    });
 
-  cases.forEach(function (item) {
-    it(title.format(item.value), function () {
-      sinon.stub(App, 'get')
-        .withArgs('supports.alwaysEnableManagedMySQLForHive').returns(item.alwaysEnableManagedMySQLForHive)
-        .withArgs('router.currentState.name').returns(item.currentStateName)
-        .withArgs('isManagedMySQLForHiveEnabled').returns(item.isManagedMySQLForHiveEnabled);
-      serviceConfigProperty.set('value', item.receivedValue);
-      serviceConfigProperty.set('options', item.options);
-      serviceConfigProperty.initialValue({});
-      expect(serviceConfigProperty.get('value')).to.equal(item.value);
-      expect(serviceConfigProperty.get('options').findProperty('displayName', 'New MySQL
Database').hidden).to.equal(item.hidden);
+    cases['hbase.tmp.dir'].forEach(function (item) {
+      var isOnlyFirstOneNeeded = true,
+        localDB = {
+          p: 'v'
+        };
+      it(item.title, function () {
+        sinon.stub(serviceConfigProperty, 'unionAllMountPoints', Em.K);
+        serviceConfigProperty.setProperties({
+          name: 'hbase.tmp.dir',
+          filename: item.filename
+        });
+        serviceConfigProperty.initialValue(localDB);
+        expect(serviceConfigProperty.unionAllMountPoints.calledWith(isOnlyFirstOneNeeded,
localDB)).to.equal(item.isUnionAllMountPointsCalled);
+        serviceConfigProperty.unionAllMountPoints.restore();
+      });
     });
-  });
 
+  });
 });


Mime
View raw message