AMBARI-19586 Ranger Admin HA Wizard should display configs changes explicitly. (ababiichuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/71c5b1f3 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/71c5b1f3 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/71c5b1f3 Branch: refs/heads/branch-dev-patch-upgrade Commit: 71c5b1f342aefe156d0af19264da0d2f0184ed8f Parents: e3e9f70 Author: ababiichuk <[email protected]> Authored: Tue Jan 17 15:53:05 2017 +0200 Committer: ababiichuk <[email protected]> Committed: Tue Jan 17 17:00:09 2017 +0200 ---------------------------------------------------------------------- ambari-web/app/assets/test/tests.js | 1 + .../rangerAdmin/step3_controller.js | 43 ++++++- .../rangerAdmin/step4_controller.js | 2 +- .../rangerAdmin/wizard_controller.js | 2 + .../app/routes/ra_high_availability_routes.js | 4 + .../highAvailability/rangerAdmin/step3.hbs | 7 ++ .../highAvailability/rangerAdmin/step3_view.js | 6 +- .../rangerAdmin/step3_controller_test.js | 114 +++++++++++++++++++ 8 files changed, 176 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/71c5b1f3/ambari-web/app/assets/test/tests.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js index 604d96b..e42c811 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -89,6 +89,7 @@ var files = [ 'test/controllers/main/admin/highAvailability/journalNode/step7_controller_test', 'test/controllers/main/admin/highAvailability/journalNode/step8_controller_test', 'test/controllers/main/admin/highAvailability/journalNode/wizard_controller_test', + 'test/controllers/main/admin/highAvailability/rangerAdmin/step3_controller_test', 'test/controllers/main/dashboard/config_history_controller_test', 'test/controllers/main/charts/heatmap_test', 'test/controllers/main/charts/heatmap_metrics/heatmap_metric_test', http://git-wip-us.apache.org/repos/asf/ambari/blob/71c5b1f3/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step3_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step3_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step3_controller.js index 475cc52..ea77d24 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step3_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step3_controller.js @@ -19,6 +19,47 @@ var App = require('app'); App.RAHighAvailabilityWizardStep3Controller = Em.Controller.extend({ - name: "rAHighAvailabilityWizardStep3Controller" + name: 'rAHighAvailabilityWizardStep3Controller', + + isLoaded: false, + + versionLoaded: true, + + hideDependenciesInfoBar: true, + + stepConfigs: [ + App.ServiceConfig.create({ + serviceName: 'MISC', + configCategories: [ + App.ServiceConfigCategory.create({ + name: 'RANGER', + displayName: App.format.role('RANGER', true) + }) + ], + showConfig: true + }) + ], + + loadStep: function () { + var self = this; + App.get('router.mainController.isLoading').call(App.get('router.clusterController'), 'isConfigsPropertiesLoaded').done(function () { + var property = App.configsCollection.getConfigByName('policymgr_external_url', 'admin-properties'), + stepConfig = self.get('stepConfigs.firstObject'); + stepConfig.set('configs', [ + App.ServiceConfigProperty.create(property, { + category: 'RANGER', + value: self.get('content.loadBalancerURL') + }) + ]); + self.setProperties({ + isLoaded: true, + selectedService: stepConfig + }); + }); + }, + + updateConfigProperty: function () { + this.set('content.policymgrExternalURL', this.get('selectedService.configs.firstObject.value')); + } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/71c5b1f3/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step4_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step4_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step4_controller.js index b7818d9..3c32af9 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step4_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step4_controller.js @@ -63,7 +63,7 @@ App.RAHighAvailabilityWizardStep4Controller = App.HighAvailabilityProgressPageCo }, onLoadConfigs: function (data) { - data.items.findProperty('type', 'admin-properties').properties['policymgr_external_url'] = this.get('content.loadBalancerURL'); + data.items.findProperty('type', 'admin-properties').properties['policymgr_external_url'] = this.get('content.policymgrExternalURL'); var configData = this.reconfigureSites(['admin-properties'], data, Em.I18n.t('admin.highAvailability.step4.save.configuration.note').format(App.format.role('RANGER_ADMIN', false))); App.ajax.send({ http://git-wip-us.apache.org/repos/asf/ambari/blob/71c5b1f3/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/wizard_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/wizard_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/wizard_controller.js index 2bc6e37..fbb0692 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/wizard_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/wizard_controller.js @@ -36,6 +36,7 @@ App.RAHighAvailabilityWizardController = App.WizardController.extend({ controllerName: 'rAHighAvailabilityWizardController', cluster: null, loadBalancerURL: null, + policymgrExternalURL: null, hosts: null, services: null, masterComponentHosts: null @@ -100,6 +101,7 @@ App.RAHighAvailabilityWizardController = App.WizardController.extend({ this.loadTasksStatuses(); this.loadTasksRequestIds(); this.loadRequestIds(); + this.load('policymgrExternalURL'); } } ] http://git-wip-us.apache.org/repos/asf/ambari/blob/71c5b1f3/ambari-web/app/routes/ra_high_availability_routes.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/ra_high_availability_routes.js b/ambari-web/app/routes/ra_high_availability_routes.js index ac975ab..dbf653b 100644 --- a/ambari-web/app/routes/ra_high_availability_routes.js +++ b/ambari-web/app/routes/ra_high_availability_routes.js @@ -135,6 +135,10 @@ module.exports = App.WizardRoute.extend({ }); }, next: function (router) { + var controller = router.get('rAHighAvailabilityWizardController'), + stepController = router.get('rAHighAvailabilityWizardStep3Controller'); + stepController.updateConfigProperty(); + controller.save('policymgrExternalURL'); router.transitionTo('step4'); }, back: function (router) { http://git-wip-us.apache.org/repos/asf/ambari/blob/71c5b1f3/ambari-web/app/templates/main/admin/highAvailability/rangerAdmin/step3.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/admin/highAvailability/rangerAdmin/step3.hbs b/ambari-web/app/templates/main/admin/highAvailability/rangerAdmin/step3.hbs index 3c798c8..5342728 100644 --- a/ambari-web/app/templates/main/admin/highAvailability/rangerAdmin/step3.hbs +++ b/ambari-web/app/templates/main/admin/highAvailability/rangerAdmin/step3.hbs @@ -46,6 +46,13 @@ <div class="alert alert-info"> {{{t admin.rm_highAvailability.wizard.step3.configs_changes}}} </div> + {{#if isLoaded}} + <div id="serviceConfig"> + {{view App.ServiceConfigView}} + </div> + {{else}} + {{view App.SpinnerView}} + {{/if}} </div> </div> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/71c5b1f3/ambari-web/app/views/main/admin/highAvailability/rangerAdmin/step3_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/highAvailability/rangerAdmin/step3_view.js b/ambari-web/app/views/main/admin/highAvailability/rangerAdmin/step3_view.js index 8aa0125..1c55608 100644 --- a/ambari-web/app/views/main/admin/highAvailability/rangerAdmin/step3_view.js +++ b/ambari-web/app/views/main/admin/highAvailability/rangerAdmin/step3_view.js @@ -21,6 +21,10 @@ var App = require('app'); App.RAHighAvailabilityWizardStep3View = Em.View.extend({ - templateName: require('templates/main/admin/highAvailability/rangerAdmin/step3') + templateName: require('templates/main/admin/highAvailability/rangerAdmin/step3'), + + didInsertElement: function () { + this.get('controller').loadStep(); + } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/71c5b1f3/ambari-web/test/controllers/main/admin/highAvailability/rangerAdmin/step3_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/highAvailability/rangerAdmin/step3_controller_test.js b/ambari-web/test/controllers/main/admin/highAvailability/rangerAdmin/step3_controller_test.js new file mode 100644 index 0000000..649bcbc --- /dev/null +++ b/ambari-web/test/controllers/main/admin/highAvailability/rangerAdmin/step3_controller_test.js @@ -0,0 +1,114 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +var App = require('app'); +require('controllers/main/admin/highAvailability/rangerAdmin/step3_controller'); +require('controllers/main'); + +describe('App.RAHighAvailabilityWizardStep3Controller', function () { + + var controller; + + beforeEach(function () { + controller = App.RAHighAvailabilityWizardStep3Controller.create(); + }); + + describe('#loadStep', function () { + + var dfd, + testCases = [ + { + path: 'isLoaded', + result: true + }, + { + path: 'selectedService.configs.length', + result: 1, + massage: 'configs length' + }, + { + path: 'selectedService.configs.firstObject.name', + result: 'policymgr_external_url', + message: 'property name' + }, + { + path: 'selectedService.configs.firstObject.category', + result: 'RANGER', + message: 'config category' + }, + { + path: 'selectedService.configs.firstObject.value', + result: 'http://localhost:1111', + message: 'property value' + } + ]; + + beforeEach(function () { + dfd = $.Deferred(); + sinon.stub(App.get('router.mainController'), 'isLoading').returns(dfd); + sinon.stub(App.configsCollection, 'getConfigByName').returns({ + name: 'policymgr_external_url' + }); + controller.set('content', { + loadBalancerURL: 'http://localhost:1111' + }); + controller.loadStep(); + dfd.resolve(); + }); + + afterEach(function () { + App.get('router.mainController.isLoading').restore(); + App.configsCollection.getConfigByName.restore(); + }); + + testCases.forEach(function (testCase) { + + it(testCase.message || testCase.path, function () { + expect(controller.get(testCase.path)).to.equal(testCase.result); + }); + + }); + + }); + + describe('#updateConfigProperty', function () { + + beforeEach(function () { + controller.setProperties({ + content: { + policymgrExternalURL: 'http://localhost:1111' + }, + selectedService: { + configs: [ + { + value: 'http://localhost:2222' + } + ] + } + }); + controller.updateConfigProperty(); + }); + + it('should update content.policymgrExternalURL', function () { + expect(controller.get('content.policymgrExternalURL')).to.equal('http://localhost:2222'); + }); + + }); + +}); \ No newline at end of file
