AMBARI-9630. Kerbeors wizard: ATS hostComponent should be deleted for HDP-2.0/2.1 stack (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/94b3509f Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/94b3509f Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/94b3509f Branch: refs/heads/trunk Commit: 94b3509f4db0254ea738470b36e058b28f237fe5 Parents: 73416b6 Author: Alex Antonenko <hiv...@gmail.com> Authored: Fri Feb 13 18:15:51 2015 +0200 Committer: Alex Antonenko <hiv...@gmail.com> Committed: Fri Feb 13 20:03:02 2015 +0200 ---------------------------------------------------------------------- ambari-web/app/assets/test/tests.js | 1 + .../main/admin/kerberos/step5_controller.js | 43 +++++++++++++++++++- ambari-web/app/messages.js | 1 + .../admin/kerberos/step5_controller_test.js | 43 ++++++++++++++++++++ 4 files changed, 87 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/94b3509f/ambari-web/app/assets/test/tests.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js index cd0dc1d..bd16cde 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -52,6 +52,7 @@ var files = ['test/init_model_test', 'test/controllers/main/admin/kerberos_test', 'test/controllers/main/admin/kerberos/kerberos_wizard_controler_test', 'test/controllers/main/admin/kerberos/step4_controller_test', + 'test/controllers/main/admin/kerberos/step5_controller_test', 'test/controllers/main/admin/stack_and_upgrade_controller_test', 'test/controllers/main/admin/serviceAccounts_controller_test', 'test/controllers/main/admin/highAvailability_controller_test', http://git-wip-us.apache.org/repos/asf/ambari/blob/94b3509f/ambari-web/app/controllers/main/admin/kerberos/step5_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/kerberos/step5_controller.js b/ambari-web/app/controllers/main/admin/kerberos/step5_controller.js index 49d2d5e..5cc06bd 100644 --- a/ambari-web/app/controllers/main/admin/kerberos/step5_controller.js +++ b/ambari-web/app/controllers/main/admin/kerberos/step5_controller.js @@ -34,5 +34,46 @@ App.KerberosWizardStep5Controller = App.KerberosProgressPageController.extend({ success: 'startPolling', error: 'onTaskError' }); + }, + + loadStep: function() { + this.checkComponentsRemoval(); + this._super(); + }, + + /** + * remove Application Timeline Server component if needed. + */ + checkComponentsRemoval: function() { + if (App.Service.find().someProperty('serviceName', 'YARN') && !App.get('doesATSSupportKerberos') && !this.get('commands').contains('deleteATS')) { + this.get('commands').pushObject('deleteATS'); + } + }, + + /** + * Remove Application Timeline Server from the host. + * @returns {$.Deferred} + */ + deleteATS: function() { + return App.ajax.send({ + name: 'common.delete.host_component', + sender: this, + data: { + componentName: 'APP_TIMELINE_SERVER', + hostName: App.HostComponent.find().findProperty('componentName', 'APP_TIMELINE_SERVER').get('hostName') + }, + success: 'onDeleteATSSuccess', + error: 'onDeleteATSError' + }); + }, + + onDeleteATSSuccess: function() { + this.onTaskCompleted(); + }, + + onDeleteATSError: function(error) { + if (error.responseText.indexOf('org.apache.ambari.server.controller.spi.NoSuchResourceException') !== -1) { + this.onDeleteATSSuccess(); + } } -}); \ No newline at end of file +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/94b3509f/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index f794271..b5c0ee1 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -970,6 +970,7 @@ Em.I18n.translations = { 'admin.kerberos.wizard.progressPage.notice.inProgress': 'Please wait while cluster is being kerberized', 'admin.kerberos.wizard.step4.info.body': 'Configure principal name and keytab location for service users and hadoop service components.', 'admin.kerberos.wizard.step5.task0.title' : 'Stop Services', + 'admin.kerberos.wizard.step5.task1.title' : 'Delete ATS', 'admin.kerberos.wizard.step5.notice.inProgress': 'Please wait while services are being stopped.', 'admin.kerberos.wizard.step5.notice.completed': 'Services have been successfully stopped.', 'admin.kerberos.wizard.step6.notice.inProgress': 'Please wait while cluster is being kerberized.', http://git-wip-us.apache.org/repos/asf/ambari/blob/94b3509f/ambari-web/test/controllers/main/admin/kerberos/step5_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/kerberos/step5_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step5_controller_test.js new file mode 100644 index 0000000..93139fb --- /dev/null +++ b/ambari-web/test/controllers/main/admin/kerberos/step5_controller_test.js @@ -0,0 +1,43 @@ +/** + * 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'); + +describe('App.KerberosWizardStep5Controller', function() { + describe('checkComponentsRemoval', function() { + + var tests = [ + { yarnInstalled: true, doesATSSupportKerberos: false, commands: ['stopServices', 'deleteATS']}, + { yarnInstalled: false, doesATSSupportKerberos: true, commands: ['stopServices']}, + { yarnInstalled: false, doesATSSupportKerberos: false, commands: ['stopServices']}, + { yarnInstalled: true, doesATSSupportKerberos: true, commands: ['stopServices']}, + ]; + + tests.forEach(function(test) { + it('YARN installed: {0}, ATS supported: {1} list of commands should be {2}'.format(test.yarnInstalled, test.doesATSSupportKerberos, test.commands.toString()), function () { + var controller = App.KerberosWizardStep5Controller.create({ commands: ['stopServices'] }); + sinon.stub(App, 'get').withArgs('doesATSSupportKerberos').returns(test.doesATSSupportKerberos); + sinon.stub(App.Service, 'find').returns(test.yarnInstalled ? [Em.Object.create({ serviceName: 'YARN'})] : []); + controller.checkComponentsRemoval(); + App.get.restore(); + App.Service.find.restore(); + expect(controller.get('commands').toArray()).to.eql(test.commands); + }); + }); + }); +});