Repository: ambari Updated Branches: refs/heads/trunk a133aee9a -> b81d1df87
Revert "AMBARI-19319 Disable auto start before RU/EU and enable during finalization phase. (atkach)" This reverts commit 4fc44e277ac396f6967402da767350a4ee2bf47d. Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b81d1df8 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b81d1df8 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b81d1df8 Branch: refs/heads/trunk Commit: b81d1df8739086db7ebc0b7602e996d0f01b63bf Parents: a133aee Author: Andrii Tkach <[email protected]> Authored: Tue Jan 31 13:44:08 2017 +0200 Committer: Andrii Tkach <[email protected]> Committed: Tue Jan 31 13:44:08 2017 +0200 ---------------------------------------------------------------------- .../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/b81d1df8/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 a585615..cb02665 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 @@ -1375,44 +1375,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} @@ -1422,9 +1389,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), @@ -1447,11 +1412,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); } }, @@ -1852,9 +1817,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/b81d1df8/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 8fbe198..9644edb 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -3344,8 +3344,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/b81d1df8/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 4e93fd6..8bb6e0d 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); @@ -1234,57 +1234,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'); }); }); @@ -3314,80 +3288,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; - }); - }); - });
