You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2015/10/19 15:54:31 UTC

[45/50] [abbrv] ambari git commit: AMBARI-13468. Strange behavior on Customize Services -> Review transition (onechiporenko)

AMBARI-13468. Strange behavior on Customize Services -> Review transition (onechiporenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0ccc873e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0ccc873e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0ccc873e

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 0ccc873e884f713025e1f56f21a3d8e5aab4c5af
Parents: 823c3b9
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Mon Oct 19 13:49:53 2015 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Mon Oct 19 14:07:29 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/wizard.js            |  7 ++
 .../app/controllers/wizard/step7_controller.js  | 79 +++++++++++-----
 .../test/controllers/wizard/step7_test.js       | 96 +++++++++++++++++++-
 .../test/mappers/configs/themes_mapper_test.js  |  6 +-
 4 files changed, 159 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0ccc873e/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 2049099..fdee580 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -238,6 +238,13 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
     return this.get('currentStep') == 10;
   }.property('currentStep'),
 
+  /**
+   * Move user to the selected step
+   *
+   * @param {number} step number of the step, where user is moved
+   * @param {boolean} disableNaviWarning true - don't show warning about moving more than 1 step back
+   * @returns {boolean}
+   */
   gotoStep: function (step, disableNaviWarning) {
     if (this.get('isStepDisabled').findProperty('step', step).get('value') !== false) {
       return false;

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ccc873e/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 635b26a..8bb37f7 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -1242,9 +1242,9 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
   getAmbariDatabaseSuccess: function (data) {
     var hiveDBHostname = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_hostname').value;
     var ambariServiceHostComponents = data.hostComponents;
-    if (!!ambariServiceHostComponents.length) {
+    if (ambariServiceHostComponents.length) {
       var ambariDBInfo = JSON.stringify(ambariServiceHostComponents[0].RootServiceHostComponents.properties);
-      this.set('mySQLServerConflict', ambariDBInfo.indexOf('mysql') > 0 && ambariDBInfo.indexOf(hiveDBHostname) > 0);
+      this.set('mySQLServerConflict', ambariDBInfo.contains('mysql') && ambariDBInfo.indexOf(hiveDBHostname) > 0);
     } else {
       this.set('mySQLServerConflict', false);
     }
@@ -1266,34 +1266,63 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
     var hiveDBType = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_database').value;
     if (hiveDBType == 'New MySQL Database') {
       var self = this;
-      this.checkMySQLHost().done(function () {
-        if (self.get('mySQLServerConflict')) {
-          // error popup before you can proceed
+      return this.checkMySQLHost().done(function () {
+        self.mySQLWarningHandler();
+      });
+    }
+    else {
+      this.moveNext();
+    }
+  },
+
+  /**
+   * Show warning popup about MySQL-DB issues (on post-submit)
+   *
+   * @returns {*}
+   * @method mySQLWarningHandler
+   */
+  mySQLWarningHandler: function () {
+    var self = this;
+    if (this.get('mySQLServerConflict')) {
+      // error popup before you can proceed
+      return App.ModalPopup.show({
+        header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'),
+        body:Em.I18n.t('installer.step7.popup.mySQLWarning.body'),
+        secondary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'),
+        primary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'),
+        encodeBody: false,
+        onPrimary: function () {
+          this._super();
+          self.set('submitButtonClicked', false);
+        },
+        onSecondary: function () {
+          var parent = this;
           return App.ModalPopup.show({
-            header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'),
-            body:Em.I18n.t('installer.step7.popup.mySQLWarning.body'),
-            secondary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'),
-            primary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'),
-            onSecondary: function () {
-              var parent = this;
-              return App.ModalPopup.show({
-                header: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'),
-                body: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'),
-                onPrimary: function () {
-                  this.hide();
-                  parent.hide();
-                  // go back to step 5: assign masters and disable default navigation warning
-                  App.router.get('installerController').gotoStep(5, true);
+            header: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'),
+            body: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'),
+            onPrimary: function () {
+              this.hide();
+              parent.hide();
+              // go back to step 5: assign masters and disable default navigation warning
+              if ('installerController' === self.get('content.controllerName')) {
+                App.router.get('installerController').gotoStep(5, true);
+              }
+              else {
+                if ('addServiceController' === self.get('content.controllerName')) {
+                  App.router.get('addServiceController').gotoStep(2, true);
                 }
-              });
+              }
+            },
+            onSecondary: function () {
+              this._super();
+              self.set('submitButtonClicked', false);
             }
           });
-        } else {
-          self.moveNext();
         }
       });
-    } else {
-      this.moveNext();
+    }
+    else {
+      return this.moveNext();
     }
   },
 
@@ -1416,6 +1445,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
    **/
   moveNext: function () {
     App.router.send('next');
+    this.set('submitButtonClicked', false);
   },
 
   /**
@@ -1462,7 +1492,6 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
     this.showOozieDerbyWarningPopup(function() {
       self.checkDatabaseConnectionTest().done(function () {
         self.resolveHiveMysqlDatabase();
-        self.set('submitButtonClicked', false);
       });
     });
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ccc873e/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 16abeb5..36caa02 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -101,10 +101,10 @@ describe('App.InstallerStep7Controller', function () {
   beforeEach(function () {
     sinon.stub(App.config, 'setPreDefinedServiceConfigs', Em.K);
     installerStep7Controller = App.WizardStep7Controller.create({
-      content: {
+      content: Em.Object.create({
         advancedServiceConfig: [],
         serviceConfigProperties: []
-      }
+      })
     });
     sinon.stub(console, 'error', Em.K);
   });
@@ -2091,4 +2091,96 @@ describe('App.InstallerStep7Controller', function () {
 
   });
 
+  describe('#resolveHiveMysqlDatabase', function () {
+
+    beforeEach(function () {
+      installerStep7Controller.get('content').setProperties({
+        services: Em.A([
+          Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false})
+        ])
+      });
+      installerStep7Controller.setProperties({
+        stepConfigs: Em.A([
+          Em.Object.create({serviceName: 'HIVE', configs: [{name: 'hive_database', value: 'New MySQL Database'}]})
+        ]),
+        mySQLServerConflict: true
+      });
+      sinon.stub(installerStep7Controller, 'moveNext', Em.K);
+      sinon.stub(installerStep7Controller, 'checkMySQLHost', function () {
+        return $.Deferred().resolve();
+      });
+      sinon.spy(App.ModalPopup, 'show');
+    });
+
+    afterEach(function () {
+      installerStep7Controller.moveNext.restore();
+      installerStep7Controller.checkMySQLHost.restore();
+
+      App.ModalPopup.show.restore();
+    });
+
+    it('no HIVE service', function () {
+      installerStep7Controller.set('content.services', Em.A([]));
+      installerStep7Controller.resolveHiveMysqlDatabase();
+      expect(installerStep7Controller.moveNext.calledOnce).to.be.true;
+      expect(App.ModalPopup.show.called).to.be.false;
+    });
+
+    it('if mySQLServerConflict, popup is shown', function () {
+      installerStep7Controller.resolveHiveMysqlDatabase();
+      expect(installerStep7Controller.moveNext.called).to.be.false;
+      expect(App.ModalPopup.show.calledOnce).to.be.true;
+    });
+
+  });
+
+  describe('#mySQLWarningHandler', function () {
+
+    beforeEach(function () {
+      installerStep7Controller.set('mySQLServerConflict', true);
+      sinon.spy(App.ModalPopup, 'show');
+      sinon.stub(App.router, 'get').returns({gotoStep: Em.K});
+      sinon.stub(App.router.get(), 'gotoStep', Em.K);
+    });
+
+    afterEach(function () {
+      App.ModalPopup.show.restore();
+      App.router.get().gotoStep.restore();
+      App.router.get.restore();
+    });
+
+    it('warning popup is shown', function () {
+      installerStep7Controller.mySQLWarningHandler();
+      expect(App.ModalPopup.show.calledOnce).to.be.true;
+    });
+
+    it('submitButtonClicked is set to false on primary click', function () {
+      installerStep7Controller.mySQLWarningHandler().onPrimary();
+      expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
+    });
+
+    it('second popup is shown on secondary click', function () {
+      installerStep7Controller.mySQLWarningHandler().onSecondary();
+      expect(App.ModalPopup.show.calledTwice).to.be.true;
+    });
+
+    it('submitButtonClicked is set to false on secondary click on the second popup', function () {
+      installerStep7Controller.mySQLWarningHandler().onSecondary().onSecondary();
+      expect(installerStep7Controller.get('submitButtonClicked')).to.be.false;
+    });
+
+    it('user is moved to step5 on primary click on the second popup (installerController)', function () {
+      installerStep7Controller.set('content.controllerName', 'installerController');
+      installerStep7Controller.mySQLWarningHandler().onSecondary().onPrimary();
+      expect(App.router.get('installerController').gotoStep.calledWith(5, true)).to.be.true;
+    });
+
+    it('user is moved to step2 on primary click on the second popup (addSeviceController)', function () {
+      installerStep7Controller.set('content.controllerName', 'addServiceController');
+      installerStep7Controller.mySQLWarningHandler().onSecondary().onPrimary();
+      expect(App.router.get('addSeviceController').gotoStep.calledWith(2, true)).to.be.true;
+    });
+
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ccc873e/ambari-web/test/mappers/configs/themes_mapper_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mappers/configs/themes_mapper_test.js b/ambari-web/test/mappers/configs/themes_mapper_test.js
index d3d6e2e..9e15958 100644
--- a/ambari-web/test/mappers/configs/themes_mapper_test.js
+++ b/ambari-web/test/mappers/configs/themes_mapper_test.js
@@ -162,7 +162,8 @@ describe('App.themeMapper', function () {
         is_advanced: false,
         service_name: 'HDFS',
         is_advanced_hidden: false,
-        is_rendered: false
+        is_rendered: false,
+        is_configs_prepared: false
       });
 
       //checking section
@@ -224,7 +225,8 @@ describe('App.themeMapper', function () {
         "is_advanced": true,
         "service_name": "HDFS",
         "is_advanced_hidden": false,
-        is_rendered: false
+        is_rendered: false,
+        is_configs_prepared: false
       });
     });
   });