You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ja...@apache.org on 2015/08/27 01:15:28 UTC

ambari git commit: AMBARI-12887. Depending upon Ranger db_flavor, SQL_CONNECTOR_JAR is not changing on Ambari UI. (jaimin)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 571178d69 -> b0c43b061


AMBARI-12887. Depending upon Ranger db_flavor, SQL_CONNECTOR_JAR is not changing on Ambari UI. (jaimin)


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

Branch: refs/heads/branch-2.1
Commit: b0c43b061450149fe2e88d093bd9cf1610975280
Parents: 571178d
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Wed Aug 26 16:15:10 2015 -0700
Committer: Jaimin Jetly <ja...@hortonworks.com>
Committed: Wed Aug 26 16:15:10 2015 -0700

----------------------------------------------------------------------
 ambari-web/app/views/common/controls_view.js    |   9 +-
 .../test/views/common/controls_view_test.js     | 185 ++++++++++---------
 2 files changed, 102 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b0c43b06/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 91be642..d61c367 100644
--- a/ambari-web/app/views/common/controls_view.js
+++ b/ambari-web/app/views/common/controls_view.js
@@ -497,7 +497,7 @@ App.ServiceConfigRadioButtons = Ember.View.extend(App.ServiceConfigCalculateId,
 
   onOptionsChange: function () {
     // The following if condition will be satisfied only for installer wizard flow
-    if (this.getPropertyByType('connection_url') && this.get('hostNameProperty')) {
+    if (this.get('hostNameProperty')) {
       /** if new db is selected host name must be same as master of selected service (and can't be changed)**/
       if (this.get('isNewDb')) {
         var initProperty = this.get('hostNameProperty.recommendedValue') || this.get('hostNameProperty.savedValue');
@@ -507,7 +507,9 @@ App.ServiceConfigRadioButtons = Ember.View.extend(App.ServiceConfigCalculateId,
         this.get('hostNameProperty').set('isEditable', true);
       }
       this.setRequiredProperties(['driver', 'sql_jar_connector', 'db_type']);
-      this.setConnectionUrl(this.get('hostNameProperty.value'), this.get('databaseProperty.value'), this.get('userProperty.value'), this.get('passwordProperty.value'));
+      if (this.getPropertyByType('connection_url')) {
+        this.setConnectionUrl(this.get('hostNameProperty.value'), this.get('databaseProperty.value'), this.get('userProperty.value'), this.get('passwordProperty.value'));
+      }
       this.handleSpecialUserPassProperties();
     }
   }.observes('databaseProperty.value', 'hostNameProperty.value', 'serviceConfig.value', 'userProperty.value', 'passwordProperty.value'),
@@ -573,8 +575,9 @@ App.ServiceConfigRadioButtons = Ember.View.extend(App.ServiceConfigCalculateId,
    */
   getPropertyByType: function(propertyType) {
     if (dbInfo.dpPropertiesByServiceMap[this.get('serviceConfig.serviceName')]) {
+      //@TODO: dbInfo.dpPropertiesByServiceMap has corresponding property name but does not have filenames with it. this can cause issue when there are multiple db properties with same name belonging to different files
       /** check if selected service has db properties**/
-      return this.get('categoryConfigsAll').findProperty('name', dbInfo.dpPropertiesByServiceMap[this.get('serviceConfig.serviceName')][propertyType]);
+      return this.get('parentView.serviceConfigs').findProperty('name', dbInfo.dpPropertiesByServiceMap[this.get('serviceConfig.serviceName')][propertyType]);
     }
     return null;
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/b0c43b06/ambari-web/test/views/common/controls_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/controls_view_test.js b/ambari-web/test/views/common/controls_view_test.js
index b21128a..95a6727 100644
--- a/ambari-web/test/views/common/controls_view_test.js
+++ b/ambari-web/test/views/common/controls_view_test.js
@@ -21,58 +21,58 @@ require('views/common/controls_view');
 
 describe('App.ServiceConfigRadioButtons', function () {
 
-  describe('#setConnectionUrl', function() {
+  describe('#setConnectionUrl', function () {
     var view = App.ServiceConfigRadioButtons.create();
-    beforeEach(function() {
-      sinon.stub(view, 'getPropertyByType', function(name) {
+    beforeEach(function () {
+      sinon.stub(view, 'getPropertyByType', function (name) {
         return App.ServiceConfigProperty.create({'name': name});
       });
-      sinon.stub(view, 'getDefaultPropertyValue', function() {
+      sinon.stub(view, 'getDefaultPropertyValue', function () {
         return 'host:{0},db:{1}';
       });
     });
 
-    afterEach(function() {
+    afterEach(function () {
       view.getPropertyByType.restore();
       view.getDefaultPropertyValue.restore();
     });
 
-    it('updates value for connection url', function() {
-      expect(view.setConnectionUrl('hostName','dbName').get('value')).to.equal('host:hostName,db:dbName');
+    it('updates value for connection url', function () {
+      expect(view.setConnectionUrl('hostName', 'dbName').get('value')).to.equal('host:hostName,db:dbName');
     });
   });
 
-  describe('#setRequiredProperties', function() {
+  describe('#setRequiredProperties', function () {
     var view = App.ServiceConfigRadioButtons.create({
-        serviceConfig: Em.Object.create(),
-        categoryConfigsAll: [
-          App.ServiceConfigProperty.create({
-            name: 'p1',
-            value: 'v1'
-          }),
-          App.ServiceConfigProperty.create({
-            name: 'p2',
-            value: 'v2'
-          })
-        ]
-      });
+      serviceConfig: Em.Object.create(),
+      categoryConfigsAll: [
+        App.ServiceConfigProperty.create({
+          name: 'p1',
+          value: 'v1'
+        }),
+        App.ServiceConfigProperty.create({
+          name: 'p2',
+          value: 'v2'
+        })
+      ]
+    });
 
-    beforeEach(function() {
-      sinon.stub(view, 'getPropertyByType', function(name) {
+    beforeEach(function () {
+      sinon.stub(view, 'getPropertyByType', function (name) {
         return view.get('categoryConfigsAll').findProperty('name', name);
       });
-      sinon.stub(view, 'getDefaultPropertyValue', function(name) {
+      sinon.stub(view, 'getDefaultPropertyValue', function (name) {
         return name + '_v';
       });
     });
 
-    afterEach(function() {
+    afterEach(function () {
       view.getPropertyByType.restore();
       view.getDefaultPropertyValue.restore();
     });
 
-    it('updates value for connection url', function() {
-      view.setRequiredProperties(['p2','p1']);
+    it('updates value for connection url', function () {
+      view.setRequiredProperties(['p2', 'p1']);
       expect(view.get('categoryConfigsAll').findProperty('name', 'p1').get('value')).to.equal('p1_v');
       expect(view.get('categoryConfigsAll').findProperty('name', 'p2').get('value')).to.equal('p2_v');
     });
@@ -90,16 +90,18 @@ describe('App.ServiceConfigRadioButtons', function () {
             value: 'New MySQL Database',
             serviceName: 'HIVE'
           },
-          categoryConfigsAll: [
-            Em.Object.create({
-              name: 'javax.jdo.option.ConnectionURL',
-              displayName: 'Database URL'
-            }),
-            Em.Object.create({
-              name: 'hive_database',
-              displayName: 'Hive Database'
-            })
-          ],
+          parentView: Em.Object.create({
+            serviceConfigs: [
+              Em.Object.create({
+                name: 'javax.jdo.option.ConnectionURL',
+                displayName: 'Database URL'
+              }),
+              Em.Object.create({
+                name: 'hive_database',
+                displayName: 'Hive Database'
+              })
+            ]
+          }),
           currentStackVersion: 'HDP-2.2',
           propertyAppendTo1: 'javax.jdo.option.ConnectionURL',
           propertyAppendTo2: 'hive_database',
@@ -115,16 +117,18 @@ describe('App.ServiceConfigRadioButtons', function () {
             value: 'Existing PostgreSQL Database',
             serviceName: 'HIVE'
           },
-          categoryConfigsAll: [
-            Em.Object.create({
-              name: 'javax.jdo.option.ConnectionURL',
-              displayName: 'Database URL'
-            }),
-            Em.Object.create({
-              name: 'hive_database',
-              displayName: 'Hive Database'
-            })
-          ],
+          parentView: Em.Object.create({
+            serviceConfigs: [
+              Em.Object.create({
+                name: 'javax.jdo.option.ConnectionURL',
+                displayName: 'Database URL'
+              }),
+              Em.Object.create({
+                name: 'hive_database',
+                displayName: 'Hive Database'
+              })
+            ]
+          }),
           currentStackVersion: 'HDP-2.2',
           propertyAppendTo1: 'javax.jdo.option.ConnectionURL',
           propertyAppendTo2: 'hive_database',
@@ -140,16 +144,18 @@ describe('App.ServiceConfigRadioButtons', function () {
             value: 'New Derby Database',
             serviceName: 'OOZIE'
           },
-          categoryConfigsAll: [
-            Em.Object.create({
-              name: 'oozie.service.JPAService.jdbc.url',
-              displayName: 'Database URL'
-            }),
-            Em.Object.create({
-              name: 'oozie_database',
-              displayName: 'Oozie Database'
-            })
-          ],
+          parentView: Em.Object.create({
+            serviceConfigs: [
+              Em.Object.create({
+                name: 'oozie.service.JPAService.jdbc.url',
+                displayName: 'Database URL'
+              }),
+              Em.Object.create({
+                name: 'oozie_database',
+                displayName: 'Oozie Database'
+              })
+            ]
+          }),
           currentStackVersion: 'HDP-2.2',
           propertyAppendTo1: 'oozie.service.JPAService.jdbc.url',
           propertyAppendTo2: 'oozie_database',
@@ -165,16 +171,18 @@ describe('App.ServiceConfigRadioButtons', function () {
             value: 'Existing Oracle Database',
             serviceName: 'OOZIE'
           },
-          categoryConfigsAll: [
-            Em.Object.create({
-              name: 'oozie.service.JPAService.jdbc.url',
-              displayName: 'Database URL'
-            }),
-            Em.Object.create({
-              name: 'oozie_database',
-              displayName: 'Oozie Database'
-            })
-          ],
+          parentView: Em.Object.create({
+            serviceConfigs: [
+              Em.Object.create({
+                name: 'oozie.service.JPAService.jdbc.url',
+                displayName: 'Database URL'
+              }),
+              Em.Object.create({
+                name: 'oozie_database',
+                displayName: 'Oozie Database'
+              })
+            ]
+          }),
           currentStackVersion: 'HDP-2.2',
           propertyAppendTo1: 'oozie.service.JPAService.jdbc.url',
           propertyAppendTo2: 'oozie_database',
@@ -190,14 +198,16 @@ describe('App.ServiceConfigRadioButtons', function () {
             value: 'MYSQL',
             serviceName: 'RANGER'
           },
-          categoryConfigsAll: [
-            Em.Object.create({
-              name: 'ranger.jpa.jdbc.url'
-            }),
-            Em.Object.create({
-              name: 'DB_FLAVOR'
-            })
-          ],
+          parentView: Em.Object.create({
+            serviceConfigs: [
+              Em.Object.create({
+                name: 'ranger.jpa.jdbc.url'
+              }),
+              Em.Object.create({
+                name: 'DB_FLAVOR'
+              })
+            ]
+          }),
           currentStackVersion: 'HDP-2.2',
           propertyAppendTo1: 'ranger.jpa.jdbc.url',
           propertyAppendTo2: 'DB_FLAVOR',
@@ -213,14 +223,16 @@ describe('App.ServiceConfigRadioButtons', function () {
             value: 'MSSQL',
             serviceName: 'RANGER'
           },
-          categoryConfigsAll: [
-            Em.Object.create({
-              name: 'ranger.jpa.jdbc.url'
-            }),
-            Em.Object.create({
-              name: 'DB_FLAVOR'
-            })
-          ],
+          parentView: Em.Object.create({
+            serviceConfigs: [
+              Em.Object.create({
+                name: 'ranger.jpa.jdbc.url'
+              }),
+              Em.Object.create({
+                name: 'DB_FLAVOR'
+              })
+            ]
+          }),
           currentStackVersion: 'HDP-2.3',
           propertyAppendTo1: 'ranger.jpa.jdbc.url',
           propertyAppendTo2: 'DB_FLAVOR',
@@ -236,10 +248,6 @@ describe('App.ServiceConfigRadioButtons', function () {
       });
     });
 
-    beforeEach(function () {
-      view = App.ServiceConfigRadioButtons.create();
-    });
-
     afterEach(function () {
       App.get.restore();
     });
@@ -251,8 +259,9 @@ describe('App.ServiceConfigRadioButtons', function () {
     cases.forEach(function (item) {
       it(item.title, function () {
         sinon.stub(App, 'get').withArgs('currentStackName').returns('HDP').withArgs('currentStackVersion').returns(item.currentStackVersion);
+        view = App.ServiceConfigRadioButtons.create({parentView: item.parentView});
         view.setProperties({
-          categoryConfigsAll: item.categoryConfigsAll,
+          categoryConfigsAll: item.parentView.get('serviceConfigs'),
           serviceConfig: item.serviceConfig
         });
         var additionalView1 = view.get('categoryConfigsAll').findProperty('name', item.propertyAppendTo1).get('additionalView'),
@@ -266,7 +275,6 @@ describe('App.ServiceConfigRadioButtons', function () {
     });
 
   });
-
 });
 
 describe('App.ServiceConfigRadioButton', function () {
@@ -571,5 +579,4 @@ describe('App.BaseUrlTextField', function () {
     });
 
   });
-
 });