Repository: ambari Updated Branches: refs/heads/branch-2.1 4145422c5 -> f42c9e85f
AMBARI-12116. Moving back from Review-step to Customize Services doesn't restore override and config groups created previously on the Customize Services step (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f42c9e85 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f42c9e85 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f42c9e85 Branch: refs/heads/branch-2.1 Commit: f42c9e85f89aab77491597e1e1d51c5143ec1b19 Parents: 4145422 Author: Oleg Nechiporenko <onechipore...@apache.org> Authored: Wed Jun 24 13:00:40 2015 +0300 Committer: Oleg Nechiporenko <onechipore...@apache.org> Committed: Wed Jun 24 13:05:21 2015 +0300 ---------------------------------------------------------------------- .../controllers/main/service/add_controller.js | 12 ++++++ .../app/controllers/wizard/step7_controller.js | 2 +- .../main/service/add_controller_test.js | 40 ++++++++++++++++++++ .../test/controllers/wizard/step7_test.js | 19 +++++++++- 4 files changed, 70 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/f42c9e85/ambari-web/app/controllers/main/service/add_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/add_controller.js b/ambari-web/app/controllers/main/service/add_controller.js index 1a5cd98..2a2f425 100644 --- a/ambari-web/app/controllers/main/service/add_controller.js +++ b/ambari-web/app/controllers/main/service/add_controller.js @@ -40,6 +40,8 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs, { */ installClientQueueLength: 0, + areInstalledConfigGroupsLoaded: false, + /** * All wizards data will be stored in this variable * @@ -589,6 +591,16 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs, { this.set('skipConfigureIdentitiesStep', true); this.get('isStepDisabled').findProperty('step', 5).set('value', true); } + }, + + loadServiceConfigGroups: function () { + this._super(); + this.set('areInstalledConfigGroupsLoaded', !Em.isNone(this.getDBProperty('serviceConfigGroups'))); + }, + + clearStorageData: function () { + this._super(); + this.set('areInstalledConfigGroupsLoaded', false); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f42c9e85/ambari-web/app/controllers/wizard/step7_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js index 3cf8f56..18ebf89 100644 --- a/ambari-web/app/controllers/wizard/step7_controller.js +++ b/ambari-web/app/controllers/wizard/step7_controller.js @@ -760,7 +760,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E if (this.get('wizardController.name') !== 'kerberosWizardController') { this.loadConfigGroups(this.get('content.configGroups')); } - if (this.get('installedServiceNames').length > 0) { + if (this.get('installedServiceNames').length > 0 && !this.get('wizardController.areInstalledConfigGroupsLoaded')) { this.loadInstalledServicesConfigGroups(this.get('installedServiceNames')); } }, http://git-wip-us.apache.org/repos/asf/ambari/blob/f42c9e85/ambari-web/test/controllers/main/service/add_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/add_controller_test.js b/ambari-web/test/controllers/main/service/add_controller_test.js index bb04c71..5e87ca8 100644 --- a/ambari-web/test/controllers/main/service/add_controller_test.js +++ b/ambari-web/test/controllers/main/service/add_controller_test.js @@ -467,4 +467,44 @@ describe('App.AddServiceController', function() { }); + describe('#loadServiceConfigGroups', function () { + + var dbMock, + cases = [ + { + serviceConfigGroups: null, + areInstalledConfigGroupsLoaded: false + }, + { + serviceConfigGroups: [], + areInstalledConfigGroupsLoaded: true + } + ]; + + beforeEach(function () { + dbMock = sinon.stub(addServiceController, 'getDBProperty'); + }); + + afterEach(function () { + dbMock.restore(); + }); + + cases.forEach(function (item) { + it(item.title, function () { + dbMock.withArgs('hosts').returns({}).withArgs('serviceConfigGroups').returns(item.serviceConfigGroups); + addServiceController.loadServiceConfigGroups(); + expect(addServiceController.get('areInstalledConfigGroupsLoaded')).to.equal(item.areInstalledConfigGroupsLoaded); + }); + }); + + }); + + describe('#clearStorageData', function () { + it('areInstalledConfigGroupsLoaded should be false', function () { + addServiceController.set('areInstalledConfigGroupsLoaded', true); + addServiceController.clearStorageData(); + expect(addServiceController.get('areInstalledConfigGroupsLoaded')).to.be.false; + }); + }); + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f42c9e85/ambari-web/test/controllers/wizard/step7_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js index 64c3e70..6dffd3d 100644 --- a/ambari-web/test/controllers/wizard/step7_test.js +++ b/ambari-web/test/controllers/wizard/step7_test.js @@ -1357,11 +1357,21 @@ describe('App.InstallerStep7Controller', function () { }, { installedServiceNames: ['s1', 's2', 's3'], - m: 'installedServiceNames isn\'t empty', + areInstalledConfigGroupsLoaded: false, + m: 'installedServiceNames isn\'t empty, config groups not yet loaded', e: { loadConfigGroups: true, loadInstalledServicesConfigGroups: true } + }, + { + installedServiceNames: ['s1', 's2', 's3'], + areInstalledConfigGroupsLoaded: true, + m: 'installedServiceNames isn\'t empty, config groups already loaded', + e: { + loadConfigGroups: true, + loadInstalledServicesConfigGroups: false + } } ]).forEach(function (test) { it(test.m, function () { @@ -1369,7 +1379,12 @@ describe('App.InstallerStep7Controller', function () { if (k === 'supports.hostOverridesInstaller') return test.hostOverridesInstaller; return Em.get(App, k); }); - installerStep7Controller.reopen({installedServiceNames: test.installedServiceNames}); + installerStep7Controller.reopen({ + installedServiceNames: test.installedServiceNames, + wizardController: { + areInstalledConfigGroupsLoaded: test.areInstalledConfigGroupsLoaded + } + }); installerStep7Controller.checkHostOverrideInstaller(); if (test.e.loadConfigGroups) { expect(installerStep7Controller.loadConfigGroups.calledOnce).to.equal(true);