Repository: ambari Updated Branches: refs/heads/trunk 4719d4724 -> 737b0e5ad
AMBARI-8762 'hive_database_type' value doesn't change after changing Hive DB type on deployed cluster. (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/737b0e5a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/737b0e5a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/737b0e5a Branch: refs/heads/trunk Commit: 737b0e5ade072bb8d0a416ed174c7f15f3d77c8a Parents: 4719d47 Author: aBabiichuk <ababiic...@cybervisiontech.com> Authored: Wed Dec 17 18:57:14 2014 +0200 Committer: aBabiichuk <ababiic...@cybervisiontech.com> Committed: Thu Dec 18 12:08:27 2014 +0200 ---------------------------------------------------------------------- .../app/controllers/wizard/step8_controller.js | 7 - ambari-web/app/data/HDP2/site_properties.js | 1 - ambari-web/app/data/site_properties.js | 1 - ambari-web/app/views/wizard/controls_view.js | 6 + .../test/controllers/wizard/step8_test.js | 5 - .../test/views/wizard/controls_view_test.js | 212 ++++++++++++++++++- 6 files changed, 217 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/737b0e5a/ambari-web/app/controllers/wizard/step8_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js index 1ad91d0..73b831f 100644 --- a/ambari-web/app/controllers/wizard/step8_controller.js +++ b/ambari-web/app/controllers/wizard/step8_controller.js @@ -268,7 +268,6 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz case 'New MySQL Database': if (configs.someProperty('name', 'hive_ambari_host')) { configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_ambari_host').value; - hiveDbType.value = 'mysql'; } hive_properties = Em.A(['hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_oracle_host', 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database', @@ -278,14 +277,12 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz case 'New PostgreSQL Database': if (configs.someProperty('name', 'hive_ambari_host')) { configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_ambari_host').value; - hiveDbType.value = 'postgres'; } hive_properties = Em.A(['hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_oracle_host', 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']); break; case 'Existing MySQL Database': configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mysql_host').value; - hiveDbType.value = 'mysql'; hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host', 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database', 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_host', @@ -293,7 +290,6 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz break; case Em.I18n.t('services.service.config.hive.oozie.postgresql'): configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_postgresql_host').value; - hiveDbType.value = 'postgres'; hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host', 'hive_existing_oracle_database', 'hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_host', @@ -301,7 +297,6 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz break; case 'Existing MSSQL Server database with integrated authentication': configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mssql_server_2_host').value; - hiveDbType.value = 'mssql'; hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host', 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database', 'hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_mssql_server_database', @@ -309,7 +304,6 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz break; case 'Existing MSSQL Server database with sql auth': configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mssql_server_host').value; - hiveDbType.value = 'mssql'; hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host', 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database', 'hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_mssql_server_database', @@ -317,7 +311,6 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz break; default: configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_oracle_host').value; - hiveDbType.value = 'oracle'; hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database', 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_host', http://git-wip-us.apache.org/repos/asf/ambari/blob/737b0e5a/ambari-web/app/data/HDP2/site_properties.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/data/HDP2/site_properties.js b/ambari-web/app/data/HDP2/site_properties.js index 4173b4e..906ac5b 100644 --- a/ambari-web/app/data/HDP2/site_properties.js +++ b/ambari-web/app/data/HDP2/site_properties.js @@ -3627,7 +3627,6 @@ module.exports = "name": "hive_database_type", "displayName": "hive_database_type", "defaultValue": "", - "isReconfigurable": false, "isOverridable": false, "isVisible": false, "serviceName": "HIVE", http://git-wip-us.apache.org/repos/asf/ambari/blob/737b0e5a/ambari-web/app/data/site_properties.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/data/site_properties.js b/ambari-web/app/data/site_properties.js index 2009913..352e461 100644 --- a/ambari-web/app/data/site_properties.js +++ b/ambari-web/app/data/site_properties.js @@ -1863,7 +1863,6 @@ module.exports = "name": "hive_database_type", "displayName": "hive_database_type", "defaultValue": "", - "isReconfigurable": false, "isOverridable": false, "isVisible": false, "serviceName": "HIVE", http://git-wip-us.apache.org/repos/asf/ambari/blob/737b0e5a/ambari-web/app/views/wizard/controls_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/wizard/controls_view.js b/ambari-web/app/views/wizard/controls_view.js index a3d0015..ea9bfb9 100644 --- a/ambari-web/app/views/wizard/controls_view.js +++ b/ambari-web/app/views/wizard/controls_view.js @@ -225,27 +225,33 @@ App.ServiceConfigRadioButtons = Ember.View.extend({ 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 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; case 'Existing MSSQL Server database with sql auth': 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; } var isNotExistingMySQLServer = this.get('serviceConfig.value') !== 'Existing MSSQL Server database with integrated authentication'; http://git-wip-us.apache.org/repos/asf/ambari/blob/737b0e5a/ambari-web/test/controllers/wizard/step8_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js index 410d0b1..823424c 100644 --- a/ambari-web/test/controllers/wizard/step8_test.js +++ b/ambari-web/test/controllers/wizard/step8_test.js @@ -295,7 +295,6 @@ describe('App.WizardStep8Controller', function () { ], removed: Em.A(['hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_oracle_host', 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']), - hive_database_type: 'mysql', m: 'hive_database: New MySQL Database', host: 'h1' }, @@ -308,7 +307,6 @@ describe('App.WizardStep8Controller', function () { ], removed: Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host', 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']), - hive_database_type: 'mysql', m: 'hive_database: Existing MySQL Database', host: 'h1' }, @@ -321,7 +319,6 @@ describe('App.WizardStep8Controller', function () { ], removed: Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host', 'hive_existing_oracle_database', 'hive_existing_mysql_host', 'hive_existing_mysql_database']), - hive_database_type: 'postgres', m: 'hive_database: Existing PostgreSQL Database', host: 'h1' }, @@ -334,7 +331,6 @@ describe('App.WizardStep8Controller', function () { ], removed: Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']), - hive_database_type: 'oracle', m: 'hive_database: Existing Oracle Database', host: 'h1' } @@ -347,7 +343,6 @@ describe('App.WizardStep8Controller', function () { test.removed.forEach(function(name) { expect(Em.isNone(configs.findProperty('name', name))).to.equal(true); }); - expect(configs.findProperty('name', 'hive_database_type').value).to.equal(test.hive_database_type); expect(configs.findProperty('name', 'hive_hostname').value).to.equal(test.host); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/737b0e5a/ambari-web/test/views/wizard/controls_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/wizard/controls_view_test.js b/ambari-web/test/views/wizard/controls_view_test.js index b52613f..a28f493 100644 --- a/ambari-web/test/views/wizard/controls_view_test.js +++ b/ambari-web/test/views/wizard/controls_view_test.js @@ -326,6 +326,216 @@ describe('App.ServiceConfigRadioButtons', function () { }); + describe('#onOptionsChange', function () { + + var view = App.ServiceConfigRadioButtons.create({ + hostName: null, + databaseName: null, + connectionUrl: Em.Object.create(), + dbClass: Em.Object.create(), + serviceConfig: Em.Object.create(), + categoryConfigsAll: [ + Em.Object.create({ + name: 'javax.jdo.option.ConnectionUserName' + }), + Em.Object.create({ + name: 'javax.jdo.option.ConnectionPassword' + }), + Em.Object.create({ + name: 'oozie.service.JPAService.jdbc.username' + }), + Em.Object.create({ + name: 'oozie.service.JPAService.jdbc.password' + }), + Em.Object.create({ + name: 'sink.dblogin' + }), + Em.Object.create({ + name: 'sink.dbpassword' + }) + ], + parentView: Em.Object.create({ + serviceConfigs: [ + { + name: 'hive_database_type', + value: null + } + ] + }), + configs: [{}] + }), + cases = [ + { + serviceName: 'HIVE', + serviceConfigValue: 'New MySQL Database', + databaseName: 'db0', + hostName: 'h0', + connectionUrlValue: 'jdbc:mysql://h0/db0?createDatabaseIfNotExist=true', + dbClassValue: 'com.mysql.jdbc.Driver', + isAuthVisibleAndRequired: true, + hiveDbTypeValue: 'mysql' + }, + { + serviceName: 'HIVE', + serviceConfigValue: Em.I18n.t('services.service.config.hive.oozie.postgresql'), + databaseName: 'db1', + hostName: 'h1', + connectionUrlValue: 'jdbc:postgresql://h1:5432/db1', + dbClassValue: 'org.postgresql.Driver', + isAuthVisibleAndRequired: true, + hiveDbTypeValue: 'postgres' + }, + { + serviceName: 'HIVE', + serviceConfigValue: 'Existing MySQL Database', + databaseName: 'db2', + hostName: 'h2', + connectionUrlValue: 'jdbc:mysql://h2/db2?createDatabaseIfNotExist=true', + dbClassValue: 'com.mysql.jdbc.Driver', + isAuthVisibleAndRequired: true, + hiveDbTypeValue: 'mysql' + }, + { + serviceName: 'HIVE', + serviceConfigValue: 'Existing MSSQL Server database with sql auth', + databaseName: 'db3', + hostName: 'h3', + connectionUrlValue: 'jdbc:sqlserver://h3;databaseName=db3', + dbClassValue: 'com.microsoft.sqlserver.jdbc.SQLServerDriver', + isAuthVisibleAndRequired: true, + hiveDbTypeValue: 'mssql' + }, + { + serviceName: 'HIVE', + serviceConfigValue: 'Existing Oracle Database', + databaseName: 'db4', + hostName: 'h4', + connectionUrlValue: 'jdbc:oracle:thin:@//h4:1521/db4', + dbClassValue: 'oracle.jdbc.driver.OracleDriver', + isAuthVisibleAndRequired: true, + hiveDbTypeValue: 'oracle' + }, + { + serviceName: 'HIVE', + serviceConfigValue: 'Existing MSSQL Server database with integrated authentication', + databaseName: 'db5', + hostName: 'h5', + connectionUrlValue: 'jdbc:sqlserver://h5;databaseName=db5;integratedSecurity=true', + dbClassValue: 'com.microsoft.sqlserver.jdbc.SQLServerDriver', + isAuthVisibleAndRequired: false, + hiveDbTypeValue: 'mssql' + }, + { + serviceName: 'OOZIE', + serviceConfigValue: 'New Derby Database', + databaseName: 'db6', + hostName: 'h6', + connectionUrlValue: 'jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true', + dbClassValue: 'org.apache.derby.jdbc.EmbeddedDriver', + isAuthVisibleAndRequired: true + }, + { + serviceName: 'OOZIE', + serviceConfigValue: 'Existing MySQL Database', + databaseName: 'db7', + hostName: 'h7', + connectionUrlValue: 'jdbc:mysql://h7/db7', + dbClassValue: 'com.mysql.jdbc.Driver', + isAuthVisibleAndRequired: true + }, + { + serviceName: 'OOZIE', + serviceConfigValue: Em.I18n.t('services.service.config.hive.oozie.postgresql'), + databaseName: 'db8', + hostName: 'h8', + connectionUrlValue: 'jdbc:postgresql://h8:5432/db8', + dbClassValue: 'org.postgresql.Driver', + isAuthVisibleAndRequired: true + }, + { + serviceName: 'OOZIE', + serviceConfigValue: 'Existing MSSQL Server database with sql auth', + databaseName: 'db9', + hostName: 'h9', + connectionUrlValue: 'jdbc:sqlserver://h9;databaseName=db9', + dbClassValue: 'com.microsoft.sqlserver.jdbc.SQLServerDriver', + isAuthVisibleAndRequired: true + }, + { + serviceName: 'OOZIE', + serviceConfigValue: 'Existing Oracle Database', + databaseName: 'db10', + hostName: 'h10', + connectionUrlValue: 'jdbc:oracle:thin:@//h10:1521/db10', + dbClassValue: 'oracle.jdbc.driver.OracleDriver', + isAuthVisibleAndRequired: true + }, + { + serviceName: 'OOZIE', + serviceConfigValue: 'Existing MSSQL Server database with integrated authentication', + databaseName: 'db11', + hostName: 'h11', + connectionUrlValue: 'jdbc:sqlserver://h11;databaseName=db11;integratedSecurity=true', + dbClassValue: 'com.microsoft.sqlserver.jdbc.SQLServerDriver', + isAuthVisibleAndRequired: false + }, + { + serviceName: 'HDFS', + serviceConfigValue: 'Existing MSSQL Server database with sql auth', + databaseName: 'db12', + hostName: 'h12', + connectionUrlValue: 'jdbc:sqlserver://h12;databaseName=db12', + dbClassValue: 'com.microsoft.sqlserver.jdbc.SQLServerDriver', + isAuthVisibleAndRequired: true + }, + { + serviceName: 'HDFS', + serviceConfigValue: 'Existing MSSQL Server database with integrated authentication', + databaseName: 'db13', + hostName: 'h13', + connectionUrlValue: 'jdbc:sqlserver://h13;databaseName=db13;integratedSecurity=true', + dbClassValue: 'com.microsoft.sqlserver.jdbc.SQLServerDriver', + isAuthVisibleAndRequired: false + } + ], + serviceAuthPropsMap = { + HIVE: ['javax.jdo.option.ConnectionUserName', 'javax.jdo.option.ConnectionPassword'], + OOZIE: ['oozie.service.JPAService.jdbc.username', 'oozie.service.JPAService.jdbc.password'], + HDFS: ['sink.dblogin', 'sink.dbpassword'] + }; + + before(function () { + sinon.stub(view, 'handleDBConnectionProperty', Em.K); + }); + + after(function () { + view.handleDBConnectionProperty.restore(); + }); + + cases.forEach(function (item) { + it(item.serviceName + ', ' + item.serviceConfigValue, function () { + view.get('serviceConfig').setProperties({ + serviceName: item.serviceName, + value: item.serviceConfigValue + }); + view.setProperties({ + databaseName: item.databaseName, + hostName: item.hostName + }); + expect(view.get('connectionUrl.value')).to.equal(item.connectionUrlValue); + 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); + expect(view.get('categoryConfigsAll').findProperty('name', propName).get('isRequired')).to.equal(item.isAuthVisibleAndRequired); + }); + if (item.serviceName == 'HIVE') { + expect(view.get('parentView.serviceConfigs').findProperty('name', 'hive_database_type').value).to.equal(item.hiveDbTypeValue); + } + }); + }); + + }); + }); describe('App.ServiceConfigRadioButton', function () { @@ -391,7 +601,7 @@ describe('App.ServiceConfigRadioButton', function () { }); it('parent view is disabled', function () { - var view = view = App.ServiceConfigRadioButton.create({ + var view = App.ServiceConfigRadioButton.create({ parentView: Em.Object.create({ serviceConfig: Em.Object.create() })