Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 63d89c072 -> c84736055


AMBARI-11943. RU: UI must retry ABORTED upgrades (onechiporenko)


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

Branch: refs/heads/branch-2.1
Commit: c847360553d646eaf1d3ade1a43f5a3b5b7204b6
Parents: 63d89c0
Author: Oleg Nechiporenko <onechipore...@apache.org>
Authored: Tue Jun 16 12:39:22 2015 +0300
Committer: Oleg Nechiporenko <onechipore...@apache.org>
Committed: Tue Jun 16 12:49:15 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/app.js                           | 16 ++++++
 .../main/admin/stack_and_upgrade_controller.js  | 50 +++++++++++++++++
 ambari-web/app/messages.js                      | 11 +++-
 ambari-web/app/styles/application.less          | 17 ++++++
 ambari-web/app/styles/common.less               | 19 +++++++
 ambari-web/app/templates/application.hbs        | 13 ++++-
 .../stack_upgrade/stack_upgrade_wizard.hbs      | 25 +++++++++
 ambari-web/app/utils/ajax/ajax.js               | 14 +++++
 .../stack_upgrade/upgrade_version_box_view.js   |  8 ++-
 .../admin/stack_upgrade/upgrade_wizard_view.js  |  4 +-
 ambari-web/test/app_test.js                     | 56 ++++++++++++++++++++
 .../admin/stack_and_upgrade_controller_test.js  | 48 +++++++++++++++++
 .../upgrade_version_box_view_test.js            | 40 ++++++++++++++
 .../stack_upgrade/upgrade_wizard_view_test.js   | 13 ++++-
 14 files changed, 328 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c8473605/ambari-web/app/app.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js
index 23db3a5..0683818 100644
--- a/ambari-web/app/app.js
+++ b/ambari-web/app/app.js
@@ -66,6 +66,14 @@ module.exports = Em.Application.create({
   }.property('upgradeState'),
 
   /**
+   * flag is true when upgrade process is aborted
+   * @returns {boolean}
+   */
+  upgradeAborted: function() {
+    return this.get('upgradeState') === "ABORTED";
+  }.property('upgradeState'),
+
+  /**
    * RU is running
    * @type {boolean}
    */
@@ -74,6 +82,14 @@ module.exports = Em.Application.create({
   }.property('upgradeInProgress', 'upgradeHolding'),
 
   /**
+   * flag is true when upgrade process is running or aborted
+   * @returns {boolean}
+   */
+  upgradeIsNotFinished: function () {
+    return this.get('upgradeIsRunning') || this.get('upgradeAborted');
+  }.property('upgradeIsRunning', 'upgradeAborted'),
+
+  /**
    * compute user access rights by permission type
    * types:
    *  - ADMIN

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8473605/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 7768f1c..309ab5e 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
@@ -69,6 +69,10 @@ App.MainAdminStackAndUpgradeController = 
Em.Controller.extend(App.LocalStorage,
    */
   requestInProgress: false,
   /**
+   * @type {boolean} true while no updated upgrade info is loaded after retry
+   */
+  isRetryPending: false,
+  /**
    * properties that stored to localStorage to resume wizard progress
    */
   wizardStorageProperties: ['upgradeId', 'upgradeVersion', 'currentVersion', 
'isDowngrade'],
@@ -207,6 +211,12 @@ App.MainAdminStackAndUpgradeController = 
Em.Controller.extend(App.LocalStorage,
     if (data.upgrade_groups) {
       this.updateUpgradeData(data);
     }
+    if (this.get('isRetryPending') && data.Upgrade.request_status != 
'ABORTED') {
+      this.setProperties({
+        requestInProgress: false,
+        isRetryPending: false
+      });
+    }
   },
 
   /**
@@ -375,6 +385,20 @@ App.MainAdminStackAndUpgradeController = 
Em.Controller.extend(App.LocalStorage,
     });
   },
 
+  retryUpgrade: function () {
+    this.setProperties({
+      requestInProgress: true,
+      isRetryPending: true
+    });
+    return App.ajax.send({
+      name: 'admin.upgrade.retry',
+      sender: this,
+      data: {
+        upgradeId: this.get('upgradeId')
+      }
+    });
+  },
+
   /**
    * make call to start upgrade process and show popup with current progress
    * @param {object} version
@@ -507,6 +531,32 @@ App.MainAdminStackAndUpgradeController = 
Em.Controller.extend(App.LocalStorage,
     this.set('requestInProgress', false);
   },
 
+  confirmRetryUpgrade: function (version) {
+    var self = this;
+    return App.showConfirmationPopup(
+      function () {
+        self.retryUpgrade();
+      },
+      
Em.I18n.t('admin.stackUpgrade.upgrade.retry.confirm.body').format(version.get('displayName')),
+      null,
+      
Em.I18n.t('admin.stackUpgrade.dialog.header').format(version.get('displayName'))
+    );
+  },
+
+  confirmRetryDowngrade: function () {
+    var self = this,
+      currentVersion = this.get('currentVersion');
+    return App.showConfirmationPopup(
+      function() {
+        self.retryUpgrade();
+      },
+      
Em.I18n.t('admin.stackUpgrade.downgrade.retry.body').format(currentVersion.repository_name),
+      null,
+      
Em.I18n.t('admin.stackUpgrade.dialog.downgrade.header').format(currentVersion.repository_name),
+      Em.I18n.t('admin.stackUpgrade.downgrade.proceed')
+    );
+  },
+
   /**
    * confirmation popup before install repository version
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8473605/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 40e76d5..0f5a8a9 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -158,6 +158,7 @@ Em.I18n.translations = {
   'common.confirm': 'Confirm',
   'common.upgrade': 'Upgrade',
   'common.reUpgrade': 'Retry Upgrade',
+  'common.reDowngrade': 'Retry Downgrade',
   'common.security':'Security',
   'common.kerberos':'Kerberos',
   'common.cluster':'Cluster',
@@ -343,7 +344,7 @@ Em.I18n.translations = {
   'popup.clusterCheck.Upgrade.fail.title': 'Requirements',
   'popup.clusterCheck.Upgrade.fail.alert': 'You <strong>must</strong> meet 
these requirements before you can proceed.',
   'popup.clusterCheck.Upgrade.warning.title': 'Warnings',
-  'popup.clusterCheck.Upgrade.warning.alert': 'Correcting the warnings are not 
required but are <strong>recommended</strong>.',
+  'popup.clusterCheck.Upgrade.warning.alert': 'Correcting the warnings is not 
required but is <strong>recommended</strong>.',
   'popup.clusterCheck.Upgrade.configsMerge.title': 'Configuration Changes',
   'popup.clusterCheck.Upgrade.configsMerge.alert': 'During upgrade, the 
following configuration changes will be applied.',
   'popup.clusterCheck.Upgrade.configsMerge.configType': 'Config Type',
@@ -1426,8 +1427,10 @@ Em.I18n.translations = {
   'admin.stackVersions.version.performUpgrade': "Perform Upgrade",
   'admin.stackVersions.version.upgrade.pause': "Upgrade: Action Required",
   'admin.stackVersions.version.upgrade.running': "Upgrade: In Process",
+  'admin.stackVersions.version.upgrade.aborted': "Upgrade: Aborted",
   'admin.stackVersions.version.downgrade.pause': "Downgrade: Action Required",
   'admin.stackVersions.version.downgrade.running': "Downgrade: In Process",
+  'admin.stackVersions.version.downgrade.aborted': "Downgrade: Aborted",
 
   'admin.stackVersions.hosts.popup.header.current': "Current",
   'admin.stackVersions.hosts.popup.header.installed': "Installed",
@@ -1454,13 +1457,17 @@ Em.I18n.translations = {
   'admin.stackUpgrade.pauseDowngrade': "Pause Downgrade",  
   'admin.stackUpgrade.downgrade.proceed': "Proceed with Downgrade",
   'admin.stackUpgrade.downgrade.body': "Are you sure you wish to abort the 
upgrade process and downgrade to <b>{0}</b>?",
+  'admin.stackUpgrade.downgrade.retry.body': "Are you sure you wish to retry 
downgrade to <b>{0}</b>?",
   'admin.stackUpgrade.upgrade.confirm.body': "You are about to perform an 
upgrade to {0}.",
+  'admin.stackUpgrade.upgrade.retry.confirm.body': "You are about to retry an 
upgrade to {0}.",
   'admin.stackUpgrade.title': "Stack and Versions",
   'admin.stackUpgrade.state.inProgress': "Upgrade in Progress",
   'admin.stackUpgrade.state.paused': "Upgrade Paused",
+  'admin.stackUpgrade.state.aborted': "Upgrade Aborted",
   'admin.stackUpgrade.state.completed': "Upgrade Finished",
   'admin.stackUpgrade.state.inProgress.downgrade': "Downgrade in Progress",
   'admin.stackUpgrade.state.paused.downgrade': "Downgrade Paused",
+  'admin.stackUpgrade.state.aborted.downgrade': "Downgrade Aborted",
   'admin.stackUpgrade.state.completed.downgrade': "Downgrade Finished",
   'admin.stackUpgrade.dialog.header': "Rolling Upgrade to {0}",
   'admin.stackUpgrade.dialog.downgrade.header': "Downgrade to {0}",
@@ -1475,6 +1482,8 @@ Em.I18n.translations = {
   'admin.stackUpgrade.dialog.manualDone': "I have performed the manual steps 
above.",
   'admin.stackUpgrade.dialog.closeProgress': "Upgrade is in progress. \n If 
you dismiss this window, Upgrade will keep running in background.",
   'admin.stackUpgrade.dialog.closePause': "Upgrade is paused. \n If you 
dismiss this window, you can resume Upgrade later.",
+  'admin.stackUpgrade.dialog.aborted': "Upgrade is aborted. \n You can either 
downgrade or retry upgrade.",
+  'admin.stackUpgrade.dialog.downgrade.aborted': "Downgrade is aborted. \n You 
can retry downgrade.",
   'admin.stackUpgrade.dialog.details.open': "show details",
   'admin.stackUpgrade.dialog.details.hide': "hide details",
   'admin.stackUpgrade.dialog.notActive': "Waiting to execute the next task...",

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8473605/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less 
b/ambari-web/app/styles/application.less
index 25e719c..5866fb0 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -181,6 +181,23 @@ footer {
         animation-iteration-count: infinite;
       }
 
+      .upgrade-aborted {
+        text-shadow: none;
+        background-color: @health-status-red;
+        -webkit-animation-name: redPulse;
+        -webkit-animation-duration: 1s;
+        -webkit-animation-iteration-count: infinite;
+        -moz-animation-name: redPulse;
+        -moz-animation-duration: 1s;
+        -moz-animation-iteration-count: infinite;
+        animation-name: redPulse;
+        animation-duration: 1s;
+        animation-iteration-count: infinite;
+        .icon-remove {
+          color: #fff;
+        }
+      }
+
     }
     @media (max-width: 1200px) {
       ul.top-nav-menu.nav {

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8473605/ambari-web/app/styles/common.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/common.less 
b/ambari-web/app/styles/common.less
index 64bfde3..0edec5f 100644
--- a/ambari-web/app/styles/common.less
+++ b/ambari-web/app/styles/common.less
@@ -115,6 +115,25 @@
   100% { color: #118fff; }
 }
 
+@-webkit-keyframes redPulse {
+  from { background-color: #ff3333; }
+  50% { background-color: #ff0000; }
+  to { background-color: #ff3333; }
+}
+
+@-moz-keyframes redPulse {
+  from { background-color: #ff3333; }
+  50% { background-color: #ff0000; }
+  to { background-color: #ff3333; }
+}
+
+@keyframes redPulse
+{
+  0% { background-color: #ff3333; }
+  50% { background-color: #ff0000; }
+  100% { background-color: #ff3333; }
+}
+
 .gradient(@color: #FAFAFA, @start: #FFFFFF, @stop: #F2F2F2) {
   background: @color;
   background: -webkit-gradient(linear, left top, left bottom, color-stop(0, 
@start), color-stop(1, @stop));

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8473605/ambari-web/app/templates/application.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/application.hbs 
b/ambari-web/app/templates/application.hbs
index 10897e9..e6de54e 100644
--- a/ambari-web/app/templates/application.hbs
+++ b/ambari-web/app/templates/application.hbs
@@ -95,7 +95,7 @@
   </div>
   <div class="container main-container">
     <div id="content">
-      {{#if App.upgradeIsRunning}}
+      {{#if App.upgradeIsNotFinished}}
         <div class="ru-badge span12">
           <div class="navbar navbar-static-top clearfix">
             <div class="span4 offset4">
@@ -123,6 +123,17 @@
                           <i class="icon-pause"></i>&nbsp;{{t 
admin.stackVersions.version.upgrade.pause}}</span>
                     {{/if}}
                   {{/if}}
+                  {{#if App.upgradeAborted}}
+                    {{#if 
App.router.mainAdminStackAndUpgradeController.isDowngrade}}
+                      <span
+                          class="label upgrade-aborted" {{action 
"openUpgradeDialog" target="App.router.mainAdminStackAndUpgradeController"}}>
+                          <i class="icon-remove"></i>&nbsp;{{t 
admin.stackVersions.version.downgrade.aborted}}</span>
+                    {{else}}
+                      <span
+                        class="label upgrade-aborted" {{action 
"openUpgradeDialog" target="App.router.mainAdminStackAndUpgradeController"}}>
+                          <i class="icon-remove"></i>&nbsp;{{t 
admin.stackVersions.version.upgrade.aborted}}</span>
+                    {{/if}}
+                  {{/if}}
                 </a>
               {{/if}}
             </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8473605/ambari-web/app/templates/main/admin/stack_upgrade/stack_upgrade_wizard.hbs
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/templates/main/admin/stack_upgrade/stack_upgrade_wizard.hbs 
b/ambari-web/app/templates/main/admin/stack_upgrade/stack_upgrade_wizard.hbs
index c6f38b5..7874175 100644
--- a/ambari-web/app/templates/main/admin/stack_upgrade/stack_upgrade_wizard.hbs
+++ b/ambari-web/app/templates/main/admin/stack_upgrade/stack_upgrade_wizard.hbs
@@ -153,6 +153,31 @@
             </div>
           </div>
         {{/if}}
+        {{#if App.upgradeAborted}}
+          {{#unless requestInProgress}}
+            <div class="box details-box">
+              <label class="message">
+                {{#if view.isDowngradeAvailable}}
+                  {{t admin.stackUpgrade.dialog.aborted}}
+                {{else}}
+                  {{t admin.stackUpgrade.dialog.downgrade.aborted}}
+                {{/if}}
+              </label>
+              <div class="button-row">
+                {{#if view.isDowngradeAvailable}}
+                  <button class="btn btn-danger" {{bindAttr 
disabled="controller.requestInProgress"}} {{action confirmDowngrade 
view.manualItem target="controller"}}>{{t common.downgrade}}</button>
+                {{/if}}
+                <button class="btn btn-success" {{action retryUpgrade 
target="controller"}}>
+                  {{#if view.isDowngradeAvailable}}
+                    {{t common.reUpgrade}}
+                  {{else}}
+                    {{t common.reDowngrade}}
+                  {{/if}}
+                </button>
+              </div>
+            </div>
+          {{/unless}}
+        {{/if}}
       </div>
       {{#each group in view.upgradeGroups}}
         {{#if group.isVisible}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8473605/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js 
b/ambari-web/app/utils/ajax/ajax.js
index 6c6b963..22e6ac6 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1553,6 +1553,20 @@ var urls = {
       }
     }
   },
+  'admin.upgrade.retry': {
+    'real': '/clusters/{clusterName}/upgrades/{upgradeId}',
+    'mock': '',
+    'type': 'PUT',
+    'format': function (data) {
+      return {
+        data: JSON.stringify({
+          "Upgrade": {
+            "request_status": "PENDING"
+          }
+        })
+      }
+    }
+  },
   'admin.upgrade.upgradeItem.setState': {
     'real': 
'/clusters/{clusterName}/upgrades/{upgradeId}/upgrade_groups/{groupId}/upgrade_items/{itemId}',
     'mock': '',

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8473605/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js 
b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
index 28d1428..9e6d5ad 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
@@ -110,6 +110,7 @@ App.UpgradeVersionBoxView = Em.View.extend({
       isDisabled: false
     });
     var isInstalling = 
this.get('parentView.repoVersions').someProperty('status', 'INSTALLING');
+    var isAborted = App.get('upgradeState') === 'ABORTED';
 
     if (status === 'CURRENT') {
       element.set('isLabel', true);
@@ -143,7 +144,7 @@ App.UpgradeVersionBoxView = Em.View.extend({
         element.set('text', Em.I18n.t('common.installed'));
         element.set('action', null);
       }
-    } else if (['UPGRADING', 'UPGRADE_FAILED', 'UPGRADED'].contains(status) || 
this.get('isUpgrading')) {
+    } else if ((['UPGRADING', 'UPGRADE_FAILED', 'UPGRADED'].contains(status) 
|| this.get('isUpgrading')) && !isAborted) {
       element.set('isLink', true);
       element.set('action', 'openUpgradeDialog');
       if (['HOLDING', 'HOLDING_FAILED', 
'HOLDING_TIMEDOUT'].contains(App.get('upgradeState'))) {
@@ -161,6 +162,11 @@ App.UpgradeVersionBoxView = Em.View.extend({
           element.set('text', 
Em.I18n.t('admin.stackVersions.version.upgrade.running'));
         }
       }
+    } else if (isAborted) {
+      element.set('isButton', true);
+      element.set('text', this.get('controller.isDowngrade') ? 
Em.I18n.t('common.reDowngrade') : Em.I18n.t('common.reUpgrade'));
+      element.set('action', this.get('controller.isDowngrade') ? 
'confirmRetryDowngrade' : 'confirmRetryUpgrade');
+      element.set('isDisabled', this.get('controller.requestInProgress'));
     }
     return element;
   }.property('content.status', 'controller.isDowngrade', 'isUpgrading', 
'controller.requestInProgress', 'parentView.repoVersions.@each.status'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8473605/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js 
b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
index 590201e..d7098a6 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
@@ -122,7 +122,7 @@ App.upgradeWizardView = Em.View.extend({
    */
   noActiveItem: function () {
     return (Em.isNone(this.get('failedItem')) && 
Em.isNone(this.get('runningItem')) && Em.isNone(this.get('manualItem'))) &&
-      !['INIT', 'COMPLETED'].contains(App.get('upgradeState'));
+      !['INIT', 'COMPLETED', 'ABORTED'].contains(App.get('upgradeState'));
   }.property('failedItem', 'runningItem', 'manualItem', 'App.upgradeState'),
 
   /**
@@ -193,6 +193,8 @@ App.upgradeWizardView = Em.View.extend({
         labelKey = 'admin.stackUpgrade.state.completed';
         break;
       case 'ABORTED':
+        labelKey = 'admin.stackUpgrade.state.aborted';
+        break;
       case 'TIMEDOUT':
       case 'FAILED':
       case 'HOLDING_FAILED':

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8473605/ambari-web/test/app_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/app_test.js b/ambari-web/test/app_test.js
index 9a2a0f6..416f3af 100644
--- a/ambari-web/test/app_test.js
+++ b/ambari-web/test/app_test.js
@@ -556,4 +556,60 @@ describe('App', function () {
 
   });
 
+  describe('#upgradeAborted', function () {
+
+    var cases = [
+      {
+        upgradeState: 'INIT',
+        upgradeAborted: false
+      },
+      {
+        upgradeState: 'ABORTED',
+        upgradeAborted: true
+      }
+    ];
+
+    cases.forEach(function (item) {
+      it(item.upgradeState, function () {
+        App.set('upgradeState', item.upgradeState);
+        expect(App.get('upgradeAborted')).to.equal(item.upgradeAborted);
+      });
+    });
+
+  });
+
+  describe('#upgradeIsNotFinished', function () {
+
+    var cases = [
+      {
+        upgradeState: 'INIT',
+        upgradeIsNotFinished: false
+      },
+      {
+        upgradeState: 'IN_PROGRESS',
+        upgradeIsNotFinished: true
+      },
+      {
+        upgradeState: 'HOLDING',
+        upgradeIsNotFinished: true
+      },
+      {
+        upgradeState: 'HOLDING_TIMEDOUT',
+        upgradeIsNotFinished: true
+      },
+      {
+        upgradeState: 'ABORTED',
+        upgradeIsNotFinished: true
+      }
+    ];
+
+    cases.forEach(function (item) {
+      it(item.upgradeState, function () {
+        App.set('upgradeState', item.upgradeState);
+        
expect(App.get('upgradeIsNotFinished')).to.equal(item.upgradeIsNotFinished);
+      });
+    });
+
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8473605/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 f456708..a37e115 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
@@ -151,6 +151,36 @@ describe('App.MainAdminStackAndUpgradeController', 
function() {
   });
 
   describe("#loadUpgradeDataSuccessCallback()", function() {
+    var retryCases = [
+      {
+        isRetryPendingInitial: true,
+        status: 'ABORTED',
+        isRetryPending: true,
+        requestInProgress: true,
+        title: 'retry request not yet applied'
+      },
+      {
+        isRetryPendingInitial: true,
+        status: 'UPGRADING',
+        isRetryPending: false,
+        requestInProgress: false,
+        title: 'retry request applied'
+      },
+      {
+        isRetryPendingInitial: false,
+        status: 'ABORTED',
+        isRetryPending: false,
+        requestInProgress: true,
+        title: 'no retry request sent'
+      },
+      {
+        isRetryPendingInitial: false,
+        status: 'UPGRADING',
+        isRetryPending: false,
+        requestInProgress: true,
+        title: 'upgrade wasn\'t aborted'
+      }
+    ];
     beforeEach(function () {
       sinon.stub(controller, 'updateUpgradeData', Em.K);
       sinon.stub(controller, 'setDBProperty', Em.K);
@@ -183,6 +213,24 @@ describe('App.MainAdminStackAndUpgradeController', 
function() {
       expect(controller.updateUpgradeData.called).to.be.false;
       expect(controller.setDBProperty.called).to.be.false;
     });
+    retryCases.forEach(function (item) {
+      it(item.title, function () {
+        var data = {
+          "Upgrade": {
+            "request_status": item.status
+          }
+        };
+        controller.setProperties({
+          isRetryPending: item.isRetryPendingInitial,
+          requestInProgress: true
+        });
+        controller.loadUpgradeDataSuccessCallback(data);
+        expect(controller.getProperties(['isRetryPending', 
'requestInProgress'])).to.eql({
+          isRetryPending: item.isRetryPending,
+          requestInProgress: item.requestInProgress
+        });
+      });
+    });
   });
 
   describe("#getUpgradeItem()", function() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8473605/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
 
b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
index e45bfd3..080bf39 100644
--- 
a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
+++ 
b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
@@ -699,6 +699,46 @@ describe('App.UpgradeVersionBoxView', function () {
           text: Em.I18n.t('admin.stackVersions.version.downgrade.pause')
         },
         title: 'downgrading, holding finished on timeout'
+      },
+      {
+        inputData: {
+          'content.status': 'UPGRADING',
+          'isUpgrading': true,
+          'controller.isDowngrade': false,
+          'controller.requestInProgress': false,
+          'parentView.repoVersions': []
+        },
+        setup: function () {
+          this.getMock.withArgs('upgradeState').returns('ABORTED');
+        },
+        expected: {
+          status: 'UPGRADING',
+          isButton: true,
+          action: 'confirmRetryUpgrade',
+          text: Em.I18n.t('common.reUpgrade'),
+          isDisabled: false
+        },
+        title: 'upgrade aborted'
+      },
+      {
+        inputData: {
+          'content.status': 'UPGRADE_FAILED',
+          'isUpgrading': true,
+          'controller.isDowngrade': true,
+          'controller.requestInProgress': true,
+          'parentView.repoVersions': []
+        },
+        setup: function () {
+          this.getMock.withArgs('upgradeState').returns('ABORTED');
+        },
+        expected: {
+          status: 'UPGRADE_FAILED',
+          isButton: true,
+          action: 'confirmRetryDowngrade',
+          text: Em.I18n.t('common.reDowngrade'),
+          isDisabled: true
+        },
+        title: 'downgrade aborted, request in progress'
       }
     ];
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8473605/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js 
b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
index 9dfaddd..37027b1 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
@@ -292,6 +292,15 @@ describe('App.upgradeWizardView', function () {
           failedItem: null,
           runningItem: null,
           manualItem: null,
+          upgradeState: 'ABORTED'
+        },
+        result: false
+      },
+      {
+        data: {
+          failedItem: null,
+          runningItem: null,
+          manualItem: null,
           upgradeState: 'IN_PROGRESS'
         },
         result: true
@@ -472,7 +481,7 @@ describe('App.upgradeWizardView', function () {
           status: 'ABORTED',
           isDowngrade: false
         },
-        result: Em.I18n.t('admin.stackUpgrade.state.paused')
+        result: Em.I18n.t('admin.stackUpgrade.state.aborted')
       },
       {
         data: {
@@ -549,7 +558,7 @@ describe('App.upgradeWizardView', function () {
           status: 'ABORTED',
           isDowngrade: true
         },
-        result: Em.I18n.t('admin.stackUpgrade.state.paused.downgrade')
+        result: Em.I18n.t('admin.stackUpgrade.state.aborted.downgrade')
       },
       {
         data: {

Reply via email to