Repository: ambari Updated Branches: refs/heads/trunk 1f53d011e -> c87fa43be
AMBARI-9062 Kerberos Wizard: prereq check (with mock data). (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7efa1212 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7efa1212 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7efa1212 Branch: refs/heads/trunk Commit: 7efa121200b4a089507bc697e7287a01d06f6823 Parents: 1f53d01 Author: aBabiichuk <[email protected]> Authored: Fri Jan 9 16:59:45 2015 +0200 Committer: aBabiichuk <[email protected]> Committed: Fri Jan 9 18:07:49 2015 +0200 ---------------------------------------------------------------------- ambari-web/app/config.js | 1 + .../app/controllers/main/admin/kerberos.js | 38 +++++++++++++++++ .../main/admin/stack_and_upgrade_controller.js | 13 ++---- ambari-web/app/messages.js | 14 +++--- .../modal_popups/cluster_check_dialog.hbs | 29 +++++++++++++ .../app/templates/main/admin/kerberos.hbs | 2 +- .../stack_upgrade/pre_upgrade_check_dialog.hbs | 29 ------------- ambari-web/app/utils/ajax/ajax.js | 6 +++ ambari-web/app/views.js | 1 + .../common/modal_popups/cluster_check_popup.js | 42 ++++++++++++++++++ .../controllers/main/admin/kerberos_test.js | 45 +++++++++++++++++++- .../admin/stack_and_upgrade_controller_test.js | 12 +++--- 12 files changed, 180 insertions(+), 52 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7efa1212/ambari-web/app/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/config.js b/ambari-web/app/config.js index a793b5c..8e2e562 100644 --- a/ambari-web/app/config.js +++ b/ambari-web/app/config.js @@ -55,6 +55,7 @@ App.isManagedMySQLForHiveEnabled = false; App.enableExperimental = false; App.supports = { + preKerberizeCheck: false, preUpgradeCheck: true, stackUpgrade: true, autoRollbackHA: false, http://git-wip-us.apache.org/repos/asf/ambari/blob/7efa1212/ambari-web/app/controllers/main/admin/kerberos.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/kerberos.js b/ambari-web/app/controllers/main/admin/kerberos.js index 202fc64..be5b23f 100644 --- a/ambari-web/app/controllers/main/admin/kerberos.js +++ b/ambari-web/app/controllers/main/admin/kerberos.js @@ -64,6 +64,44 @@ App.MainAdminKerberosController = App.KerberosWizardStep4Controller.extend({ return this.get('securityEnabled'); }, + /** + * performes clustere check before kerbefos security + * wizard starts if <code>preKerberizeCheck<code> supports is true + * otherwise runs <code>startKerberosWizard<code> + * @method checkAndStartKerberosWizard + */ + checkAndStartKerberosWizard: function() { + if (App.get('supports.preKerberizeCheck')) { + App.ajax.send({ + name: "admin.kerberos_security.checks", + sender: this, + success: "runSecurityCheckSuccess" + }); + } else { + this.startKerberosWizard(); + } + }, + + /** + * success callback of <code>checkAndStartKerberosWizard()</code> + * if there are some fails - it shows popup else open security wizard + * @param data {object} + * @param opt {object} + * @param params {object} + * @returns {App.ModalPopup|undefined} + */ + runSecurityCheckSuccess: function (data, opt, params) { + //TODO correct check + if (data.items.someProperty('UpgradeChecks.status', "FAIL")) { + var header = Em.I18n.t('popup.clusterCheck.Security.header').format(params.label); + var title = Em.I18n.t('popup.clusterCheck.Security.title'); + var alert = Em.I18n.t('popup.clusterCheck.Security.alert'); + App.showClusterCheckPopup(data, header, title, alert); + } else { + this.startKerberosWizard(); + } + }, + startKerberosWizard: function () { this.setAddSecurityWizardStatus('RUNNING'); App.router.transitionTo('adminAddKerberos'); http://git-wip-us.apache.org/repos/asf/ambari/blob/7efa1212/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js index 1629555..bbd69fa 100644 --- a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js +++ b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js @@ -316,15 +316,10 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage, */ runPreUpgradeCheckSuccess: function (data, opt, params) { if (data.items.someProperty('UpgradeChecks.status', "FAIL")) { - return App.ModalPopup.show({ - header: Em.I18n.t('admin.stackUpgrade.preupgradeCheck.header').format(params.label), - primary: Em.I18n.t('common.dismiss'), - secondary: false, - bodyClass: Em.View.extend({ - templateName: require('templates/main/admin/stack_upgrade/pre_upgrade_check_dialog'), - checks: data.items.filterProperty('UpgradeChecks.status', "FAIL") - }) - }) + var header = Em.I18n.t('popup.clusterCheck.Upgrade.header').format(params.label); + var title = Em.I18n.t('popup.clusterCheck.Upgrade.title'); + var alert = Em.I18n.t('popup.clusterCheck.Upgrade.alert'); + App.showClusterCheckPopup(data, header, title, alert); } else { this.upgrade(params); } http://git-wip-us.apache.org/repos/asf/ambari/blob/7efa1212/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index e8dc05b..2f39823 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -312,6 +312,15 @@ Em.I18n.translations = { 'popup.confirmationFeedBack.sending':'Sending...', 'popup.confirmationFeedBack.query.fail':'Request failed', + 'popup.clusterCheck.failedOn': 'Failed on: ', + 'popup.clusterCheck.reason': 'Reason: ', + 'popup.clusterCheck.Upgrade.header': 'Upgrade to {0}', + 'popup.clusterCheck.Upgrade.title': 'Upgrade Requirements Not Met', + 'popup.clusterCheck.Upgrade.alert': 'You must meet the following requirements before you can proceed with rolling upgrade.', + 'popup.clusterCheck.Security.header': 'Enable Security', + 'popup.clusterCheck.Security.title': 'Security Requirements Not Met', + 'popup.clusterCheck.Security.alert': 'You must meet the following requirements before you can enable security.', + 'login.header':'Sign in', 'login.username':'Username', 'login.loginButton':'Sign in', @@ -1347,11 +1356,6 @@ Em.I18n.translations = { 'admin.stackUpgrade.dialog.closePause': "Upgrade is paused. \n If you dismiss this window, you can resume Upgrade later.", 'admin.stackUpgrade.dialog.details.open': "show details", 'admin.stackUpgrade.dialog.details.hide': "hide details", - 'admin.stackUpgrade.preupgradeCheck.header': "Upgrade to {0}", - 'admin.stackUpgrade.preupgradeCheck.title': "Upgrade Requirements Not Met", - 'admin.stackUpgrade.preupgradeCheck.alert': "You must meet the following requirements before you can proceed with rolling upgrade.", - 'admin.stackUpgrade.preupgradeCheck.failedOn': "Failed on: ", - 'admin.stackUpgrade.preupgradeCheck.reason': "Reason: ", 'services.service.start':'Start', 'services.service.stop':'Stop', 'services.service.metrics':'Metrics', http://git-wip-us.apache.org/repos/asf/ambari/blob/7efa1212/ambari-web/app/templates/common/modal_popups/cluster_check_dialog.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/modal_popups/cluster_check_dialog.hbs b/ambari-web/app/templates/common/modal_popups/cluster_check_dialog.hbs new file mode 100644 index 0000000..7390aaa --- /dev/null +++ b/ambari-web/app/templates/common/modal_popups/cluster_check_dialog.hbs @@ -0,0 +1,29 @@ +{{! +* 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. +}} +<div id="pre-upgrade-check"> + <h4>{{view.title}}</h4> + <div class="alert alert-warning"> + {{view.alert}} + </div> + <div class="limited-height-2"> + {{#each item in view.checks}} + <i class="icon-remove"></i> <span>{{item.UpgradeChecks.check}}</span> + <pre>{{t popup.clusterCheck.reason}}{{item.UpgradeChecks.reason}}<br/>{{t popup.clusterCheck.failedOn}}{{item.UpgradeChecks.failed_on}}</pre> + {{/each}} + </div> +</div> http://git-wip-us.apache.org/repos/asf/ambari/blob/7efa1212/ambari-web/app/templates/main/admin/kerberos.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/admin/kerberos.hbs b/ambari-web/app/templates/main/admin/kerberos.hbs index 2bb714a..dd40a5c 100644 --- a/ambari-web/app/templates/main/admin/kerberos.hbs +++ b/ambari-web/app/templates/main/admin/kerberos.hbs @@ -29,7 +29,7 @@ {{else}} <div> <p class="muted">{{t admin.security.disabled}} - <a class="btn btn-padding btn-success admin-enable-security-btn" {{action startKerberosWizard target="controller"}}>{{t admin.kerberos.button.enable}} </a> + <a class="btn btn-padding btn-success admin-enable-security-btn" {{action checkAndStartKerberosWizard target="controller"}}>{{t admin.kerberos.button.enable}} </a> <br/> </p> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/7efa1212/ambari-web/app/templates/main/admin/stack_upgrade/pre_upgrade_check_dialog.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/pre_upgrade_check_dialog.hbs b/ambari-web/app/templates/main/admin/stack_upgrade/pre_upgrade_check_dialog.hbs deleted file mode 100644 index f6613ee..0000000 --- a/ambari-web/app/templates/main/admin/stack_upgrade/pre_upgrade_check_dialog.hbs +++ /dev/null @@ -1,29 +0,0 @@ -{{! -* 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. -}} -<div id="pre-upgrade-check"> - <h4>{{t admin.stackUpgrade.preupgradeCheck.title}}</h4> - <div class="alert alert-warning"> - {{t admin.stackUpgrade.preupgradeCheck.alert}} - </div> - <div class="limited-height-2"> - {{#each item in view.checks}} - <i class="icon-remove"></i> <span>{{item.UpgradeChecks.check}}</span> - <pre>{{t admin.stackUpgrade.preupgradeCheck.reason}}{{item.UpgradeChecks.reason}}<br/>{{t admin.stackUpgrade.preupgradeCheck.failedOn}}{{item.UpgradeChecks.failed_on}}</pre> - {{/each}} - </div> -</div> http://git-wip-us.apache.org/repos/asf/ambari/blob/7efa1212/ambari-web/app/utils/ajax/ajax.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js index 82e73b1..a7ee18d 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -1383,6 +1383,12 @@ var urls = { 'mock': '/data/stack_versions/pre_upgrade_check.json' }, + 'admin.kerberos_security.checks': { + //TODO when api will be known + 'real': '', + 'mock': '/data/stack_versions/pre_upgrade_check.json' + }, + 'wizard.advanced_repositories.valid_url': { 'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems/{osType}/repositories/{repoId}', 'mock': '', http://git-wip-us.apache.org/repos/asf/ambari/blob/7efa1212/ambari-web/app/views.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js index a86bf39..1873b22 100644 --- a/ambari-web/app/views.js +++ b/ambari-web/app/views.js @@ -30,6 +30,7 @@ require('views/common/modal_popups/confirmation_feedback_popup'); require('views/common/modal_popups/confirmation_popup'); require('views/common/modal_popups/prompt_popup'); require('views/common/modal_popups/reload_popup'); +require('views/common/modal_popups/cluster_check_popup'); require('views/common/editable_list'); require('views/common/rolling_restart_view'); require('views/common/select_custom_date_view'); http://git-wip-us.apache.org/repos/asf/ambari/blob/7efa1212/ambari-web/app/views/common/modal_popups/cluster_check_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/modal_popups/cluster_check_popup.js b/ambari-web/app/views/common/modal_popups/cluster_check_popup.js new file mode 100644 index 0000000..73dd274 --- /dev/null +++ b/ambari-web/app/views/common/modal_popups/cluster_check_popup.js @@ -0,0 +1,42 @@ +/** + * 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'); + +/** + * popup to display requirements that are not met + * for current action + * @param data + * @param header + * @param title + * @param alert + * @returns {*|void} + */ +App.showClusterCheckPopup = function (data, header, title, alert) { + return App.ModalPopup.show({ + primary: Em.I18n.t('common.dismiss'), + secondary: false, + header: header, + bodyClass: Em.View.extend({ + title: title, + alert: alert, + templateName: require('templates/common/modal_popups/cluster_check_dialog'), + checks: data.items.filterProperty('UpgradeChecks.status', "FAIL") + }) + }); +}; http://git-wip-us.apache.org/repos/asf/ambari/blob/7efa1212/ambari-web/test/controllers/main/admin/kerberos_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/kerberos_test.js b/ambari-web/test/controllers/main/admin/kerberos_test.js index b203fc9..2198b14 100644 --- a/ambari-web/test/controllers/main/admin/kerberos_test.js +++ b/ambari-web/test/controllers/main/admin/kerberos_test.js @@ -19,14 +19,16 @@ var App = require('app'); describe('App.MainAdminKerberosController', function() { + + var controller = App.MainAdminKerberosController.create({}); + describe('#prepareConfigProperties', function() { beforeEach(function() { - this.controller = App.MainAdminKerberosController.create({}); sinon.stub(App.Service, 'find').returns([ Em.Object.create({ serviceName: 'KERBEROS'}), Em.Object.create({ serviceName: 'HDFS' }) ]); - this.result = this.controller.prepareConfigProperties([ + this.result = controller.prepareConfigProperties([ Em.Object.create({ name: 'prop1', isEditable: true, serviceName: 'SERVICE1'}), Em.Object.create({ name: 'prop2', isEditable: true, serviceName: 'KERBEROS'}), Em.Object.create({ name: 'prop3', isEditable: true, serviceName: 'HDFS'}), @@ -53,4 +55,43 @@ describe('App.MainAdminKerberosController', function() { }); }); }); + + describe("#runSecurityCheckSuccess()", function () { + beforeEach(function () { + sinon.stub(App, 'showClusterCheckPopup', Em.K); + sinon.stub(controller, 'startKerberosWizard', Em.K); + }); + afterEach(function () { + App.showClusterCheckPopup.restore(); + controller.startKerberosWizard.restore(); + }); + it("shows popup", function () { + var check = { items: [{ + UpgradeChecks: { + "check": "Work-preserving RM/NM restart is enabled in YARN configs", + "status": "FAIL", + "reason": "FAIL", + "failed_on": [], + "check_type": "SERVICE" + } + }]}; + controller.runSecurityCheckSuccess(check,null,{label: "name"}); + expect(controller.startKerberosWizard.called).to.be.false; + expect(App.showClusterCheckPopup.called).to.be.true; + }); + it("runs startKerberosWizard", function () { + var check = { items: [{ + UpgradeChecks: { + "check": "Work-preserving RM/NM restart is enabled in YARN configs", + "status": "PASS", + "reason": "OK", + "failed_on": [], + "check_type": "SERVICE" + } + }]}; + controller.runSecurityCheckSuccess(check,null,{label: "name"}); + expect(controller.startKerberosWizard.called).to.be.true; + expect(App.showClusterCheckPopup.called).to.be.false; + }); + }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/7efa1212/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js index 3f770f3..6388692 100644 --- a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js +++ b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js @@ -256,11 +256,11 @@ describe('App.MainAdminStackAndUpgradeController', function() { describe("#runPreUpgradeCheckSuccess()", function () { beforeEach(function () { - sinon.stub(App.ModalPopup, 'show', Em.K); + sinon.stub(App, 'showClusterCheckPopup', Em.K); sinon.stub(controller, 'upgrade', Em.K); }); afterEach(function () { - App.ModalPopup.show.restore(); + App.showClusterCheckPopup.restore(); controller.upgrade.restore(); }); it("shows popup", function () { @@ -274,8 +274,8 @@ describe('App.MainAdminStackAndUpgradeController', function() { } }]}; controller.runPreUpgradeCheckSuccess(check,null,{label: "name"}); - expect(controller.upgrade.calledOnce).to.be.false; - expect(App.ModalPopup.show.calledOnce).to.be.true; + expect(controller.upgrade.called).to.be.false; + expect(App.showClusterCheckPopup.called).to.be.true; }); it("runs upgrade popup", function () { var check = { items: [{ @@ -288,8 +288,8 @@ describe('App.MainAdminStackAndUpgradeController', function() { } }]}; controller.runPreUpgradeCheckSuccess(check,null,{label: "name"}); - expect(controller.upgrade.calledOnce).to.be.true; - expect(App.ModalPopup.show.calledOnce).to.be.false; + expect(controller.upgrade.called).to.be.true; + expect(App.showClusterCheckPopup.called).to.be.false; }); });
