AMBARI-21117. Existing hosts state didn't save after host was added (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/91d10fdc Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/91d10fdc Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/91d10fdc Branch: refs/heads/branch-feature-AMBARI-12556 Commit: 91d10fdc849f884f7e215a4006a843f2f91b9ea3 Parents: 1adb70d Author: Alex Antonenko <hiv...@gmail.com> Authored: Thu May 25 01:35:41 2017 +0300 Committer: Alex Antonenko <hiv...@gmail.com> Committed: Thu May 25 13:00:46 2017 +0300 ---------------------------------------------------------------------- .../app/controllers/main/host/add_controller.js | 3 -- ambari-web/app/controllers/wizard.js | 9 ++--- ambari-web/app/routes/add_host_routes.js | 38 +++++++++++--------- .../main/host/add_controller_test.js | 19 ---------- ambari-web/test/controllers/wizard_test.js | 4 --- 5 files changed, 27 insertions(+), 46 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/91d10fdc/ambari-web/app/controllers/main/host/add_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/host/add_controller.js b/ambari-web/app/controllers/main/host/add_controller.js index 38179ea..6b158c1 100644 --- a/ambari-web/app/controllers/main/host/add_controller.js +++ b/ambari-web/app/controllers/main/host/add_controller.js @@ -420,9 +420,6 @@ App.AddHostController = App.WizardController.extend({ finish: function () { this.clearAllSteps(); this.clearStorageData(); - App.router.get('updateController').updateAll(); - App.updater.immediateRun('updateHost'); - App.router.get('clusterController').getAllHostNames(); }, /** http://git-wip-us.apache.org/repos/asf/ambari/blob/91d10fdc/ambari-web/app/controllers/wizard.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js index efda62d..d709d7e 100644 --- a/ambari-web/app/controllers/wizard.js +++ b/ambari-web/app/controllers/wizard.js @@ -872,14 +872,15 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM /** * Save cluster status before going to deploy step * @param name cluster state. Unique for every wizard + * @param callbackObj can have additional params for ajax callBacks and sender */ - saveClusterState: function (name) { + saveClusterState: function (name, callbackObj) { App.clusterStatus.setClusterStatus({ clusterName: this.get('content.cluster.name'), clusterState: name, wizardControllerName: this.get('content.controllerName'), localdb: App.db.data - }); + }, callbackObj); }, /** @@ -1499,10 +1500,9 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM * @param {App.WizardController} controller - wizard controller * @param {string} route - preferable path to go after wizard finished */ - resetOnClose: function(controller, route) { + resetOnClose: function(controller, route, router) { App.router.get('wizardWatcherController').resetUser(); controller.finish(); - App.router.get('updateController').set('isWorking', true); App.clusterStatus.setClusterStatus({ clusterName: App.get('clusterName'), clusterState: 'DEFAULT', @@ -1510,6 +1510,7 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM }, { alwaysCallback: function () { + router && router.set('nextBtnClickInProgress', false); controller.get('popup').hide(); App.router.transitionTo(route); Em.run.next(function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/91d10fdc/ambari-web/app/routes/add_host_routes.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/add_host_routes.js b/ambari-web/app/routes/add_host_routes.js index f18cc2c..0158269 100644 --- a/ambari-web/app/routes/add_host_routes.js +++ b/ambari-web/app/routes/add_host_routes.js @@ -23,7 +23,7 @@ module.exports = App.WizardRoute.extend({ leaveWizard: function (router, context) { var addHostController = router.get('addHostController'); - addHostController.resetOnClose(addHostController, 'hosts.index'); + addHostController.resetOnClose(addHostController, 'hosts.index', router); }, enter: function (router) { @@ -50,6 +50,7 @@ module.exports = App.WizardRoute.extend({ }, onClose: function () { var popupContext = this; + router.set('nextBtnClickInProgress', true); if (addHostController.get('currentStep') == '6') { App.ModalPopup.show({ header: Em.I18n.t('hosts.add.exit.header'), @@ -267,9 +268,14 @@ module.exports = App.WizardRoute.extend({ addHostController.installServices(false, function () { addHostController.setInfoForStep9(); // We need to do recovery based on whether we are in Add Host or Installer wizard - addHostController.saveClusterState('ADD_HOSTS_INSTALLING_3'); - wizardStep8Controller.set('servicesInstalled', true); - router.transitionTo('step6'); + router.set('nextBtnClickInProgress', true); + addHostController.saveClusterState('ADD_HOSTS_INSTALLING_3', { + alwaysCallback: function () { + wizardStep8Controller.set('servicesInstalled', true); + router.set('nextBtnClickInProgress', false); + router.transitionTo('step6'); + } + }); }); }); } @@ -302,8 +308,11 @@ module.exports = App.WizardRoute.extend({ addHostController.setInfoForStep9(); wizardStep9Controller.resetHostsForRetry(); // We need to do recovery based on whether we are in Add Host or Installer wizard - addHostController.saveClusterState('ADD_HOSTS_INSTALLING_3'); - wizardStep9Controller.navigateStep(); + addHostController.saveClusterState('ADD_HOSTS_INSTALLING_3', { + alwaysCallback: function () { + wizardStep9Controller.navigateStep(); + } + }); }); } else { wizardStep9Controller.navigateStep(); @@ -318,10 +327,15 @@ module.exports = App.WizardRoute.extend({ var wizardStep9Controller = router.get('wizardStep9Controller'); wizardStep9Controller.set('wizardController', addHostController); addHostController.saveInstalledHosts(wizardStep9Controller); + router.set('nextBtnClickInProgress', true); // We need to do recovery based on whether we are in Add Host or Installer wizard - addHostController.saveClusterState('ADD_HOSTS_INSTALLED_4'); - router.transitionTo('step7'); + addHostController.saveClusterState('ADD_HOSTS_INSTALLED_4', { + alwaysCallback: function () { + router.set('nextBtnClickInProgress', false); + router.transitionTo('step7'); + } + }); } }), @@ -343,14 +357,6 @@ module.exports = App.WizardRoute.extend({ }, back: Em.Router.transitionTo('step6'), complete: function (router, context) { - var addHostController = router.get('addHostController'); - var hostsUrl = '/hosts?fields=Hosts/host_name,Hosts/public_host_name,Hosts/cpu_count,Hosts/total_mem,' + - 'Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components,' + - 'metrics/disk,metrics/load/load_one,metrics/cpu/cpu_system,metrics/cpu/cpu_user,metrics/memory/mem_total,metrics/memory/mem_free'; - router.get('clusterController').requestHosts(hostsUrl, function () { - - }); - router.get('updateController').updateAll(); $(context.currentTarget).parents("#modal").find(".close").trigger('click'); } }), http://git-wip-us.apache.org/repos/asf/ambari/blob/91d10fdc/ambari-web/test/controllers/main/host/add_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/host/add_controller_test.js b/ambari-web/test/controllers/main/host/add_controller_test.js index c03075f..089d018 100644 --- a/ambari-web/test/controllers/main/host/add_controller_test.js +++ b/ambari-web/test/controllers/main/host/add_controller_test.js @@ -1207,24 +1207,14 @@ describe('App.AddHostController', function () { }); describe("#finish()", function () { - var mock = { - updateAll: Em.K, - getAllHostNames: Em.K - }; beforeEach(function () { sinon.stub(controller, 'clearAllSteps', Em.K); sinon.stub(controller, 'clearStorageData', Em.K); - sinon.stub(App.router, 'get').returns(mock); - sinon.spy(mock, 'updateAll'); - sinon.spy(mock, 'getAllHostNames'); controller.finish(); }); afterEach(function () { controller.clearAllSteps.restore(); controller.clearStorageData.restore(); - App.router.get.restore(); - mock.updateAll.restore(); - mock.getAllHostNames.restore(); }); it("clearAllSteps called once", function () { expect(controller.clearAllSteps.calledOnce).to.be.true; @@ -1232,14 +1222,5 @@ describe('App.AddHostController', function () { it('clearStorageData called once', function () { expect(controller.clearStorageData.calledOnce).to.be.true; }); - it('updateAll called once', function () { - expect(mock.updateAll.calledOnce).to.be.true; - }); - it('App.updater.immediateRun called with valid arguments', function () { - expect(App.updater.immediateRun.calledWith('updateHost')).to.be.true; - }); - it('getAllHostNames called once', function () { - expect(mock.getAllHostNames.calledOnce).to.be.true; - }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/91d10fdc/ambari-web/test/controllers/wizard_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard_test.js b/ambari-web/test/controllers/wizard_test.js index 1ce96ed..db215a2 100644 --- a/ambari-web/test/controllers/wizard_test.js +++ b/ambari-web/test/controllers/wizard_test.js @@ -1694,10 +1694,6 @@ describe('App.WizardController', function () { expect(ctrl.finish.calledOnce).to.be.true; }); - it("isWorking should be true", function () { - expect(mock.get('isWorking')).to.be.true; - }); - it("App.clusterStatus.setClusterStatus should be called", function () { expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true; });