Repository: ambari Updated Branches: refs/heads/trunk 8ae2c8b7c -> d0fe0a329
AMBARI-14667. Cannot add new service when kerberos is enabled w/ blueprint (alexantonenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d0fe0a32 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d0fe0a32 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d0fe0a32 Branch: refs/heads/trunk Commit: d0fe0a3292a2c612567bb3fcf240eac920566bee Parents: 8ae2c8b Author: Alex Antonenko <[email protected]> Authored: Thu Jan 14 16:43:00 2016 +0200 Committer: Alex Antonenko <[email protected]> Committed: Thu Jan 14 16:56:20 2016 +0200 ---------------------------------------------------------------------- .../app/controllers/wizard/step8_controller.js | 4 +- .../app/mixins/wizard/addSecurityConfigs.js | 16 +++++ .../admin/kerberos/step4_controller_test.js | 75 ++++++++++++++++++-- .../test/controllers/wizard/step8_test.js | 6 +- 4 files changed, 95 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/d0fe0a32/ambari-web/app/controllers/wizard/step8_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js index ea79f5e..50629f3 100644 --- a/ambari-web/app/controllers/wizard/step8_controller.js +++ b/ambari-web/app/controllers/wizard/step8_controller.js @@ -826,8 +826,10 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz */ updateKerberosDescriptor: function(instant) { var kerberosDescriptor = App.db.get('KerberosWizard', 'kerberosDescriptorConfigs'); + var descriptorExists = this.get('wizardController').getDBProperty('isClusterDescriptorExists') === true; + var ajaxOpts = { - name: 'admin.kerberos.cluster.artifact.update', + name: descriptorExists ? 'admin.kerberos.cluster.artifact.update' : 'admin.kerberos.cluster.artifact.create', data: { artifactName: 'kerberos_descriptor', data: { http://git-wip-us.apache.org/repos/asf/ambari/blob/d0fe0a32/ambari-web/app/mixins/wizard/addSecurityConfigs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/wizard/addSecurityConfigs.js b/ambari-web/app/mixins/wizard/addSecurityConfigs.js index 5b2bce8..0e500c6 100644 --- a/ambari-web/app/mixins/wizard/addSecurityConfigs.js +++ b/ambari-web/app/mixins/wizard/addSecurityConfigs.js @@ -71,8 +71,10 @@ App.AddSecurityConfigs = Em.Mixin.create({ this.loadStackDescriptorConfigs().then(function(data) { var stackArtifacts = data; self.loadClusterDescriptorConfigs().then(function(clusterArtifacts) { + self.storeClusterDescriptorStatus(true); dfd.resolve(self.createServicesStackDescriptorConfigs(objectUtils.deepMerge(data, clusterArtifacts))); }, function() { + self.storeClusterDescriptorStatus(false); dfd.resolve(self.createServicesStackDescriptorConfigs(stackArtifacts)); }); }, function() { @@ -81,6 +83,20 @@ App.AddSecurityConfigs = Em.Mixin.create({ return dfd.promise(); }, + + /** + * Store status of kerberos descriptor located in cluster artifacts. + * This status needed for Add Service Wizard to select appropriate method to create + * or update descriptor. + * + * @param {Boolean} isExists <code>true</code> if cluster descriptor present + */ + storeClusterDescriptorStatus: function(isExists) { + if (this.get('isWithinAddService')) { + this.get('wizardController').setDBProperty('isClusterDescriptorExists', isExists); + } + }, + /** * * @param {object[]} items - stack descriptor json response http://git-wip-us.apache.org/repos/asf/ambari/blob/d0fe0a32/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js index 1174f0a..f0fe836 100644 --- a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js +++ b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js @@ -32,7 +32,7 @@ describe('App.KerberosWizardStep4Controller', function() { App.ServiceConfigProperty.create({ name: 'prop1', value: 'someVal1', identityType: 'user', category: 'Ambari Principals', serviceName: 'Cluster'}) ]); controller.set('stepConfigs', controller.createServiceConfig(configs)); - + it('configuration errors are absent, submit should be not disabled', function() { expect(controller.get('stepConfigs')[0].get('errorCount')).to.be.eql(0); expect(controller.get('isSubmitDisabled')).to.be.false; @@ -43,7 +43,7 @@ describe('App.KerberosWizardStep4Controller', function() { serviceConfig.get('configs').findProperty('name', 'prop1').set('value', ''); expect(serviceConfig.get('errorCount')).to.be.eql(1); expect(controller.get('isSubmitDisabled')).to.be.true; - }); + }); }); describe('#createServiceConfig', function() { @@ -141,7 +141,7 @@ describe('App.KerberosWizardStep4Controller', function() { expect(this.result.findProperty('name', item)).to.be.undefined; }); }, this); - + propertyValidationCases.forEach(function(test) { it('property {0} should be created'.format(test.property), function() { expect(this.result.findProperty('name', test.property)).to.be.ok; @@ -157,7 +157,7 @@ describe('App.KerberosWizardStep4Controller', function() { }, this); }); }); - + describe('#setStepConfigs', function() { describe('Add Service Wizard', function() { @@ -348,4 +348,71 @@ describe('App.KerberosWizardStep4Controller', function() { }); }); + describe('#getDescriptorConfigs', function() { + describe('Within Add Service', function () { + var controller; + beforeEach(function () { + controller = App.KerberosWizardStep4Controller.create({ + wizardController: Em.Object.create({ + name: 'addServiceController', + setDBProperty: sinon.spy() + }) + }); + this.loadStackDescriptorStub = sinon.stub(controller, 'loadStackDescriptorConfigs').returns($.Deferred().resolve().promise()); + this.loadClusterDescriptorStub = sinon.stub(controller, 'loadClusterDescriptorConfigs'); + sinon.stub(controller, 'createServicesStackDescriptorConfigs', Em.K); + }); + + afterEach(function() { + this.loadStackDescriptorStub.restore(); + this.loadClusterDescriptorStub.restore(); + controller.createServicesStackDescriptorConfigs.restore(); + controller.destroy(); + controller = null; + }); + + var cases = [ + { + wizardController: 'addServiceController', + clusterDescriptorExists: false, + m: 'Within Add Service, Cluster Descriptor not exists. Should be reflected in wizard controller', + e: { + setDBPropertyCalled: true, + setDBPropertyCalledWith: ['isClusterDescriptorExists', false] + } + }, + { + wizardController: 'addServiceController', + clusterDescriptorExists: true, + m: 'Within Add Service, Cluster Descriptor is present. Should be reflected in wizard controller', + e: { + setDBPropertyCalled: true, + setDBPropertyCalledWith: ['isClusterDescriptorExists', true] + } + }, + { + wizardController: 'notAddService', + clusterDescriptorExists: true, + m: 'Within another controller, nothing to store', + e: { + setDBPropertyCalled: false + } + } + ]; + + cases.forEach(function(test) { + it(test.m, function () { + controller.get('wizardController').set('name', test.wizardController); + this.loadClusterDescriptorStub.returns(test.clusterDescriptorExists ? + $.Deferred().resolve().promise() : + $.Deferred().reject().promise()); + controller.getDescriptorConfigs(); + expect(controller.get('wizardController').setDBProperty.called).to.be.eql(test.e.setDBPropertyCalled); + if (test.e.setDBPropertyCalled) { + expect(controller.get('wizardController').setDBProperty.args[0]).to.be.eql(test.e.setDBPropertyCalledWith); + } + }) + }) + }); + }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/d0fe0a32/ambari-web/test/controllers/wizard/step8_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js index 62168b6..f70c25f 100644 --- a/ambari-web/test/controllers/wizard/step8_test.js +++ b/ambari-web/test/controllers/wizard/step8_test.js @@ -1848,7 +1848,7 @@ describe('App.WizardStep8Controller', function () { hosts: Em.A([ Em.Object.create({hostName: 'h1', isInstalled: false}), Em.Object.create({hostName: 'h2', isInstalled: false}) - ]), + ]) }), Em.Object.create({ componentName: 'CLIENT', @@ -2443,12 +2443,16 @@ describe('App.WizardStep8Controller', function () { sinon.stub(App.db, 'get').withArgs('KerberosWizard', 'kerberosDescriptorConfigs').returns(1234); sinon.stub(App.ajax, 'send', Em.K); sinon.stub(installerStep8Controller, 'addRequestToAjaxQueue', Em.K); + sinon.stub(installerStep8Controller, 'get').withArgs('wizardController').returns(Em.Object.create({ + getDBProperty: function() { return true; } + })); }); afterEach(function () { App.db.get.restore(); App.ajax.send.restore(); installerStep8Controller.addRequestToAjaxQueue.restore(); + installerStep8Controller.get.restore(); }); it('should send request instantly', function () {
