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-11587. Test DB connection popup issues (alexantonenko)
Date Mon, 01 Jun 2015 17:14:01 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 8db087af8 -> aefc39aaa


AMBARI-11587. Test DB connection popup issues (alexantonenko)


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

Branch: refs/heads/trunk
Commit: aefc39aaa3bda41e19872be61a0ccab2cd26d706
Parents: 748b2a1
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Mon Jun 1 20:02:00 2015 +0300
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Mon Jun 1 20:13:55 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/messages.js                      |   3 +
 .../app/templates/common/error_log_body.hbs     |   2 +-
 ambari-web/app/views/common/controls_view.js    |  23 +++-
 .../test/views/common/controls_view_test.js     | 128 +++++++++++++++++++
 4 files changed, 153 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/aefc39aa/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index fba9fa2..2b97242 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -252,6 +252,7 @@ Em.I18n.translations = {
   'common.dismiss': "Dismiss",
   'common.stdout': "stdout",
   'common.stderr': "stderr",
+  'common.structuredOut': "structured_out",
   'common.fileName': 'File name',
   'common.days': "Days",
   'common.hours': "Hours",
@@ -266,6 +267,7 @@ Em.I18n.translations = {
   'common.scope': 'Scope',
   'common.clone': 'Clone',
   'common.removed': 'Removed',
+  'common.testing': 'Testing',
 
   'models.alert_instance.tiggered.verbose': "Occured on {0} <br> Checked on {1}",
   'models.alert_definition.triggered.verbose': "Occured on {0}",
@@ -1766,6 +1768,7 @@ Em.I18n.translations = {
   'services.service.config.database.connection.success': 'Connection OK',
   'services.service.config.database.connection.inProgress': 'Checking connectivity',
   'services.service.config.database.connection.failed': 'Connection Failed',
+  'services.service.config.connection.logsPopup.header': '{0} Connection: {1}',
   'services.service.config.connection.exitPopup.msg': 'Test connection is in progress. It\'s
recommended to wait until it wil be complete. Are you sure you want to exit Enable Kerberos
Wizard?',
   'services.service.config.database.btn.idle': 'Test Connection',
   'services.service.config.kdc.btn.idle': 'Test KDC Connection',

http://git-wip-us.apache.org/repos/asf/ambari/blob/aefc39aa/ambari-web/app/templates/common/error_log_body.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/error_log_body.hbs b/ambari-web/app/templates/common/error_log_body.hbs
index b532901..6f98fe1 100644
--- a/ambari-web/app/templates/common/error_log_body.hbs
+++ b/ambari-web/app/templates/common/error_log_body.hbs
@@ -25,7 +25,7 @@
       <h5>{{t common.stdout}}: &nbsp; <span class="muted"> {{view.openedTask.outputLog}}
</span></h5>
       <pre class="stdout">{{view.openedTask.stdout}}</pre>
       {{#if view.openedTask.structuredOut}}
-        <h5>structured_out: &nbsp;</h5>
+        <h5>{{t common.structuredOut}}: &nbsp;</h5>
         <pre class="stdout">{{view.openedTask.structuredOut}}</pre>
       {{/if}}
     </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/aefc39aa/ambari-web/app/views/common/controls_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/controls_view.js b/ambari-web/app/views/common/controls_view.js
index 76e032f..4c03330 100644
--- a/ambari-web/app/views/common/controls_view.js
+++ b/ambari-web/app/views/common/controls_view.js
@@ -1195,6 +1195,8 @@ App.CheckDBConnectionView = Ember.View.extend({
   request: null,
   /** @property {Number} pollInterval - timeout interval for ajax polling **/
   pollInterval: 3000,
+  /** @property {Object} logsPopup - popup with DB connection check info **/
+  logsPopup: null,
   /** @property {string} hostNameProperty - host name property based on service and database
names **/
   hostNameProperty: function() {
     if (!/wizard/i.test(this.get('controller.name')) && this.get('parentView.service.serviceName')
=== 'HIVE') {
@@ -1526,6 +1528,10 @@ App.CheckDBConnectionView = Ember.View.extend({
     this.set('responseCaption', isSuccess ? Em.I18n.t('services.service.config.database.connection.success')
: Em.I18n.t('services.service.config.database.connection.failed'));
     this.set('isConnectionSuccess', isSuccess);
     this.set('isRequestResolved', true);
+    if (this.get('logsPopup')) {
+      var statusString = isSuccess ? 'common.success' : 'common.error';
+      this.set('logsPopup.header', Em.I18n.t('services.service.config.connection.logsPopup.header').format(this.get('databaseName'),
Em.I18n.t(statusString)));
+    }
   },
   /**
    * Switch captions and statuses for active/non-active request.
@@ -1564,15 +1570,28 @@ App.CheckDBConnectionView = Ember.View.extend({
   showLogsPopup: function() {
     if (this.get('isConnectionSuccess')) return;
     var _this = this;
-    var popup = App.showAlertPopup('Error: {0} connection'.format(this.get('databaseName')));
+    var statusString = this.get('isRequestResolved') ? 'common.error' : 'common.testing';
+    var popup = App.showAlertPopup(Em.I18n.t('services.service.config.connection.logsPopup.header').format(this.get('databaseName'),
Em.I18n.t(statusString)), null, function () {
+      _this.set('logsPopup', null);
+    });
+    popup.reopen({
+      onClose: function () {
+        this._super();
+        _this.set('logsPopup', null);
+      }
+    });
     if (typeof this.get('responseFromServer') == 'object') {
       popup.set('bodyClass', Em.View.extend({
+        checkDBConnectionView: _this,
         templateName: require('templates/common/error_log_body'),
-        openedTask: _this.get('responseFromServer')
+        openedTask: function () {
+          return this.get('checkDBConnectionView.responseFromServer');
+        }.property('checkDBConnectionView.responseFromServer.stderr', 'checkDBConnectionView.responseFromServer.stdout',
'checkDBConnectionView.responseFromServer.structuredOut')
       }));
     } else {
       popup.set('body', this.get('responseFromServer'));
     }
+    this.set('logsPopup', popup);
     return popup;
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/aefc39aa/ambari-web/test/views/common/controls_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/controls_view_test.js b/ambari-web/test/views/common/controls_view_test.js
index 7a27f46..b886ea7 100644
--- a/ambari-web/test/views/common/controls_view_test.js
+++ b/ambari-web/test/views/common/controls_view_test.js
@@ -952,6 +952,134 @@ describe('App.CheckDBConnectionView', function () {
 
   });
 
+  describe('#setResponseStatus', function () {
+
+    var view,
+      cases = [
+        {
+          isSuccess: 'success',
+          logsPopupBefore: null,
+          logsPopup: null,
+          responseCaption: Em.I18n.t('services.service.config.database.connection.success'),
+          isConnectionSuccess: true,
+          title: 'success, no popup displayed'
+        },
+        {
+          isSuccess: 'success',
+          logsPopupBefore: {},
+          logsPopup: {
+            header: Em.I18n.t('services.service.config.connection.logsPopup.header').format('MySQL',
Em.I18n.t('common.success'))
+          },
+          responseCaption: Em.I18n.t('services.service.config.database.connection.success'),
+          isConnectionSuccess: true,
+          title: 'success, popup is displayed'
+        },
+        {
+          isSuccess: 'error',
+          logsPopupBefore: {},
+          logsPopup: {
+            header: Em.I18n.t('services.service.config.connection.logsPopup.header').format('MySQL',
Em.I18n.t('common.error'))
+          },
+          responseCaption: Em.I18n.t('services.service.config.database.connection.failed'),
+          isConnectionSuccess: false,
+          title: 'error, popup is displayed'
+        }
+      ];
+
+    beforeEach(function () {
+      view = App.CheckDBConnectionView.create({
+        databaseName: 'MySQL'
+      });
+      sinon.stub(view, 'setConnectingStatus', Em.K);
+    });
+
+    afterEach(function () {
+      view.setConnectingStatus.restore();
+    });
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        view.set('logsPopup', item.logsPopupBefore);
+        view.setResponseStatus(item.isSuccess);
+        expect(view.get('isRequestResolved')).to.be.true;
+        expect(view.setConnectingStatus.calledOnce).to.be.true;
+        expect(view.setConnectingStatus.calledWith(false)).to.be.true;
+        expect(view.get('responseCaption')).to.equal(item.responseCaption);
+        expect(view.get('isConnectionSuccess')).to.equal(item.isConnectionSuccess);
+        expect(view.get('logsPopup')).to.eql(item.logsPopup);
+      });
+    });
+
+  });
+
+  describe('#showLogsPopup', function () {
+
+    var view,
+      cases = [
+        {
+          isConnectionSuccess: true,
+          showAlertPopupCallCount: 0,
+          title: 'successful connection'
+        },
+        {
+          isConnectionSuccess: false,
+          isRequestResolved: true,
+          showAlertPopupCallCount: 1,
+          responseFromServer: 'fail',
+          header: Em.I18n.t('services.service.config.connection.logsPopup.header').format('MySQL',
Em.I18n.t('common.error')),
+          popupMethodExecuted: 'onClose',
+          title: 'failed connection without output data, popup dismissed with Close button'
+        },
+        {
+          isConnectionSuccess: false,
+          isRequestResolved: false,
+          showAlertPopupCallCount: 1,
+          responseFromServer: {
+            stderr: 'stderr',
+            stdout: 'stdout',
+            structuredOut: 'structuredOut'
+          },
+          header: Em.I18n.t('services.service.config.connection.logsPopup.header').format('MySQL',
Em.I18n.t('common.testing')),
+          popupMethodExecuted: 'onPrimary',
+          title: 'check in progress with output data, popup dismissed with OK button'
+        }
+      ];
+
+    beforeEach(function () {
+      view = App.CheckDBConnectionView.create({
+        databaseName: 'MySQL'
+      });
+      sinon.spy(App, 'showAlertPopup');
+    });
+
+    afterEach(function () {
+      App.showAlertPopup.restore();
+    });
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        view.setProperties({
+          isConnectionSuccess: item.isConnectionSuccess,
+          isRequestResolved: item.isRequestResolved,
+          responseFromServer: item.responseFromServer
+        });
+        view.showLogsPopup();
+        expect(App.showAlertPopup.callCount).to.equal(item.showAlertPopupCallCount);
+        if (!item.isConnectionSuccess) {
+          expect(view.get('logsPopup.header')).to.equal(item.header);
+          if (typeof item.responseFromServer == 'object') {
+            expect(view.get('logsPopup.bodyClass').create().get('openedTask')).to.eql(item.responseFromServer);
+          } else {
+            expect(view.get('logsPopup.body')).to.equal(item.responseFromServer);
+          }
+          view.get('logsPopup')[item.popupMethodExecuted]();
+          expect(view.get('logsPopup')).to.be.null;
+        }
+      });
+    });
+
+  });
+
 });
 
 describe('App.BaseUrlTextField', function () {


Mime
View raw message