123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- /**
- * 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('controllers/main/service/reassign/step1_controller');
- require('models/host_component');
- var testHelpers = require('test/helpers');
- describe('App.ReassignMasterWizardStep1Controller', function () {
- var controller = App.ReassignMasterWizardStep1Controller.create({
- content: Em.Object.create({
- reassign: Em.Object.create({}),
- services: []
- })
- });
- controller.set('_super', Em.K);
- describe('#loadConfigTags', function() {
- beforeEach(function() {
- this.stub = sinon.stub(App.router, 'get');
- });
- afterEach(function() {
- this.stub.restore();
- });
- it('tests loadConfigTags', function() {
- controller.loadConfigsTags();
- var args = testHelpers.findAjaxRequest('name', 'config.tags');
- expect(args).exists;
- });
- it('tests saveDatabaseType with type', function() {
- this.stub.returns({ saveDatabaseType: Em.K});
- controller.saveDatabaseType(true);
- expect(App.router.get.calledOnce).to.be.true;
- });
- it('tests saveDatabaseType without type', function() {
- this.stub.returns({ saveDatabaseType: Em.K});
- controller.saveDatabaseType(false);
- expect(App.router.get.called).to.be.false;
- });
- it('tests saveServiceProperties with properties', function() {
- this.stub.returns({ saveServiceProperties: Em.K});
- controller.saveServiceProperties(true);
- expect(App.router.get.calledOnce).to.be.true;
- });
- it('tests saveServiceProperties without properties', function() {
- this.stub.returns({ saveServiceProperties: Em.K});
- controller.saveServiceProperties(false);
- expect(App.router.get.called).to.be.false;
- });
- it('tests getDatabaseHost', function() {
- controller.set('content.serviceProperties', {
- 'javax.jdo.option.ConnectionURL': "jdbc:mysql://c6401/hive?createDatabaseIfNotExist=true"
- });
- controller.set('content.reassign.service_id', 'HIVE');
- controller.set('databaseType', 'mysql');
- expect(controller.getDatabaseHost()).to.equal('c6401')
- });
- });
- describe('#onLoadConfigs', function() {
- var reassignCtrl;
- beforeEach(function() {
- controller = App.ReassignMasterWizardStep1Controller.create({
- content: Em.Object.create({
- reassign: Em.Object.create({
- 'component_name': 'OOZIE_SERVER',
- 'service_id': 'OOZIE'
- }),
- services: []
- })
- });
- controller.set('_super', Em.K);
- sinon.stub(controller, 'getDatabaseHost', Em.K);
- sinon.stub(controller, 'saveDatabaseType', Em.K);
- sinon.stub(controller, 'saveServiceProperties', Em.K);
-
- reassignCtrl = App.router.reassignMasterController;
- reassignCtrl.set('content.hasManualSteps', true);
- });
- afterEach(function() {
- controller.getDatabaseHost.restore();
- controller.saveDatabaseType.restore();
- controller.saveServiceProperties.restore();
- });
-
- it('should not set hasManualSteps to false for oozie with derby db', function() {
- var data = {
- items: [
- {
- properties: {
- 'oozie.service.JPAService.jdbc.driver': 'jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true'
- }
- }
- ]
- };
-
- expect(reassignCtrl.get('content.hasManualSteps')).to.be.true;
- controller.onLoadConfigs(data);
- expect(reassignCtrl.get('content.hasManualSteps')).to.be.true;
- });
-
- it('should set hasManualSteps to false for oozie without derby db', function() {
- var data = {
- items: [
- {
- properties: {
- 'oozie.service.JPAService.jdbc.driver': 'mysql'
- }
- }
- ]
- };
-
- expect(reassignCtrl.get('content.hasManualSteps')).to.be.true;
- controller.onLoadConfigs(data);
- expect(reassignCtrl.get('content.hasManualSteps')).to.be.false;
- });
- });
- describe("#getConfigUrlParams()", function() {
- it("unknown component", function() {
- expect(controller.getConfigUrlParams("", {})).to.be.empty;
- });
- it("OOZIE_SERVER component", function() {
- var data = {
- Clusters: {
- desired_configs: {
- 'oozie-site': {
- tag: 'tag'
- },
- 'oozie-env': {
- tag: 'tag'
- }
- }
- }
- };
- expect(controller.getConfigUrlParams("OOZIE_SERVER", data)).to.eql([
- "(type=oozie-site&tag=tag)",
- "(type=oozie-env&tag=tag)"
- ]);
- });
- it("HIVE_SERVER component", function() {
- var data = {
- Clusters: {
- desired_configs: {
- 'hive-site': {
- tag: 'tag'
- },
- 'hive-env': {
- tag: 'tag'
- }
- }
- }
- };
- expect(controller.getConfigUrlParams("HIVE_SERVER", data)).to.eql([
- "(type=hive-site&tag=tag)",
- "(type=hive-env&tag=tag)"
- ]);
- });
- });
- describe("#onLoadConfigsTags()", function () {
- beforeEach(function () {
- this.mock = sinon.stub(controller, 'getConfigUrlParams');
- });
- afterEach(function () {
- this.mock.restore();
- });
- it("empty params", function () {
- this.mock.returns([]);
- controller.onLoadConfigsTags();
- var args = testHelpers.findAjaxRequest('name', 'reassign.load_configs');
- expect(args).not.exists;
- });
- it("correct params", function () {
- this.mock.returns(['p1', 'p2']);
- controller.onLoadConfigsTags();
- var args = testHelpers.findAjaxRequest('name', 'reassign.load_configs');
- expect(args[0]).exists;
- expect(args[0].sender).to.be.eql(controller);
- expect(args[0].data).to.be.eql({
- urlParams: 'p1|p2'
- });
- });
- });
- });
|