ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject ambari git commit: AMBARI-14175. Upgrade Options popup: no handling for the case of incomplete pre-upgrade check
Date Thu, 03 Dec 2015 11:39:14 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 6ce004126 -> a39f11355


AMBARI-14175. Upgrade Options popup: no handling for the case of incomplete pre-upgrade check


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

Branch: refs/heads/branch-2.1
Commit: a39f113553b59824ae611520a4ee05b74e3d2f4b
Parents: 6ce0041
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Thu Dec 3 13:38:54 2015 +0200
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Thu Dec 3 13:39:07 2015 +0200

----------------------------------------------------------------------
 .../app/controllers/global/update_controller.js |   2 +-
 .../main/admin/stack_and_upgrade_controller.js  | 178 ++++++++-----
 ambari-web/app/messages.js                      |   3 +
 ambari-web/app/styles/application.less          |  14 +-
 ambari-web/app/styles/common.less               |   5 +
 ambari-web/app/styles/stack_versions.less       |  26 +-
 .../admin/stack_upgrade/upgrade_options.hbs     |  10 +-
 .../main/admin/stack_upgrade/versions_view.js   |   5 +
 .../global/update_controller_test.js            |  12 +-
 .../admin/stack_and_upgrade_controller_test.js  | 266 ++++++++++++++++++-
 .../admin/stack_upgrade/version_view_test.js    |  10 +-
 11 files changed, 435 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a39f1135/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index af98bec..c75e7c9 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -585,7 +585,7 @@ App.UpdateController = Em.Controller.extend({
   
   updateUpgradeState: function (callback) {
     var currentStateName = App.get('router.currentState.name'),
-      parentStateName = App.get('router.parentState.name'),
+      parentStateName = App.get('router.currentState.parentState.name'),
       mainAdminStackAndUpgradeController = App.get('router.mainAdminStackAndUpgradeController');
     if (!(currentStateName === 'versions' && parentStateName === 'stackAndUpgrade')
&& currentStateName !== 'stackUpgrade' && App.get('upgradeIsNotFinished')
&& !mainAdminStackAndUpgradeController.get('isLoadUpgradeDataPending')) {
       mainAdminStackAndUpgradeController.loadUpgradeData(true).done(callback);

http://git-wip-us.apache.org/repos/asf/ambari/blob/a39f1135/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
index c26243a..7265532 100644
--- a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
@@ -111,7 +111,12 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
       icon: "icon-dashboard",
       description: Em.I18n.t('admin.stackVersions.version.upgrade.upgradeOptions.RU.description'),
       selected: false,
-      allowed: true
+      allowed: true,
+      isCheckComplete: false,
+      isCheckRequestInProgress: false,
+      precheckResultsMessage: '',
+      precheckResultsTitle: '',
+      action: ''
     }),
     Em.Object.create({
       displayName: Em.I18n.t('admin.stackVersions.version.upgrade.upgradeOptions.EU.title'),
@@ -119,10 +124,17 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
       icon: "icon-bolt",
       description: Em.I18n.t('admin.stackVersions.version.upgrade.upgradeOptions.EU.description'),
       selected: false,
-      allowed: true
+      allowed: true,
+      isCheckComplete: false,
+      isCheckRequestInProgress: false,
+      precheckResultsMessage: '',
+      precheckResultsTitle: '',
+      action: ''
     })
   ],
 
+  runningCheckRequests: [],
+
   /**
    * @type {boolean} true if some request that should disable actions is in progress
    */
@@ -658,6 +670,29 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
     }, this);
   },
 
+  getConfigsWarnings: function (configsMergeWarning) {
+    var configs = [];
+    if (configsMergeWarning && Em.get(configsMergeWarning, 'UpgradeChecks.status')
=== 'WARNING') {
+      var configsMergeCheckData = Em.get(configsMergeWarning, 'UpgradeChecks.failed_detail');
+      if (configsMergeCheckData && Em.isArray(configsMergeCheckData)) {
+        configs = configsMergeCheckData.map(function (item) {
+          var isDeprecated = Em.isNone(item.new_stack_value),
+            willBeRemoved = Em.isNone(item.result_value);
+          return {
+            type: item.type,
+            name: item.property,
+            currentValue: item.current,
+            recommendedValue: isDeprecated ? Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.deprecated')
: item.new_stack_value,
+            isDeprecated: isDeprecated,
+            resultingValue: willBeRemoved ? Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.willBeRemoved')
: item.result_value,
+            willBeRemoved: willBeRemoved
+          };
+        });
+      }
+    }
+    return configs;
+  },
+
   /**
    * Open upgrade options window: upgrade type and failures tolerance
    * @param {boolean} isInUpgradeWizard
@@ -665,15 +700,25 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
    * @return App.ModalPopup
    */
   upgradeOptions: function (isInUpgradeWizard, version) {
-    var self = this;
+    var self = this,
+      upgradeMethods = this.get('upgradeMethods'),
+      runningCheckRequests = this.get('runningCheckRequests');
     if (!isInUpgradeWizard) {
-      this.getSupportedUpgradeTypes(Ember.Object.create({
+      upgradeMethods.setEach('isCheckRequestInProgress', true);
+      upgradeMethods.setEach('selected', false);
+      var request = this.getSupportedUpgradeTypes(Ember.Object.create({
         stackName: App.get('currentStackVersion').split('-')[0],
         stackVersion: App.get('currentStackVersion').split('-')[1],
         toVersion: version.get('repositoryVersion')
-      })).done(function(){
-          self.runUpgradeMethodChecks(version);
-      });
+      })).done(function () {
+          if (App.get('router.currentState.name') === 'versions' && App.get('router.currentState.parentState.name')
=== 'stackAndUpgrade') {
+            self.runUpgradeMethodChecks(version);
+          }
+      }).always(function () {
+          self.set('runningCheckRequests', runningCheckRequests.rejectProperty('type', 'ALL'));
+        });
+      request.type = 'ALL';
+      this.get('runningCheckRequests').push(request);
     }
 
     return App.ModalPopup.show({
@@ -716,6 +761,20 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
           selectedMethod.set('selected', true);
           this.set('parentView.selectedMethod', selectedMethod);
         },
+        runAction: function (event) {
+          var method = event.context,
+            action = method.get('action');
+          if (action) {
+            this.get(action)(event);
+          }
+        },
+        rerunCheck: function (event) {
+          self.runPreUpgradeCheckOnly({
+            value: version.get('repositoryVersion'),
+            label: version.get('displayName'),
+            type: event.context.get('type')
+          });
+        },
         openMessage: function (event) {
           if (isInUpgradeWizard || !event.context.get('allowed')) return;
           var data = event.context.get('precheckResultsData');
@@ -728,25 +787,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
             popupData = {
               items: data.items.rejectProperty('UpgradeChecks.id', 'CONFIG_MERGE')
             },
-            configs = [];
-          if (configsMergeWarning && Em.get(configsMergeWarning, 'UpgradeChecks.status')
=== 'WARNING') {
-            var configsMergeCheckData = Em.get(configsMergeWarning, 'UpgradeChecks.failed_detail');
-            if (configsMergeCheckData) {
-              configs = configsMergeCheckData.map(function (item) {
-                var isDeprecated = Em.isNone(item.new_stack_value),
-                  willBeRemoved = Em.isNone(item.result_value);
-                return {
-                  type: item.type,
-                  name: item.property,
-                  currentValue: item.current,
-                  recommendedValue: isDeprecated ? Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.deprecated')
: item.new_stack_value,
-                  isDeprecated: isDeprecated,
-                  resultingValue: willBeRemoved ? Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.willBeRemoved')
: item.result_value,
-                  willBeRemoved: willBeRemoved
-                };
-              });
-            }
-          }
+            configs = self.getConfigsWarnings(configsMergeWarning);
           App.showClusterCheckPopup(popupData, {
             header: header,
             failTitle: failTitle,
@@ -775,9 +816,9 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
       skipSCFailures: self.get('failuresTolerance.skipSCFailures'),
       disablePrimary: function () {
         if (isInUpgradeWizard) return false;
-        var selectedMethod = self.get('upgradeMethods').findProperty('selected');
-        return selectedMethod ? selectedMethod.get('isPrecheckFailed') : true;
-      }.property('selectedMethod'),
+        var selectedMethod = this.get('selectedMethod');
+        return (selectedMethod ? (selectedMethod.get('isPrecheckFailed') || selectedMethod.get('isCheckRequestInProgress'))
: true);
+      }.property('selectedMethod', 'selectedMethod.isPrecheckFailed', 'selectedMethod.isCheckRequestInProgress'),
       onPrimary: function () {
         this.hide();
         if (isInUpgradeWizard) {
@@ -834,15 +875,28 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
   /**
    * send request for pre upgrade check only
    */
-  runPreUpgradeCheckOnly: function(data) {
+  runPreUpgradeCheckOnly: function (data) {
     if (App.get('supports.preUpgradeCheck')) {
-      App.ajax.send({
+      var method = this.get('upgradeMethods').findProperty('type', data.type);
+      method.setProperties({
+        isCheckComplete: false,
+        isCheckRequestInProgress: true,
+        action: ''
+      });
+      var request = App.ajax.send({
         name: "admin.upgrade.pre_upgrade_check",
         sender: this,
         data: data,
-        success: "runPreUpgradeCheckOnlySuccess",
-        error: "runPreUpgradeCheckError"
+        success: 'runPreUpgradeCheckOnlySuccess',
+        error: 'runPreUpgradeCheckOnlyError',
+        callback: function () {
+          var runningCheckRequests = this.sender.get('runningCheckRequests');
+          method.set('isCheckRequestInProgress', false);
+          this.sender.set('runningCheckRequests', runningCheckRequests.rejectProperty('type',
this.data.type));
+        }
       });
+      request.type = data.type;
+      this.get('runningCheckRequests').push(request);
     }
   },
 
@@ -854,8 +908,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
       name: "admin.upgrade.get_supported_upgradeTypes",
       sender: this,
       data: data,
-      success: "getSupportedUpgradeTypesSuccess",
-      error: "getSupportedUpgradeTypesError"
+      success: "getSupportedUpgradeTypesSuccess"
     });
   },
 
@@ -898,11 +951,16 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
       message = Em.I18n.t('admin.stackVersions.version.upgrade.upgradeOptions.preCheck.allPassed');
     }
     var method = self.get('upgradeMethods').findProperty('type', params.type);
-    method.set('precheckResultsMessage', message);
-    method.set('precheckResultsMessageClass', messageClass);
-    method.set('isPrecheckFailed', messageClass == 'RED');
-    method.set('precheckResultsMessageIconClass', messageIconClass);
-    method.set('precheckResultsData', data);
+    method.setProperties({
+      precheckResultsMessage: message,
+      precheckResultsMessageClass: messageClass,
+      precheckResultsTitle: Em.I18n.t('admin.stackVersions.version.upgrade.upgradeOptions.preCheck.msg.title'),
+      isPrecheckFailed: messageClass == 'RED',
+      precheckResultsMessageIconClass: messageIconClass,
+      precheckResultsData: data,
+      isCheckComplete: true,
+      action: 'openMessage'
+    });
     this.updateSelectedMethod(false);
     Em.run.later(this, function () {
       // add tooltip for the type with preCheck errors
@@ -915,6 +973,18 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
     }, 1000);
   },
 
+  runPreUpgradeCheckOnlyError: function (request, ajaxOptions, error, data, params) {
+    var method = this.get('upgradeMethods').findProperty('type', params.type);
+    method.setProperties({
+      precheckResultsMessage: Em.I18n.t('admin.stackVersions.version.upgrade.upgradeOptions.preCheck.msg.failed.link'),
+      precheckResultsTitle: Em.I18n.t('admin.stackVersions.version.upgrade.upgradeOptions.preCheck.msg.failed.title'),
+      precheckResultsMessageClass: 'RED',
+      isPrecheckFailed: true,
+      precheckResultsMessageIconClass: 'icon-warning-sign',
+      action: 'rerunCheck'
+    });
+  },
+
   /**
    * In Upgrade Wizard: update which method already been selected on open
    * Not in upgrade wizard: de-select the method with pre-check errors
@@ -982,28 +1052,12 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
         failAlert = new Em.Handlebars.SafeString(Em.I18n.t('popup.clusterCheck.Upgrade.fail.alert')),
         warningTitle = Em.I18n.t('popup.clusterCheck.Upgrade.warning.title'),
         warningAlert = new Em.Handlebars.SafeString(Em.I18n.t('popup.clusterCheck.Upgrade.warning.alert')),
-        configsMergeWarning = data.items.findProperty('UpgradeChecks.id', "CONFIG_MERGE"),
-        configs = [];
-      if (configsMergeWarning && Em.get(configsMergeWarning, 'UpgradeChecks.status')
=== 'WARNING') {
-        data.items = data.items.rejectProperty('UpgradeChecks.id', 'CONFIG_MERGE');
-        var configsMergeCheckData = Em.get(configsMergeWarning, 'UpgradeChecks.failed_detail');
-        if (configsMergeCheckData) {
-          configs = configsMergeCheckData.map(function (item) {
-            var isDeprecated = Em.isNone(item.new_stack_value),
-              willBeRemoved = Em.isNone(item.result_value);
-            return {
-              type: item.type,
-              name: item.property,
-              currentValue: item.current,
-              recommendedValue: isDeprecated ? Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.deprecated')
: item.new_stack_value,
-              isDeprecated: isDeprecated,
-              resultingValue: willBeRemoved ? Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.willBeRemoved')
: item.result_value,
-              willBeRemoved: willBeRemoved
-            };
-          });
-        }
-      }
-      App.showClusterCheckPopup(data, {
+        configsMergeWarning = data.items.findProperty('UpgradeChecks.id', 'CONFIG_MERGE'),
+        popupData = {
+          items: data.items.rejectProperty('UpgradeChecks.id', 'CONFIG_MERGE')
+        },
+        configs = this.getConfigsWarnings(configsMergeWarning);
+      App.showClusterCheckPopup(popupData, {
         header: header,
         failTitle: failTitle,
         failAlert: failAlert,

http://git-wip-us.apache.org/repos/asf/ambari/blob/a39f1135/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 1905385..d263be3 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1497,6 +1497,9 @@ Em.I18n.translations = {
   'admin.stackVersions.version.upgrade.upgradeOptions.EU.description': "Services are stopped
while the upgrade is performed. Incurs downtime, but faster upgrade.",
   'admin.stackVersions.version.upgrade.upgradeOptions.preCheck.rerun':'Rerun Checks',
   'admin.stackVersions.version.upgrade.upgradeOptions.preCheck.msg.title':'Checks:',
+  'admin.stackVersions.version.upgrade.upgradeOptions.preCheck.msg.checking': 'Checking...',
+  'admin.stackVersions.version.upgrade.upgradeOptions.preCheck.msg.failed.title': 'Check
failed',
+  'admin.stackVersions.version.upgrade.upgradeOptions.preCheck.msg.failed.link': 'Rerun',
   'admin.stackVersions.version.upgrade.upgradeOptions.preCheck.allPassed':'Passed',
   'admin.stackVersions.version.upgrade.upgradeOptions.preCheck.allPassed.msg':'All checks
passed',
   'admin.stackVersions.version.upgrade.upgradeOptions.preCheck.failed.tooltip':'Option not
available',

http://git-wip-us.apache.org/repos/asf/ambari/blob/a39f1135/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index b85107c..cf7c59a 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -1084,14 +1084,14 @@ h1 {
 }
 
 .spinner {
-  width: 36px;
-  height: 36px;
+  width: @spinner-default-width;
+  height: @spinner-default-height;
   background: url("/img/spinner.gif");
   margin: 0 auto;
 
   &.service-button-spinner {
-    width: 30px;
-    height: 30px;
+    width: @spinner-small-width;
+    height: @spinner-small-height;
     background-size: cover;
   }
 }
@@ -1365,9 +1365,9 @@ h1 {
   }
   .db-connection {
     .spinner {
-      width: 30px;
-      height: 30px;
-      background-size: 30px 30px;
+      width: @spinner-small-width;
+      height: @spinner-small-height;
+      background-size: cover;
     }
     .icon-ok-sign, .icon-warning-sign {
       font-size: 27px;

http://git-wip-us.apache.org/repos/asf/ambari/blob/a39f1135/ambari-web/app/styles/common.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/common.less b/ambari-web/app/styles/common.less
index a561bd4..b54cd06 100644
--- a/ambari-web/app/styles/common.less
+++ b/ambari-web/app/styles/common.less
@@ -42,6 +42,11 @@
 @blue: #0572ff;
 @gray-blue: #80A0B9;
 
+@spinner-default-width: 36px;
+@spinner-default-height: 36px;
+@spinner-small-width: 30px;
+@spinner-small-height: 30px;
+
 (~".@{health-status-red-icon}") {
   color: @health-status-red;
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/a39f1135/ambari-web/app/styles/stack_versions.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/stack_versions.less b/ambari-web/app/styles/stack_versions.less
index 94d779f..8529606 100644
--- a/ambari-web/app/styles/stack_versions.less
+++ b/ambari-web/app/styles/stack_versions.less
@@ -119,7 +119,7 @@
       .checkbox {
         margin-left: 3px;
         margin-right: 8px;
-        margin-top: 0px;
+        margin-top: 0;
       }
       .icon-question-sign {
         color: @blue;
@@ -139,7 +139,7 @@
     border: 1px solid #d2d9dd;
     height: 168px;
     margin: 15px 15px 0 0;
-    padding: 5px 0px;
+    padding: 5px 0;
     a.not-active:hover {
       text-decoration: none;
     }
@@ -192,8 +192,8 @@
       font-weight: 500;
       font-size: 20px;
       line-height: 20px;
-      padding: 5px 5px 0px 5px;
-      margin-bottom: 0px;
+      padding: 5px 5px 0 5px;
+      margin-bottom: 0;
       span {
         margin-left: 20px;
       }
@@ -207,7 +207,7 @@
       text-align: center;
       color: #888;
       font-size: 12px;
-      margin: 0px 0px -18px 1px;
+      margin: 0 0px -18px 1px;
       padding: 1px;
     }
     .hosts-section {
@@ -392,6 +392,18 @@
     text-align: center;
     padding-top: 10px;
     font-size: 13px;
+    &.checking {
+      padding-top: 5px;
+      line-height: @spinner-small-height;
+      .spinner {
+        display: inline-block;
+        width: auto;
+        height: @spinner-small-height;
+        padding-left: @spinner-small-width + 4px;
+        background-repeat: no-repeat;
+        background-size: contain;
+      }
+    }
   }
   .method-precheck-message.GREEN {
     .icon-ok {
@@ -414,7 +426,7 @@
   .tolerance-text .tolerance-option {
     margin: 5px 15px;
     .ember-checkbox {
-      margin-top: 0px;
+      margin-top: 0;
     }
   }
   .text {
@@ -530,7 +542,7 @@
     .checkbox {
       margin-left: 3px;
       margin-right: 8px;
-      margin-top: 0px;
+      margin-top: 0;
     }
     .icon-question-sign {
       color: @blue;

http://git-wip-us.apache.org/repos/asf/ambari/blob/a39f1135/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_options.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_options.hbs b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_options.hbs
index 1be2539..4bb9db6 100644
--- a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_options.hbs
+++ b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_options.hbs
@@ -30,11 +30,15 @@
             <div class="method-name">{{method.displayName}}</div>
             <div class="method-description">{{{method.description}}}</div>
             {{#unless view.isInUpgradeWizard}}
-              {{#if method.precheckResultsMessage}}
+              {{#if method.isCheckRequestInProgress}}
+                <div class="method-precheck-message checking">
+                  <div class="spinner">{{t admin.stackVersions.version.upgrade.upgradeOptions.preCheck.msg.checking}}</div>
+                </div>
+              {{else}}
                 <div {{bindAttr class=":method-precheck-message method.precheckResultsMessageClass"}}>
                   <i {{bindAttr class="method.precheckResultsMessageIconClass"}}></i>
-                  <b>{{t admin.stackVersions.version.upgrade.upgradeOptions.preCheck.msg.title}}</b>&nbsp;
-                  <a {{action openMessage method target="view"}}>
+                  <b>{{method.precheckResultsTitle}}</b>&nbsp;
+                  <a {{action runAction method target="view"}}>
                     {{method.precheckResultsMessage}}
                   </a>
                 </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/a39f1135/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js b/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
index 33b995b..5984aa4 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
@@ -202,7 +202,12 @@ App.MainAdminStackVersionsView = Em.View.extend({
    * stop polling upgrade state
    */
   willDestroyElement: function () {
+    var runningCheckRequests = this.get('controller.runningCheckRequests');
     window.clearTimeout(this.get('updateTimer'));
+    runningCheckRequests.forEach(function (request) {
+      request.abort();
+    });
+    runningCheckRequests.clear();
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/a39f1135/ambari-web/test/controllers/global/update_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/global/update_controller_test.js b/ambari-web/test/controllers/global/update_controller_test.js
index 51babda..3abfe47 100644
--- a/ambari-web/test/controllers/global/update_controller_test.js
+++ b/ambari-web/test/controllers/global/update_controller_test.js
@@ -308,7 +308,7 @@ describe('App.UpdateController', function () {
         },
         {
           currentStateName: 'stackUpgrade',
-          parentStateName: null,
+          parentStateName: 'admin',
           upgradeIsNotFinished: true,
           isLoadUpgradeDataPending: true,
           loadUpgradeDataCallCount: 0,
@@ -317,7 +317,7 @@ describe('App.UpdateController', function () {
         },
         {
           currentStateName: 'versions',
-          parentStateName: null,
+          parentStateName: 'admin',
           upgradeIsNotFinished: true,
           isLoadUpgradeDataPending: false,
           loadUpgradeDataCallCount: 1,
@@ -326,7 +326,7 @@ describe('App.UpdateController', function () {
         },
         {
           currentStateName: 'versions',
-          parentStateName: null,
+          parentStateName: 'admin',
           upgradeIsNotFinished: false,
           isLoadUpgradeDataPending: false,
           loadUpgradeDataCallCount: 0,
@@ -335,7 +335,7 @@ describe('App.UpdateController', function () {
         },
         {
           currentStateName: 'versions',
-          parentStateName: null,
+          parentStateName: 'admin',
           upgradeIsNotFinished: true,
           isLoadUpgradeDataPending: true,
           loadUpgradeDataCallCount: 0,
@@ -426,7 +426,9 @@ describe('App.UpdateController', function () {
         appGetMock.withArgs('router.mainAdminStackAndUpgradeController').returns(Em.Object.create({
           loadUpgradeData: mock.loadUpgradeData,
           isLoadUpgradeDataPending: item.isLoadUpgradeDataPending
-        })).withArgs('upgradeIsNotFinished').returns(item.upgradeIsNotFinished);
+        })).withArgs('upgradeIsNotFinished').returns(item.upgradeIsNotFinished)
+          .withArgs('router.currentState.name').returns(item.currentStateName)
+          .withArgs('router.currentState.parentState.name').returns(item.parentStateName);
         controller.updateUpgradeState(mock.callback);
         expect(mock.loadUpgradeData.callCount).to.equal(item.loadUpgradeDataCallCount);
         expect(mock.callback.callCount).to.equal(item.callbackCallCount);

http://git-wip-us.apache.org/repos/asf/ambari/blob/a39f1135/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
index 0575d26..d1d5761 100644
--- a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
@@ -801,38 +801,55 @@ describe('App.MainAdminStackAndUpgradeController', function() {
     before(function () {
       sinon.spy(App, 'ModalPopup');
       sinon.spy(App, 'showConfirmationFeedBackPopup');
-      this.mock = sinon.stub(controller, 'getSupportedUpgradeTypes');
+      sinon.stub(controller, 'getSupportedUpgradeTypes').returns({
+        done: function (callback) {
+          callback([1]);
+          return {
+            always: function (alwaysCallback) {
+              alwaysCallback();
+              return {};
+            }
+          };
+        }
+      });
       sinon.stub(controller, 'runPreUpgradeCheck', Em.K);
+      sinon.stub(App.RepositoryVersion, 'find').returns([
+        Em.Object.create({
+          status: 'CURRENT'
+        })
+      ]);
+    });
+    beforeEach(function () {
+      controller.get('runningCheckRequests').clear();
     });
     after(function () {
       App.ModalPopup.restore();
       App.showConfirmationFeedBackPopup.restore();
       controller.runPreUpgradeCheck.restore();
-      this.mock.restore();
+      controller.getSupportedUpgradeTypes.restore();
       controller.get('upgradeMethods').setEach('selected', false);
+      App.RepositoryVersion.find.restore();
     });
     it("show confirmation popup", function() {
       var version = Em.Object.create({displayName: 'HDP-2.2'});
-      this.mock.returns({
-        done: function(callback) {callback([1]);}
-      });
-      controller.get('upgradeMethods')[0].set('selected', true);
       controller.set('isDowngrade', false);
       var popup = controller.upgradeOptions(false, version);
       expect(App.ModalPopup.calledOnce).to.be.true;
+      expect(controller.get('upgradeMethods').everyProperty('isCheckRequestInProgress')).to.be.true;
+      expect(controller.get('upgradeMethods').someProperty('selected')).to.be.false;
+      controller.get('upgradeMethods')[0].set('selected', true);
       var confirmPopup = popup.onPrimary();
       expect(App.showConfirmationFeedBackPopup.calledOnce).to.be.true;
       confirmPopup.onPrimary();
       expect(controller.runPreUpgradeCheck.calledWith(version)).to.be.true;
+      expect( controller.get('runningCheckRequests')).to.have.length(1);
     });
     it("NOT show confirmation popup on Downgrade", function() {
       var version = Em.Object.create({displayName: 'HDP-2.2'});
-      this.mock.returns({
-        done: function(callback) {callback([1]);}
-      });
       controller.set('isDowngrade', true);
-      var popup = controller.upgradeOptions(false, version);
+      controller.upgradeOptions(false, version);
       expect(App.ModalPopup.calledOnce).to.be.false;
+      expect( controller.get('runningCheckRequests')).to.have.length(1);
     });
   });
 
@@ -1644,4 +1661,233 @@ describe('App.MainAdminStackAndUpgradeController', function() {
     });
   });
 
+  describe('#getConfigsWarnings', function () {
+
+    var cases = [
+      {
+        configs: [],
+        title: 'no warning'
+      },
+      {
+        configsMergeWarning: {},
+        configs: [],
+        title: 'empty data'
+      },
+      {
+        configsMergeWarning: {
+          UpgradeChecks: {}
+        },
+        configs: [],
+        title: 'incomplete data'
+      },
+      {
+        configsMergeWarning: {
+          UpgradeChecks: {
+            failed_detail: {}
+          }
+        },
+        configs: [],
+        title: 'invalid data'
+      },
+      {
+        configsMergeWarning: {
+          UpgradeChecks: {
+            failed_detail: []
+          }
+        },
+        configs: [],
+        title: 'empty configs array'
+      },
+      {
+        configsMergeWarning: {
+          UpgradeChecks: {
+            status: 'FAIL',
+            failed_detail: [
+              {
+                type: 't0',
+                property: 'p0',
+                current: 'c0',
+                new_stack_value: 'n0',
+                result_value: 'r0'
+              },
+              {
+                type: 't1',
+                property: 'p1',
+                current: 'c1',
+                new_stack_value: 'n1'
+              },
+              {
+                type: 't2',
+                property: 'p2',
+                current: 'c2',
+                result_value: 'r2'
+              }
+            ]
+          }
+        },
+        configs: [],
+        title: 'not a warning'
+      },
+      {
+        configsMergeWarning: {
+          UpgradeChecks: {
+            status: 'WARNING',
+            failed_detail: [
+              {
+                type: 't0',
+                property: 'p0',
+                current: 'c0',
+                new_stack_value: 'n0',
+                result_value: 'r0'
+              },
+              {
+                type: 't1',
+                property: 'p1',
+                current: 'c1',
+                new_stack_value: 'n1'
+              },
+              {
+                type: 't2',
+                property: 'p2',
+                current: 'c2',
+                result_value: 'r2'
+              }
+            ]
+          }
+        },
+        configs: [
+          {
+            type: 't0',
+            name: 'p0',
+            currentValue: 'c0',
+            recommendedValue: 'n0',
+            isDeprecated: false,
+            resultingValue: 'r0',
+            willBeRemoved: false
+          },
+          {
+            type: 't1',
+            name: 'p1',
+            currentValue: 'c1',
+            recommendedValue: 'n1',
+            isDeprecated: false,
+            resultingValue: Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.willBeRemoved'),
+            willBeRemoved: true
+          },
+          {
+            type: 't2',
+            name: 'p2',
+            currentValue: 'c2',
+            recommendedValue: Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.deprecated'),
+            isDeprecated: true,
+            resultingValue: 'r2',
+            willBeRemoved: false
+          }
+        ],
+        title: 'normal case'
+      }
+    ];
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        expect(controller.getConfigsWarnings(item.configsMergeWarning)).to.eql(item.configs);
+      });
+    });
+
+  });
+
+  describe('#runPreUpgradeCheckOnly', function () {
+
+    var appGetMock,
+      upgradeMethods = controller.get('upgradeMethods'),
+      cases = [
+      {
+        supportsPreUpgradeCheck: false,
+        ru: {
+          isCheckComplete: true,
+          isCheckRequestInProgress: false,
+          action: 'a'
+        },
+        eu: {
+          isCheckComplete: true,
+          isCheckRequestInProgress: false,
+          action: 'a'
+        },
+        ajaxCallCount: 0,
+        runningCheckRequestsLength: 0,
+        title: 'pre-upgrade checks not supported'
+      },
+      {
+        supportsPreUpgradeCheck: true,
+        ru: {
+          isCheckComplete: false,
+          isCheckRequestInProgress: true,
+          action: ''
+        },
+        eu: {
+          isCheckComplete: true,
+          isCheckRequestInProgress: false,
+          action: 'a'
+        },
+        ajaxCallCount: 1,
+        type: 'ROLLING',
+        runningCheckRequestsLength: 1,
+        title: 'rolling upgrade'
+      },
+      {
+        supportsPreUpgradeCheck: true,
+        ru: {
+          isCheckComplete: true,
+          isCheckRequestInProgress: false,
+          action: 'a'
+        },
+        eu: {
+          isCheckComplete: false,
+          isCheckRequestInProgress: true,
+          action: ''
+        },
+        ajaxCallCount: 1,
+        type: 'NON_ROLLING',
+        runningCheckRequestsLength: 1,
+        title: 'express upgrade'
+      }
+    ];
+
+    beforeEach(function () {
+      appGetMock = sinon.stub(App, 'get');
+      controller.get('runningCheckRequests').clear();
+      upgradeMethods.forEach(function (method) {
+        method.setProperties({
+          isCheckComplete: true,
+          isCheckRequestInProgress: false,
+          action: 'a'
+        });
+      });
+      sinon.stub(App.ajax, 'send').returns({});
+    });
+
+    afterEach(function () {
+      appGetMock.restore();
+      App.ajax.send.restore();
+    });
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        var runningCheckRequests = controller.get('runningCheckRequests');
+        appGetMock.returns(item.supportsPreUpgradeCheck);
+        controller.runPreUpgradeCheckOnly({
+          type: item.type
+        });
+        expect(upgradeMethods.findProperty('type', 'ROLLING').getProperties('isCheckComplete',
'isCheckRequestInProgress', 'action')).to.eql(item.ru);
+        expect(upgradeMethods.findProperty('type', 'NON_ROLLING').getProperties('isCheckComplete',
'isCheckRequestInProgress', 'action')).to.eql(item.eu);
+        expect(App.ajax.send.callCount).to.equal(item.ajaxCallCount);
+        expect(runningCheckRequests).to.have.length(item.runningCheckRequestsLength);
+        if (item.runningCheckRequestsLength) {
+          expect(runningCheckRequests[0].type).to.equal(item.type);
+        }
+      });
+    });
+
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/a39f1135/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
index 887b25c..8f7d7c5 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
@@ -24,7 +24,8 @@ describe('App.mainAdminStackVersionsView', function () {
   var view = App.MainAdminStackVersionsView.create({
     controller: {
       currentVersion: {
-        repository_version: "2.2.1.0"
+        repository_version: "2.2.1.0",
+        runningCheckRequests: []
       },
       load: Em.K
     }
@@ -354,8 +355,13 @@ describe('App.mainAdminStackVersionsView', function () {
   });
 
   describe("#willDestroyElement()", function() {
+    var abort = sinon.spy(),
+      request = {
+        abort: abort
+      };
     before(function () {
       sinon.stub(window, 'clearTimeout', Em.K);
+      view.set('controller.runningCheckRequests', [request, request]);
     });
     after(function () {
       window.clearTimeout.restore();
@@ -363,6 +369,8 @@ describe('App.mainAdminStackVersionsView', function () {
     it("", function() {
       view.willDestroyElement();
       expect(window.clearTimeout.calledOnce).to.be.true;
+      expect(abort.calledTwice).to.be.true;
+      expect(view.get('controller.runningCheckRequests')).to.have.length(0);
     });
   });
 


Mime
View raw message