ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject ambari git commit: AMBARI-9645 Modifying the oozie password in the oozie configuration causes the JDBC url to reset to oozie's localhost. (ababiichuk)
Date Sun, 15 Feb 2015 11:54:23 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 7d002b155 -> 394471622


AMBARI-9645 Modifying the oozie password in the oozie configuration causes the JDBC url to
reset to oozie's localhost. (ababiichuk)


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

Branch: refs/heads/trunk
Commit: 3944716224003e371484e3c43b6a2a4851e94343
Parents: 7d002b1
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Sun Feb 15 13:29:37 2015 +0200
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Sun Feb 15 13:54:21 2015 +0200

----------------------------------------------------------------------
 ambari-web/app/views/common/controls_view.js    | 193 +++++++++++--------
 .../test/views/common/controls_view_test.js     |  57 +++++-
 2 files changed, 170 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/39447162/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 91441e3..416ed30 100644
--- a/ambari-web/app/views/common/controls_view.js
+++ b/ambari-web/app/views/common/controls_view.js
@@ -340,85 +340,124 @@ App.ServiceConfigRadioButtons = Ember.View.extend(App.ServiceConfigCalculateId,
     // The following if condition will be satisfied only for installer wizard flow
     if (this.get('configs').length) {
       var connectionUrl = this.get('connectionUrl');
-      var dbClass = this.get('dbClass');
       if (connectionUrl) {
-        if (this.get('serviceConfig.serviceName') === 'HIVE') {
-          var hiveDbType = this.get('parentView.serviceConfigs').findProperty('name', 'hive_database_type');
-          switch (this.get('serviceConfig.value')) {
-            case 'New MySQL Database':
-            case 'Existing MySQL Database':
-              connectionUrl.set('value', "jdbc:mysql://" + this.get('hostName') + "/" + this.get('databaseName')
+ "?createDatabaseIfNotExist=true");
-              dbClass.set('value', "com.mysql.jdbc.Driver");
-              Em.set(hiveDbType, 'value', 'mysql');
-              break;
-            case Em.I18n.t('services.service.config.hive.oozie.postgresql'):
-              connectionUrl.set('value', "jdbc:postgresql://" + this.get('hostName') + ":5432/"
+ this.get('databaseName'));
-              dbClass.set('value', "org.postgresql.Driver");
-              Em.set(hiveDbType, 'value', 'postgres');
-              break;
-            case 'Existing Oracle Database':
-              connectionUrl.set('value', "jdbc:oracle:thin:@//" + this.get('hostName') +
":1521/" + this.get('databaseName'));
-              dbClass.set('value', "oracle.jdbc.driver.OracleDriver");
-              Em.set(hiveDbType, 'value', 'oracle');
-              break;
-            case 'Existing MSSQL Server database with SQL authentication':
-              connectionUrl.set('value', "jdbc:sqlserver://" + this.get('hostName') + ";databaseName="
+ this.get('databaseName'));
-              dbClass.set('value', "com.microsoft.sqlserver.jdbc.SQLServerDriver");
-              Em.set(hiveDbType, 'value', 'mssql');
-              break;
-            case 'Existing MSSQL Server database with integrated authentication':
-              connectionUrl.set('value', "jdbc:sqlserver://" + this.get('hostName') + ";databaseName="
+ this.get('databaseName') + ";integratedSecurity=true");
-              dbClass.set('value', "com.microsoft.sqlserver.jdbc.SQLServerDriver");
-              Em.set(hiveDbType, 'value', 'mssql');
-              break;
-          }
-          var isNotExistingMySQLServer = this.get('serviceConfig.value') !== 'Existing MSSQL
Server database with integrated authentication';
-          this.get('categoryConfigsAll').findProperty('name', 'javax.jdo.option.ConnectionUserName').setProperties({
-            isVisible: isNotExistingMySQLServer,
-            isRequired: isNotExistingMySQLServer
-          });
-          this.get('categoryConfigsAll').findProperty('name', 'javax.jdo.option.ConnectionPassword').setProperties({
-            isVisible: isNotExistingMySQLServer,
-            isRequired: isNotExistingMySQLServer
-          });
-        } else if (this.get('serviceConfig.serviceName') === 'OOZIE') {
-          switch (this.get('serviceConfig.value')) {
-            case 'New Derby Database':
-              connectionUrl.set('value', "jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true");
-              dbClass.set('value', "org.apache.derby.jdbc.EmbeddedDriver");
-              break;
-            case 'Existing MySQL Database':
-              connectionUrl.set('value', "jdbc:mysql://" + this.get('hostName') + "/" + this.get('databaseName'));
-              dbClass.set('value', "com.mysql.jdbc.Driver");
-              break;
-            case Em.I18n.t('services.service.config.hive.oozie.postgresql'):
-              connectionUrl.set('value', "jdbc:postgresql://" + this.get('hostName') + ":5432/"
+ this.get('databaseName'));
-              dbClass.set('value', "org.postgresql.Driver");
-              break;
-            case 'Existing Oracle Database':
-              connectionUrl.set('value', "jdbc:oracle:thin:@//" + this.get('hostName') +
":1521/" + this.get('databaseName'));
-              dbClass.set('value', "oracle.jdbc.driver.OracleDriver");
-              break;
-            case 'Existing MSSQL Server database with SQL authentication':
-              connectionUrl.set('value', "jdbc:sqlserver://" + this.get('hostName') + ";databaseName="
+ this.get('databaseName'));
-              dbClass.set('value', "com.microsoft.sqlserver.jdbc.SQLServerDriver");
-              break;
-            case 'Existing MSSQL Server database with integrated authentication':
-              connectionUrl.set('value', "jdbc:sqlserver://" + this.get('hostName') + ";databaseName="
+ this.get('databaseName') + ";integratedSecurity=true");
-              dbClass.set('value', "com.microsoft.sqlserver.jdbc.SQLServerDriver");
-              break;
-          }
-          isNotExistingMySQLServer = this.get('serviceConfig.value') !== 'Existing MSSQL
Server database with integrated authentication';
-          this.get('categoryConfigsAll').findProperty('name', 'oozie.service.JPAService.jdbc.username').setProperties({
-            isVisible: isNotExistingMySQLServer,
-            isRequired: isNotExistingMySQLServer
-          });
-          this.get('categoryConfigsAll').findProperty('name', 'oozie.service.JPAService.jdbc.password').setProperties({
-            isVisible: isNotExistingMySQLServer,
-            isRequired: isNotExistingMySQLServer
-          });
+        var dbClass = this.get('dbClass');
+        var hostName = this.get('hostName');
+        var databaseName = this.get('databaseName');
+        var hostNameDefault;
+        var databaseNameDefault;
+        var connectionUrlValue = connectionUrl.get('value');
+        var connectionUrlDefaultValue = connectionUrl.get('defaultValue');
+        var dbClassValue = dbClass.get('value');
+        var serviceName = this.get('serviceConfig.serviceName');
+        var isServiceInstalled = App.Service.find().someProperty('serviceName', serviceName);
+        var postgresUrl = 'jdbc:postgresql://{0}:5432/{1}';
+        var oracleUrl = 'jdbc:oracle:thin:@//{0}:1521/{1}';
+        var mssqlUrl = 'jdbc:sqlserver://{0};databaseName={1}';
+        var mssqlIntegratedAuthUrl = 'jdbc:sqlserver://{0};databaseName={1};integratedSecurity=true';
+        var isNotExistingMySQLServer = this.get('serviceConfig.value') !== 'Existing MSSQL
Server database with integrated authentication';
+        var categoryConfigsAll = this.get('categoryConfigsAll');
+        if (isServiceInstalled) {
+          hostNameDefault = this.get('hostNameProperty.defaultValue');
+          databaseNameDefault = this.get('databaseNameProperty.defaultValue');
+        } else {
+          hostNameDefault = hostName;
+          databaseNameDefault = databaseName;
+        }
+        switch (serviceName) {
+          case 'HIVE':
+            var hiveDbType = this.get('parentView.serviceConfigs').findProperty('name', 'hive_database_type');
+            var mysqlUrl = 'jdbc:mysql://{0}/{1}?createDatabaseIfNotExist=true';
+            switch (this.get('serviceConfig.value')) {
+              case 'New MySQL Database':
+              case 'Existing MySQL Database':
+                connectionUrlValue = mysqlUrl.format(hostName, databaseName);
+                connectionUrlDefaultValue = mysqlUrl.format(hostNameDefault, databaseNameDefault);
+                dbClassValue = 'com.mysql.jdbc.Driver';
+                Em.set(hiveDbType, 'value', 'mysql');
+                break;
+              case Em.I18n.t('services.service.config.hive.oozie.postgresql'):
+                connectionUrlValue = postgresUrl.format(hostName, databaseName);
+                connectionUrlDefaultValue = postgresUrl.format(hostNameDefault, databaseNameDefault);
+                dbClassValue = 'org.postgresql.Driver';
+                Em.set(hiveDbType, 'value', 'postgres');
+                break;
+              case 'Existing Oracle Database':
+                connectionUrlValue = oracleUrl.format(hostName, databaseName);
+                connectionUrlDefaultValue = oracleUrl.format(hostNameDefault, databaseNameDefault);
+                dbClassValue = 'oracle.jdbc.driver.OracleDriver';
+                Em.set(hiveDbType, 'value', 'oracle');
+                break;
+              case 'Existing MSSQL Server database with SQL authentication':
+                connectionUrlValue = mssqlUrl.format(hostName, databaseName);
+                connectionUrlDefaultValue = mssqlUrl.format(hostNameDefault, databaseNameDefault);
+                dbClassValue = 'com.microsoft.sqlserver.jdbc.SQLServerDriver';
+                Em.set(hiveDbType, 'value', 'mssql');
+                break;
+              case 'Existing MSSQL Server database with integrated authentication':
+                connectionUrlValue = mssqlIntegratedAuthUrl.format(hostName, databaseName);
+                connectionUrlDefaultValue = mssqlIntegratedAuthUrl.format(hostNameDefault,
databaseNameDefault);
+                dbClassValue = 'com.microsoft.sqlserver.jdbc.SQLServerDriver';
+                Em.set(hiveDbType, 'value', 'mssql');
+                break;
+            }
+            categoryConfigsAll.findProperty('name', 'javax.jdo.option.ConnectionUserName').setProperties({
+              isVisible: isNotExistingMySQLServer,
+              isRequired: isNotExistingMySQLServer
+            });
+            categoryConfigsAll.findProperty('name', 'javax.jdo.option.ConnectionPassword').setProperties({
+              isVisible: isNotExistingMySQLServer,
+              isRequired: isNotExistingMySQLServer
+            });
+            break;
+          case 'OOZIE':
+            var derbyUrl = 'jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true';
+            var mysqlUrl = 'jdbc:mysql://{0}/{1}';
+            switch (this.get('serviceConfig.value')) {
+              case 'New Derby Database':
+                connectionUrlValue = derbyUrl;
+                connectionUrlDefaultValue = derbyUrl;
+                dbClassValue = 'org.apache.derby.jdbc.EmbeddedDriver';
+                break;
+              case 'Existing MySQL Database':
+                connectionUrlValue = mysqlUrl.format(hostName, databaseName);
+                connectionUrlDefaultValue = mysqlUrl.format(hostNameDefault, databaseNameDefault);
+                dbClassValue = 'com.mysql.jdbc.Driver';
+                break;
+              case Em.I18n.t('services.service.config.hive.oozie.postgresql'):
+                connectionUrlValue = postgresUrl.format(hostName, databaseName);
+                connectionUrlDefaultValue = postgresUrl.format(hostNameDefault, databaseNameDefault);
+                dbClassValue = 'org.postgresql.Driver';
+                break;
+              case 'Existing Oracle Database':
+                connectionUrlValue = oracleUrl.format(hostName, databaseName);
+                connectionUrlDefaultValue = oracleUrl.format(hostNameDefault, databaseNameDefault);
+                dbClassValue = 'oracle.jdbc.driver.OracleDriver';
+                break;
+              case 'Existing MSSQL Server database with SQL authentication':
+                connectionUrlValue = mssqlUrl.format(hostName, databaseName);
+                connectionUrlDefaultValue = mssqlUrl.format(hostNameDefault, databaseNameDefault);
+                dbClassValue = 'com.microsoft.sqlserver.jdbc.SQLServerDriver';
+                break;
+              case 'Existing MSSQL Server database with integrated authentication':
+                connectionUrlValue = mssqlIntegratedAuthUrl.format(hostName, databaseName);
+                connectionUrlDefaultValue = mssqlIntegratedAuthUrl.format(hostNameDefault,
databaseNameDefault);
+                dbClassValue = 'com.microsoft.sqlserver.jdbc.SQLServerDriver';
+                break;
+            }
+            categoryConfigsAll.findProperty('name', 'oozie.service.JPAService.jdbc.username').setProperties({
+              isVisible: isNotExistingMySQLServer,
+              isRequired: isNotExistingMySQLServer
+            });
+            categoryConfigsAll.findProperty('name', 'oozie.service.JPAService.jdbc.password').setProperties({
+              isVisible: isNotExistingMySQLServer,
+              isRequired: isNotExistingMySQLServer
+            });
+            break;
         }
-        connectionUrl.set('defaultValue', connectionUrl.get('value'));
+        connectionUrl.set('value', connectionUrlValue);
+        connectionUrl.set('defaultValue', connectionUrlDefaultValue);
+        dbClass.set('value', dbClassValue);
       }
     }
   }.observes('databaseName', 'hostName'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/39447162/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 7828f83..dfbef69 100644
--- a/ambari-web/test/views/common/controls_view_test.js
+++ b/ambari-web/test/views/common/controls_view_test.js
@@ -296,6 +296,8 @@ describe('App.ServiceConfigRadioButtons', function () {
     var view = App.ServiceConfigRadioButtons.create({
         hostName: null,
         databaseName: null,
+        hostNameProperty: null,
+        databaseNameProperty: null,
         connectionUrl: Em.Object.create(),
         dbClass: Em.Object.create(),
         serviceConfig: Em.Object.create(),
@@ -329,7 +331,10 @@ describe('App.ServiceConfigRadioButtons', function () {
           serviceConfigValue: 'New MySQL Database',
           databaseName: 'db0',
           hostName: 'h0',
+          databaseNameDefault: 'db0d',
+          hostNameDefault: 'h0d',
           connectionUrlValue: 'jdbc:mysql://h0/db0?createDatabaseIfNotExist=true',
+          connectionUrlDefaultValue: 'jdbc:mysql://h0d/db0d?createDatabaseIfNotExist=true',
           dbClassValue: 'com.mysql.jdbc.Driver',
           isAuthVisibleAndRequired: true,
           hiveDbTypeValue: 'mysql'
@@ -339,7 +344,10 @@ describe('App.ServiceConfigRadioButtons', function () {
           serviceConfigValue: Em.I18n.t('services.service.config.hive.oozie.postgresql'),
           databaseName: 'db1',
           hostName: 'h1',
+          databaseNameDefault: 'db1d',
+          hostNameDefault: 'h1d',
           connectionUrlValue: 'jdbc:postgresql://h1:5432/db1',
+          connectionUrlDefaultValue: 'jdbc:postgresql://h1d:5432/db1d',
           dbClassValue: 'org.postgresql.Driver',
           isAuthVisibleAndRequired: true,
           hiveDbTypeValue: 'postgres'
@@ -349,7 +357,10 @@ describe('App.ServiceConfigRadioButtons', function () {
           serviceConfigValue: 'Existing MySQL Database',
           databaseName: 'db2',
           hostName: 'h2',
+          databaseNameDefault: 'db2d',
+          hostNameDefault: 'h2d',
           connectionUrlValue: 'jdbc:mysql://h2/db2?createDatabaseIfNotExist=true',
+          connectionUrlDefaultValue: 'jdbc:mysql://h2d/db2d?createDatabaseIfNotExist=true',
           dbClassValue: 'com.mysql.jdbc.Driver',
           isAuthVisibleAndRequired: true,
           hiveDbTypeValue: 'mysql'
@@ -359,7 +370,10 @@ describe('App.ServiceConfigRadioButtons', function () {
           serviceConfigValue: 'Existing MSSQL Server database with SQL authentication',
           databaseName: 'db3',
           hostName: 'h3',
+          databaseNameDefault: 'db3d',
+          hostNameDefault: 'h3d',
           connectionUrlValue: 'jdbc:sqlserver://h3;databaseName=db3',
+          connectionUrlDefaultValue: 'jdbc:sqlserver://h3d;databaseName=db3d',
           dbClassValue: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
           isAuthVisibleAndRequired: true,
           hiveDbTypeValue: 'mssql'
@@ -369,7 +383,10 @@ describe('App.ServiceConfigRadioButtons', function () {
           serviceConfigValue: 'Existing Oracle Database',
           databaseName: 'db4',
           hostName: 'h4',
+          databaseNameDefault: 'db4d',
+          hostNameDefault: 'h4d',
           connectionUrlValue: 'jdbc:oracle:thin:@//h4:1521/db4',
+          connectionUrlDefaultValue: 'jdbc:oracle:thin:@//h4d:1521/db4d',
           dbClassValue: 'oracle.jdbc.driver.OracleDriver',
           isAuthVisibleAndRequired: true,
           hiveDbTypeValue: 'oracle'
@@ -379,7 +396,10 @@ describe('App.ServiceConfigRadioButtons', function () {
           serviceConfigValue: 'Existing MSSQL Server database with integrated authentication',
           databaseName: 'db5',
           hostName: 'h5',
+          databaseNameDefault: 'db5d',
+          hostNameDefault: 'h5d',
           connectionUrlValue: 'jdbc:sqlserver://h5;databaseName=db5;integratedSecurity=true',
+          connectionUrlDefaultValue: 'jdbc:sqlserver://h5d;databaseName=db5d;integratedSecurity=true',
           dbClassValue: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
           isAuthVisibleAndRequired: false,
           hiveDbTypeValue: 'mssql'
@@ -389,7 +409,10 @@ describe('App.ServiceConfigRadioButtons', function () {
           serviceConfigValue: 'New Derby Database',
           databaseName: 'db6',
           hostName: 'h6',
+          databaseNameDefault: 'db6d',
+          hostNameDefault: 'h6d',
           connectionUrlValue: 'jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true',
+          connectionUrlDefaultValue: 'jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true',
           dbClassValue: 'org.apache.derby.jdbc.EmbeddedDriver',
           isAuthVisibleAndRequired: true
         },
@@ -398,7 +421,10 @@ describe('App.ServiceConfigRadioButtons', function () {
           serviceConfigValue: 'Existing MySQL Database',
           databaseName: 'db7',
           hostName: 'h7',
+          databaseNameDefault: 'db7d',
+          hostNameDefault: 'h7d',
           connectionUrlValue: 'jdbc:mysql://h7/db7',
+          connectionUrlDefaultValue: 'jdbc:mysql://h7/db7',
           dbClassValue: 'com.mysql.jdbc.Driver',
           isAuthVisibleAndRequired: true
         },
@@ -407,7 +433,10 @@ describe('App.ServiceConfigRadioButtons', function () {
           serviceConfigValue: Em.I18n.t('services.service.config.hive.oozie.postgresql'),
           databaseName: 'db8',
           hostName: 'h8',
+          databaseNameDefault: 'db8d',
+          hostNameDefault: 'h8d',
           connectionUrlValue: 'jdbc:postgresql://h8:5432/db8',
+          connectionUrlDefaultValue: 'jdbc:postgresql://h8:5432/db8',
           dbClassValue: 'org.postgresql.Driver',
           isAuthVisibleAndRequired: true
         },
@@ -416,7 +445,10 @@ describe('App.ServiceConfigRadioButtons', function () {
           serviceConfigValue: 'Existing MSSQL Server database with SQL authentication',
           databaseName: 'db9',
           hostName: 'h9',
+          databaseNameDefault: 'db9d',
+          hostNameDefault: 'h9d',
           connectionUrlValue: 'jdbc:sqlserver://h9;databaseName=db9',
+          connectionUrlDefaultValue: 'jdbc:sqlserver://h9;databaseName=db9',
           dbClassValue: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
           isAuthVisibleAndRequired: true
         },
@@ -425,7 +457,10 @@ describe('App.ServiceConfigRadioButtons', function () {
           serviceConfigValue: 'Existing Oracle Database',
           databaseName: 'db10',
           hostName: 'h10',
+          databaseNameDefault: 'db10d',
+          hostNameDefault: 'h10d',
           connectionUrlValue: 'jdbc:oracle:thin:@//h10:1521/db10',
+          connectionUrlDefaultValue: 'jdbc:oracle:thin:@//h10:1521/db10',
           dbClassValue: 'oracle.jdbc.driver.OracleDriver',
           isAuthVisibleAndRequired: true
         },
@@ -434,7 +469,10 @@ describe('App.ServiceConfigRadioButtons', function () {
           serviceConfigValue: 'Existing MSSQL Server database with integrated authentication',
           databaseName: 'db11',
           hostName: 'h11',
+          databaseNameDefault: 'db11d',
+          hostNameDefault: 'h11d',
           connectionUrlValue: 'jdbc:sqlserver://h11;databaseName=db11;integratedSecurity=true',
+          connectionUrlDefaultValue: 'jdbc:sqlserver://h11;databaseName=db11;integratedSecurity=true',
           dbClassValue: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
           isAuthVisibleAndRequired: false
         }
@@ -444,12 +482,18 @@ describe('App.ServiceConfigRadioButtons', function () {
         OOZIE: ['oozie.service.JPAService.jdbc.username', 'oozie.service.JPAService.jdbc.password']
       };
 
-    before(function () {
+    beforeEach(function () {
       sinon.stub(view, 'handleDBConnectionProperty', Em.K);
+      sinon.stub(App.Service, 'find').returns([
+        {
+          serviceName: 'HIVE'
+        }
+      ]);
     });
 
-    after(function () {
+    afterEach(function () {
       view.handleDBConnectionProperty.restore();
+      App.Service.find.restore();
     });
 
     cases.forEach(function (item) {
@@ -460,9 +504,16 @@ describe('App.ServiceConfigRadioButtons', function () {
         });
         view.setProperties({
           databaseName: item.databaseName,
-          hostName: item.hostName
+          hostName: item.hostName,
+          databaseNameProperty: Em.Object.create({
+            defaultValue: item.databaseNameDefault
+          }),
+          hostNameProperty: Em.Object.create({
+            defaultValue: item.hostNameDefault
+          })
         });
         expect(view.get('connectionUrl.value')).to.equal(item.connectionUrlValue);
+        expect(view.get('connectionUrl.defaultValue')).to.equal(item.connectionUrlDefaultValue);
         expect(view.get('dbClass.value')).to.equal(item.dbClassValue);
         serviceAuthPropsMap[item.serviceName].forEach(function (propName) {
           expect(view.get('categoryConfigsAll').findProperty('name', propName).get('isVisible')).to.equal(item.isAuthVisibleAndRequired);


Mime
View raw message