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

ambari git commit: AMBARI-11523. Add Service Wizard: issues with JDBC setup warning for Ranger (onechiporenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk 0f602e15c -> 3dd19b160


AMBARI-11523. Add Service Wizard: issues with JDBC setup warning for Ranger (onechiporenko)


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

Branch: refs/heads/trunk
Commit: 3dd19b16027440e837f0a5acd0369771eca95122
Parents: 0f602e1
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Fri May 29 12:21:26 2015 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Fri May 29 12:21:26 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/views/common/controls_view.js    |  36 ++--
 .../test/views/common/controls_view_test.js     | 183 +++++++++++++++++++
 2 files changed, 202 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3dd19b16/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 d2953b9..96e8a5d 100644
--- a/ambari-web/app/views/common/controls_view.js
+++ b/ambari-web/app/views/common/controls_view.js
@@ -780,26 +780,28 @@ App.ServiceConfigRadioButtons = Ember.View.extend(App.ServiceConfigCalculateId,
       // check for all db types when installing Ranger - not only for existing ones
       checkDatabase = true;
     }
-    propertyAppendTo1.set('additionalView', null);
-    propertyAppendTo2.set('additionalView', null);
-    if (currentDB && checkDatabase) {
-      if (handledProperties.contains(this.get('serviceConfig.name'))) {
-        if (propertyAppendTo1) {
-          Em.run.next(function(){
-            propertyAppendTo1.set('additionalView', App.CheckDBConnectionView.extend({databaseName: currentDB}));
-          });
-        }
-        if (propertyAppendTo2) {
-          propertyAppendTo2.set('additionalView', Ember.View.extend({
-            template: Ember.Handlebars.compile('<div class="alert">{{{view.message}}}</div>'),
-            message: Em.I18n.t('services.service.config.database.msg.jdbcSetup').format(currentDBType.toLowerCase(), currentDBType.toLowerCase())
-          }));
-        }
-      }
-    } else {
+    if (propertyAppendTo1) {
       propertyAppendTo1.set('additionalView', null);
+    }
+    if (propertyAppendTo2) {
       propertyAppendTo2.set('additionalView', null);
     }
+    var shouldAdditionalViewsBeSet = currentDB && checkDatabase && handledProperties.contains(this.get('serviceConfig.name')),
+      additionalView1 = shouldAdditionalViewsBeSet ? App.CheckDBConnectionView.extend({databaseName: currentDB}) : null,
+      additionalView2 = shouldAdditionalViewsBeSet ? Ember.View.extend({
+        template: Ember.Handlebars.compile('<div class="alert">{{{view.message}}}</div>'),
+        message: Em.I18n.t('services.service.config.database.msg.jdbcSetup').format(currentDBType.toLowerCase(), currentDBType.toLowerCase())
+      }) : null;
+    if (propertyAppendTo1) {
+      Em.run.next(function () {
+        propertyAppendTo1.set('additionalView', additionalView1);
+      });
+    }
+    if (propertyAppendTo2) {
+      Em.run.next(function () {
+        propertyAppendTo2.set('additionalView', additionalView2);
+      });
+    }
   }.observes('serviceConfig.value'),
 
   optionsBinding: 'serviceConfig.options'

http://git-wip-us.apache.org/repos/asf/ambari/blob/3dd19b16/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 f673871..7a27f46 100644
--- a/ambari-web/test/views/common/controls_view_test.js
+++ b/ambari-web/test/views/common/controls_view_test.js
@@ -634,6 +634,189 @@ describe('App.ServiceConfigRadioButtons', function () {
 
   });
 
+  describe('#handleDBConnectionProperty', function () {
+
+    var view,
+      cases = [
+        {
+          dbType: 'mysql',
+          serviceConfig: {
+            name: 'hive_database',
+            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'
+            })
+          ],
+          currentStackVersion: 'HDP-2.2',
+          propertyAppendTo1: 'javax.jdo.option.ConnectionURL',
+          propertyAppendTo2: 'hive_database',
+          isAdditionalView1Null: true,
+          isAdditionalView2Null: true,
+          title: 'Hive, embedded database'
+        },
+        {
+          dbType: 'postgres',
+          serviceConfig: {
+            name: 'hive_database',
+            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'
+            })
+          ],
+          currentStackVersion: 'HDP-2.2',
+          propertyAppendTo1: 'javax.jdo.option.ConnectionURL',
+          propertyAppendTo2: 'hive_database',
+          isAdditionalView1Null: false,
+          isAdditionalView2Null: false,
+          title: 'Hive, external database'
+        },
+        {
+          dbType: 'derby',
+          serviceConfig: {
+            name: 'oozie_database',
+            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'
+            })
+          ],
+          currentStackVersion: 'HDP-2.2',
+          propertyAppendTo1: 'oozie.service.JPAService.jdbc.url',
+          propertyAppendTo2: 'oozie_database',
+          isAdditionalView1Null: true,
+          isAdditionalView2Null: true,
+          title: 'Oozie, embedded database'
+        },
+        {
+          dbType: 'oracle',
+          serviceConfig: {
+            name: 'oozie_database',
+            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'
+            })
+          ],
+          currentStackVersion: 'HDP-2.2',
+          propertyAppendTo1: 'oozie.service.JPAService.jdbc.url',
+          propertyAppendTo2: 'oozie_database',
+          isAdditionalView1Null: false,
+          isAdditionalView2Null: false,
+          title: 'Oozie, external database'
+        },
+        {
+          dbType: 'mysql',
+          serviceConfig: {
+            name: 'DB_FLAVOR',
+            value: 'MYSQL',
+            serviceName: 'RANGER'
+          },
+          categoryConfigsAll: [
+            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',
+          isAdditionalView1Null: true,
+          isAdditionalView2Null: true,
+          title: 'Ranger, HDP 2.2, external database'
+        },
+        {
+          dbType: 'mssql',
+          serviceConfig: {
+            name: 'DB_FLAVOR',
+            value: 'MSSQL',
+            serviceName: 'RANGER'
+          },
+          categoryConfigsAll: [
+            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',
+          isAdditionalView1Null: false,
+          isAdditionalView2Null: false,
+          title: 'Ranger, HDP 2.3, external database'
+        }
+      ];
+
+    before(function () {
+      sinon.stub(Em.run, 'next', function (arg) {
+        arg();
+      });
+    });
+
+    beforeEach(function () {
+      view = App.ServiceConfigRadioButtons.create();
+    });
+
+    afterEach(function () {
+      App.get.restore();
+    });
+
+    after(function () {
+      Em.run.next.restore();
+    });
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        sinon.stub(App, 'get').withArgs('currentStackName').returns('HDP').withArgs('currentStackVersion').returns(item.currentStackVersion);
+        view.setProperties({
+          categoryConfigsAll: item.categoryConfigsAll,
+          serviceConfig: item.serviceConfig
+        });
+        var additionalView1 = view.get('categoryConfigsAll').findProperty('name', item.propertyAppendTo1).get('additionalView'),
+          additionalView2 = view.get('categoryConfigsAll').findProperty('name', item.propertyAppendTo2).get('additionalView');
+        expect(Em.isNone(additionalView1)).to.equal(item.isAdditionalView1Null);
+        expect(Em.isNone(additionalView2)).to.equal(item.isAdditionalView2Null);
+        if (!item.isAdditionalView2Null) {
+          expect(additionalView2.create().get('message')).to.equal(Em.I18n.t('services.service.config.database.msg.jdbcSetup').format(item.dbType, item.dbType));
+        }
+      });
+    });
+
+  });
+
 });
 
 describe('App.ServiceConfigRadioButton', function () {