123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657 |
- /**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- var App = require('app');
- require('views/common/controls_view');
- describe('App.ServiceConfigRadioButtons', function () {
- describe('#didInsertElement', function () {
- var view = App.ServiceConfigRadioButtons.create({
- categoryConfigsAll: [],
- controller: Em.Object.create({
- wizardController: Em.Object.create({})
- }),
- serviceConfig: Em.Object.create({
- value: null
- })
- }),
- cases = [
- {
- wizardControllerName: 'addServiceController',
- serviceConfigValue: 'New MySQL Database',
- onOptionsChangeCalledTwice: true,
- handleDBConnectionPropertyCalledTwice: false,
- title: 'Add Service Wizard, New MySQL Database'
- },
- {
- wizardControllerName: 'addServiceController',
- serviceConfigValue: 'Existing MySQL Database',
- onOptionsChangeCalledTwice: false,
- handleDBConnectionPropertyCalledTwice: true,
- title: 'Add Service Wizard, Existing MySQL Database'
- },
- {
- wizardControllerName: 'installerController',
- serviceConfigValue: 'New MySQL Database',
- onOptionsChangeCalledTwice: true,
- handleDBConnectionPropertyCalledTwice: false,
- title: 'Install Wizard, New MySQL Database'
- },
- {
- wizardControllerName: 'installerController',
- serviceConfigValue: 'Existing MySQL Database',
- onOptionsChangeCalledTwice: false,
- handleDBConnectionPropertyCalledTwice: true,
- title: 'Install Wizard, Existing MySQL Database'
- },
- {
- wizardControllerName: null,
- serviceConfigValue: null,
- onOptionsChangeCalledTwice: false,
- handleDBConnectionPropertyCalledTwice: false,
- title: 'Service Configs Page'
- }
- ];
- beforeEach(function () {
- sinon.stub(view, 'onOptionsChange', Em.K);
- sinon.stub(view, 'handleDBConnectionProperty', Em.K);
- });
- afterEach(function () {
- view.onOptionsChange.restore();
- view.handleDBConnectionProperty.restore();
- });
- cases.forEach(function (item) {
- it(item.title, function () {
- view.set('controller.wizardController.name', item.wizardControllerName);
- view.set('serviceConfig.value', item.serviceConfigValue);
- view.didInsertElement();
- expect(view.onOptionsChange.calledTwice).to.equal(item.onOptionsChangeCalledTwice);
- expect(view.handleDBConnectionProperty.calledTwice).to.equal(item.handleDBConnectionPropertyCalledTwice);
- });
- });
- });
- describe('#databaseNameProperty', function () {
- var view = App.ServiceConfigRadioButtons.create({
- serviceConfig: Em.Object.create(),
- categoryConfigsAll: [
- {
- name: 'ambari.hive.db.schema.name',
- value: 'db0'
- },
- {
- name: 'oozie.db.schema.name',
- value: 'db2'
- }
- ]
- }),
- cases = [
- {
- serviceName: 'HIVE',
- value: 'db0'
- },
- {
- serviceName: 'OOZIE',
- value: 'db2'
- }
- ];
- cases.forEach(function (item) {
- it(item.serviceName, function () {
- view.set('serviceConfig.serviceName', item.serviceName);
- expect(view.get('databaseNameProperty.value')).to.equal(item.value);
- expect(view.get('databaseName')).to.equal(item.value);
- });
- });
- it('default case', function () {
- view.set('serviceConfig.serviceName', 'YARN');
- expect(view.get('databaseNameProperty')).to.be.null;
- expect(view.get('databaseName')).to.be.null;
- });
- });
- describe('#hostNameProperty', function () {
- var view = App.ServiceConfigRadioButtons.create({
- serviceConfig: Em.Object.create(),
- categoryConfigsAll: [
- {
- name: 'hive_ambari_host',
- value: 'h0'
- },
- {
- name: 'hive_existing_mysql_host',
- value: 'h1'
- },
- {
- name: 'hive_existing_postgresql_host',
- value: 'h2'
- },
- {
- name: 'hive_existing_oracle_host',
- value: 'h3'
- },
- {
- name: 'hive_existing_mssql_server_host',
- value: 'h4'
- },
- {
- name: 'hive_existing_mssql_server_2_host',
- value: 'h5'
- },
- {
- name: 'hive_hostname',
- value: 'h6'
- },
- {
- name: 'oozie_ambari_host',
- value: 'h10'
- },
- {
- name: 'oozie_existing_mysql_host',
- value: 'h11'
- },
- {
- name: 'oozie_existing_postgresql_host',
- value: 'h12'
- },
- {
- name: 'oozie_existing_oracle_host',
- value: 'h13'
- },
- {
- name: 'oozie_existing_mssql_server_host',
- value: 'h14'
- },
- {
- name: 'oozie_existing_mssql_server_2_host',
- value: 'h15'
- },
- {
- name: 'oozie_hostname',
- value: 'h16'
- }
- ]
- }),
- cases = [
- {
- serviceName: 'HIVE',
- value: 'New MySQL Database',
- expected: 'h0'
- },
- {
- serviceName: 'HIVE',
- value: 'Existing MySQL Database',
- expected: 'h1'
- },
- {
- serviceName: 'HIVE',
- value: Em.I18n.t('services.service.config.hive.oozie.postgresql'),
- expected: 'h2'
- },
- {
- serviceName: 'HIVE',
- value: 'Existing Oracle Database',
- expected: 'h3'
- },
- {
- serviceName: 'HIVE',
- value: 'Existing MSSQL Server database with SQL authentication',
- expected: 'h4'
- },
- {
- serviceName: 'HIVE',
- value: 'Existing MSSQL Server database with integrated authentication',
- expected: 'h5'
- },
- {
- serviceName: 'HIVE',
- value: 'default case',
- expected: 'h6'
- },
- {
- serviceName: 'OOZIE',
- value: 'New Derby Database',
- expected: 'h10'
- },
- {
- serviceName: 'OOZIE',
- value: 'Existing MySQL Database',
- expected: 'h11'
- },
- {
- serviceName: 'OOZIE',
- value: Em.I18n.t('services.service.config.hive.oozie.postgresql'),
- expected: 'h12'
- },
- {
- serviceName: 'OOZIE',
- value: 'Existing Oracle Database',
- expected: 'h13'
- },
- {
- serviceName: 'OOZIE',
- value: 'Existing MSSQL Server database with SQL authentication',
- expected: 'h14'
- },
- {
- serviceName: 'OOZIE',
- value: 'Existing MSSQL Server database with integrated authentication',
- expected: 'h15'
- },
- {
- serviceName: 'OOZIE',
- value: 'default case',
- expected: 'h16'
- }
- ];
- before(function () {
- sinon.stub(view, 'handleDBConnectionProperty', Em.K);
- });
- after(function () {
- view.handleDBConnectionProperty.restore();
- });
- cases.forEach(function (item) {
- it(item.serviceName + ', ' + item.value, function () {
- view.get('serviceConfig').setProperties({
- serviceName: item.serviceName,
- value: item.value
- });
- expect(view.get('hostNameProperty.value')).to.equal(item.expected);
- expect(view.get('hostName')).to.equal(item.expected);
- });
- });
- });
- describe('#onOptionsChange', 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(),
- 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'
- })
- ],
- parentView: Em.Object.create({
- serviceConfigs: [
- {
- name: 'hive_database_type',
- value: null
- }
- ]
- }),
- configs: [{}]
- }),
- cases = [
- {
- serviceName: 'HIVE',
- 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'
- },
- {
- serviceName: 'HIVE',
- 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'
- },
- {
- serviceName: 'HIVE',
- 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'
- },
- {
- serviceName: 'HIVE',
- 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'
- },
- {
- serviceName: 'HIVE',
- 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'
- },
- {
- serviceName: 'HIVE',
- 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'
- },
- {
- serviceName: 'OOZIE',
- 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
- },
- {
- serviceName: 'OOZIE',
- 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
- },
- {
- serviceName: 'OOZIE',
- 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
- },
- {
- serviceName: 'OOZIE',
- 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
- },
- {
- serviceName: 'OOZIE',
- 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
- },
- {
- serviceName: 'OOZIE',
- 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
- }
- ],
- serviceAuthPropsMap = {
- HIVE: ['javax.jdo.option.ConnectionUserName', 'javax.jdo.option.ConnectionPassword'],
- OOZIE: ['oozie.service.JPAService.jdbc.username', 'oozie.service.JPAService.jdbc.password']
- };
- beforeEach(function () {
- sinon.stub(view, 'handleDBConnectionProperty', Em.K);
- sinon.stub(App.Service, 'find').returns([
- {
- serviceName: 'HIVE'
- }
- ]);
- });
- afterEach(function () {
- view.handleDBConnectionProperty.restore();
- App.Service.find.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,
- 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);
- 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 () {
- describe('#disabled', function () {
- var cases = [
- {
- wizardControllerName: 'addServiceController',
- value: 'New MySQL Database',
- title: 'Add Service Wizard, new database',
- disabled: false
- },
- {
- wizardControllerName: 'installerController',
- value: 'New MySQL Database',
- title: 'Install Wizard, new database',
- disabled: false
- },
- {
- wizardControllerName: 'addServiceController',
- value: 'Existing MySQL Database',
- title: 'Add Service Wizard, existing database',
- disabled: false
- },
- {
- wizardControllerName: 'installerController',
- value: 'Existing MySQL Database',
- title: 'Install Wizard, existing database',
- disabled: false
- },
- {
- wizardControllerName: null,
- value: 'New MySQL Database',
- title: 'No installer, new database',
- disabled: true
- },
- {
- wizardControllerName: null,
- value: 'Existing MySQL Database',
- title: 'No installer, existing database',
- disabled: false
- }
- ];
- cases.forEach(function (item) {
- it(item.title, function () {
- var view = App.ServiceConfigRadioButton.create({
- parentView: Em.Object.create({
- serviceConfig: Em.Object.create()
- }),
- controller: Em.Object.create({
- wizardController: Em.Object.create({
- name: null
- })
- })
- });
- view.set('value', item.value);
- view.set('controller.wizardController.name', item.wizardControllerName);
- view.set('parentView.serviceConfig.isEditable', true);
- expect(view.get('disabled')).to.equal(item.disabled);
- });
- });
- it('parent view is disabled', function () {
- var view = App.ServiceConfigRadioButton.create({
- parentView: Em.Object.create({
- serviceConfig: Em.Object.create()
- })
- });
- view.set('parentView.serviceConfig.isEditable', false);
- expect(view.get('disabled')).to.be.true;
- });
- });
- });
- describe('App.CheckDBConnectionView', function () {
- describe('#masterHostName', function () {
- var cases = [
- {
- serviceName: 'OOZIE',
- value: 'h0'
- },
- {
- serviceName: 'KERBEROS',
- value: 'h1'
- },
- {
- serviceName: 'HIVE',
- value: 'h2'
- }
- ],
- categoryConfigsAll = [
- Em.Object.create({
- name: 'oozieserver_host',
- value: 'h0'
- }),
- Em.Object.create({
- name: 'kdc_host',
- value: 'h1'
- }),
- Em.Object.create({
- name: 'hive_ambari_host',
- value: 'h2'
- })
- ];
- cases.forEach(function (item) {
- it(item.serviceName, function () {
- var view = App.CheckDBConnectionView.create({
- parentView: {
- service: {
- serviceName: item.serviceName
- },
- categoryConfigsAll: categoryConfigsAll
- }
- });
- expect(view.get('masterHostName')).to.equal(item.value);
- });
- });
- });
- });
|