You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/09/19 21:14:02 UTC

ambari git commit: AMBARI-13160. Host Checks on Add Hosts wizard are stuck if 2 sessions are active (alexantonenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk d2ae799f7 -> 338360b6e


AMBARI-13160. Host Checks on Add Hosts wizard are stuck if 2 sessions are active (alexantonenko)


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

Branch: refs/heads/trunk
Commit: 338360b6ed359bd1c3f52df06d279f07017851c4
Parents: d2ae799
Author: Alex Antonenko <hi...@gmail.com>
Authored: Sat Sep 19 14:54:37 2015 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Sat Sep 19 22:13:58 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/wizard.js            |  24 ++--
 .../app/controllers/wizard/step3_controller.js  |  16 ++-
 .../templates/wizard/bootstrap_call_popup.hbs   |   6 +-
 ambari-web/app/templates/wizard/step3.hbs       |   6 +-
 .../test/controllers/wizard/step3_test.js       |  89 +++++++++++++-
 ambari-web/test/controllers/wizard_test.js      | 120 +++++++++++++++++--
 6 files changed, 235 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/338360b6/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 4d4eff7..b4bb4ab 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -481,13 +481,23 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
        * otherwise notify error and enable buttons to close popup
        * @param requestId
        * @param serverError
+       * @param status
+       * @param log
        */
-      finishLoading: function (requestId, serverError) {
-        if (Em.isNone(requestId)) {
-          this.set('isError', true);
-          this.set('showFooter', true);
-          this.set('showCloseButton', true);
-          this.set('serverError', serverError);
+      finishLoading: function (requestId, serverError, status, log) {
+        if (Em.isNone(requestId) || status == 'ERROR') {
+          var stepController = App.get('router.wizardStep3Controller');
+          this.setProperties({
+            isError: true,
+            showFooter: true,
+            showCloseButton: true,
+            serverError: status == 'ERROR' ? log : serverError
+          });
+          stepController.setProperties({
+            isRegistrationInProgress: false,
+            isBootstrapFailed: true
+          });
+          stepController.get('hosts').setEach('bootStatus', 'FAILED');
         } else {
           callback(requestId);
           this.hide();
@@ -518,7 +528,7 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
 
   launchBootstrapSuccessCallback: function (data, opt, params) {
     console.log("TRACE: POST bootstrap succeeded");
-    params.popup.finishLoading(data.requestId, null);
+    params.popup.finishLoading(data.requestId, null, data.status, data.log);
   },
 
   launchBootstrapErrorCallback: function (request, ajaxOptions, error, opt, params) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/338360b6/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 8905993..054a364 100644
--- a/ambari-web/app/controllers/wizard/step3_controller.js
+++ b/ambari-web/app/controllers/wizard/step3_controller.js
@@ -95,6 +95,12 @@ App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin, {
   isSubmitDisabled: true,
 
   /**
+   * True if bootstrap POST request failed
+   * @type {bool}
+   */
+  isBootstrapFailed: false,
+
+  /**
    * is Retry button disabled
    * @type {bool}
    */
@@ -107,8 +113,8 @@ App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin, {
    * @return {bool}
    */
   isBackDisabled: function () {
-    return this.get('isRegistrationInProgress') || !this.get('isWarningsLoaded');
-  }.property('isRegistrationInProgress', 'isWarningsLoaded'),
+    return (this.get('isRegistrationInProgress') || !this.get('isWarningsLoaded')) && !this.get('isBootstrapFailed');
+  }.property('isRegistrationInProgress', 'isWarningsLoaded', 'isBootstrapFailed'),
 
   /**
    * Controller is using in Add Host Wizard
@@ -588,7 +594,9 @@ App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin, {
       // Multiple hosts : if one or more hostnames are invalid
       // following check will mark the bootStatus as 'FAILED' for the invalid hostname
       var installedHosts = App.Host.find().mapProperty('hostName');
-      if (data.status == 'ERROR' || data.hostsStatus.mapProperty('hostName').removeObjects(installedHosts).length != this.get('bootHosts').length) {
+      var isErrorStatus = data.status == 'ERROR';
+      this.set('isBootstrapFailed', isErrorStatus);
+      if (isErrorStatus || data.hostsStatus.mapProperty('hostName').removeObjects(installedHosts).length != this.get('bootHosts').length) {
 
         var hosts = this.get('bootHosts');
 
@@ -604,7 +612,7 @@ App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin, {
         }
       }
 
-      if (data.status == 'ERROR' || data.hostsStatus.someProperty('status', 'DONE') || data.hostsStatus.someProperty('status', 'FAILED')) {
+      if (isErrorStatus || data.hostsStatus.someProperty('status', 'DONE') || data.hostsStatus.someProperty('status', 'FAILED')) {
         // kicking off registration polls after at least one host has succeeded
         this.startRegistration();
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/338360b6/ambari-web/app/templates/wizard/bootstrap_call_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/wizard/bootstrap_call_popup.hbs b/ambari-web/app/templates/wizard/bootstrap_call_popup.hbs
index eb282a1..bac83ec 100644
--- a/ambari-web/app/templates/wizard/bootstrap_call_popup.hbs
+++ b/ambari-web/app/templates/wizard/bootstrap_call_popup.hbs
@@ -22,9 +22,9 @@
         <div class="alert alert-error">
           {{t installer.step2.bootStrap.error}}
         </div>
-      <pre>
-        {{view.parentView.serverError}}
-      </pre>
+        {{#if view.parentView.serverError}}
+          <pre>{{view.parentView.serverError}}</pre>
+        {{/if}}
     </div>
 {{else}}
     <div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/338360b6/ambari-web/app/templates/wizard/step3.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/wizard/step3.hbs b/ambari-web/app/templates/wizard/step3.hbs
index f345b87..9388f56 100644
--- a/ambari-web/app/templates/wizard/step3.hbs
+++ b/ambari-web/app/templates/wizard/step3.hbs
@@ -141,8 +141,10 @@
   <div {{bindAttr class=":alert view.status isWarningsBoxVisible::hidden"}}>
     {{view.message}}
     <a href="#" {{action hostWarningsPopup warnings target="controller"}}>{{view.linkText}}</a>
-    {{#unless isWarningsLoaded}}
-      <div class="spinner"></div>
+    {{#unless isBootstrapFailed}}
+      {{#unless isWarningsLoaded}}
+        <div class="spinner"></div>
+      {{/unless}}
     {{/unless}}
   </div>
   <div class="btn-area">

http://git-wip-us.apache.org/repos/asf/ambari/blob/338360b6/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 6cab32a..aad0509 100644
--- a/ambari-web/test/controllers/wizard/step3_test.js
+++ b/ambari-web/test/controllers/wizard/step3_test.js
@@ -2191,7 +2191,7 @@ describe('App.WizardStep3Controller', function () {
       expect(host.get('cpu')).to.equal(2);
       expect(host.get('os_type')).to.equal('t1');
       expect(host.get('os_arch')).to.equal('os1');
-      expect(host.get('os_family')).to.equal('osf1')
+      expect(host.get('os_family')).to.equal('osf1');
       expect(host.get('ip')).to.equal('0.0.0.0');
       expect(host.get('memory')).to.equal('12345.00');
       expect(host.get('disk_info.length')).to.equal(2);
@@ -2589,4 +2589,91 @@ describe('App.WizardStep3Controller', function () {
       });
     })
   });
+
+  describe('#isBackDisabled', function () {
+
+    var cases = [
+      {
+        inputData: {
+          isRegistrationInProgress: true,
+          isWarningsLoaded: true,
+          isBootstrapFailed: true
+        },
+        isBackDisabled: false
+      },
+      {
+        inputData: {
+          isRegistrationInProgress: true,
+          isWarningsLoaded: false,
+          isBootstrapFailed: false
+        },
+        isBackDisabled: true
+      },
+      {
+        inputData: {
+          isRegistrationInProgress: true,
+          isWarningsLoaded: true,
+          isBootstrapFailed: false
+        },
+        isBackDisabled: true
+      },
+      {
+        inputData: {
+          isRegistrationInProgress: true,
+          isWarningsLoaded: false,
+          isBootstrapFailed: true
+        },
+        isBackDisabled: false
+      },
+      {
+        inputData: {
+          isRegistrationInProgress: false,
+          isWarningsLoaded: true,
+          isBootstrapFailed: true
+        },
+        isBackDisabled: false
+      },
+      {
+        inputData: {
+          isRegistrationInProgress: false,
+          isWarningsLoaded: false,
+          isBootstrapFailed: false
+        },
+        isBackDisabled: true
+      },
+      {
+        inputData: {
+          isRegistrationInProgress: false,
+          isWarningsLoaded: true,
+          isBootstrapFailed: false
+        },
+        isBackDisabled: false
+      },
+      {
+        inputData: {
+          isRegistrationInProgress: false,
+          isWarningsLoaded: false,
+          isBootstrapFailed: true
+        },
+        isBackDisabled: false
+      }
+    ];
+
+    cases.forEach(function (item) {
+      var title = Em.keys(item.inputData).map(function (key) {
+        return key + ':' + item.inputData[key];
+      }).join(', ');
+      it(title, function () {
+        c.setProperties({
+          isRegistrationInProgress: item.inputData.isRegistrationInProgress,
+          isBootstrapFailed: item.inputData.isBootstrapFailed
+        });
+        c.reopen({
+          isWarningsLoaded: item.inputData.isWarningsLoaded
+        });
+        expect(c.get('isBackDisabled')).to.equal(item.isBackDisabled);
+      });
+    });
+
+  });
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/338360b6/ambari-web/test/controllers/wizard_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard_test.js b/ambari-web/test/controllers/wizard_test.js
index f88101a..420e8eb 100644
--- a/ambari-web/test/controllers/wizard_test.js
+++ b/ambari-web/test/controllers/wizard_test.js
@@ -94,11 +94,11 @@ describe('App.WizardController', function () {
 
   describe('#launchBootstrapSuccessCallback', function() {
     it('Save bootstrapRequestId', function() {
-      var data = {requestId: 123};
+      var data = {requestId: 123, status: 'SUCCESS', log: 'ok'};
       var params = {popup: {finishLoading: function(){}}};
       sinon.spy(params.popup, "finishLoading");
       wizardController.launchBootstrapSuccessCallback(data, {}, params);
-      expect(params.popup.finishLoading.calledWith(123)).to.be.true;
+      expect(params.popup.finishLoading.calledWith(123, null, 'SUCCESS', 'ok')).to.be.true;
       params.popup.finishLoading.restore();
     });
   });
@@ -247,17 +247,119 @@ describe('App.WizardController', function () {
   });
 
   describe('#showLaunchBootstrapPopup', function () {
-    beforeEach(function(){
-      sinon.stub(App.ModalPopup,'show', function(data){
-        data.finishLoading.call(wizardController);
-      });
-    });
     afterEach(function(){
       App.ModalPopup.show.restore();
     });
     it('should set error', function () {
-      wizardController.showLaunchBootstrapPopup(Em.K);
-      expect(wizardController.get('isError')).to.be.true;
+      sinon.stub(App.ModalPopup,'show', function (data) {
+        data.finishLoading.call(c);
+      });
+      c.showLaunchBootstrapPopup(Em.K);
+      expect(c.get('isError')).to.be.true;
+    });
+    describe('#finishLoading', function () {
+      var callback = sinon.spy(),
+        stepController = App.get('router.wizardStep3Controller'),
+        cases = [
+          {
+            requestId: null,
+            serverError: 'error',
+            wizardControllerProperties: {
+              isError: true,
+              showFooter: true,
+              showCloseButton: true,
+              serverError: 'error'
+            },
+            stepControllerProperties: {
+              isRegistrationInProgress: false,
+              isBootstrapFailed: true
+            },
+            bootStatus: 'FAILED',
+            callbackCallCount: 0,
+            hideCallCount: 0,
+            title: 'no request id'
+          },
+          {
+            requestId: 0,
+            status: 'ERROR',
+            log: 'log',
+            wizardControllerProperties: {
+              isError: true,
+              showFooter: true,
+              showCloseButton: true,
+              serverError: 'log'
+            },
+            stepControllerProperties: {
+              isRegistrationInProgress: false,
+              isBootstrapFailed: true
+            },
+            bootStatus: 'FAILED',
+            callbackCallCount: 0,
+            hideCallCount: 0,
+            title: 'ERROR status'
+          },
+          {
+            requestId: 1,
+            log: 'log',
+            wizardControllerProperties: {
+              isError: false,
+              showFooter: false,
+              showCloseButton: false,
+              serverError: null
+            },
+            stepControllerProperties: {
+              isRegistrationInProgress: true,
+              isBootstrapFailed: false
+            },
+            bootStatus: 'PENDING',
+            callbackCallCount: 1,
+            hideCallCount: 1,
+            title: 'request accepted'
+          }
+        ];
+      beforeEach(function () {
+        c.setProperties({
+          isError: false,
+          showFooter: false,
+          showCloseButton: false,
+          serverError: null,
+          hide: Em.K,
+          callback: Em.K
+        });
+        stepController.setProperties({
+          isRegistrationInProgress: true,
+          isBootstrapFailed: false,
+          hosts: [
+            {
+              bootStatus: 'PENDING'
+            },
+            {
+              bootStatus: 'PENDING'
+            }
+          ]
+        });
+        sinon.spy(c, 'hide');
+        sinon.spy(c, 'callback');
+      });
+      afterEach(function () {
+        c.hide.restore();
+        c.callback.restore();
+      });
+      cases.forEach(function (item) {
+        it(item.title, function () {
+          var wizardControllerProperties = Em.keys(item.wizardControllerProperties),
+            stepControllerProperties = Em.keys(item.stepControllerProperties);
+          sinon.stub(App.ModalPopup,'show', function (data) {
+            data.finishLoading.call(c, item.requestId, item.serverError, item.status, item.log);
+          });
+          c.showLaunchBootstrapPopup(c.callback);
+          expect(c.getProperties.apply(c, wizardControllerProperties)).to.eql(item.wizardControllerProperties);
+          expect(stepController.getProperties.apply(stepController, stepControllerProperties)).to.eql(item.stepControllerProperties);
+          expect(stepController.get('hosts').mapProperty('bootStatus').uniq()).to.eql([item.bootStatus]);
+          expect(c.callback.callCount).to.equal(item.callbackCallCount);
+          expect(c.hide.callCount).to.equal(item.hideCallCount);
+        });
+      });
     });
   });