Updated Branches: refs/heads/trunk dd35bed89 -> a50d9904e
AMBARI-3193. Problems with service selection for 2.x stack. (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/a50d9904 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/a50d9904 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/a50d9904 Branch: refs/heads/trunk Commit: a50d9904e89cd34c691adc0a98383563e391b158 Parents: dd35bed Author: Oleg Nechiporenko <[email protected]> Authored: Thu Sep 12 13:51:22 2013 +0300 Committer: Oleg Nechiporenko <[email protected]> Committed: Thu Sep 12 14:26:40 2013 +0300 ---------------------------------------------------------------------- ambari-web/app/assets/test/tests.js | 2 +- .../app/controllers/wizard/step4_controller.js | 156 ++++++++++++------- ambari-web/app/messages.js | 12 +- .../heatmap_metrics/heatmap_metric_test.js | 2 +- ambari-web/test/installer/step4_test.js | 93 +++++++---- 5 files changed, 176 insertions(+), 89 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a50d9904/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 070e238..62ca5c6 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -91,4 +91,4 @@ require('test/views/main/dashboard/widgets/pie_chart_widget_test'); require('test/views/main/dashboard/widgets/namenode_cpu_test'); require('test/views/common/configs/services_config_test'); require('test/models/host_test'); -require('test/models/rack_test'); +require('test/models/rack_test'); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a50d9904/ambari-web/app/controllers/wizard/step4_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step4_controller.js b/ambari-web/app/controllers/wizard/step4_controller.js index a61a91b..96653cc 100644 --- a/ambari-web/app/controllers/wizard/step4_controller.js +++ b/ambari-web/app/controllers/wizard/step4_controller.js @@ -60,9 +60,6 @@ App.WizardStep4Controller = Em.ArrayController.extend({ zookeeper.set('isSelected', hbase.get('isSelected') || hive.get('isSelected')); } else { - if (!zookeeper.get('isSelected')) { - zookeeper.set('isSelected', hbase.get('isSelected')); - } mapreduce2.set('isSelected', yarn.get('isSelected')); } hcatalog.set('isSelected', hive.get('isSelected')); @@ -85,25 +82,51 @@ App.WizardStep4Controller = Em.ArrayController.extend({ }, /** - * Check whether we should turn on <code>MapReduce</code> service - * @return {Boolean} + * Check whether we should turn on <code>serviceName</code> service according to selected <code>dependentServices</code> + * @param serviceName checked service + * @param dependentServices list of dependent services + * @returns {boolean} */ - needToAddMapReduce: function () { - if (this.findProperty('serviceName', 'MAPREDUCE') && this.findProperty('serviceName', 'MAPREDUCE').get('isSelected') === false) { - var mapreduceDependentServices = this.filter(function (item) { - return ['PIG', 'OOZIE', 'HIVE'].contains(item.get('serviceName')) && item.get('isSelected', true); + needAddService: function(serviceName, dependentServices) { + if (!(dependentServices instanceof Array)) { + dependentServices = [dependentServices]; + } + if (this.findProperty('serviceName', serviceName) && this.findProperty('serviceName', serviceName).get('isSelected') === false) { + var ds = this.filter(function (item) { + return dependentServices.contains(item.get('serviceName')) && item.get('isSelected'); }); - return (mapreduceDependentServices.get('length') > 0); + return (ds.get('length') > 0); } - return false; }, + /** + * Check whether we should turn on <code>MapReduce</code> service + * @return {Boolean} + */ + needToAddMapReduce: function () { + return this.needAddService('MAPREDUCE', ['PIG', 'OOZIE', 'HIVE']); + }, + /** + * Check whether we should turn on <code>MapReduce2</code> service + * @return {Boolean} + */ + needToAddYarnMapReduce2: function() { + return this.needAddService('YARN', ['PIG', 'OOZIE', 'HIVE']); + }, + /** + * Check whether we should turn on <code>ZooKeeper</code> service + * @return {Boolean} + */ + needToAddZooKeeper: function() { + return this.needAddService('ZOOKEEPER', 'HBASE'); + }, + /** * Check whether we should turn on <code>HDFS or HCFS</code> service * @return {Boolean} */ - needToAddHDFS: function () { + noDFSs: function () { return (this.findProperty('serviceName', 'HDFS').get('isSelected') === false && (!this.findProperty('serviceName', 'HCFS') || this.findProperty('serviceName', 'HCFS').get('isSelected') === false)); }, @@ -113,7 +136,7 @@ App.WizardStep4Controller = Em.ArrayController.extend({ * @return {Boolean} */ multipleDFSs: function () { - return (this.findProperty('serviceName', 'HDFS').get('isSelected') === true && + return (this.findProperty('serviceName', 'HDFS').get('isSelected') === true && (this.findProperty('serviceName', 'HCFS') && this.findProperty('serviceName', 'HCFS').get('isSelected') === true)); }, @@ -140,67 +163,92 @@ App.WizardStep4Controller = Em.ArrayController.extend({ * Onclick handler for <code>Next</code> button */ submit: function () { - if(!this.get("isSubmitDisabled")){ + if(!this.get("isSubmitDisabled")) { if (this.needToAddMapReduce()) { this.mapReduceCheckPopup(); - } else if (this.needToAddHDFS()) { - this.needToAddHDFSPopup(); - } else if (this.multipleDFSs()) { - this.multipleDFSPopup(); } - else { - this.validateMonitoring(); + else { + if (this.noDFSs()) { + this.needToAddHDFSPopup(); + } + else { + if (this.needToAddYarnMapReduce2()) { + this.mapReduce2CheckPopup(); + } + else { + if (this.needToAddZooKeeper()) { + this.zooKeeperCheckPopup(); + } + else { + if (this.multipleDFSs()) { + this.multipleDFSPopup(); + } + else { + this.validateMonitoring(); + } + } + } + } } } }, multipleDFSPopup: function() { + var services = [ + {serviceName: 'HDFS', selected: true}, + {serviceName: 'HCFS', selected: false} + ]; + this.needToAddServicePopup(services, 'multipleDFS'); + }, + /** + * Select/deselect services + * @param services array of objects + * <code> + * [ + * { + * service: 'HDFS', + * selected: true + * }, + * .... + * ] + * </code> + * @param i18nSuffix + */ + needToAddServicePopup: function(services, i18nSuffix) { + if (!(services instanceof Array)) { + services = [services]; + } var self = this; App.ModalPopup.show({ - header: Em.I18n.t('installer.step4.multipleDFS.popup.header'), - body: Em.I18n.t('installer.step4.multipleDFS.popup.body'), + header: Em.I18n.t('installer.step4.' + i18nSuffix + '.popup.header'), + body: Em.I18n.t('installer.step4.' + i18nSuffix + '.popup.body'), onPrimary: function () { - self.findProperty('serviceName', 'HDFS').set('isSelected', true); - self.findProperty('serviceName', 'HCFS').set('isSelected', false); + services.forEach(function(service) { + self.findProperty('serviceName', service.serviceName).set('isSelected', service.selected); + }); this.hide(); - self.validateMonitoring(); + self.submit(); }, onSecondary: function () { this.hide(); } - }); + }); }, - + needToAddHDFSPopup: function() { - var self = this; - App.ModalPopup.show({ - header: Em.I18n.t('installer.step4.hdfsCheck.popup.header'), - body: Em.I18n.t('installer.step4.hdfsCheck.popup.body'), - onPrimary: function () { - self.findProperty('serviceName', 'HDFS').set('isSelected', true); - this.hide(); - self.validateMonitoring(); - }, - onSecondary: function () { - this.hide(); - } - }); + this.needToAddServicePopup({serviceName:'HDFS', selected: true}, 'hdfsCheck'); }, mapReduceCheckPopup: function () { - var self = this; - App.ModalPopup.show({ - header: Em.I18n.t('installer.step4.mapreduceCheck.popup.header'), - body: Em.I18n.t('installer.step4.mapreduceCheck.popup.body'), - onPrimary: function () { - self.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true); - this.hide(); - self.validateMonitoring(); - }, - onSecondary: function () { - this.hide(); - } - }); + this.needToAddServicePopup({serviceName:'MAPREDUCE', selected: true}, 'mapreduceCheck'); + }, + + mapReduce2CheckPopup: function () { + this.needToAddServicePopup({serviceName:'YARN', selected:true}, 'yarnCheck'); + }, + + zooKeeperCheckPopup: function () { + this.needToAddServicePopup({serviceName:'ZOOKEEPER', selected: true}, 'zooKeeperCheck'); }, monitoringCheckPopup: function () { @@ -216,4 +264,4 @@ App.WizardStep4Controller = Em.ArrayController.extend({ } }); } -}) \ No newline at end of file +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a50d9904/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 72c9c05..89b3a1e 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -407,13 +407,17 @@ Em.I18n.translations = { 'installer.step4.header':'Choose Services', 'installer.step4.body':'Choose which services you want to install on your cluster.', 'installer.step4.hdfsCheck.popup.header':'Hadoop File System Needed', - 'installer.step4.hdfsCheck.popup.body':'You did not select HDFS or HCFS, but one is required. We will automatically add HDFS. Is this OK?', + 'installer.step4.hdfsCheck.popup.body':'You did not select HDFS or HCFS, but one is required. We will automatically add HDFS. Is this OK?', 'installer.step4.multipleDFS.popup.header':'Multiple File Systems Selected', - 'installer.step4.multipleDFS.popup.body':'You selected more than one file system. We will automatically select only HDFS. Is this OK?', + 'installer.step4.multipleDFS.popup.body':'You selected more than one file system. We will automatically select only HDFS. Is this OK?', 'installer.step4.mapreduceCheck.popup.header':'MapReduce Needed', - 'installer.step4.mapreduceCheck.popup.body':'You did not select MapReduce, but it is needed by other services you selected. We will automatically add MapReduce. Is this OK?', + 'installer.step4.mapreduceCheck.popup.body':'You did not select MapReduce, but it is needed by other services you selected. We will automatically add MapReduce. Is this OK?', + 'installer.step4.yarnCheck.popup.header':'Yarn+MarReduce2 Needed', + 'installer.step4.yarnCheck.popup.body':'You did not select Yarn+MarReduce2, but it is needed by other services you selected. We will automatically add Yarn+MarReduce2. Is this OK?', + 'installer.step4.zooKeeperCheck.popup.header':'ZooKeeper Needed', + 'installer.step4.zooKeeperCheck.popup.body':'You did not select ZooKeeper, but it is needed by other services you selected. We will automatically add ZooKeeper. Is this OK?', 'installer.step4.monitoringCheck.popup.header':'Limited Functionality Warning', - 'installer.step4.monitoringCheck.popup.body':'You did not select Nagios and/or Ganglia. If both are not selected, monitoring and alerts will not function properly. Is this OK?', + 'installer.step4.monitoringCheck.popup.body':'You did not select Nagios and/or Ganglia. If both are not selected, monitoring and alerts will not function properly. Is this OK?', 'installer.step5.header':'Assign Masters', 'installer.step5.reassign.header':'Select Target Host', http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a50d9904/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js index 63562d1..7d3a02b 100644 --- a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js +++ b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js @@ -27,7 +27,7 @@ describe('MainChartHeatmapMetric', function () { {m:'undefined to undefined',i:undefined,e:undefined}, {m:'0 to 0',i:0,e:0}, {m:'1 to 1',i:1,e:1}, - {m:'1.23 to 1.2',i:1.23,e:'1.2'} + {m:'1.23 to 1.2',i:1.23,e:1.2} ]; tests.forEach(function(test) { it(test.m + ' ', function () { http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a50d9904/ambari-web/test/installer/step4_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/installer/step4_test.js b/ambari-web/test/installer/step4_test.js index 1d39dab..c70b45a4 100644 --- a/ambari-web/test/installer/step4_test.js +++ b/ambari-web/test/installer/step4_test.js @@ -24,7 +24,7 @@ describe('App.WizardStep4Controller', function () { var services = [ 'HDFS', 'MAPREDUCE', 'NAGIOS', 'GANGLIA', 'OOZIE', 'HIVE', 'HBASE', 'PIG', 'SCOOP', 'ZOOKEEPER', 'HCATALOG', 'WEBHCAT', 'YARN', 'MAPREDUCE2' - ] + ]; var controller = App.WizardStep4Controller.create(); services.forEach(function(serviceName, index){ @@ -36,52 +36,52 @@ describe('App.WizardStep4Controller', function () { describe('#isSubmitDisabled', function () { it('should return false if at least one selected service is not installed', function () { expect(controller.get('isSubmitDisabled')).to.equal(false); - }) + }); it('should return true if all selected services are already installed', function () { controller.setEach('isInstalled', true); controller.findProperty('serviceName', 'HDFS').set('isSelected', false); expect(controller.get('isSubmitDisabled')).to.equal(true); - }) - }) + }); + }); describe('#isAll', function () { it('should return true if all services are selected', function () { controller.findProperty('serviceName', 'HDFS').set('isSelected', true); expect(controller.get('isAll')).to.equal(true); - }) + }); it('should return false if at least one service is not selected', function () { controller.findProperty('serviceName', 'HDFS').set('isSelected', false); expect(controller.get('isAll')).to.equal(false); - }) - }) + }); + }); describe('#isMinimum', function () { it('should return true if there are no services selected, except disabled', function () { controller.setEach('isSelected', false); expect(controller.get('isMinimum')).to.equal(true); - }) + }); it('should return false if at least one service is selected, except disabled', function () { controller.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true); expect(controller.get('isMinimum')).to.equal(false); - }) - }) + }); + }); describe('#checkDependencies()', function () { - it('should set ZooKeeper isSelected property like in HBase', function () { + /*it('should set ZooKeeper isSelected property like in HBase', function () { controller.setEach('isSelected', false); controller.findProperty('serviceName', 'HBASE').set('isSelected', true); controller.checkDependencies(); expect(controller.findProperty('serviceName', 'ZOOKEEPER').get('isSelected')).to.equal(true); - }) + });*/ it('should set ZooKeeper, HCatalog, WebHCatalog isSelected property like in Hive', function () { controller.setEach('isSelected', false); controller.findProperty('serviceName', 'HIVE').set('isSelected', true); controller.checkDependencies(); expect(controller.findProperty('serviceName', 'HCATALOG').get('isSelected')).to.equal(true); expect(controller.findProperty('serviceName', 'WEBHCAT').get('isSelected')).to.equal(true); - }) + }); it('should set MapReduce2 isSelected property like in Yarn', function () { App.set('currentStackVersion', 'HDP-2.0.1'); App.set('defaultStackVersion', 'HDP-2.0.1'); @@ -91,16 +91,16 @@ describe('App.WizardStep4Controller', function () { expect(controller.findProperty('serviceName', 'MAPREDUCE2').get('isSelected')).to.equal(true); App.set('currentStackVersion', 'HDP-1.2.2'); App.set('defaultStackVersion', 'HDP-1.2.2'); - }) - }) + }); + }); describe('#selectAll()', function () { it('should select all services', function () { controller.setEach('isSelected', false); controller.selectAll(); expect(controller.filterProperty('canBeSelected', true).everyProperty('isSelected', true)).to.equal(true); - }) - }) + }); + }); describe('#selectMinimum()', function () { it('should set isSelected false for all not disabled services', function () { @@ -108,35 +108,71 @@ describe('App.WizardStep4Controller', function () { controller.selectMinimum(); expect(controller.findProperty('serviceName', 'HDFS').get('isSelected')).to.equal(true); expect(controller.filterProperty('isDisabled', false).everyProperty('isSelected', false)).to.equal(true); - }) - }) + }); + }); describe('#needToAddMapReduce()', function () { it('should return true if Pig is selected and MapReduce is not selected', function () { controller.setEach('isSelected', false); controller.findProperty('serviceName', 'PIG').set('isSelected', true); expect(controller.needToAddMapReduce()).to.equal(true); - }) + }); it('should return true if Oozie is selected and MapReduce is not selected', function () { controller.setEach('isSelected', false); controller.findProperty('serviceName', 'OOZIE').set('isSelected', true); expect(controller.needToAddMapReduce()).to.equal(true); - }) + }); it('should return true if Hive is selected and MapReduce is not selected', function () { controller.setEach('isSelected', false); controller.findProperty('serviceName', 'HIVE').set('isSelected', true); expect(controller.needToAddMapReduce()).to.equal(true); - }) + }); it('should return false if MapReduce is selected or Pig, Oozie and Hive are not selected', function () { controller.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true); expect(controller.needToAddMapReduce()).to.equal(false); controller.setEach('isSelected', false); expect(controller.needToAddMapReduce()).to.equal(false); - }) - }) + }); + }); + + describe('#needToAddYarnMapReduce2()', function () { + it('should return true if Pig is selected and YARN+MapReduce2 is not selected', function () { + controller.setEach('isSelected', false); + controller.findProperty('serviceName', 'PIG').set('isSelected', true); + expect(controller.needToAddYarnMapReduce2()).to.equal(true); + }); + + it('should return true if Oozie is selected and YARN+MapReduce2 is not selected', function () { + controller.setEach('isSelected', false); + controller.findProperty('serviceName', 'OOZIE').set('isSelected', true); + expect(controller.needToAddYarnMapReduce2()).to.equal(true); + }); + + it('should return true if Hive is selected and YARN+MapReduce2 is not selected', function () { + controller.setEach('isSelected', false); + controller.findProperty('serviceName', 'HIVE').set('isSelected', true); + expect(controller.needToAddYarnMapReduce2()).to.equal(true); + }); + + it('should return false if YARN+MapReduce2 is selected or Pig, Oozie and Hive are not selected', function () { + controller.findProperty('serviceName', 'YARN').set('isSelected', true); + expect(controller.needToAddYarnMapReduce2()).to.equal(false); + controller.setEach('isSelected', false); + expect(controller.needToAddYarnMapReduce2()).to.equal(false); + }); + }); + + describe('#needToAddZooKeeper()', function () { + it('should return false if ZOOKEEPER is selected or HBASE is not selected', function () { + controller.findProperty('serviceName', 'ZOOKEEPER').set('isSelected', true); + expect(controller.needToAddZooKeeper()).to.equal(false); + controller.setEach('isSelected', false); + expect(controller.needToAddZooKeeper()).to.equal(false); + }); + }); describe('#gangliaOrNagiosNotSelected()', function () { it('should return true if Nagios or Ganglia is not selected', function () { @@ -146,15 +182,14 @@ describe('App.WizardStep4Controller', function () { controller.setEach('isSelected', true); controller.findProperty('serviceName', 'GANGLIA').set('isSelected', false); expect(controller.gangliaOrNagiosNotSelected()).to.equal(true); - }) + }); it('should return false if Nagios and Ganglia is selected', function () { controller.setEach('isSelected', false); controller.findProperty('serviceName', 'GANGLIA').set('isSelected', true); controller.findProperty('serviceName', 'NAGIOS').set('isSelected', true); expect(controller.gangliaOrNagiosNotSelected()).to.equal(false); - }) - }) - -}) + }); + }); +}); \ No newline at end of file
