Browse Source

AMBARI-9564. Add warning if the user tries to install Spark with "HDP 2.2" (warn that it won't work with HDP 2.2.0). (onechiporenko)

Oleg Nechiporenko 10 years ago
parent
commit
edec73af9b

+ 35 - 0
ambari-web/app/controllers/wizard/step4_controller.js

@@ -107,6 +107,22 @@ App.WizardStep4Controller = Em.ArrayController.extend({
     }
   },
 
+  /**
+   * Warn user if he tries to install Spark with HDP 2.2
+   * @method sparkValidation
+   */
+  sparkValidation: function () {
+    var sparkService = this.findProperty('serviceName', 'SPARK');
+    if (sparkService && sparkService.get('isSelected') && !sparkService.get('isInstalled') &&
+      App.get('currentStackName') == 'HDP' && App.get('currentStackVersionNumber') == '2.2') {
+      this.addValidationError({
+        id: 'sparkWarning',
+        type: 'WARNING',
+        callback: this.sparkWarningPopup
+      });
+    }
+  },
+
   /**
    * Onclick handler for <code>Next</code> button.
    * @method submit
@@ -145,6 +161,7 @@ App.WizardStep4Controller = Em.ArrayController.extend({
       this.ambariMetricsValidation();
     }
     this.rangerValidation();
+    this.sparkValidation();
     if (!!this.get('errorStack').filterProperty('isShown', false).length) {
       this.showError(this.get('errorStack').findProperty('isShown', false));
       return false;
@@ -398,5 +415,23 @@ App.WizardStep4Controller = Em.ArrayController.extend({
         this.hide();
       }
     });
+  },
+
+  /**
+   * Show popup with Spark installation warning
+   * @return {App.ModalPopup}
+   * @method sparkWarningPopup
+   */
+  sparkWarningPopup: function () {
+    var self = this;
+    return App.ModalPopup.show({
+      header: Em.I18n.t('common.warning'),
+      body: Em.I18n.t('installer.step4.sparkWarning.popup.body'),
+      primary: Em.I18n.t('common.proceedAnyway'),
+      onPrimary: function () {
+        self.onPrimaryPopupCallback();
+        this.hide();
+      }
+    });
   }
 });

+ 1 - 0
ambari-web/app/messages.js

@@ -662,6 +662,7 @@ Em.I18n.translations = {
     '<li>Execute the following command on the Ambari Server host. Replace <code>database-type</code> with <strong>mysql</strong> or <strong>oracle</strong> and <code>/jdbc/driver/path</code> based on the location of the MySQL or Oracle JDBC driver:' +
     '<pre>ambari-server setup --jdbc-db={database-type} --jdbc-driver={/jdbc/driver/path}</pre></li></ol>',
   'installer.step4.rangerRequirements.popup.body.confirmation': 'I have met all the requirements above.',
+  'installer.step4.sparkWarning.popup.body': 'Spark requires HDP 2.2.1 or later. Attempting to install Spark to a HDP 2.2.0 cluster will fail. Confirm you are using HDP 2.2.1 or later packages. Are you sure you want to proceed?',
 
   'installer.step5.header':'Assign Masters',
   'installer.step5.reassign.header':'Select Target Host',

+ 171 - 4
ambari-web/test/controllers/wizard/step4_test.js

@@ -25,7 +25,7 @@ describe('App.WizardStep4Controller', function () {
 
   var services = [
     'HDFS', 'GANGLIA', 'OOZIE', 'HIVE', 'HBASE', 'PIG', 'SCOOP', 'ZOOKEEPER',
-    'YARN', 'MAPREDUCE2', 'FALCON', 'TEZ', 'STORM', 'AMBARI_METRICS', 'RANGER'
+    'YARN', 'MAPREDUCE2', 'FALCON', 'TEZ', 'STORM', 'AMBARI_METRICS', 'RANGER', 'SPARK'
   ];
 
   var controller = App.WizardStep4Controller.create();
@@ -300,7 +300,31 @@ describe('App.WizardStep4Controller', function () {
       wizardNames = {
         installerController: 'Install Wizard',
         addServiceController: 'Add Service Wizard'
-      };
+      },
+      sparkCases = [
+        {
+          currentStackName: 'HDP',
+          currentStackVersionNumber: '2.2',
+          sparkWarningExpected: true,
+          title: 'HDP 2.2'
+        },
+        {
+          currentStackName: 'HDP',
+          currentStackVersionNumber: '2.3',
+          sparkWarningExpected: false,
+          title: 'HDP 2.3'
+        },
+        {
+          currentStackName: 'BIGTOP',
+          currentStackVersionNumber: '0.8',
+          sparkWarningExpected: false,
+          title: 'Non-HDP stack'
+        }
+      ];
+
+    beforeEach(function () {
+      controller.clear();
+    });
 
     controllerNames.forEach(function (name) {
       tests.forEach(function(test) {
@@ -312,7 +336,6 @@ describe('App.WizardStep4Controller', function () {
           .format(wizardNames[name], test.services.join(','), errorsExpected.length ? 'passed' : 'failed',
             errorsExpected.length ? errorsExpected.join(',') : 'absent');
         it(message, function() {
-          controller.clear();
           controller.setProperties({
             content: generateSelectedServicesContent(test.services),
             wizardController: Em.Object.create({
@@ -325,6 +348,17 @@ describe('App.WizardStep4Controller', function () {
       })
     });
 
+    sparkCases.forEach(function (item) {
+      it(item.title, function () {
+        sinon.stub(App, 'get').withArgs('currentStackName').returns(item.currentStackName).
+          withArgs('currentStackVersionNumber').returns(item.currentStackVersionNumber);
+        controller.set('content', generateSelectedServicesContent(['SPARK']));
+        controller.validate();
+        expect(controller.get('errorStack').someProperty('id', 'sparkWarning')).to.equal(item.sparkWarningExpected);
+        App.get.restore();
+      });
+    });
+
   });
 
   describe('#onPrimaryPopupCallback()', function() {
@@ -599,7 +633,7 @@ describe('App.WizardStep4Controller', function () {
         if (item.services.contains('RANGER')) {
           ranger.setProperties({
             isSelected: item.isRangerSelected,
-            isInstalled: item.isRangerInstalled,
+            isInstalled: item.isRangerInstalled
           });
         } else {
           controller.removeObject(ranger);
@@ -611,4 +645,137 @@ describe('App.WizardStep4Controller', function () {
 
   });
 
+  describe('#sparkValidation', function () {
+
+    var cases = [
+      {
+        services: ['HDFS'],
+        isSparkWarning: false,
+        currentStackName: 'HDP',
+        currentStackVersionNumber: '2.2',
+        title: 'HDP 2.2, Spark not available'
+      },
+      {
+        services: ['HDFS'],
+        isSparkWarning: false,
+        currentStackName: 'HDP',
+        currentStackVersionNumber: '2.3',
+        title: 'HDP 2.3, Spark not available'
+      },
+      {
+        services: ['HDFS'],
+        isSparkWarning: false,
+        currentStackName: 'BIGTOP',
+        currentStackVersionNumber: '0.8',
+        title: 'Non-HDP stack, Spark not available'
+      },
+      {
+        services: ['SPARK'],
+        isSparkSelected: false,
+        isSparkInstalled: false,
+        isSparkWarning: false,
+        currentStackName: 'HDP',
+        currentStackVersionNumber: '2.2',
+        title: 'HDP 2.2, Spark not selected'
+      },
+      {
+        services: ['SPARK'],
+        isSparkSelected: true,
+        isSparkInstalled: false,
+        isSparkWarning: true,
+        currentStackName: 'HDP',
+        currentStackVersionNumber: '2.2',
+        title: 'HDP 2.2, Spark selected'
+      },
+      {
+        services: ['SPARK'],
+        isSparkSelected: true,
+        isSparkInstalled: true,
+        isSparkWarning: false,
+        currentStackName: 'HDP',
+        currentStackVersionNumber: '2.2',
+        title: 'HDP 2.2, Spark installed'
+      },
+      {
+        services: ['SPARK'],
+        isSparkSelected: false,
+        isSparkInstalled: false,
+        isSparkWarning: false,
+        currentStackName: 'HDP',
+        currentStackVersionNumber: '2.3',
+        title: 'HDP 2.3, Spark not selected'
+      },
+      {
+        services: ['SPARK'],
+        isSparkSelected: true,
+        isSparkInstalled: false,
+        isSparkWarning: false,
+        currentStackName: 'HDP',
+        currentStackVersionNumber: '2.3',
+        title: 'HDP 2.3, Spark selected'
+      },
+      {
+        services: ['SPARK'],
+        isSparkSelected: true,
+        isSparkInstalled: true,
+        isSparkWarning: false,
+        currentStackName: 'HDP',
+        currentStackVersionNumber: '2.3',
+        title: 'HDP 2.3, Spark installed'
+      },
+      {
+        services: ['SPARK'],
+        isSparkSelected: false,
+        isSparkInstalled: false,
+        isSparkWarning: false,
+        currentStackName: 'BIGTOP',
+        currentStackVersionNumber: '0.8',
+        title: 'Non-HDP stack, Spark not selected'
+      },
+      {
+        services: ['SPARK'],
+        isSparkSelected: true,
+        isSparkInstalled: false,
+        isSparkWarning: false,
+        currentStackName: 'BIGTOP',
+        currentStackVersionNumber: '0.8',
+        title: 'Non-HDP stack, Spark selected'
+      },
+      {
+        services: ['SPARK'],
+        isSparkSelected: true,
+        isSparkInstalled: true,
+        isSparkWarning: false,
+        currentStackName: 'BIGTOP',
+        currentStackVersionNumber: '0.8',
+        title: 'Non-HDP stack, Spark installed'
+      }
+    ];
+
+    afterEach(function () {
+      App.get.restore();
+    });
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        sinon.stub(App, 'get').withArgs('currentStackName').returns(item.currentStackName).
+          withArgs('currentStackVersionNumber').returns(item.currentStackVersionNumber);
+        controller.clear();
+        controller.set('content', generateSelectedServicesContent(item.services));
+        var spark = controller.findProperty('serviceName', 'SPARK');
+        if (item.services.contains('SPARK')) {
+          spark.setProperties({
+            isSelected: item.isSparkSelected,
+            isInstalled: item.isSparkInstalled
+          });
+        } else {
+          controller.removeObject(spark);
+        }
+        controller.sparkValidation();
+        expect(controller.get('errorStack').mapProperty('id').contains('sparkWarning')).to.equal(item.isSparkWarning);
+      });
+    });
+
+  });
+
 });