ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject ambari git commit: AMBARI-12887. Depending upon Ranger db_flavor, SQL_CONNECTOR_JAR is not changing on Ambari UI. (jaimin)
Date Wed, 26 Aug 2015 23:22:49 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk d7f3f31a6 -> 892270d0d


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/892270d0
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/892270d0
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/892270d0

Branch: refs/heads/trunk
Commit: 892270d0df9c9f4e708c0d74da7af294a9988289
Parents: d7f3f31
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Wed Aug 26 16:15:10 2015 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Wed Aug 26 16:22:36 2015 -0700

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


http://git-wip-us.apache.org/repos/asf/ambari/blob/892270d0/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 a93f957..4ff6222 100644
--- a/ambari-web/app/views/common/controls_view.js
+++ b/ambari-web/app/views/common/controls_view.js
@@ -498,7 +498,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');
@@ -508,7 +508,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'),
@@ -574,8 +576,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/892270d0/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 6dd1185..e191068 100644
--- a/ambari-web/test/views/common/controls_view_test.js
+++ b/ambari-web/test/views/common/controls_view_test.js
@@ -22,58 +22,58 @@ var validator = require('utils/validator');
 
 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');
     });
@@ -91,16 +91,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',
@@ -116,16 +118,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',
@@ -141,16 +145,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',
@@ -166,16 +172,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',
@@ -191,14 +199,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',
@@ -214,14 +224,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',
@@ -237,10 +249,6 @@ describe('App.ServiceConfigRadioButtons', function () {
       });
     });
 
-    beforeEach(function () {
-      view = App.ServiceConfigRadioButtons.create();
-    });
-
     afterEach(function () {
       App.get.restore();
     });
@@ -252,8 +260,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'),
@@ -267,7 +276,6 @@ describe('App.ServiceConfigRadioButtons', function () {
     });
 
   });
-
 });
 
 describe('App.ServiceConfigRadioButton', function () {


Mime
View raw message