Repository: ambari Updated Branches: refs/heads/branch-2.5 191e1d3a1 -> 6607d1103
Revert "AMBARI-19319 Disable auto start before RU/EU and enable during finalization phase. (atkach)" This reverts commit 2bd7f2821cf52b8c072356b2f420d7036926d26e. Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6607d110 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6607d110 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6607d110 Branch: refs/heads/branch-2.5 Commit: 6607d1103505a81234a526b70340424d1e1155e8 Parents: 191e1d3 Author: Yusaku Sako <[email protected]> Authored: Tue Jan 3 09:23:45 2017 -0800 Committer: Yusaku Sako <[email protected]> Committed: Tue Jan 3 09:23:45 2017 -0800 ---------------------------------------------------------------------- .../main/admin/stack_and_upgrade_controller.js | 46 +----- ambari-web/app/messages.js | 2 - .../admin/stack_and_upgrade_controller_test.js | 150 +++---------------- 3 files changed, 28 insertions(+), 170 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/6607d110/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 3c1de84..3058580 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 @@ -1313,44 +1313,11 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage, error: "runPreUpgradeCheckError" }); } else { - this.showAutoStartDisableModal(params); + this.upgrade(params); } }, /** - * - * @param {object} upgradeParams - */ - showAutoStartDisableModal: function(upgradeParams) { - var self = this; - return App.showAlertPopup( - Em.I18n.t('common.warning'), - Em.I18n.t('admin.serviceAutoStart.disabled.popup.body'), - function() { - self.switchServiceAutoStartTo(false); - self.upgrade(upgradeParams); - } - ); - }, - - /** - * - * @param {boolean} state - */ - switchServiceAutoStartTo: function(state) { - var autoStartController = App.router.get('mainAdminServiceAutoStartController'); - return autoStartController.load().done(function() { - var clusterConfigs = autoStartController.get('clusterConfigs'); - if (clusterConfigs && clusterConfigs.recovery_enabled !== String(state)) { - clusterConfigs.recovery_enabled = String(state); - autoStartController.saveClusterConfigs(clusterConfigs); - autoStartController.set('servicesAutoStart', state); - autoStartController.syncStatus(); - } - }); - }, - - /** * success callback of <code>runPreUpgradeCheckSuccess()</code> * if there are some fails - it shows popup else run upgrade * @param data {object} @@ -1360,9 +1327,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage, */ runPreUpgradeCheckSuccess: function (data, opt, params) { var self = this; - if (data.items.someProperty('UpgradeChecks.status', 'FAIL') || - data.items.someProperty('UpgradeChecks.status', 'WARNING') || - data.items.someProperty('UpgradeChecks.status', 'BYPASS')) { + if (data.items.someProperty('UpgradeChecks.status', 'FAIL') || data.items.someProperty('UpgradeChecks.status', 'WARNING') || data.items.someProperty('UpgradeChecks.status', 'BYPASS')) { this.set('requestInProgress', false); var hasFails = data.items.someProperty('UpgradeChecks.status', 'FAIL'), header = Em.I18n.t('popup.clusterCheck.Upgrade.header').format(params.label), @@ -1385,11 +1350,11 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage, bypassedFailures: bypassedFailures, noCallbackCondition: hasFails, callback: function () { - self.showAutoStartDisableModal(params); + self.upgrade(params); } }, configs, params.label); } else { - this.showAutoStartDisableModal(params); + this.upgrade(params); } }, @@ -1788,9 +1753,6 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage, * @param status */ setUpgradeItemStatus: function(item, status) { - if (this.get('isFinalizeItem') && status === 'COMPLETED') { - this.switchServiceAutoStartTo(true); - } this.set('requestInProgress', true); return App.ajax.send({ name: 'admin.upgrade.upgradeItem.setState', http://git-wip-us.apache.org/repos/asf/ambari/blob/6607d110/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index d2c4edf..01382bd 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -3295,8 +3295,6 @@ Em.I18n.translations = { 'Click <b>Save</b> to commit the change or <b>Discard</b> to revert your changes', 'admin.serviceAutoStart.save.popup.transition.title': 'Warning', 'admin.serviceAutoStart.save.popup.transition.body': 'You have unsaved changes', - 'admin.serviceAutoStart.disabled.popup.body': 'During RU/EU auto-start of service components will be disabled.' + - ' Auto-start will be enabled after upgrade is completed.', 'reset.ui.states': 'Reset UI State', 'reset.ui.states.body': 'You should proceed only if the UI is misbehaving (such as incorrect navigation upon login, UI is stuck and won't load, etc.). Are you sure you want to reset the UI state?', http://git-wip-us.apache.org/repos/asf/ambari/blob/6607d110/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 1afd8f4..78e81a0 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 @@ -502,11 +502,11 @@ describe('App.MainAdminStackAndUpgradeController', function() { ]; beforeEach(function () { sinon.stub(App, 'showClusterCheckPopup', Em.K); - sinon.stub(controller, 'showAutoStartDisableModal', Em.K); + sinon.stub(controller, 'upgrade', Em.K); }); afterEach(function () { App.showClusterCheckPopup.restore(); - controller.showAutoStartDisableModal.restore(); + controller.upgrade.restore(); }); cases.forEach(function (item) { it(item.title, function () { @@ -521,7 +521,7 @@ describe('App.MainAdminStackAndUpgradeController', function() { label: 'name' } ); - expect(controller.showAutoStartDisableModal.callCount).to.equal(item.upgradeCalledCount); + expect(controller.upgrade.callCount).to.equal(item.upgradeCalledCount); expect(App.showClusterCheckPopup.callCount).to.equal(item.showClusterCheckPopupCalledCount); if (item.check.id === 'CONFIG_MERGE') { expect(App.showClusterCheckPopup.firstCall.args[2]).to.eql(item.configs); @@ -1264,57 +1264,31 @@ describe('App.MainAdminStackAndUpgradeController', function() { }); describe("#setUpgradeItemStatus()", function () { + var item; + beforeEach(function () { + item = Em.Object.create({ + request_id: 1, + stage_id: 1, + group_id: 1 + }); + controller.setUpgradeItemStatus(item, 'PENDING'); + this.callArgs = testHelpers.findAjaxRequest('name', 'admin.upgrade.upgradeItem.setState')[0]; + }); - beforeEach(function() { - sinon.stub(controller, 'switchServiceAutoStartTo'); + it('request-data is valid', function () { + expect(this.callArgs.data).to.be.eql({upgradeId: 1, itemId: 1, groupId: 1, status: 'PENDING'}); }); - afterEach(function() { - controller.switchServiceAutoStartTo.restore(); + it('request-name is valid', function () { + expect(this.callArgs.name).to.be.equal('admin.upgrade.upgradeItem.setState'); }); - - describe('#PENDING status', function() { - var item; - beforeEach(function () { - item = Em.Object.create({ - request_id: 1, - stage_id: 1, - group_id: 1 - }); - controller.setUpgradeItemStatus(item, 'PENDING'); - this.callArgs = testHelpers.findAjaxRequest('name', 'admin.upgrade.upgradeItem.setState')[0]; - }); - - it('request-data is valid', function () { - expect(this.callArgs.data).to.be.eql({upgradeId: 1, itemId: 1, groupId: 1, status: 'PENDING'}); - }); - it('request-name is valid', function () { - expect(this.callArgs.name).to.be.equal('admin.upgrade.upgradeItem.setState'); - }); - it('request-sendeer is valid', function () { - expect(this.callArgs.sender).to.be.eql(controller); - }); - it('callback is called', function () { - expect(this.callArgs.callback).to.be.called; - }); - it('item.status is PENDING', function () { - expect(item.get('status')).to.equal('PENDING'); - }); - it('switchServiceAutoStartTo should not be called', function () { - expect(controller.switchServiceAutoStartTo.called).to.be.false; - }); + it('request-sendeer is valid', function () { + expect(this.callArgs.sender).to.be.eql(controller); }); - - describe('#COMPLETED status', function() { - it('switchServiceAutoStartTo should not be called', function () { - var item = Em.Object.create({ - request_id: 1, - stage_id: 1, - group_id: 1 - }); - controller.set('isFinalizeItem', true); - controller.setUpgradeItemStatus(item, 'COMPLETED'); - expect(controller.switchServiceAutoStartTo.calledOnce).to.be.true; - }); + it('callback is called', function () { + expect(this.callArgs.callback).to.be.called; + }); + it('item.status is PENDING', function () { + expect(item.get('status')).to.equal('PENDING'); }); }); @@ -3304,80 +3278,4 @@ describe('App.MainAdminStackAndUpgradeController', function() { }); }); - describe('#showAutoStartDisableModal', function() { - - beforeEach(function() { - sinon.spy(App, 'showAlertPopup'); - sinon.stub(controller, 'switchServiceAutoStartTo'); - sinon.stub(controller, 'upgrade'); - }); - - afterEach(function() { - App.showAlertPopup.restore(); - controller.switchServiceAutoStartTo.restore(); - controller.upgrade.restore(); - }); - - it('showAlertPopup should be called', function() { - controller.showAutoStartDisableModal({}); - expect(App.showAlertPopup.calledOnce).to.be.true; - }); - - it('switchServiceAutoStartTo should be called', function() { - var popup = controller.showAutoStartDisableModal({}); - popup.onPrimary(); - expect(controller.switchServiceAutoStartTo.calledWith(false)).to.be.true; - }); - - it('upgrade should be called', function() { - var popup = controller.showAutoStartDisableModal({}); - popup.onPrimary(); - expect(controller.upgrade.calledWith({})).to.be.true; - }); - }); - - describe('#switchServiceAutoStartTo', function() { - var mockController = Em.Object.create({ - load: Em.K, - saveClusterConfigs: Em.K, - syncStatus: Em.K - }); - - beforeEach(function() { - sinon.stub(App.router, 'get').returns(mockController); - sinon.stub(mockController, 'load').returns({ - done: Em.clb - }); - sinon.stub(mockController, 'saveClusterConfigs'); - sinon.stub(mockController, 'syncStatus'); - }); - - afterEach(function() { - App.router.get.restore(); - mockController.load.restore(); - mockController.saveClusterConfigs.restore(); - mockController.syncStatus.restore(); - }); - - it('should not update value on server when state have not been changed', function() { - mockController.set('servicesAutoStart', true); - mockController.set('clusterConfigs', {recovery_enabled: 'true'}); - controller.switchServiceAutoStartTo(true); - expect(mockController.load.calledOnce).to.be.true; - expect(mockController.saveClusterConfigs.called).to.be.false; - expect(mockController.syncStatus.called).to.be.false; - expect(mockController.get('servicesAutoStart')).to.be.true; - }); - - it('should update value on server when state been changed', function() { - mockController.set('servicesAutoStart', true); - mockController.set('clusterConfigs', {recovery_enabled: 'true'}); - controller.switchServiceAutoStartTo(false); - expect(mockController.load.calledOnce).to.be.true; - expect(mockController.saveClusterConfigs.calledWith({recovery_enabled: 'false'})).to.be.true; - expect(mockController.syncStatus.calledOnce).to.be.true; - expect(mockController.get('servicesAutoStart')).to.be.false; - }); - }); - });
