ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject [1/2] ambari git commit: AMBARI-16904. 'Reload Page' popup is still shown when connection is established (alexantonenko)
Date Thu, 26 May 2016 17:18:41 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk d51e75297 -> fe05d3671


AMBARI-16904. 'Reload Page' popup is still shown when connection is established (alexantonenko)


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

Branch: refs/heads/trunk
Commit: fe05d36717a9b6a9e58a5242e80c755e119a4a86
Parents: 30397cd
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Thu May 26 20:03:01 2016 +0300
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Thu May 26 20:18:34 2016 +0300

----------------------------------------------------------------------
 .../app/controllers/wizard/step3_controller.js  |  14 +-
 .../app/controllers/wizard/step9_controller.js  |   7 +-
 ambari-web/app/mixins/common/reload_popup.js    |  23 +--
 ambari-web/app/utils/polling.js                 |   3 +-
 .../test/controllers/wizard/step3_test.js       |  38 ++++
 .../test/mixins/common/reload_popup_test.js     | 174 ++++++++++---------
 ambari-web/test/utils/polling_test.js           |   6 +-
 7 files changed, 160 insertions(+), 105 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fe05d367/ambari-web/app/controllers/wizard/step3_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step3_controller.js b/ambari-web/app/controllers/wizard/step3_controller.js
index 8e8eb11..f4a7d18 100644
--- a/ambari-web/app/controllers/wizard/step3_controller.js
+++ b/ambari-web/app/controllers/wizard/step3_controller.js
@@ -534,6 +534,16 @@ App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin,
{
   }.observes('isBackDisabled'),
 
   /**
+   * Close reload popup on exit from Confirm Hosts step
+   * @method closeReloadPopupOnExit
+   */
+  closeReloadPopupOnExit: function () {
+    if (this.get('stopBootstrap')) {
+      this.closeReloadPopup();
+    }
+  }.observes('stopBootstrap'),
+
+  /**
    * Do bootstrap calls
    * @method doBootstrap
    * @return {$.ajax|null}
@@ -550,8 +560,8 @@ App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin,
{
       data: {
         bootRequestId: this.get('content.installOptions.bootRequestId'),
         numPolls: this.get('numPolls'),
-        errorLogMessage: 'Bootstrap failed',
         callback: this.doBootstrap,
+        timeout: 3000,
         shouldUseDefaultHandler: true
       },
       success: 'doBootstrapSuccessCallback',
@@ -640,8 +650,8 @@ App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin,
{
       success: 'isHostsRegisteredSuccessCallback',
       error: 'reloadErrorCallback',
       data: {
-        errorLogMessage: 'Error: Getting registered host information from the server',
         callback: this.isHostsRegistered,
+        timeout: 3000,
         shouldUseDefaultHandler: true
       }
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/fe05d367/ambari-web/app/controllers/wizard/step9_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step9_controller.js b/ambari-web/app/controllers/wizard/step9_controller.js
index 412589e..916f9dc 100644
--- a/ambari-web/app/controllers/wizard/step9_controller.js
+++ b/ambari-web/app/controllers/wizard/step9_controller.js
@@ -1053,8 +1053,7 @@ App.WizardStep9Controller = Em.Controller.extend(App.ReloadPopupMixin,
{
         numPolls: this.get('numPolls'),
         callback: this.getLogsByRequest,
         args: [polling, requestId],
-        timeout: 3000,
-        errorLogMessage: 'Install services all retries failed'
+        timeout: 3000
       },
       success: 'reloadSuccessCallback',
       error: 'reloadErrorCallback'
@@ -1085,9 +1084,11 @@ App.WizardStep9Controller = Em.Controller.extend(App.ReloadPopupMixin,
{
    * @method reloadErrorCallback
    */
   reloadErrorCallback: function (jqXHR, ajaxOptions, error, opt, params) {
-    this._super(jqXHR, ajaxOptions, error, opt, params);
     if (jqXHR.status) {
+      this.closeReloadPopup();
       this.loadLogData(true);
+    } else {
+      this._super(jqXHR, ajaxOptions, error, opt, params);
     }
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/fe05d367/ambari-web/app/mixins/common/reload_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/reload_popup.js b/ambari-web/app/mixins/common/reload_popup.js
index c4b37d7..bc37f9f 100644
--- a/ambari-web/app/mixins/common/reload_popup.js
+++ b/ambari-web/app/mixins/common/reload_popup.js
@@ -20,8 +20,6 @@ var App = require('app');
 
 App.ReloadPopupMixin = Em.Mixin.create({
 
-  retryCount: 0,
-
   reloadPopup: null,
 
   reloadSuccessCallback: function () {
@@ -35,17 +33,13 @@ App.ReloadPopupMixin = Em.Mixin.create({
         App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.type, jqXHR.status);
       }
     } else {
-      var times = Em.isNone(params.times) ? App.get('maxRetries') : params.times,
-        timeout = Em.isNone(params.timeout) ? App.get('timeout') : params.timeout;
+      var timeout = Em.isNone(params.timeout) ? App.get('timeout') : params.timeout;
       this.showReloadPopup(params.reloadPopupText);
-      if (this.get('retryCount') < times) {
-        if (params.callback) {
-          var self = this;
-          window.setTimeout(function () {
-            params.callback.apply(self, params.args || []);
-          }, timeout);
-        }
-        this.incrementProperty('retryCount');
+      if (params.callback) {
+        var self = this;
+        window.setTimeout(function () {
+          params.callback.apply(self, params.args || []);
+        }, timeout);
       }
     }
   },
@@ -70,10 +64,7 @@ App.ReloadPopupMixin = Em.Mixin.create({
             + this.t('app.reloadPopup.link') + "</a></div>")
         }),
         onClose: function () {
-          self.setProperties({
-            reloadPopup: null,
-            retryCount: 0
-          });
+          self.set('reloadPopup', null);
           this._super();
         }
       }));

http://git-wip-us.apache.org/repos/asf/ambari/blob/fe05d367/ambari-web/app/utils/polling.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/polling.js b/ambari-web/app/utils/polling.js
index 7337fbb..6bb00e8 100644
--- a/ambari-web/app/utils/polling.js
+++ b/ambari-web/app/utils/polling.js
@@ -147,8 +147,7 @@ App.Poll = Em.Object.extend(App.ReloadPopupMixin, {
       sender: this,
       data: {
         requestId: this.get('requestId'),
-        callback: this.startPolling,
-        errorLogMessage: 'Install services all retries failed'
+        callback: this.startPolling
       },
       success: 'reloadSuccessCallback',
       error: 'reloadErrorCallback'

http://git-wip-us.apache.org/repos/asf/ambari/blob/fe05d367/ambari-web/test/controllers/wizard/step3_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step3_test.js b/ambari-web/test/controllers/wizard/step3_test.js
index 6cb7ee7..a214656 100644
--- a/ambari-web/test/controllers/wizard/step3_test.js
+++ b/ambari-web/test/controllers/wizard/step3_test.js
@@ -3149,4 +3149,42 @@ describe('App.WizardStep3Controller', function () {
 
   });
 
+  describe('#closeReloadPopupOnExit', function () {
+
+    var cases = [
+      {
+        stopBootstrap: true,
+        closeReloadPopupCallCount: 1,
+        title: 'bootstrap should be stopped'
+      },
+      {
+        stopBootstrap: false,
+        closeReloadPopupCallCount: 0,
+        title: 'bootstrap should not be stopped'
+      }
+    ];
+
+    beforeEach(function () {
+      sinon.stub(c, 'closeReloadPopup', Em.K);
+    });
+
+    afterEach(function () {
+      c.closeReloadPopup.restore();
+    });
+
+    cases.forEach(function (item) {
+
+      it(item.title, function () {
+        if (c.get('stopBootstrap') === item.stopBootstrap) {
+          c.propertyDidChange('stopBootstrap');
+        } else {
+          c.set('stopBootstrap', item.stopBootstrap);
+        }
+        expect(c.closeReloadPopup.callCount).to.equal(item.closeReloadPopupCallCount);
+      });
+
+    });
+
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/fe05d367/ambari-web/test/mixins/common/reload_popup_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/reload_popup_test.js b/ambari-web/test/mixins/common/reload_popup_test.js
index 6df35a2..619255a 100644
--- a/ambari-web/test/mixins/common/reload_popup_test.js
+++ b/ambari-web/test/mixins/common/reload_popup_test.js
@@ -52,11 +52,9 @@ describe('App.ReloadPopupMixin', function () {
   describe('#closeReloadPopup', function () {
 
     it('should hide modal popup', function () {
-      obj.set('retryCount', 1);
       obj.showReloadPopup();
       obj.closeReloadPopup();
       expect(obj.get('reloadPopup')).to.be.null;
-      expect(obj.get('retryCount')).to.equal(0);
     });
 
   });
@@ -64,110 +62,130 @@ describe('App.ReloadPopupMixin', function () {
   describe('#reloadSuccessCallback', function () {
 
     it('should hide modal popup', function () {
-      obj.set('retryCount', 1);
       obj.showReloadPopup();
       obj.reloadSuccessCallback();
       expect(obj.get('reloadPopup')).to.be.null;
-      expect(obj.get('retryCount')).to.equal(0);
     });
 
   });
 
   describe('#reloadErrorCallback', function () {
 
-    var cases = [
-      {
-        args: [{status: 404}, null, null, {}, {shouldUseDefaultHandler: true}],
-        closeReloadPopupCallCount: 1,
-        consoleLogCallCount: 0,
-        defaultErrorHandlerCallCount: 1,
-        showReloadPopupCallCount: 0,
-        setTimeoutCount: 0,
-        title: 'status received, no console message, default error handler'
-      },
-      {
-        args: [{status: 404}, null, null, {}, {errorLogMessage: 'error'}],
-        closeReloadPopupCallCount: 1,
-        consoleLogCallCount: 1,
-        defaultErrorHandlerCallCount: 0,
-        showReloadPopupCallCount: 0,
-        setTimeoutCount: 0,
-        title: 'status received, console message displayed, no default error handler'
-      },
-      {
-        args: [{status: 0}, null, null, {}, {times: 5}],
-        retryCount: 5,
-        retryCountResult: 5,
-        closeReloadPopupCallCount: 0,
-        consoleLogCallCount: 0,
-        defaultErrorHandlerCallCount: 0,
-        showReloadPopupCallCount: 1,
-        setTimeoutCount: 0,
-        title: 'no status received, custom retries count, max retries reached'
-      },
-      {
-        args: [{status: 0}, null, null, {}, {}],
-        retryCount: 2,
-        retryCountResult: 3,
-        closeReloadPopupCallCount: 0,
-        consoleLogCallCount: 0,
-        defaultErrorHandlerCallCount: 0,
-        showReloadPopupCallCount: 1,
-        setTimeoutCount: 0,
-        title: 'no status received, default retries count, max retries not reached, no callback'
-      },
-      {
-        args: [{status: 0}, null, null, {}, {callback: Em.K}],
-        retryCount: 2,
-        retryCountResult: 3,
-        closeReloadPopupCallCount: 0,
-        consoleLogCallCount: 0,
-        defaultErrorHandlerCallCount: 0,
-        showReloadPopupCallCount: 1,
-        setTimeoutCount: 1,
-        title: 'no status received, default retries count, max retries not reached, callback
specified'
-      }
-    ];
-
-    beforeEach(function () {
-      sinon.stub(obj, 'closeReloadPopup', Em.K);
-      sinon.stub(App.ajax, 'defaultErrorHandler', Em.K);
-      sinon.stub(obj, 'showReloadPopup', Em.K);
-      sinon.stub(App, 'get').withArgs('maxRetries').returns(3);
-    });
-
-    afterEach(function () {
-      obj.closeReloadPopup.restore();
-      App.ajax.defaultErrorHandler.restore();
-      obj.showReloadPopup.restore();
-      App.get.restore();
-    });
+    var clock,
+      cases = [
+        {
+          args: [{status: 404}, null, null, {}, {shouldUseDefaultHandler: true}],
+          closeReloadPopupCallCount: 1,
+          defaultErrorHandlerCallCount: 1,
+          showReloadPopupCallCount: 0,
+          isCallbackCalled: false,
+          title: 'status received, default error handler'
+        },
+        {
+          args: [{status: 404}, null, null, {}, {}],
+          closeReloadPopupCallCount: 1,
+          defaultErrorHandlerCallCount: 0,
+          showReloadPopupCallCount: 0,
+          isCallbackCalled: false,
+          title: 'status received, no default error handler'
+        },
+        {
+          args: [{status: 0}, null, null, {}, {}],
+          closeReloadPopupCallCount: 0,
+          defaultErrorHandlerCallCount: 0,
+          showReloadPopupCallCount: 1,
+          isCallbackCalled: false,
+          title: 'no status received, no callback'
+        },
+        {
+          args: [{status: 0}, null, null, {}, {callback: Em.K, timeout: 2000}],
+          timeout: 1999,
+          closeReloadPopupCallCount: 0,
+          defaultErrorHandlerCallCount: 0,
+          showReloadPopupCallCount: 1,
+          isCallbackCalled: false,
+          title: 'no status received, callback specified, custom timeout, not enough time
passed'
+        },
+        {
+          args: [{status: 0}, null, null, {}, {callback: Em.K}],
+          timeout: 999,
+          closeReloadPopupCallCount: 0,
+          defaultErrorHandlerCallCount: 0,
+          showReloadPopupCallCount: 1,
+          isCallbackCalled: false,
+          title: 'no status received, callback specified, default timeout, not enough time
passed'
+        },
+        {
+          args: [{status: 0}, null, null, {}, {callback: Em.K, args: [{}], timeout: 2000}],
+          timeout: 2000,
+          closeReloadPopupCallCount: 0,
+          defaultErrorHandlerCallCount: 0,
+          showReloadPopupCallCount: 1,
+          isCallbackCalled: true,
+          callbackArgs: [{}],
+          title: 'no status received, callback with arguments specified, custom timeout,
enough time passed'
+        },
+        {
+          args: [{status: 0}, null, null, {}, {callback: Em.K}],
+          timeout: 1000,
+          closeReloadPopupCallCount: 0,
+          defaultErrorHandlerCallCount: 0,
+          showReloadPopupCallCount: 1,
+          isCallbackCalled: true,
+          callbackArgs: [],
+          title: 'no status received, callback with no arguments specified, default timeout,
enough time passed'
+        }
+      ];
 
     cases.forEach(function (item) {
       describe(item.title, function () {
 
         beforeEach(function () {
-          if (!Em.isNone(item.retryCount)) {
-            obj.set('retryCount', item.retryCount);
+          sinon.stub(obj, 'closeReloadPopup', Em.K);
+          sinon.stub(App.ajax, 'defaultErrorHandler', Em.K);
+          sinon.stub(obj, 'showReloadPopup', Em.K);
+          sinon.stub(App, 'get').withArgs('timeout').returns(1000);
+          if (item.args[4].callback) {
+            sinon.spy(item.args[4], 'callback');
           }
+          clock = sinon.useFakeTimers();
           obj.reloadErrorCallback.apply(obj, item.args);
+          clock.tick(item.timeout);
         });
 
         afterEach(function () {
-          if (!Em.isNone(item.retryCountResult)) {
-            obj.set('retryCount', item.retryCountResult);
+          obj.closeReloadPopup.restore();
+          App.ajax.defaultErrorHandler.restore();
+          obj.showReloadPopup.restore();
+          App.get.restore();
+          if (item.args[4].callback) {
+            item.args[4].callback.restore();
           }
+          clock.restore();
         });
 
-        it('closeReloadPopup is called needed number of times', function () {
+        it('closeReloadPopup call', function () {
           expect(obj.closeReloadPopup.callCount).to.equal(item.closeReloadPopupCallCount);
         });
-        it('defaultErrorHandler is called needed number of times', function () {
+        it('defaultErrorHandler call', function () {
           expect(App.ajax.defaultErrorHandler.callCount).to.equal(item.defaultErrorHandlerCallCount);
         });
-        it('showReloadPopup is called needed number of times', function () {
+        it('showReloadPopup call', function () {
           expect(obj.showReloadPopup.callCount).to.equal(item.showReloadPopupCallCount);
         });
+
+        if (item.isCallbackCalled) {
+          it('callback call', function () {
+            expect(item.args[4].callback.calledOnce).to.be.true;
+          });
+          it('callback context', function () {
+            expect(item.args[4].callback.calledOn(obj)).to.be.true;
+          });
+          it('callback arguments', function () {
+            expect(item.args[4].callback.firstCall.args).to.eql(item.callbackArgs);
+          });
+        }
+
       });
     });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/fe05d367/ambari-web/test/utils/polling_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/polling_test.js b/ambari-web/test/utils/polling_test.js
index 2682890..2e5f105 100644
--- a/ambari-web/test/utils/polling_test.js
+++ b/ambari-web/test/utils/polling_test.js
@@ -515,8 +515,7 @@ describe('App.Poll', function () {
         ajaxCallArguments: [{
           name: 'background_operations.get_by_request',
           data: {
-            requestId: 0,
-            errorLogMessage: 'Install services all retries failed'
+            requestId: 0
           },
           success: 'reloadSuccessCallback',
           error: 'reloadErrorCallback'
@@ -530,8 +529,7 @@ describe('App.Poll', function () {
         ajaxCallArguments: [{
           name: 'background_operations.get_by_request',
           data: {
-            requestId: 1,
-            errorLogMessage: 'Install services all retries failed'
+            requestId: 1
           },
           success: 'reloadSuccessCallback',
           error: 'reloadErrorCallback'


Mime
View raw message